Initialize gstreamer independent of witch engine is used
This commit is contained in:
@@ -552,8 +552,8 @@ optional_source(X11_FOUND
|
|||||||
|
|
||||||
# GStreamer
|
# GStreamer
|
||||||
optional_source(HAVE_GSTREAMER
|
optional_source(HAVE_GSTREAMER
|
||||||
SOURCES engine/gstengine.cpp engine/gstenginepipeline.cpp engine/gstelementdeleter.cpp
|
SOURCES engine/gststartup.cpp engine/gstengine.cpp engine/gstenginepipeline.cpp engine/gstelementdeleter.cpp
|
||||||
HEADERS engine/gstengine.h engine/gstenginepipeline.h engine/gstelementdeleter.h
|
HEADERS engine/gststartup.h engine/gstengine.h engine/gstenginepipeline.h engine/gstelementdeleter.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# Xine
|
# Xine
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "appearance.h"
|
#include "appearance.h"
|
||||||
|
#include "engine/enginetype.h"
|
||||||
#include "engine/enginebase.h"
|
#include "engine/enginebase.h"
|
||||||
#include "dialogs/errordialog.h"
|
#include "dialogs/errordialog.h"
|
||||||
#include "dialogs/about.h"
|
#include "dialogs/about.h"
|
||||||
@@ -281,6 +282,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
app_->player()->SetAnalyzer(ui_->analyzer);
|
app_->player()->SetAnalyzer(ui_->analyzer);
|
||||||
app_->player()->SetEqualizer(equalizer_.get());
|
app_->player()->SetEqualizer(equalizer_.get());
|
||||||
app_->player()->Init();
|
app_->player()->Init();
|
||||||
|
EngineChanged(app_->player()->engine()->type());
|
||||||
int volume = app_->player()->GetVolume();
|
int volume = app_->player()->GetVolume();
|
||||||
ui_->volume->setValue(volume);
|
ui_->volume->setValue(volume);
|
||||||
VolumeChanged(volume);
|
VolumeChanged(volume);
|
||||||
@@ -450,6 +452,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
// Player connections
|
// Player connections
|
||||||
connect(ui_->volume, SIGNAL(valueChanged(int)), app_->player(), SLOT(SetVolume(int)));
|
connect(ui_->volume, SIGNAL(valueChanged(int)), app_->player(), SLOT(SetVolume(int)));
|
||||||
|
|
||||||
|
connect(app_->player(), SIGNAL(EngineChanged(Engine::EngineType)), SLOT(EngineChanged(Engine::EngineType)));
|
||||||
connect(app_->player(), SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString)));
|
connect(app_->player(), SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString)));
|
||||||
connect(app_->player(), SIGNAL(SongChangeRequestProcessed(QUrl,bool)), app_->playlist_manager(), SLOT(SongChangeRequestProcessed(QUrl,bool)));
|
connect(app_->player(), SIGNAL(SongChangeRequestProcessed(QUrl,bool)), app_->playlist_manager(), SLOT(SongChangeRequestProcessed(QUrl,bool)));
|
||||||
|
|
||||||
@@ -479,16 +482,18 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
connect(app_->playlist_manager(), SIGNAL(PlayRequested(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
connect(app_->playlist_manager(), SIGNAL(PlayRequested(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
||||||
|
|
||||||
connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlaylistDoubleClick(QModelIndex)));
|
connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlaylistDoubleClick(QModelIndex)));
|
||||||
//connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
|
||||||
connect(ui_->playlist->view(), SIGNAL(PlayItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
connect(ui_->playlist->view(), SIGNAL(PlayItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
|
||||||
connect(ui_->playlist->view(), SIGNAL(PlayPause()), app_->player(), SLOT(PlayPause()));
|
connect(ui_->playlist->view(), SIGNAL(PlayPause()), app_->player(), SLOT(PlayPause()));
|
||||||
connect(ui_->playlist->view(), SIGNAL(RightClicked(QPoint,QModelIndex)), SLOT(PlaylistRightClick(QPoint,QModelIndex)));
|
connect(ui_->playlist->view(), SIGNAL(RightClicked(QPoint,QModelIndex)), SLOT(PlaylistRightClick(QPoint,QModelIndex)));
|
||||||
//connect(ui_->playlist->view(), SIGNAL(SeekTrack(int)), ui_->track_slider, SLOT(Seek(int)));
|
|
||||||
connect(ui_->playlist->view(), SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward()));
|
connect(ui_->playlist->view(), SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward()));
|
||||||
connect(ui_->playlist->view(), SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward()));
|
connect(ui_->playlist->view(), SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward()));
|
||||||
connect(ui_->playlist->view(), SIGNAL(BackgroundPropertyChanged()), SLOT(RefreshStyleSheet()));
|
connect(ui_->playlist->view(), SIGNAL(BackgroundPropertyChanged()), SLOT(RefreshStyleSheet()));
|
||||||
|
|
||||||
connect(ui_->track_slider, SIGNAL(ValueChangedSeconds(int)), app_->player(), SLOT(SeekTo(int)));
|
connect(ui_->track_slider, SIGNAL(ValueChangedSeconds(int)), app_->player(), SLOT(SeekTo(int)));
|
||||||
|
connect(ui_->track_slider, SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward()));
|
||||||
|
connect(ui_->track_slider, SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward()));
|
||||||
|
connect(ui_->track_slider, SIGNAL(Previous()), app_->player(), SLOT(Previous()));
|
||||||
|
connect(ui_->track_slider, SIGNAL(Next()), app_->player(), SLOT(Next()));
|
||||||
|
|
||||||
// Context connections
|
// Context connections
|
||||||
|
|
||||||
@@ -884,6 +889,17 @@ void MainWindow::RefreshStyleSheet() {
|
|||||||
setStyleSheet(contents);
|
setStyleSheet(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::EngineChanged(Engine::EngineType enginetype) {
|
||||||
|
|
||||||
|
if (enginetype == Engine::EngineType::GStreamer) {
|
||||||
|
ui_->action_open_cd->setEnabled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui_->action_open_cd->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::MediaStopped() {
|
void MainWindow::MediaStopped() {
|
||||||
|
|
||||||
setWindowTitle("Strawberry Music Player");
|
setWindowTitle("Strawberry Music Player");
|
||||||
@@ -1316,6 +1332,7 @@ void MainWindow::AddToPlaylist(QMimeData *data) {
|
|||||||
}
|
}
|
||||||
app_->playlist_manager()->current()->dropMimeData(data, Qt::CopyAction, -1, 0, QModelIndex());
|
app_->playlist_manager()->current()->dropMimeData(data, Qt::CopyAction, -1, 0, QModelIndex());
|
||||||
delete data;
|
delete data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddToPlaylist(QAction *action) {
|
void MainWindow::AddToPlaylist(QAction *action) {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
#include "core/lazy.h"
|
#include "core/lazy.h"
|
||||||
#include "core/tagreaderclient.h"
|
#include "core/tagreaderclient.h"
|
||||||
|
#include "engine/enginetype.h"
|
||||||
#include "engine/engine_fwd.h"
|
#include "engine/engine_fwd.h"
|
||||||
#include "mac_startup.h"
|
#include "mac_startup.h"
|
||||||
#include "widgets/osd.h"
|
#include "widgets/osd.h"
|
||||||
@@ -135,6 +136,7 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void FilePathChanged(const QString& path);
|
void FilePathChanged(const QString& path);
|
||||||
|
|
||||||
|
void EngineChanged(Engine::EngineType enginetype);
|
||||||
void MediaStopped();
|
void MediaStopped();
|
||||||
void MediaPaused();
|
void MediaPaused();
|
||||||
void MediaPlaying();
|
void MediaPlaying();
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
#ifdef HAVE_GSTREAMER
|
#ifdef HAVE_GSTREAMER
|
||||||
# include "engine/gstengine.h"
|
# include "engine/gstengine.h"
|
||||||
|
# include "engine/gststartup.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_XINE
|
#ifdef HAVE_XINE
|
||||||
# include "engine/xineengine.h"
|
# include "engine/xineengine.h"
|
||||||
@@ -75,12 +76,17 @@
|
|||||||
#include "scrobbler/audioscrobbler.h"
|
#include "scrobbler/audioscrobbler.h"
|
||||||
|
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
using std::unique_ptr;
|
||||||
|
|
||||||
const char *Player::kSettingsGroup = "Player";
|
const char *Player::kSettingsGroup = "Player";
|
||||||
|
|
||||||
Player::Player(Application *app, QObject *parent)
|
Player::Player(Application *app, QObject *parent)
|
||||||
: PlayerInterface(parent),
|
: PlayerInterface(parent),
|
||||||
app_(app),
|
app_(app),
|
||||||
|
engine_(nullptr),
|
||||||
|
#ifdef HAVE_GSTREAMER
|
||||||
|
gst_startup_(new GstStartup(this)),
|
||||||
|
#endif
|
||||||
analyzer_(nullptr),
|
analyzer_(nullptr),
|
||||||
equalizer_(nullptr),
|
equalizer_(nullptr),
|
||||||
stream_change_type_(Engine::First),
|
stream_change_type_(Engine::First),
|
||||||
@@ -117,10 +123,13 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
|||||||
switch(enginetype) {
|
switch(enginetype) {
|
||||||
case Engine::None:
|
case Engine::None:
|
||||||
#ifdef HAVE_GSTREAMER
|
#ifdef HAVE_GSTREAMER
|
||||||
case Engine::GStreamer:
|
case Engine::GStreamer:{
|
||||||
use_enginetype=Engine::GStreamer;
|
use_enginetype=Engine::GStreamer;
|
||||||
engine_.reset(new GstEngine(app_->task_manager()));
|
unique_ptr<GstEngine> gst_engine(new GstEngine(app_->task_manager()));
|
||||||
|
gst_engine->SetStartup(gst_startup_);
|
||||||
|
engine_.reset(gst_engine.release());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_XINE
|
#ifdef HAVE_XINE
|
||||||
case Engine::Xine:
|
case Engine::Xine:
|
||||||
@@ -160,6 +169,8 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
|||||||
qFatal("Failed to create engine!");
|
qFatal("Failed to create engine!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit EngineChanged(use_enginetype);
|
||||||
|
|
||||||
return use_enginetype;
|
return use_enginetype;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@
|
|||||||
#include "urlhandler.h"
|
#include "urlhandler.h"
|
||||||
#include "engine/engine_fwd.h"
|
#include "engine/engine_fwd.h"
|
||||||
#include "engine/enginetype.h"
|
#include "engine/enginetype.h"
|
||||||
|
#ifdef HAVE_GSTREAMER
|
||||||
|
#include "engine/gststartup.h"
|
||||||
|
#endif
|
||||||
#include "playlist/playlistitem.h"
|
#include "playlist/playlistitem.h"
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
@@ -45,6 +48,8 @@ class Song;
|
|||||||
class AnalyzerContainer;
|
class AnalyzerContainer;
|
||||||
class Equalizer;
|
class Equalizer;
|
||||||
|
|
||||||
|
using std::unique_ptr;
|
||||||
|
|
||||||
namespace Engine {
|
namespace Engine {
|
||||||
struct SimpleMetaBundle;
|
struct SimpleMetaBundle;
|
||||||
} // namespace Engine
|
} // namespace Engine
|
||||||
@@ -183,6 +188,9 @@ class Player : public PlayerInterface {
|
|||||||
|
|
||||||
void HandleAuthentication();
|
void HandleAuthentication();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void EngineChanged(Engine::EngineType enginetype);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void EngineStateChanged(Engine::State);
|
void EngineStateChanged(Engine::State);
|
||||||
void EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle);
|
void EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle);
|
||||||
@@ -207,6 +215,10 @@ class Player : public PlayerInterface {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Application *app_;
|
Application *app_;
|
||||||
|
std::unique_ptr<EngineBase> engine_;
|
||||||
|
#ifdef HAVE_GSTREAMER
|
||||||
|
GstStartup *gst_startup_;
|
||||||
|
#endif
|
||||||
AnalyzerContainer *analyzer_;
|
AnalyzerContainer *analyzer_;
|
||||||
Equalizer *equalizer_;
|
Equalizer *equalizer_;
|
||||||
|
|
||||||
@@ -214,7 +226,6 @@ class Player : public PlayerInterface {
|
|||||||
|
|
||||||
PlaylistItemPtr current_item_;
|
PlaylistItemPtr current_item_;
|
||||||
|
|
||||||
std::unique_ptr<EngineBase> engine_;
|
|
||||||
Engine::TrackChangeFlags stream_change_type_;
|
Engine::TrackChangeFlags stream_change_type_;
|
||||||
Engine::State last_state_;
|
Engine::State last_state_;
|
||||||
int nb_errors_received_;
|
int nb_errors_received_;
|
||||||
|
|||||||
@@ -37,4 +37,4 @@ Q_DECLARE_FLAGS(TrackChangeFlags, TrackChangeType);
|
|||||||
|
|
||||||
typedef Engine::Base EngineBase;
|
typedef Engine::Base EngineBase;
|
||||||
|
|
||||||
#endif
|
#endif // ENGINE_FWD_H
|
||||||
|
|||||||
@@ -33,9 +33,6 @@
|
|||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QtConcurrentRun>
|
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -63,13 +60,6 @@
|
|||||||
#include "gstengine.h"
|
#include "gstengine.h"
|
||||||
#include "gstenginepipeline.h"
|
#include "gstenginepipeline.h"
|
||||||
#include "gstbufferconsumer.h"
|
#include "gstbufferconsumer.h"
|
||||||
#ifdef HAVE_IMOBILEDEVICE_ // FIXME
|
|
||||||
# include "ext/gstafc/gstafcsrc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_MOODBAR
|
|
||||||
# include "ext/gstmoodbar/gstmoodbarplugin.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "settings/backendsettingspage.h"
|
#include "settings/backendsettingspage.h"
|
||||||
|
|
||||||
@@ -119,10 +109,6 @@ GstEngine::~GstEngine() {
|
|||||||
|
|
||||||
bool GstEngine::Init() {
|
bool GstEngine::Init() {
|
||||||
|
|
||||||
SetEnvironment();
|
|
||||||
|
|
||||||
initialising_ = QtConcurrent::run(this, &GstEngine::InitialiseGStreamer);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -412,60 +398,6 @@ void GstEngine::ReloadSettings() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GstEngine::InitialiseGStreamer() {
|
|
||||||
|
|
||||||
gst_init(nullptr, nullptr);
|
|
||||||
|
|
||||||
#ifdef HAVE_IMOBILEDEVICE_ // FIXME
|
|
||||||
afcsrc_register_static();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_MOODBAR
|
|
||||||
gstfastspectrum_register_static();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GstEngine::SetEnvironment() {
|
|
||||||
|
|
||||||
QString scanner_path;
|
|
||||||
QString plugin_path;
|
|
||||||
QString registry_filename;
|
|
||||||
|
|
||||||
// On Windows and macOS we bundle the gstreamer plugins with strawberry
|
|
||||||
#ifdef USE_BUNDLE
|
|
||||||
#if defined(Q_OS_MACOS)
|
|
||||||
scanner_path = QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gst-plugin-scanner";
|
|
||||||
plugin_path = QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gstreamer";
|
|
||||||
#elif defined(Q_OS_WIN32)
|
|
||||||
plugin_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/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());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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()) {
|
|
||||||
Utilities::SetEnv("GST_REGISTRY", registry_filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(Q_OS_MACOS) && defined(USE_BUNDLE)
|
|
||||||
Utilities::SetEnv("GIO_EXTRA_MODULES", QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gio-modules");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Utilities::SetEnv("PULSE_PROP_media.role", "music");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GstElement *GstEngine::CreateElement(const QString &factoryName, GstElement *bin, bool showerror) {
|
GstElement *GstEngine::CreateElement(const QString &factoryName, GstElement *bin, bool showerror) {
|
||||||
|
|
||||||
// Make a unique name
|
// Make a unique name
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "core/timeconstants.h"
|
#include "core/timeconstants.h"
|
||||||
#include "engine_fwd.h"
|
#include "engine_fwd.h"
|
||||||
#include "enginebase.h"
|
#include "enginebase.h"
|
||||||
|
#include "gststartup.h"
|
||||||
#include "gstbufferconsumer.h"
|
#include "gstbufferconsumer.h"
|
||||||
|
|
||||||
class TaskManager;
|
class TaskManager;
|
||||||
@@ -90,9 +91,8 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
|||||||
bool CustomDeviceSupport(const QString &output);
|
bool CustomDeviceSupport(const QString &output);
|
||||||
bool ALSADeviceSupport(const QString &output);
|
bool ALSADeviceSupport(const QString &output);
|
||||||
|
|
||||||
void EnsureInitialised() { initialising_.waitForFinished(); }
|
void SetStartup(GstStartup *gst_startup) { gst_startup_ = gst_startup; }
|
||||||
void InitialiseGStreamer();
|
void EnsureInitialised() { gst_startup_->EnsureInitialised(); }
|
||||||
void SetEnvironment();
|
|
||||||
|
|
||||||
GstElement *CreateElement(const QString &factoryName, GstElement *bin = nullptr, bool showerror = true);
|
GstElement *CreateElement(const QString &factoryName, GstElement *bin = nullptr, bool showerror = true);
|
||||||
void ConsumeBuffer(GstBuffer *buffer, int pipeline_id);
|
void ConsumeBuffer(GstBuffer *buffer, int pipeline_id);
|
||||||
@@ -168,10 +168,9 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
|||||||
static const qint64 kSeekDelayNanosec = 100 * kNsecPerMsec; // 100msec
|
static const qint64 kSeekDelayNanosec = 100 * kNsecPerMsec; // 100msec
|
||||||
|
|
||||||
TaskManager *task_manager_;
|
TaskManager *task_manager_;
|
||||||
|
GstStartup *gst_startup_;
|
||||||
int buffering_task_id_;
|
int buffering_task_id_;
|
||||||
|
|
||||||
QFuture<void> initialising_;
|
|
||||||
|
|
||||||
std::shared_ptr<GstEnginePipeline> current_pipeline_;
|
std::shared_ptr<GstEnginePipeline> current_pipeline_;
|
||||||
std::shared_ptr<GstEnginePipeline> fadeout_pipeline_;
|
std::shared_ptr<GstEnginePipeline> fadeout_pipeline_;
|
||||||
std::shared_ptr<GstEnginePipeline> fadeout_pause_pipeline_;
|
std::shared_ptr<GstEnginePipeline> fadeout_pause_pipeline_;
|
||||||
@@ -209,4 +208,4 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* GSTENGINE_H */
|
#endif /* GSTENGINE_H */
|
||||||
|
|||||||
106
src/engine/gststartup.cpp
Normal file
106
src/engine/gststartup.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QtConcurrentRun>
|
||||||
|
#include <QFuture>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "core/utilities.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_MOODBAR
|
||||||
|
# include "ext/gstmoodbar/gstmoodbarplugin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gststartup.h"
|
||||||
|
|
||||||
|
GstStartup::GstStartup(QObject *parent) : QObject(parent) {
|
||||||
|
initialising_ = QtConcurrent::run(this, &GstStartup::InitialiseGStreamer);
|
||||||
|
}
|
||||||
|
|
||||||
|
GstStartup::~GstStartup() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void GstStartup::InitialiseGStreamer() {
|
||||||
|
|
||||||
|
SetEnvironment();
|
||||||
|
|
||||||
|
gst_init(nullptr, nullptr);
|
||||||
|
|
||||||
|
#ifdef HAVE_MOODBAR
|
||||||
|
gstfastspectrum_register_static();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GstStartup::SetEnvironment() {
|
||||||
|
|
||||||
|
QString scanner_path;
|
||||||
|
QString plugin_path;
|
||||||
|
QString registry_filename;
|
||||||
|
|
||||||
|
// On Windows and macOS we bundle the gstreamer plugins with strawberry
|
||||||
|
#ifdef USE_BUNDLE
|
||||||
|
#if defined(Q_OS_MACOS)
|
||||||
|
scanner_path = QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gst-plugin-scanner";
|
||||||
|
plugin_path = QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gstreamer";
|
||||||
|
#elif defined(Q_OS_WIN32)
|
||||||
|
plugin_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/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());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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()) {
|
||||||
|
Utilities::SetEnv("GST_REGISTRY", registry_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(Q_OS_MACOS) && defined(USE_BUNDLE)
|
||||||
|
Utilities::SetEnv("GIO_EXTRA_MODULES", QCoreApplication::applicationDirPath() + "/" + USE_BUNDLE_DIR + "/gio-modules");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Utilities::SetEnv("PULSE_PROP_media.role", "music");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
47
src/engine/gststartup.h
Normal file
47
src/engine/gststartup.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GSTSTARTUP_H
|
||||||
|
#define GSTSTARTUP_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QFuture>
|
||||||
|
|
||||||
|
class GstStartup : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GstStartup(QObject *parent = nullptr);
|
||||||
|
~GstStartup();
|
||||||
|
|
||||||
|
void EnsureInitialised() { initialising_.waitForFinished(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void InitialiseGStreamer();
|
||||||
|
void SetEnvironment();
|
||||||
|
QFuture<void> initialising_;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* GSTSTARTUP_H */
|
||||||
Reference in New Issue
Block a user