mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-04 00:36:36 +00:00
Move audio renderer destruction back off the main thread now that we're using atexit(SDL_Quit)
This commit is contained in:
parent
f7789a1e4a
commit
c239d0814b
@ -94,21 +94,13 @@ int Session::arInit(int /* audioConfiguration */,
|
|||||||
|
|
||||||
void Session::arCleanup()
|
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);
|
opus_multistream_decoder_destroy(s_ActiveSession->m_OpusDecoder);
|
||||||
s_ActiveSession->m_OpusDecoder = nullptr;
|
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)
|
void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
|
||||||
{
|
{
|
||||||
int samplesDecoded;
|
int samplesDecoded;
|
||||||
@ -120,16 +112,9 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
|
|||||||
SAMPLES_PER_FRAME,
|
SAMPLES_PER_FRAME,
|
||||||
0);
|
0);
|
||||||
if (samplesDecoded > 0) {
|
if (samplesDecoded > 0) {
|
||||||
// If we can't acquire the lock, that means we're being destroyed
|
s_ActiveSession->m_AudioRenderer->submitAudio(s_ActiveSession->m_OpusDecodeBuffer,
|
||||||
// so don't even bother trying to wait.
|
static_cast<int>(sizeof(short) *
|
||||||
if (SDL_AtomicTryLock(&s_ActiveSession->m_AudioRendererLock)) {
|
samplesDecoded *
|
||||||
if (s_ActiveSession->m_AudioRenderer != nullptr) {
|
s_ActiveSession->m_AudioConfig.channelCount));
|
||||||
s_ActiveSession->m_AudioRenderer->submitAudio(s_ActiveSession->m_OpusDecodeBuffer,
|
|
||||||
static_cast<int>(sizeof(short) *
|
|
||||||
samplesDecoded *
|
|
||||||
s_ActiveSession->m_AudioConfig.channelCount));
|
|
||||||
}
|
|
||||||
SDL_AtomicUnlock(&s_ActiveSession->m_AudioRendererLock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,8 +288,7 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere
|
|||||||
m_DisplayOriginY(0),
|
m_DisplayOriginY(0),
|
||||||
m_PendingWindowedTransition(false),
|
m_PendingWindowedTransition(false),
|
||||||
m_OpusDecoder(nullptr),
|
m_OpusDecoder(nullptr),
|
||||||
m_AudioRenderer(nullptr),
|
m_AudioRenderer(nullptr)
|
||||||
m_AudioRendererLock(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,9 +1142,6 @@ DispatchDeferredCleanup:
|
|||||||
m_VideoDecoder = nullptr;
|
m_VideoDecoder = nullptr;
|
||||||
SDL_AtomicUnlock(&m_DecoderLock);
|
SDL_AtomicUnlock(&m_DecoderLock);
|
||||||
|
|
||||||
// Destroy the audio renderer which must also be done on the main thread
|
|
||||||
cleanupAudioRendererOnMainThread();
|
|
||||||
|
|
||||||
SDL_DestroyWindow(m_Window);
|
SDL_DestroyWindow(m_Window);
|
||||||
if (iconSurface != nullptr) {
|
if (iconSurface != nullptr) {
|
||||||
SDL_FreeSurface(iconSurface);
|
SDL_FreeSurface(iconSurface);
|
||||||
|
@ -54,8 +54,6 @@ private:
|
|||||||
|
|
||||||
int detectAudioConfiguration();
|
int detectAudioConfiguration();
|
||||||
|
|
||||||
void cleanupAudioRendererOnMainThread();
|
|
||||||
|
|
||||||
bool testAudio(int audioConfiguration);
|
bool testAudio(int audioConfiguration);
|
||||||
|
|
||||||
void getWindowDimensions(int& x, int& y,
|
void getWindowDimensions(int& x, int& y,
|
||||||
@ -126,7 +124,6 @@ private:
|
|||||||
short m_OpusDecodeBuffer[MAX_CHANNELS * SAMPLES_PER_FRAME];
|
short m_OpusDecodeBuffer[MAX_CHANNELS * SAMPLES_PER_FRAME];
|
||||||
IAudioRenderer* m_AudioRenderer;
|
IAudioRenderer* m_AudioRenderer;
|
||||||
OPUS_MULTISTREAM_CONFIGURATION m_AudioConfig;
|
OPUS_MULTISTREAM_CONFIGURATION m_AudioConfig;
|
||||||
SDL_SpinLock m_AudioRendererLock;
|
|
||||||
|
|
||||||
static AUDIO_RENDERER_CALLBACKS k_AudioCallbacks;
|
static AUDIO_RENDERER_CALLBACKS k_AudioCallbacks;
|
||||||
static CONNECTION_LISTENER_CALLBACKS k_ConnCallbacks;
|
static CONNECTION_LISTENER_CALLBACKS k_ConnCallbacks;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user