Move GstStartup
This commit is contained in:
@@ -850,7 +850,6 @@ set(HEADERS
|
|||||||
|
|
||||||
src/engine/enginebase.h
|
src/engine/enginebase.h
|
||||||
src/engine/devicefinders.h
|
src/engine/devicefinders.h
|
||||||
src/engine/gststartup.h
|
|
||||||
src/engine/gstengine.h
|
src/engine/gstengine.h
|
||||||
src/engine/gstenginepipeline.h
|
src/engine/gstenginepipeline.h
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||||
* Copyright 2012, 2014, John Maguire <john.maguire@gmail.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
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -28,9 +28,14 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QMetaObject>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QAbstractEventDispatcher>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
@@ -241,10 +246,17 @@ class ApplicationImpl {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Application::Application(QObject *parent)
|
Application::Application(QObject *parent)
|
||||||
: QObject(parent), p_(new ApplicationImpl(this)) {
|
: QObject(parent),
|
||||||
|
p_(new ApplicationImpl(this)),
|
||||||
|
g_thread_(nullptr) {
|
||||||
|
|
||||||
setObjectName(QLatin1String(metaObject()->className()));
|
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();
|
device_finders()->Init();
|
||||||
collection()->Init();
|
collection()->Init();
|
||||||
tagreader_client();
|
tagreader_client();
|
||||||
@@ -264,6 +276,22 @@ Application::~Application() {
|
|||||||
thread->deleteLater();
|
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) {
|
QThread *Application::MoveToNewThread(QObject *object) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||||
* Copyright 2012, 2014, John Maguire <john.maguire@gmail.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
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -114,8 +116,12 @@ class Application : public QObject {
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void ExitFinished();
|
void ExitFinished();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static gpointer GLibMainLoopThreadFunc(gpointer data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScopedPtr<ApplicationImpl> p_;
|
ScopedPtr<ApplicationImpl> p_;
|
||||||
|
GThread *g_thread_;
|
||||||
QList<QThread*> threads_;
|
QList<QThread*> threads_;
|
||||||
QList<QObject*> wait_for_exit_;
|
QList<QObject*> wait_for_exit_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
|
|
||||||
#include "engine/enginebase.h"
|
#include "engine/enginebase.h"
|
||||||
#include "engine/gstengine.h"
|
#include "engine/gstengine.h"
|
||||||
#include "engine/gststartup.h"
|
|
||||||
|
|
||||||
#include "collection/collectionbackend.h"
|
#include "collection/collectionbackend.h"
|
||||||
#include "playlist/playlist.h"
|
#include "playlist/playlist.h"
|
||||||
@@ -80,7 +79,6 @@ Player::Player(const SharedPtr<TaskManager> task_manager, const SharedPtr<UrlHan
|
|||||||
url_handlers_(url_handlers),
|
url_handlers_(url_handlers),
|
||||||
playlist_manager_(playlist_manager),
|
playlist_manager_(playlist_manager),
|
||||||
engine_(nullptr),
|
engine_(nullptr),
|
||||||
gst_startup_(new GstStartup(this)),
|
|
||||||
analyzer_(nullptr),
|
analyzer_(nullptr),
|
||||||
equalizer_(nullptr),
|
equalizer_(nullptr),
|
||||||
timer_save_volume_(new QTimer(this)),
|
timer_save_volume_(new QTimer(this)),
|
||||||
@@ -128,7 +126,6 @@ EngineBase::Type Player::CreateEngine(EngineBase::Type enginetype) {
|
|||||||
case EngineBase::Type::GStreamer:{
|
case EngineBase::Type::GStreamer:{
|
||||||
use_enginetype=EngineBase::Type::GStreamer;
|
use_enginetype=EngineBase::Type::GStreamer;
|
||||||
ScopedPtr<GstEngine> gst_engine(new GstEngine(task_manager_));
|
ScopedPtr<GstEngine> gst_engine(new GstEngine(task_manager_));
|
||||||
gst_engine->SetStartup(gst_startup_);
|
|
||||||
engine_.reset(gst_engine.release());
|
engine_.reset(gst_engine.release());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class UrlHandlers;
|
|||||||
class PlaylistManager;
|
class PlaylistManager;
|
||||||
class AnalyzerContainer;
|
class AnalyzerContainer;
|
||||||
class Equalizer;
|
class Equalizer;
|
||||||
class GstStartup;
|
|
||||||
|
|
||||||
class Player : public PlayerInterface {
|
class Player : public PlayerInterface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -144,7 +143,6 @@ class Player : public PlayerInterface {
|
|||||||
const SharedPtr<UrlHandlers> url_handlers_;
|
const SharedPtr<UrlHandlers> url_handlers_;
|
||||||
const SharedPtr<PlaylistManager> playlist_manager_;
|
const SharedPtr<PlaylistManager> playlist_manager_;
|
||||||
SharedPtr<EngineBase> engine_;
|
SharedPtr<EngineBase> engine_;
|
||||||
GstStartup *gst_startup_;
|
|
||||||
AnalyzerContainer *analyzer_;
|
AnalyzerContainer *analyzer_;
|
||||||
SharedPtr<Equalizer> equalizer_;
|
SharedPtr<Equalizer> equalizer_;
|
||||||
QTimer *timer_save_volume_;
|
QTimer *timer_save_volume_;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Copyright (C) 2003-2005 by Mark Kretschmann <markey@web.de> *
|
* Copyright (C) 2003-2005 by Mark Kretschmann <markey@web.de> *
|
||||||
* Copyright (C) 2005 by Jakub Stachowski <qbast@go2.pl> *
|
* Copyright (C) 2005 by Jakub Stachowski <qbast@go2.pl> *
|
||||||
* Copyright (C) 2006 Paul Cifarelli <paul@cifarelli.net> *
|
* Copyright (C) 2006 Paul Cifarelli <paul@cifarelli.net> *
|
||||||
* Copyright (C) 2017-2021 Jonas Kvinge <jonas@jkvinge.net> *
|
* Copyright (C) 2017-2024 Jonas Kvinge <jonas@jkvinge.net> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@@ -97,7 +97,6 @@ constexpr qint64 kSeekDelayNanosec = 100 * kNsecPerMsec; // 100msec
|
|||||||
GstEngine::GstEngine(SharedPtr<TaskManager> task_manager, QObject *parent)
|
GstEngine::GstEngine(SharedPtr<TaskManager> task_manager, QObject *parent)
|
||||||
: EngineBase(parent),
|
: EngineBase(parent),
|
||||||
task_manager_(task_manager),
|
task_manager_(task_manager),
|
||||||
gst_startup_(nullptr),
|
|
||||||
discoverer_(nullptr),
|
discoverer_(nullptr),
|
||||||
buffering_task_id_(-1),
|
buffering_task_id_(-1),
|
||||||
latest_buffer_(nullptr),
|
latest_buffer_(nullptr),
|
||||||
@@ -129,7 +128,6 @@ GstEngine::GstEngine(SharedPtr<TaskManager> task_manager, QObject *parent)
|
|||||||
|
|
||||||
GstEngine::~GstEngine() {
|
GstEngine::~GstEngine() {
|
||||||
|
|
||||||
EnsureInitialized();
|
|
||||||
current_pipeline_.reset();
|
current_pipeline_.reset();
|
||||||
|
|
||||||
if (latest_buffer_) {
|
if (latest_buffer_) {
|
||||||
@@ -181,8 +179,6 @@ EngineBase::State GstEngine::state() const {
|
|||||||
|
|
||||||
void GstEngine::StartPreloading(const QUrl &media_url, const QUrl &stream_url, const bool force_stop_at_end, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
void GstEngine::StartPreloading(const QUrl &media_url, const QUrl &stream_url, const bool force_stop_at_end, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||||
|
|
||||||
EnsureInitialized();
|
|
||||||
|
|
||||||
const QByteArray gst_url = FixupUrl(stream_url);
|
const QByteArray gst_url = FixupUrl(stream_url);
|
||||||
|
|
||||||
// No crossfading, so we can just queue the new URL in the existing pipeline and get gapless playback (hopefully)
|
// No crossfading, so we can just queue the new URL in the existing pipeline and get gapless playback (hopefully)
|
||||||
@@ -200,8 +196,6 @@ void GstEngine::StartPreloading(const QUrl &media_url, const QUrl &stream_url, c
|
|||||||
|
|
||||||
bool GstEngine::Load(const QUrl &media_url, const QUrl &stream_url, const EngineBase::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec, const std::optional<double> ebur128_integrated_loudness_lufs) {
|
bool GstEngine::Load(const QUrl &media_url, const QUrl &stream_url, const EngineBase::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec, const std::optional<double> ebur128_integrated_loudness_lufs) {
|
||||||
|
|
||||||
EnsureInitialized();
|
|
||||||
|
|
||||||
EngineBase::Load(media_url, stream_url, change, force_stop_at_end, beginning_nanosec, end_nanosec, ebur128_integrated_loudness_lufs);
|
EngineBase::Load(media_url, stream_url, change, force_stop_at_end, beginning_nanosec, end_nanosec, ebur128_integrated_loudness_lufs);
|
||||||
|
|
||||||
const QByteArray gst_url = FixupUrl(stream_url);
|
const QByteArray gst_url = FixupUrl(stream_url);
|
||||||
@@ -270,8 +264,6 @@ bool GstEngine::Load(const QUrl &media_url, const QUrl &stream_url, const Engine
|
|||||||
|
|
||||||
bool GstEngine::Play(const bool pause, const quint64 offset_nanosec) {
|
bool GstEngine::Play(const bool pause, const quint64 offset_nanosec) {
|
||||||
|
|
||||||
EnsureInitialized();
|
|
||||||
|
|
||||||
if (!current_pipeline_ || current_pipeline_->is_buffering() || current_pipeline_->state() == GstState::GST_STATE_PLAYING) return false;
|
if (!current_pipeline_ || current_pipeline_->is_buffering() || current_pipeline_->state() == GstState::GST_STATE_PLAYING) return false;
|
||||||
|
|
||||||
if (OldExclusivePipelineActive()) {
|
if (OldExclusivePipelineActive()) {
|
||||||
@@ -458,8 +450,6 @@ const EngineBase::Scope &GstEngine::scope(const int chunk_length) {
|
|||||||
|
|
||||||
EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
||||||
|
|
||||||
const_cast<GstEngine*>(this)->EnsureInitialized();
|
|
||||||
|
|
||||||
OutputDetailsList outputs;
|
OutputDetailsList outputs;
|
||||||
|
|
||||||
GstRegistry *registry = gst_registry_get();
|
GstRegistry *registry = gst_registry_get();
|
||||||
@@ -498,8 +488,6 @@ EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
|||||||
|
|
||||||
bool GstEngine::ValidOutput(const QString &output) {
|
bool GstEngine::ValidOutput(const QString &output) {
|
||||||
|
|
||||||
EnsureInitialized();
|
|
||||||
|
|
||||||
const OutputDetailsList output_details = GetOutputsList();
|
const OutputDetailsList output_details = GetOutputsList();
|
||||||
return std::any_of(output_details.begin(), output_details.end(), [output](const OutputDetails &output_detail) { return output_detail.name == output; });
|
return std::any_of(output_details.begin(), output_details.end(), [output](const OutputDetails &output_detail) { return output_detail.name == output; });
|
||||||
|
|
||||||
@@ -804,8 +792,6 @@ void GstEngine::BufferingFinished() {
|
|||||||
|
|
||||||
QByteArray GstEngine::FixupUrl(const QUrl &url) {
|
QByteArray GstEngine::FixupUrl(const QUrl &url) {
|
||||||
|
|
||||||
EnsureInitialized();
|
|
||||||
|
|
||||||
QByteArray uri;
|
QByteArray uri;
|
||||||
|
|
||||||
// It's a file:// url with a hostname set.
|
// It's a file:// url with a hostname set.
|
||||||
@@ -901,8 +887,6 @@ void GstEngine::StopTimers() {
|
|||||||
|
|
||||||
GstEnginePipelinePtr GstEngine::CreatePipeline() {
|
GstEnginePipelinePtr GstEngine::CreatePipeline() {
|
||||||
|
|
||||||
EnsureInitialized();
|
|
||||||
|
|
||||||
GstEnginePipelinePtr pipeline = make_shared<GstEnginePipeline>();
|
GstEnginePipelinePtr pipeline = make_shared<GstEnginePipeline>();
|
||||||
pipeline->set_output_device(output_, device_);
|
pipeline->set_output_device(output_, device_);
|
||||||
pipeline->set_exclusive_mode(exclusive_mode_);
|
pipeline->set_exclusive_mode(exclusive_mode_);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Copyright (C) 2003-2005 by Mark Kretschmann <markey@web.de> *
|
* Copyright (C) 2003-2005 by Mark Kretschmann <markey@web.de> *
|
||||||
* Copyright (C) 2005 by Jakub Stachowski <qbast@go2.pl> *
|
* Copyright (C) 2005 by Jakub Stachowski <qbast@go2.pl> *
|
||||||
* Copyright (C) 2006 Paul Cifarelli <paul@cifarelli.net> *
|
* Copyright (C) 2006 Paul Cifarelli <paul@cifarelli.net> *
|
||||||
* Copyright (C) 2017-2021 Jonas Kvinge <jonas@jkvinge.net> *
|
* Copyright (C) 2017-2024 Jonas Kvinge <jonas@jkvinge.net> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
#include "includes/shared_ptr.h"
|
#include "includes/shared_ptr.h"
|
||||||
#include "enginebase.h"
|
#include "enginebase.h"
|
||||||
#include "gststartup.h"
|
|
||||||
#include "gstenginepipeline.h"
|
#include "gstenginepipeline.h"
|
||||||
#include "gstbufferconsumer.h"
|
#include "gstbufferconsumer.h"
|
||||||
|
|
||||||
@@ -85,9 +84,6 @@ class GstEngine : public EngineBase, public GstBufferConsumer {
|
|||||||
bool ALSADeviceSupport(const QString &output) const override;
|
bool ALSADeviceSupport(const QString &output) const override;
|
||||||
bool ExclusiveModeSupport(const QString &output) const override;
|
bool ExclusiveModeSupport(const QString &output) const override;
|
||||||
|
|
||||||
void SetStartup(GstStartup *gst_startup) { gst_startup_ = gst_startup; }
|
|
||||||
void EnsureInitialized() { gst_startup_->EnsureInitialized(); }
|
|
||||||
|
|
||||||
void ConsumeBuffer(GstBuffer *buffer, const int pipeline_id, const QString &format) override;
|
void ConsumeBuffer(GstBuffer *buffer, const int pipeline_id, const QString &format) override;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
@@ -153,7 +149,6 @@ class GstEngine : public EngineBase, public GstBufferConsumer {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SharedPtr<TaskManager> task_manager_;
|
SharedPtr<TaskManager> task_manager_;
|
||||||
GstStartup *gst_startup_;
|
|
||||||
GstDiscoverer *discoverer_;
|
GstDiscoverer *discoverer_;
|
||||||
|
|
||||||
int buffering_task_id_;
|
int buffering_task_id_;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.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
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.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
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* 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
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,15 +25,11 @@
|
|||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/pbutils/pbutils.h>
|
#include <gst/pbutils/pbutils.h>
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QMetaObject>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QtConcurrentRun>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QAbstractEventDispatcher>
|
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "utilities/envutils.h"
|
#include "utilities/envutils.h"
|
||||||
@@ -46,38 +42,9 @@
|
|||||||
|
|
||||||
using namespace Qt::Literals::StringLiterals;
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
GThread *GstStartup::kGThread = nullptr;
|
namespace GstStartup {
|
||||||
|
|
||||||
gpointer GstStartup::GLibMainLoopThreadFunc(gpointer data) {
|
void Initialize() {
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GstStartup::GstStartup(QObject *parent) : QObject(parent) {
|
|
||||||
|
|
||||||
initializing_ = QtConcurrent::run(&GstStartup::InitializeGStreamer);
|
|
||||||
|
|
||||||
const QMetaObject *mo = QAbstractEventDispatcher::instance(qApp->thread())->metaObject();
|
|
||||||
if (mo && strcmp(mo->className(), "QEventDispatcherGlib") != 0 && strcmp(mo->superClass()->className(), "QEventDispatcherGlib") != 0) {
|
|
||||||
kGThread = g_thread_new(nullptr, GstStartup::GLibMainLoopThreadFunc, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GstStartup::~GstStartup() {
|
|
||||||
if (kGThread) g_thread_unref(kGThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GstStartup::InitializeGStreamer() {
|
|
||||||
|
|
||||||
SetEnvironment();
|
SetEnvironment();
|
||||||
|
|
||||||
@@ -110,7 +77,7 @@ void GstStartup::InitializeGStreamer() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GstStartup::SetEnvironment() {
|
void SetEnvironment() {
|
||||||
|
|
||||||
#ifdef USE_BUNDLE
|
#ifdef USE_BUNDLE
|
||||||
|
|
||||||
@@ -177,7 +144,6 @@ void GstStartup::SetEnvironment() {
|
|||||||
|
|
||||||
#endif // USE_BUNDLE
|
#endif // USE_BUNDLE
|
||||||
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32) || defined(Q_OS_MACOS)
|
#if defined(Q_OS_WIN32) || defined(Q_OS_MACOS)
|
||||||
QString gst_registry_filename = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion());
|
QString gst_registry_filename = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion());
|
||||||
qLog(Debug) << "Setting GStreamer registry file to" << gst_registry_filename;
|
qLog(Debug) << "Setting GStreamer registry file to" << gst_registry_filename;
|
||||||
@@ -185,3 +151,5 @@ void GstStartup::SetEnvironment() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace GstStartup
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* 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
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,32 +20,9 @@
|
|||||||
#ifndef GSTSTARTUP_H
|
#ifndef GSTSTARTUP_H
|
||||||
#define GSTSTARTUP_H
|
#define GSTSTARTUP_H
|
||||||
|
|
||||||
#include "config.h"
|
namespace GstStartup {
|
||||||
|
void Initialize();
|
||||||
#include <glib.h>
|
void SetEnvironment();
|
||||||
#include <gst/gst.h>
|
} // namespace
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QFuture>
|
|
||||||
|
|
||||||
class GstStartup : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit GstStartup(QObject *parent = nullptr);
|
|
||||||
~GstStartup() override;
|
|
||||||
|
|
||||||
void EnsureInitialized() { initializing_.waitForFinished(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
static GThread *kGThread;
|
|
||||||
static gpointer GLibMainLoopThreadFunc(gpointer data);
|
|
||||||
|
|
||||||
static void InitializeGStreamer();
|
|
||||||
static void SetEnvironment();
|
|
||||||
|
|
||||||
QFuture<void> initializing_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // GSTSTARTUP_H
|
#endif // GSTSTARTUP_H
|
||||||
|
|||||||
@@ -118,6 +118,8 @@
|
|||||||
# include "osd/osdbase.h"
|
# include "osd/osdbase.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "engine/gststartup.h"
|
||||||
|
|
||||||
using namespace Qt::Literals::StringLiterals;
|
using namespace Qt::Literals::StringLiterals;
|
||||||
using std::make_shared;
|
using std::make_shared;
|
||||||
|
|
||||||
@@ -191,6 +193,8 @@ int main(int argc, char *argv[]) {
|
|||||||
QGuiApplication::setDesktopFileName(u"org.strawberrymusicplayer.strawberry"_s);
|
QGuiApplication::setDesktopFileName(u"org.strawberrymusicplayer.strawberry"_s);
|
||||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
|
GstStartup::Initialize();
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
KDSingleApplication single_app(QCoreApplication::applicationName(), KDSingleApplication::Option::IncludeUsernameInSocketName);
|
KDSingleApplication single_app(QCoreApplication::applicationName(), KDSingleApplication::Option::IncludeUsernameInSocketName);
|
||||||
if (!single_app.isPrimaryInstance()) {
|
if (!single_app.isPrimaryInstance()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user