diff --git a/app/streaming/audio/audio.cpp b/app/streaming/audio/audio.cpp index f652d80c..60c21bb0 100644 --- a/app/streaming/audio/audio.cpp +++ b/app/streaming/audio/audio.cpp @@ -94,21 +94,13 @@ int Session::arInit(int /* audioConfiguration */, void Session::arCleanup() { - // m_AudioRenderer is deleted in cleanupAudioRenderer() + delete s_ActiveSession->m_AudioRenderer; + s_ActiveSession->m_AudioRenderer = nullptr; opus_multistream_decoder_destroy(s_ActiveSession->m_OpusDecoder); s_ActiveSession->m_OpusDecoder = nullptr; } -// This is called on the main thread -void Session::cleanupAudioRendererOnMainThread() -{ - SDL_AtomicLock(&m_AudioRendererLock); - delete m_AudioRenderer; - m_AudioRenderer = nullptr; - SDL_AtomicUnlock(&m_AudioRendererLock); -} - void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength) { int samplesDecoded; @@ -120,16 +112,9 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength) SAMPLES_PER_FRAME, 0); if (samplesDecoded > 0) { - // If we can't acquire the lock, that means we're being destroyed - // so don't even bother trying to wait. - if (SDL_AtomicTryLock(&s_ActiveSession->m_AudioRendererLock)) { - if (s_ActiveSession->m_AudioRenderer != nullptr) { - s_ActiveSession->m_AudioRenderer->submitAudio(s_ActiveSession->m_OpusDecodeBuffer, - static_cast(sizeof(short) * - samplesDecoded * - s_ActiveSession->m_AudioConfig.channelCount)); - } - SDL_AtomicUnlock(&s_ActiveSession->m_AudioRendererLock); - } + s_ActiveSession->m_AudioRenderer->submitAudio(s_ActiveSession->m_OpusDecodeBuffer, + static_cast(sizeof(short) * + samplesDecoded * + s_ActiveSession->m_AudioConfig.channelCount)); } } diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 39dc9d97..fdc98971 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -288,8 +288,7 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere m_DisplayOriginY(0), m_PendingWindowedTransition(false), m_OpusDecoder(nullptr), - m_AudioRenderer(nullptr), - m_AudioRendererLock(0) + m_AudioRenderer(nullptr) { } @@ -1143,9 +1142,6 @@ DispatchDeferredCleanup: m_VideoDecoder = nullptr; SDL_AtomicUnlock(&m_DecoderLock); - // Destroy the audio renderer which must also be done on the main thread - cleanupAudioRendererOnMainThread(); - SDL_DestroyWindow(m_Window); if (iconSurface != nullptr) { SDL_FreeSurface(iconSurface); diff --git a/app/streaming/session.h b/app/streaming/session.h index 824d58d4..9918bb1e 100644 --- a/app/streaming/session.h +++ b/app/streaming/session.h @@ -54,8 +54,6 @@ private: int detectAudioConfiguration(); - void cleanupAudioRendererOnMainThread(); - bool testAudio(int audioConfiguration); void getWindowDimensions(int& x, int& y, @@ -126,7 +124,6 @@ private: short m_OpusDecodeBuffer[MAX_CHANNELS * SAMPLES_PER_FRAME]; IAudioRenderer* m_AudioRenderer; OPUS_MULTISTREAM_CONFIGURATION m_AudioConfig; - SDL_SpinLock m_AudioRendererLock; static AUDIO_RENDERER_CALLBACKS k_AudioCallbacks; static CONNECTION_LISTENER_CALLBACKS k_ConnCallbacks;