diff --git a/input.cpp b/input.cpp index 7f1bde8..abb33da 100644 --- a/input.cpp +++ b/input.cpp @@ -27,6 +27,11 @@ static int ConvertPPButtonToLiButton(PP_InputEvent_MouseButton ppButton) { void MoonlightInstance::DidLockMouse(int32_t result) { m_MouseLocked = (result == PP_OK); + if (m_MouseLocked) { + // Request an IDR frame to dump the frame queue that may have + // built up from the GL pipeline being stalled. + g_Instance->m_RequestIdrFrame = true; + } } void MoonlightInstance::MouseLockLost() { diff --git a/moonlight-common-c b/moonlight-common-c index c9d3320..a8d9828 160000 --- a/moonlight-common-c +++ b/moonlight-common-c @@ -1 +1 @@ -Subproject commit c9d332089fbd0662afb1386fcb4ae10979dc4f67 +Subproject commit a8d98284a784d7e1f17d87bda220ee41e51c6560 diff --git a/moonlight.hpp b/moonlight.hpp index d46ff0d..b3f36af 100644 --- a/moonlight.hpp +++ b/moonlight.hpp @@ -39,6 +39,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock { pp::Instance(instance), pp::MouseLock(this), m_IsPainting(false), + m_RequestIdrFrame(false), m_OpusDecoder(NULL), m_CallbackFactory(this), m_MouseLocked(false), @@ -69,6 +70,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock { void DidLockMouse(int32_t result); void MouseLockLost(); + void DidChangeFocus(bool got_focus); void OnConnectionStopped(uint32_t unused); void OnConnectionStarted(uint32_t error); @@ -125,6 +127,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock { Shader m_ExternalOesShader; std::queue m_PendingPictureQueue; bool m_IsPainting; + bool m_RequestIdrFrame; OpusMSDecoder* m_OpusDecoder; pp::Audio m_AudioPlayer; diff --git a/viddec.cpp b/viddec.cpp index e057ab3..ea98c59 100644 --- a/viddec.cpp +++ b/viddec.cpp @@ -54,6 +54,14 @@ static const char k_FragmentShaderExternal[] = " gl_FragColor = texture2D(s_texture, v_texCoord); \n" "}"; +void MoonlightInstance::DidChangeFocus(bool got_focus) { + // Request an IDR frame to dump the frame queue that may have + // built up from the GL pipeline being stalled. + if (got_focus) { + g_Instance->m_RequestIdrFrame = true; + } +} + void MoonlightInstance::DidChangeView(const pp::Rect& position, const pp::Rect& clip) { @@ -169,6 +177,12 @@ int MoonlightInstance::VidDecSubmitDecodeUnit(PDECODE_UNIT decodeUnit) { PLENTRY entry; unsigned int offset; + // Request an IDR frame if needed + if (g_Instance->m_RequestIdrFrame) { + g_Instance->m_RequestIdrFrame = false; + return DR_NEED_IDR; + } + // Resize the decode buffer if needed if (decodeUnit->fullLength > s_DecodeBufferLength) { free(s_DecodeBuffer);