Use new LiRequestIdrFrame() API

This commit is contained in:
Cameron Gutman 2022-10-05 00:53:31 -05:00
parent f8c7e2ee41
commit fbbbd5e0b8
4 changed files with 7 additions and 22 deletions

View File

@ -291,14 +291,9 @@ int Session::drSubmitDecodeUnit(PDECODE_UNIT du)
// We need to destroy the decoder on the main thread to satisfy
// some API constraints (like DXVA2). If we can't acquire it,
// that means the decoder is about to be destroyed, so we can
// safely return DR_OK and wait for m_NeedsIdr to be set by
// safely return DR_OK and wait for the IDR frame request by
// the decoder reinitialization code.
if (s_ActiveSession->getAndClearPendingIdrFrameStatus()) {
// If we reset our decoder, we'll need to request an IDR frame
return DR_NEED_IDR;
}
if (SDL_AtomicTryLock(&s_ActiveSession->m_DecoderLock)) {
IVideoDecoder* decoder = s_ActiveSession->m_VideoDecoder;
if (decoder != nullptr) {
@ -469,7 +464,6 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere
m_AudioSampleCount(0),
m_DropAudioEndTime(0)
{
SDL_AtomicSet(&m_NeedsIdr, 0);
}
bool Session::initialize()
@ -1266,11 +1260,6 @@ void Session::flushWindowEvents()
SDL_PushEvent(&flushEvent);
}
bool Session::getAndClearPendingIdrFrameStatus()
{
return SDL_AtomicSet(&m_NeedsIdr, 0);
}
class ExecThread : public QThread
{
public:
@ -1746,7 +1735,7 @@ void Session::execInternal()
}
// Request an IDR frame to complete the reset
SDL_AtomicSet(&m_NeedsIdr, 1);
LiRequestIdrFrame();
// Set HDR mode. We may miss the callback if we're in the middle
// of recreating our decoder at the time the HDR transition happens.

View File

@ -45,8 +45,6 @@ public:
void flushWindowEvents();
bool getAndClearPendingIdrFrameStatus();
signals:
void stageStarting(QString stage);
@ -156,7 +154,6 @@ private:
SDL_Window* m_Window;
IVideoDecoder* m_VideoDecoder;
SDL_SpinLock m_DecoderLock;
SDL_atomic_t m_NeedsIdr;
bool m_AudioDisabled;
bool m_AudioMuted;
Uint32 m_FullScreenFlag;

View File

@ -1108,6 +1108,10 @@ void FFmpegVideoDecoder::decoderThreadProc()
// Don't consume any additional data
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 1);
}
// Just in case the error resulted in the loss of the frame,
// request an IDR frame to reset our decoder state.
LiRequestIdrFrame();
}
} while (err == AVERROR(EAGAIN) && !SDL_AtomicGet(&m_DecoderThreadShouldQuit));
@ -1131,11 +1135,6 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
return DR_NEED_IDR;
}
// Bail immediately if we need an IDR frame to continue
if (Session::get()->getAndClearPendingIdrFrameStatus()) {
return DR_NEED_IDR;
}
if (!m_LastFrameNumber) {
m_ActiveWndVideoStats.measurementStartTimestamp = SDL_GetTicks();
m_LastFrameNumber = du->frameNumber;

@ -1 +1 @@
Subproject commit 502f799a735f4c1b042819ebbf4b79f734473345
Subproject commit 9240090983d588bf7c40138c9a23ac1403c551f7