mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-30 09:05:04 +01:00
MoodbarPipeline: Cleanup on finish
This commit is contained in:
parent
af525e42b6
commit
c7830f6f05
@ -90,6 +90,7 @@ QByteArray MoodbarPipeline::ToGstUrl(const QUrl &url) {
|
|||||||
|
|
||||||
void MoodbarPipeline::Start() {
|
void MoodbarPipeline::Start() {
|
||||||
|
|
||||||
|
Q_ASSERT(QThread::currentThread() == thread());
|
||||||
Q_ASSERT(QThread::currentThread() != qApp->thread());
|
Q_ASSERT(QThread::currentThread() != qApp->thread());
|
||||||
|
|
||||||
Utilities::SetThreadIOPriority(Utilities::IoPriority::IOPRIO_CLASS_IDLE);
|
Utilities::SetThreadIOPriority(Utilities::IoPriority::IOPRIO_CLASS_IDLE);
|
||||||
@ -208,6 +209,8 @@ GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus *bus, GstMessage *messag
|
|||||||
|
|
||||||
MoodbarPipeline *instance = reinterpret_cast<MoodbarPipeline*>(self);
|
MoodbarPipeline *instance = reinterpret_cast<MoodbarPipeline*>(self);
|
||||||
|
|
||||||
|
if (!instance->running_) return GST_BUS_PASS;
|
||||||
|
|
||||||
switch (GST_MESSAGE_TYPE(message)) {
|
switch (GST_MESSAGE_TYPE(message)) {
|
||||||
case GST_MESSAGE_EOS:
|
case GST_MESSAGE_EOS:
|
||||||
instance->Stop(true);
|
instance->Stop(true);
|
||||||
@ -228,13 +231,26 @@ GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus *bus, GstMessage *messag
|
|||||||
|
|
||||||
void MoodbarPipeline::Stop(const bool success) {
|
void MoodbarPipeline::Stop(const bool success) {
|
||||||
|
|
||||||
success_ = success;
|
|
||||||
running_ = false;
|
running_ = false;
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(this, "Finish", Qt::QueuedConnection, Q_ARG(bool, success));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoodbarPipeline::Finish(const bool success) {
|
||||||
|
|
||||||
|
Q_ASSERT(QThread::currentThread() == thread());
|
||||||
|
Q_ASSERT(QThread::currentThread() != qApp->thread());
|
||||||
|
|
||||||
|
success_ = success;
|
||||||
|
|
||||||
if (builder_) {
|
if (builder_) {
|
||||||
data_ = builder_->Finish(1000);
|
data_ = builder_->Finish(1000);
|
||||||
builder_.reset();
|
builder_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cleanup();
|
||||||
|
|
||||||
Q_EMIT Finished(success);
|
Q_EMIT Finished(success);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -242,6 +258,7 @@ void MoodbarPipeline::Stop(const bool success) {
|
|||||||
void MoodbarPipeline::Cleanup() {
|
void MoodbarPipeline::Cleanup() {
|
||||||
|
|
||||||
running_ = false;
|
running_ = false;
|
||||||
|
|
||||||
if (pipeline_) {
|
if (pipeline_) {
|
||||||
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_));
|
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_));
|
||||||
if (bus) {
|
if (bus) {
|
||||||
|
@ -47,8 +47,7 @@ class MoodbarPipeline : public QObject {
|
|||||||
bool success() const { return success_; }
|
bool success() const { return success_; }
|
||||||
const QByteArray &data() const { return data_; }
|
const QByteArray &data() const { return data_; }
|
||||||
|
|
||||||
public Q_SLOTS:
|
Q_INVOKABLE void Start();
|
||||||
void Start();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void Finished(const bool success);
|
void Finished(const bool success);
|
||||||
@ -59,6 +58,7 @@ class MoodbarPipeline : public QObject {
|
|||||||
QByteArray ToGstUrl(const QUrl &url);
|
QByteArray ToGstUrl(const QUrl &url);
|
||||||
void ReportError(GstMessage *msg);
|
void ReportError(GstMessage *msg);
|
||||||
void Stop(const bool success);
|
void Stop(const bool success);
|
||||||
|
Q_INVOKABLE void Finish(const bool success);
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
static void NewPadCallback(GstElement *element, GstPad *pad, gpointer self);
|
static void NewPadCallback(GstElement *element, GstPad *pad, gpointer self);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user