output/osx: postpone start until the end of Play()

Wait until there is data in the ring buffer.
This commit is contained in:
Max Kellermann 2020-07-02 15:22:16 +02:00
parent 6fed6e50e4
commit daefc61aa4

View File

@ -769,14 +769,6 @@ OSXOutput::Play(const void *chunk, size_t size)
pause = false;
if (!started) {
OSStatus status = AudioOutputUnitStart(au);
if (status != noErr)
throw std::runtime_error("Unable to restart audio output after pause");
started = true;
}
ConstBuffer<uint8_t> input((const uint8_t *)chunk, size);
#ifdef ENABLE_DSD
@ -795,6 +787,14 @@ OSXOutput::Play(const void *chunk, size_t size)
size_t bytes_written = ring_buffer->push(input.data, input.size);
if (!started) {
OSStatus status = AudioOutputUnitStart(au);
if (status != noErr)
throw std::runtime_error("Unable to restart audio output after pause");
started = true;
}
#ifdef ENABLE_DSD
if (dop_enabled)
bytes_written = pcm_export->CalcSourceSize(bytes_written);