mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-21 23:50:26 +00:00
Don't block in audio/video renderer callbacks while the renderer is being destroyed
This commit is contained in:
@@ -120,13 +120,16 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
|
||||
SAMPLES_PER_FRAME,
|
||||
0);
|
||||
if (samplesDecoded > 0) {
|
||||
SDL_AtomicLock(&s_ActiveSession->m_AudioRendererLock);
|
||||
if (s_ActiveSession->m_AudioRenderer != nullptr) {
|
||||
s_ActiveSession->m_AudioRenderer->submitAudio(s_ActiveSession->m_OpusDecodeBuffer,
|
||||
static_cast<int>(sizeof(short) *
|
||||
samplesDecoded *
|
||||
s_ActiveSession->m_AudioConfig.channelCount));
|
||||
// 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<int>(sizeof(short) *
|
||||
samplesDecoded *
|
||||
s_ActiveSession->m_AudioConfig.channelCount));
|
||||
}
|
||||
SDL_AtomicUnlock(&s_ActiveSession->m_AudioRendererLock);
|
||||
}
|
||||
SDL_AtomicUnlock(&s_ActiveSession->m_AudioRendererLock);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user