mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
Implement fallback to software when hardware decoding is unavailable
This commit is contained in:
parent
f2d9bce746
commit
1f3f4bd0aa
@ -28,13 +28,13 @@ void MoonlightInstance::ClConnectionTerminated(long errorCode) {
|
||||
g_Instance->m_CallbackFactory.NewCallback(&MoonlightInstance::OnConnectionStopped), (uint32_t)errorCode);
|
||||
}
|
||||
|
||||
void MoonlightInstance::ClDisplayMessage(char* message) {
|
||||
pp::Var response(message);
|
||||
void MoonlightInstance::ClDisplayMessage(const char* message) {
|
||||
pp::Var response(std::string("DialogMsg: ") + std::string(message));
|
||||
g_Instance->PostMessage(response);
|
||||
}
|
||||
|
||||
void MoonlightInstance::ClDisplayTransientMessage(char* message) {
|
||||
pp::Var response(message);
|
||||
void MoonlightInstance::ClDisplayTransientMessage(const char* message) {
|
||||
pp::Var response(std::string("TransientMsg: ") + std::string(message));
|
||||
g_Instance->PostMessage(response);
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 69c8881187590bf131f18ee150cdce65f02bdd34
|
||||
Subproject commit 86ade5204e7c8c8cc7be218940037b08bdde3b47
|
@ -35,6 +35,9 @@
|
||||
// which a profiling message is printed
|
||||
#define PROFILING_MESSAGE_THRESHOLD 1
|
||||
|
||||
|
||||
#define DR_FLAG_FORCE_SW_DECODE 0x01
|
||||
|
||||
struct Shader {
|
||||
Shader() : program(0), texcoord_scale_location(0) {}
|
||||
~Shader() {}
|
||||
@ -108,8 +111,8 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
static void ClStageFailed(int stage, long errorCode);
|
||||
static void ClConnectionStarted(void);
|
||||
static void ClConnectionTerminated(long errorCode);
|
||||
static void ClDisplayMessage(char* message);
|
||||
static void ClDisplayTransientMessage(char* message);
|
||||
static void ClDisplayMessage(const char* message);
|
||||
static void ClDisplayTransientMessage(const char* message);
|
||||
|
||||
static Shader CreateProgram(const char* vertexShader, const char* fragmentShader);
|
||||
static void CreateShader(GLuint program, GLenum type, const char* source, int size);
|
||||
|
@ -30,6 +30,8 @@ function handleMessage(msg) {
|
||||
$('#loadingSpinner').css('display', 'none');
|
||||
} else if(msg.data.indexOf('ProgressMsg: ') === 0) {
|
||||
$('#loadingMessage').text(msg.data.replace('ProgressMsg: ', ''));
|
||||
} else if(msg.data.indexOf('TransientMsg: ') === 0) {
|
||||
snackbarLog(msg.data.replace('TransientMsg: ', ''));
|
||||
}
|
||||
}
|
||||
}
|
34
viddec.cpp
34
viddec.cpp
@ -133,11 +133,35 @@ void MoonlightInstance::VidDecSetup(int videoFormat, int width, int height, int
|
||||
s_LastSpsLength = 0;
|
||||
s_LastPpsLength = 0;
|
||||
|
||||
g_Instance->m_VideoDecoder->Initialize(g_Instance->m_Graphics3D,
|
||||
PP_VIDEOPROFILE_H264HIGH,
|
||||
PP_HARDWAREACCELERATION_ONLY,
|
||||
0,
|
||||
pp::BlockUntilComplete());
|
||||
int32_t err;
|
||||
|
||||
if (!(drFlags & DR_FLAG_FORCE_SW_DECODE)) {
|
||||
// Try to initialize hardware decoding only
|
||||
err = g_Instance->m_VideoDecoder->Initialize(
|
||||
g_Instance->m_Graphics3D,
|
||||
PP_VIDEOPROFILE_H264HIGH,
|
||||
PP_HARDWAREACCELERATION_ONLY,
|
||||
0,
|
||||
pp::BlockUntilComplete());
|
||||
}
|
||||
else {
|
||||
err = PP_ERROR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
if (err == PP_ERROR_NOTSUPPORTED) {
|
||||
// Fallback to software decoding
|
||||
err = g_Instance->m_VideoDecoder->Initialize(
|
||||
g_Instance->m_Graphics3D,
|
||||
PP_VIDEOPROFILE_H264HIGH,
|
||||
PP_HARDWAREACCELERATION_NONE,
|
||||
0,
|
||||
pp::BlockUntilComplete());
|
||||
|
||||
if (!(drFlags & DR_FLAG_FORCE_SW_DECODE)) {
|
||||
// Tell the user we had to fall back
|
||||
ClDisplayTransientMessage("Hardware decoding is unavailable. Falling back to CPU decoding");
|
||||
}
|
||||
}
|
||||
|
||||
pp::Module::Get()->core()->CallOnMainThread(0,
|
||||
g_Instance->m_CallbackFactory.NewCallback(&MoonlightInstance::DispatchGetPicture));
|
||||
|
Loading…
x
Reference in New Issue
Block a user