Move GstStartup
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2012, 2014, John Maguire <john.maguire@gmail.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2018-2024, 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
|
||||
@@ -28,9 +28,14 @@
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
#include <QMetaObject>
|
||||
#include <QCoreApplication>
|
||||
#include <QAbstractEventDispatcher>
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
@@ -241,10 +246,17 @@ class ApplicationImpl {
|
||||
};
|
||||
|
||||
Application::Application(QObject *parent)
|
||||
: QObject(parent), p_(new ApplicationImpl(this)) {
|
||||
: QObject(parent),
|
||||
p_(new ApplicationImpl(this)),
|
||||
g_thread_(nullptr) {
|
||||
|
||||
setObjectName(QLatin1String(metaObject()->className()));
|
||||
|
||||
const QMetaObject *mo = QAbstractEventDispatcher::instance(QCoreApplication::instance()->thread())->metaObject();
|
||||
if (mo && strcmp(mo->className(), "QEventDispatcherGlib") != 0 && strcmp(mo->superClass()->className(), "QEventDispatcherGlib") != 0) {
|
||||
g_thread_ = g_thread_new(nullptr, Application::GLibMainLoopThreadFunc, nullptr);
|
||||
}
|
||||
|
||||
device_finders()->Init();
|
||||
collection()->Init();
|
||||
tagreader_client();
|
||||
@@ -264,6 +276,22 @@ Application::~Application() {
|
||||
thread->deleteLater();
|
||||
}
|
||||
|
||||
if (g_thread_) g_thread_unref(g_thread_);
|
||||
|
||||
}
|
||||
|
||||
gpointer Application::GLibMainLoopThreadFunc(gpointer data) {
|
||||
|
||||
Q_UNUSED(data)
|
||||
|
||||
qLog(Info) << "Creating GLib main event loop.";
|
||||
|
||||
GMainLoop *gloop = g_main_loop_new(nullptr, false);
|
||||
g_main_loop_run(gloop);
|
||||
g_main_loop_unref(gloop);
|
||||
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
QThread *Application::MoveToNewThread(QObject *object) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2012, 2014, John Maguire <john.maguire@gmail.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2018-2024, 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
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
@@ -114,8 +116,12 @@ class Application : public QObject {
|
||||
Q_SIGNALS:
|
||||
void ExitFinished();
|
||||
|
||||
private:
|
||||
static gpointer GLibMainLoopThreadFunc(gpointer data);
|
||||
|
||||
private:
|
||||
ScopedPtr<ApplicationImpl> p_;
|
||||
GThread *g_thread_;
|
||||
QList<QThread*> threads_;
|
||||
QList<QObject*> wait_for_exit_;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
|
||||
#include "engine/enginebase.h"
|
||||
#include "engine/gstengine.h"
|
||||
#include "engine/gststartup.h"
|
||||
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "playlist/playlist.h"
|
||||
@@ -80,7 +79,6 @@ Player::Player(const SharedPtr<TaskManager> task_manager, const SharedPtr<UrlHan
|
||||
url_handlers_(url_handlers),
|
||||
playlist_manager_(playlist_manager),
|
||||
engine_(nullptr),
|
||||
gst_startup_(new GstStartup(this)),
|
||||
analyzer_(nullptr),
|
||||
equalizer_(nullptr),
|
||||
timer_save_volume_(new QTimer(this)),
|
||||
@@ -128,7 +126,6 @@ EngineBase::Type Player::CreateEngine(EngineBase::Type enginetype) {
|
||||
case EngineBase::Type::GStreamer:{
|
||||
use_enginetype=EngineBase::Type::GStreamer;
|
||||
ScopedPtr<GstEngine> gst_engine(new GstEngine(task_manager_));
|
||||
gst_engine->SetStartup(gst_startup_);
|
||||
engine_.reset(gst_engine.release());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ class UrlHandlers;
|
||||
class PlaylistManager;
|
||||
class AnalyzerContainer;
|
||||
class Equalizer;
|
||||
class GstStartup;
|
||||
|
||||
class Player : public PlayerInterface {
|
||||
Q_OBJECT
|
||||
@@ -144,7 +143,6 @@ class Player : public PlayerInterface {
|
||||
const SharedPtr<UrlHandlers> url_handlers_;
|
||||
const SharedPtr<PlaylistManager> playlist_manager_;
|
||||
SharedPtr<EngineBase> engine_;
|
||||
GstStartup *gst_startup_;
|
||||
AnalyzerContainer *analyzer_;
|
||||
SharedPtr<Equalizer> equalizer_;
|
||||
QTimer *timer_save_volume_;
|
||||
|
||||
Reference in New Issue
Block a user