Permalink
Browse files

Add the code back to request an IDR frame when switching back to Moon…

…light
  • Loading branch information...
1 parent c2fde81 commit 12e34a9f4e7b8211dc4e9cabb061c370dd2bb7f4 @cgutman cgutman committed Jul 11, 2016
Showing with 22 additions and 0 deletions.
  1. +5 −0 input.cpp
  2. +3 −0 moonlight.hpp
  3. +14 −0 viddec.cpp
View
@@ -23,6 +23,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() {
View
@@ -53,6 +53,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
pp::MouseLock(this),
m_HasNextPicture(false),
m_IsPainting(false),
+ m_RequestIdrFrame(false),
m_OpusDecoder(NULL),
m_CallbackFactory(this),
m_MouseLocked(false),
@@ -122,6 +123,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
void PictureReady(int32_t result, PP_VideoPicture picture);
void PaintPicture(void);
void InitializeRenderingSurface(int width, int height);
+ void DidChangeFocus(bool got_focus);
static void VidDecSetup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags);
static void VidDecCleanup(void);
@@ -159,6 +161,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
bool m_HasNextPicture;
PP_VideoPicture m_CurrentPicture;
bool m_IsPainting;
+ bool m_RequestIdrFrame;
OpusMSDecoder* m_OpusDecoder;
pp::Audio m_AudioPlayer;
View
@@ -62,6 +62,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::InitializeRenderingSurface(int width, int height) {
if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
return;
@@ -230,6 +238,12 @@ int MoonlightInstance::VidDecSubmitDecodeUnit(PDECODE_UNIT decodeUnit) {
bool isSps = false;
bool isPps = false;
bool isIframe = false;
+
+ // Request an IDR frame if needed
+ if (g_Instance->m_RequestIdrFrame) {
+ g_Instance->m_RequestIdrFrame = false;
+ return DR_NEED_IDR;
+ }
// Look at the NALU type
if (decodeUnit->bufferList->length > 5) {

0 comments on commit 12e34a9

Please sign in to comment.