audio/internal/readerdriver: Use AudioQueuePrime

This commit is contained in:
Hajime Hoshi 2021-05-09 21:31:55 +09:00
parent 6644e43025
commit a285a84df0

View File

@ -366,18 +366,23 @@ func (p *playerImpl) Play() {
} }
for { for {
if osstatus := C.AudioQueueStart(p.audioQueue, nil); osstatus != C.noErr { if osstatus := C.AudioQueuePrime(p.audioQueue, 0, nil); osstatus != C.noErr {
// AudioQueueStart might fail just after recovering from Siri. // AudioQueuePrime might fail just after recovering from Siri.
if osstatus == C.AVAudioSessionErrorCodeSiriIsRecording { if osstatus == C.AVAudioSessionErrorCodeSiriIsRecording {
time.Sleep(10 * time.Millisecond) time.Sleep(10 * time.Millisecond)
continue continue
} }
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueStart failed: %d", osstatus)) p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePrime failed: %d", osstatus))
return return
} }
break break
} }
if osstatus := C.AudioQueueStart(p.audioQueue, nil); osstatus != C.noErr {
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueStart failed: %d", osstatus))
return
}
p.state = playerPlay p.state = playerPlay
p.cond.Signal() p.cond.Signal()