commit 35da1fb2cc3457d4e2825feba86cc53497c3c60f
Author: Gwenole Beauchesne
Date: Tue Mar 2 12:22:14 2010 +0000
Fix SW fallback if VA-API is built-in.
diff --git a/gui/gtk_canvas.cpp b/gui/gtk_canvas.cpp
index 0377a9f..62bf68d 100644
--- a/gui/gtk_canvas.cpp
+++ b/gui/gtk_canvas.cpp
@@ -30,6 +30,10 @@
#include "log.h"
#include "gtk_glue.h"
+#if USE_VAAPI
+#include "vaapi_utils.h"
+#endif
+
// OpenGL support for rendering in the canvas. This also requires
// the GtkGL widget for GTK2.
#ifdef HAVE_GTK_GTKGL_H
@@ -225,6 +229,8 @@ gnash_canvas_setup(GnashCanvas *canvas, std::string& hwaccel,
}
while (!initialized_renderer) {
+ // Global enable VA-API, if requested
+ gnash::vaapi_set_is_enabled(hwaccel == "vaapi");
// Use the Cairo renderer. Cairo is also used by GTK2, so using
// Cairo makes much sense. Unfortunately, our implementation seems
// to have serious performance issues, although it does work.
diff --git a/libvaapi/VaapiGlobalContext.cpp b/libvaapi/VaapiGlobalContext.cpp
index c6da9e4..3235ef6 100644
--- a/libvaapi/VaapiGlobalContext.cpp
+++ b/libvaapi/VaapiGlobalContext.cpp
@@ -130,6 +130,9 @@ VaapiGlobalContext *VaapiGlobalContext::get()
static std::auto_ptr vaapi_global_context;
+ if (!vaapi_is_enabled())
+ return NULL;
+
if (!vaapi_global_context.get()) {
std::auto_ptr dpy;
/* XXX: this won't work with multiple renders built-in */
diff --git a/libvaapi/vaapi.cpp b/libvaapi/vaapi.cpp
index f2c375e..1c1f9e2 100644
--- a/libvaapi/vaapi.cpp
+++ b/libvaapi/vaapi.cpp
@@ -23,57 +23,6 @@
namespace gnash {
-/// Parse ENV environment variable expecting "yes" | "no" values
-static bool
-getenv_yesno(const char *env, int *pval)
-{
- const char *env_str = getenv(env);
- if (!env_str) {
- return false;
- }
-
- int val;
- if (strcmp(env_str, "1") == 0 || strcmp(env_str, "yes") == 0) {
- val = 1;
- } else if (strcmp(env_str, "0") == 0 || strcmp(env_str, "no") == 0) {
- val = 0;
- } else {
- return false;
- }
-
- if (pval) {
- *pval = val;
- }
-
- return true;
-}
-
-static int g_vaapi_is_enabled = -1;
-
-// Enable video acceleration (with VA API)
-void vaapi_enable()
-{
- g_vaapi_is_enabled = 1;
-}
-
-// Disable video acceleration (with VA API)
-void vaapi_disable()
-{
- g_vaapi_is_enabled = 0;
-}
-
-// Check whether video acceleration is enabled
-bool vaapi_is_enabled()
-{
- if (g_vaapi_is_enabled < 0) {
- if (!getenv_yesno("GNASH_VAAPI", &g_vaapi_is_enabled)) {
- g_vaapi_is_enabled = 1;
- }
- }
-
- return g_vaapi_is_enabled;
-}
-
} // gnash namespace
diff --git a/libvaapi/vaapi.h b/libvaapi/vaapi.h
index bea3660..68ac2c8 100644
--- a/libvaapi/vaapi.h
+++ b/libvaapi/vaapi.h
@@ -29,17 +29,4 @@
#include "VaapiImage.h"
#include "VaapiException.h"
-namespace gnash {
-
-/// Enable video acceleration (with VA API)
-void DSOEXPORT vaapi_enable();
-
-/// Disable video acceleration (with VA API)
-void DSOEXPORT vaapi_disable();
-
-/// Check whether video acceleration is enabled
-bool DSOEXPORT vaapi_is_enabled();
-
-} // gnash namespace
-
#endif /* GNASH_VAAPI_H */
diff --git a/libvaapi/vaapi_utils.cpp b/libvaapi/vaapi_utils.cpp
index 2dcebfe..112bc03 100644
--- a/libvaapi/vaapi_utils.cpp
+++ b/libvaapi/vaapi_utils.cpp
@@ -23,6 +23,20 @@
namespace gnash {
+static bool g_vaapi_is_enabled = false;
+
+// Enable video acceleration (with VA API)
+void vaapi_set_is_enabled(bool enabled)
+{
+ g_vaapi_is_enabled = enabled;
+}
+
+// Check whether video acceleration is enabled
+bool vaapi_is_enabled()
+{
+ return g_vaapi_is_enabled;
+}
+
// Debug output
void DSOEXPORT vaapi_dprintf(const char *format, ...)
{
diff --git a/libvaapi/vaapi_utils.h b/libvaapi/vaapi_utils.h
index 0b364b9..9f8440c 100644
--- a/libvaapi/vaapi_utils.h
+++ b/libvaapi/vaapi_utils.h
@@ -24,6 +24,12 @@
namespace gnash {
+/// Enable video acceleration (with VA API)
+void DSOEXPORT vaapi_set_is_enabled(bool enabled);
+
+/// Check whether video acceleration is enabled
+bool DSOEXPORT vaapi_is_enabled();
+
/// Debug output
void DSOEXPORT vaapi_dprintf(const char *format, ...);