From 458efe91689e8dbfb8d26242116cde4ddf0705eb Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 3 Oct 2020 20:05:30 +0200 Subject: [PATCH] Remove gstreamer registry workaround for Windows --- src/core/scangiomodulepath.cpp | 48 ------------------- src/core/scangiomodulepath.h | 21 --------- src/engine/gststartup.cpp | 84 ++++++++++++++++++++++------------ src/main.cpp | 5 +- 4 files changed, 55 insertions(+), 103 deletions(-) delete mode 100644 src/core/scangiomodulepath.cpp delete mode 100644 src/core/scangiomodulepath.h diff --git a/src/core/scangiomodulepath.cpp b/src/core/scangiomodulepath.cpp deleted file mode 100644 index 0bcf3949..00000000 --- a/src/core/scangiomodulepath.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Strawberry Music Player - * This code was part of Clementine. - * Copyright 2010, David Sansome - * - * Strawberry is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Strawberry is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Strawberry. If not, see . - * - */ - -#include "config.h" - -#include - -#include -#include -#include -#include -#include - -#include "core/logging.h" -#include "scangiomodulepath.h" - -void ScanGIOModulePath() { - - QString gio_module_path; - -#if defined(Q_OS_WIN32) - gio_module_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/gio-modules"); -#endif - - if (!gio_module_path.isEmpty()) { - qLog(Debug) << "Adding GIO module path:" << gio_module_path; - QByteArray bytes = gio_module_path.toLocal8Bit(); - g_io_modules_scan_all_in_directory(bytes.data()); - } - -} diff --git a/src/core/scangiomodulepath.h b/src/core/scangiomodulepath.h deleted file mode 100644 index 387a5d9e..00000000 --- a/src/core/scangiomodulepath.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Strawberry Music Player - * This code was part of Clementine. - * Copyright 2010, David Sansome - * - * Strawberry is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Strawberry is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Strawberry. If not, see . - * - */ - -void ScanGIOModulePath(); diff --git a/src/engine/gststartup.cpp b/src/engine/gststartup.cpp index b031f6dd..689bf889 100644 --- a/src/engine/gststartup.cpp +++ b/src/engine/gststartup.cpp @@ -31,6 +31,7 @@ #include #include +#include "core/logging.h" #include "core/utilities.h" #ifdef HAVE_MOODBAR @@ -62,50 +63,73 @@ void GstStartup::InitialiseGStreamer() { void GstStartup::SetEnvironment() { - QString gio_path; - QString scanner_path; - QString plugin_path; - QString registry_filename; + QString bundle_path = QCoreApplication::applicationDirPath(); + +#ifdef USE_BUNDLE_DIR + QString bundle_dir = USE_BUNDLE_DIR; + if (!bundle_dir.isEmpty()) { + bundle_path.append("/" + bundle_dir); + } +#endif + + QString gio_module_path; + QString gst_plugin_scanner; + QString gst_plugin_path; + QString gst_registry_filename; -// On Windows and macOS we bundle the gstreamer plugins with strawberry #ifdef USE_BUNDLE #if defined(Q_OS_WIN32) || defined(Q_OS_MACOS) - gio_path = QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gio-modules"; + gio_module_path = bundle_path + "/gio-modules"; #endif #if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) - scanner_path = QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gst-plugin-scanner"; - plugin_path = QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gstreamer"; + gst_plugin_scanner = bundle_path + "/gst-plugin-scanner"; + gst_plugin_path = bundle_path + "/gstreamer"; #endif #if defined(Q_OS_WIN32) - plugin_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/gstreamer-plugins"); + //gst_plugin_scanner = bundle_path + "/gst-plugin-scanner.exe"; + gst_plugin_path = bundle_path + "/gstreamer-plugins"; #endif #endif #if defined(Q_OS_WIN32) || defined(Q_OS_MACOS) - registry_filename = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QString("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion()); + gst_registry_filename = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QString("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion()); #endif - if (!gio_path.isEmpty()) { - //Utilities::SetEnv("GIO_MODULE_DIR", gio_path); - Utilities::SetEnv("GIO_EXTRA_MODULES", gio_path); - } - - if (!scanner_path.isEmpty()) Utilities::SetEnv("GST_PLUGIN_SCANNER", scanner_path); - - if (!plugin_path.isEmpty()) { - Utilities::SetEnv("GST_PLUGIN_PATH", plugin_path); - // Never load plugins from anywhere else. - Utilities::SetEnv("GST_PLUGIN_SYSTEM_PATH", plugin_path); - } - - if (!registry_filename.isEmpty()) { -#ifdef Q_OS_WIN32 // Workaround for issue #266 - TLS/SSL support not available; install glib-networking - QFile registry_file(registry_filename); - if (registry_file.exists()) { - registry_file.remove(); + if (!gio_module_path.isEmpty()) { + if (QDir(gio_module_path).exists()) { + qLog(Debug) << "Setting GIO module path to" << gio_module_path; + Utilities::SetEnv("GIO_EXTRA_MODULES", gio_module_path); } -#endif - Utilities::SetEnv("GST_REGISTRY", registry_filename); + else { + qLog(Debug) << "GIO module path does not exist:" << gio_module_path; + } + } + + if (!gst_plugin_scanner.isEmpty()) { + if (QFile(gst_plugin_scanner).exists()) { + qLog(Debug) << "Setting GST plugin scanner to" << gst_plugin_scanner; + Utilities::SetEnv("GST_PLUGIN_SCANNER", gst_plugin_scanner); + } + else { + qLog(Debug) << "GST plugin scanner does not exist:" << gst_plugin_scanner; + } + } + + if (!gst_plugin_path.isEmpty()) { + if (QDir(gst_plugin_path).exists()) { + qLog(Debug) << "Setting GST plugin path to" << gst_plugin_path; + Utilities::SetEnv("GST_PLUGIN_PATH", gst_plugin_path); + // Never load plugins from anywhere else. + Utilities::SetEnv("GST_PLUGIN_SYSTEM_PATH", gst_plugin_path); + } + else { + qLog(Debug) << "GST plugin path does not exist:" << gst_plugin_path; + } + } + + if (!gst_registry_filename.isEmpty()) { + qLog(Debug) << "Setting GST registry file to" << gst_registry_filename; + Utilities::SetEnv("GST_REGISTRY", gst_registry_filename); } Utilities::SetEnv("PULSE_PROP_media.role", "music"); diff --git a/src/main.cpp b/src/main.cpp index 531c072d..5591ca35 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -93,7 +93,6 @@ #include "core/systemtrayicon.h" #include "core/application.h" #include "core/networkproxyfactory.h" -#include "core/scangiomodulepath.h" #ifdef HAVE_TRANSLATIONS # include "core/translations.h" #endif @@ -280,9 +279,7 @@ int main(int argc, char* argv[]) { #ifdef Q_OS_MACOS mac::EnableFullScreen(w); #endif // Q_OS_MACOS -#ifdef HAVE_GIO - ScanGIOModulePath(); -#endif + #ifdef HAVE_DBUS QObject::connect(&mpris, SIGNAL(RaiseMainWindow()), &w, SLOT(Raise())); #endif