diff --git a/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp b/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp index a03e4a84e77..99406187751 100644 --- a/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp +++ b/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp @@ -65,20 +65,35 @@ OSStatus CoreAudioDevice::CoreAudio_mix(void* data, AudioUnitRenderActionFlags* return noErr; } +void CoreAudioDevice::preMixingWork(bool playing) +{ + if(!playing) + { + if((getRingBuffer().getReadSize() == 0) && m_active) + { + AudioOutputUnitStop(m_audio_unit); + m_active = false; + } + } +} + void CoreAudioDevice::playing(bool playing) { + MixingThreadDevice::playing(playing); + if(m_playback != playing) { if(playing) + { AudioOutputUnitStart(m_audio_unit); - else - AudioOutputUnitStop(m_audio_unit); + m_active = true; + } } m_playback = playing; } -CoreAudioDevice::CoreAudioDevice(DeviceSpecs specs, int buffersize) : m_buffersize(uint32_t(buffersize)), m_playback(false), m_audio_unit(nullptr), m_audio_clock_ready(false) +CoreAudioDevice::CoreAudioDevice(DeviceSpecs specs, int buffersize) : m_buffersize(uint32_t(buffersize)), m_playback(false), m_audio_unit(nullptr) { if(specs.channels == CHANNELS_INVALID) specs.channels = CHANNELS_STEREO; diff --git a/extern/audaspace/plugins/coreaudio/CoreAudioDevice.h b/extern/audaspace/plugins/coreaudio/CoreAudioDevice.h index 79b617458dd..91ebd03681d 100644 --- a/extern/audaspace/plugins/coreaudio/CoreAudioDevice.h +++ b/extern/audaspace/plugins/coreaudio/CoreAudioDevice.h @@ -53,10 +53,11 @@ private: * The CoreAudio AudioUnit. */ AudioUnit m_audio_unit; + bool m_active{false}; /// The CoreAudio clock referene. CAClockRef m_clock_ref; - bool m_audio_clock_ready; + bool m_audio_clock_ready{false}; double m_synchronizerStartTime{0}; /** @@ -74,6 +75,7 @@ private: CoreAudioDevice(const CoreAudioDevice&) = delete; CoreAudioDevice& operator=(const CoreAudioDevice&) = delete; + AUD_LOCAL void preMixingWork(bool playing) override; void playing(bool playing) override; public: