Clear the decode queue on mouse lock or focus gain. This closes #5

This commit is contained in:
Cameron Gutman 2016-02-18 13:25:49 -05:00
parent 3ce2d68250
commit 5d25874131
4 changed files with 23 additions and 1 deletions

View File

@ -27,6 +27,11 @@ static int ConvertPPButtonToLiButton(PP_InputEvent_MouseButton ppButton) {
void MoonlightInstance::DidLockMouse(int32_t result) { void MoonlightInstance::DidLockMouse(int32_t result) {
m_MouseLocked = (result == PP_OK); 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() { void MoonlightInstance::MouseLockLost() {

@ -1 +1 @@
Subproject commit c9d332089fbd0662afb1386fcb4ae10979dc4f67 Subproject commit a8d98284a784d7e1f17d87bda220ee41e51c6560

View File

@ -39,6 +39,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
pp::Instance(instance), pp::Instance(instance),
pp::MouseLock(this), pp::MouseLock(this),
m_IsPainting(false), m_IsPainting(false),
m_RequestIdrFrame(false),
m_OpusDecoder(NULL), m_OpusDecoder(NULL),
m_CallbackFactory(this), m_CallbackFactory(this),
m_MouseLocked(false), m_MouseLocked(false),
@ -69,6 +70,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
void DidLockMouse(int32_t result); void DidLockMouse(int32_t result);
void MouseLockLost(); void MouseLockLost();
void DidChangeFocus(bool got_focus);
void OnConnectionStopped(uint32_t unused); void OnConnectionStopped(uint32_t unused);
void OnConnectionStarted(uint32_t error); void OnConnectionStarted(uint32_t error);
@ -125,6 +127,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
Shader m_ExternalOesShader; Shader m_ExternalOesShader;
std::queue<PP_VideoPicture> m_PendingPictureQueue; std::queue<PP_VideoPicture> m_PendingPictureQueue;
bool m_IsPainting; bool m_IsPainting;
bool m_RequestIdrFrame;
OpusMSDecoder* m_OpusDecoder; OpusMSDecoder* m_OpusDecoder;
pp::Audio m_AudioPlayer; pp::Audio m_AudioPlayer;

View File

@ -54,6 +54,14 @@ static const char k_FragmentShaderExternal[] =
" gl_FragColor = texture2D(s_texture, v_texCoord); \n" " 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, void MoonlightInstance::DidChangeView(const pp::Rect& position,
const pp::Rect& clip) { const pp::Rect& clip) {
@ -169,6 +177,12 @@ int MoonlightInstance::VidDecSubmitDecodeUnit(PDECODE_UNIT decodeUnit) {
PLENTRY entry; PLENTRY entry;
unsigned int offset; 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 // Resize the decode buffer if needed
if (decodeUnit->fullLength > s_DecodeBufferLength) { if (decodeUnit->fullLength > s_DecodeBufferLength) {
free(s_DecodeBuffer); free(s_DecodeBuffer);