From 264710d56a989bb61c724df1c624ebc6c572abcc Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 12 Aug 2024 07:04:42 -0400 Subject: [PATCH 1/3] Continue processing Song even when no tracks are found --- src/core/Song.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 92cb2ba3051..e4f31c622c3 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -235,9 +235,6 @@ void Song::processNextBuffer() return; } - // If we have no tracks to play, there is nothing to do - if (trackList.empty()) { return; } - // If the playback position is outside of the range [begin, end), move it to // begin and inform interested parties. // Returns true if the playback position was moved, else false. From 90f46cdca0da1a7cd7438831dfec49f4e327a69f Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 12 Aug 2024 07:52:00 -0400 Subject: [PATCH 2/3] Do not restart audio devices when changing quality settings --- src/core/AudioEngine.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/core/AudioEngine.cpp b/src/core/AudioEngine.cpp index 42e7079b016..4093a920a21 100644 --- a/src/core/AudioEngine.cpp +++ b/src/core/AudioEngine.cpp @@ -549,15 +549,9 @@ void AudioEngine::clearInternal() void AudioEngine::changeQuality(const struct qualitySettings & qs) { - // don't delete the audio-device - stopProcessing(); - m_qualitySettings = qs; - emit sampleRateChanged(); emit qualitySettingsChanged(); - - startProcessing(); } From 688ca66d0085bc3de758b7ea6b2143afbbdbd977 Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 12 Aug 2024 15:01:09 -0400 Subject: [PATCH 3/3] Remove m_stopped variable in AudioSDL A potential infinite wait can happen when closing the FIFO thread if m_stopped is set to true and the device thread never reads the null buffer that signals that the FIFO thread is closing. --- include/AudioSdl.h | 2 -- src/core/audio/AudioSdl.cpp | 22 ++-------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/include/AudioSdl.h b/include/AudioSdl.h index 651ed96be57..7dd7ead1c87 100644 --- a/include/AudioSdl.h +++ b/include/AudioSdl.h @@ -89,8 +89,6 @@ class AudioSdl : public AudioDevice size_t m_currentBufferFramePos; size_t m_currentBufferFramesCount; - bool m_stopped; - SDL_AudioDeviceID m_outputDevice; SDL_AudioSpec m_inputAudioHandle; diff --git a/src/core/audio/AudioSdl.cpp b/src/core/audio/AudioSdl.cpp index 8f533119c8a..c68c9280912 100644 --- a/src/core/audio/AudioSdl.cpp +++ b/src/core/audio/AudioSdl.cpp @@ -139,8 +139,6 @@ AudioSdl::~AudioSdl() void AudioSdl::startProcessing() { - m_stopped = false; - SDL_PauseAudioDevice (m_outputDevice, 0); SDL_PauseAudioDevice (m_inputDevice, 0); } @@ -150,19 +148,8 @@ void AudioSdl::startProcessing() void AudioSdl::stopProcessing() { - if( SDL_GetAudioDeviceStatus(m_outputDevice) == SDL_AUDIO_PLAYING ) - { - SDL_LockAudioDevice (m_inputDevice); - SDL_LockAudioDevice (m_outputDevice); - - m_stopped = true; - - SDL_PauseAudioDevice (m_inputDevice, 1); - SDL_PauseAudioDevice (m_outputDevice, 1); - - SDL_UnlockAudioDevice (m_inputDevice); - SDL_UnlockAudioDevice (m_outputDevice); - } + SDL_PauseAudioDevice (m_inputDevice, 1); + SDL_PauseAudioDevice (m_outputDevice, 1); } void AudioSdl::sdlAudioCallback( void * _udata, Uint8 * _buf, int _len ) @@ -177,11 +164,6 @@ void AudioSdl::sdlAudioCallback( void * _udata, Uint8 * _buf, int _len ) void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len ) { - if( m_stopped ) - { - memset( _buf, 0, _len ); - return; - } // SDL2: process float samples while( _len )