1 files changed, 32 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4ecc18d2..2ae631cf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,6 +34,11 @@
#include "emoji/MacHelper.h"
#endif
+#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS))
+#include <QAbstractEventDispatcher>
+#include <gst/gst.h>
+#endif
+
#ifdef QML_DEBUGGING
#include <QQmlDebuggingEnabler>
QQmlDebuggingEnabler enabler;
@@ -100,6 +105,23 @@ registerSignalHandlers()
#endif
+#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS))
+GMainLoop *gloop = 0;
+GThread *gthread = 0;
+
+extern "C"
+{
+ static gpointer glibMainLoopThreadFunc(gpointer)
+ {
+ gloop = g_main_loop_new(0, false);
+ g_main_loop_run(gloop);
+ g_main_loop_unref(gloop);
+ gloop = 0;
+ return 0;
+ }
+} // extern "C"
+#endif
+
QPoint
screenCenter(int width, int height)
{
@@ -220,6 +242,16 @@ main(int argc, char *argv[])
registerSignalHandlers();
+#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS))
+ // If the version of Qt we're running in does not use GLib, we need to
+ // start a GMainLoop so that gstreamer can dispatch events.
+ const QMetaObject *mo = QAbstractEventDispatcher::instance(qApp->thread())->metaObject();
+ if (gloop == 0 && strcmp(mo->className(), "QEventDispatcherGlib") != 0 &&
+ strcmp(mo->superClass()->className(), "QEventDispatcherGlib") != 0) {
+ gthread = g_thread_new(0, glibMainLoopThreadFunc, 0);
+ }
+#endif
+
if (parser.isSet(debugOption))
nhlog::enable_debug_log_from_commandline = true;
|