mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-27 15:49:43 +01:00
GstEnginePipeline: Add separate set state async function
This commit is contained in:
parent
0a361bfb3b
commit
70d0772e04
@ -349,7 +349,7 @@ void GstEngine::Pause() {
|
||||
StartFadeoutPause();
|
||||
}
|
||||
else {
|
||||
current_pipeline_->SetStateAsync(GST_STATE_PAUSED);
|
||||
current_pipeline_->SetState(GST_STATE_PAUSED);
|
||||
Q_EMIT StateChanged(State::Paused);
|
||||
StopTimers();
|
||||
}
|
||||
@ -371,7 +371,7 @@ void GstEngine::Unpause() {
|
||||
has_faded_out_to_pause_ = false;
|
||||
}
|
||||
|
||||
current_pipeline_->SetStateAsync(GST_STATE_PLAYING);
|
||||
current_pipeline_->SetState(GST_STATE_PLAYING);
|
||||
|
||||
Q_EMIT StateChanged(State::Playing);
|
||||
|
||||
@ -688,7 +688,7 @@ void GstEngine::FadeoutPauseFinished() {
|
||||
|
||||
if (!fadeout_pause_pipeline_) return;
|
||||
|
||||
fadeout_pause_pipeline_->SetStateAsync(GST_STATE_PAUSED);
|
||||
fadeout_pause_pipeline_->SetState(GST_STATE_PAUSED);
|
||||
Q_EMIT StateChanged(State::Paused);
|
||||
StopTimers();
|
||||
has_faded_out_to_pause_ = true;
|
||||
|
@ -408,7 +408,7 @@ bool GstEnginePipeline::Finish() {
|
||||
finished_ = true;
|
||||
}
|
||||
else {
|
||||
SetStateAsync(GST_STATE_NULL);
|
||||
SetState(GST_STATE_NULL);
|
||||
}
|
||||
|
||||
return finished_.value();
|
||||
@ -1793,7 +1793,13 @@ bool GstEnginePipeline::IsStateNull() const {
|
||||
|
||||
}
|
||||
|
||||
QFuture<GstStateChangeReturn> GstEnginePipeline::SetStateAsync(const GstState state) {
|
||||
void GstEnginePipeline::SetStateAsync(const GstState state) {
|
||||
|
||||
QMetaObject::invokeMethod(this, "SetState", Qt::QueuedConnection, Q_ARG(GstState, state));
|
||||
|
||||
}
|
||||
|
||||
QFuture<GstStateChangeReturn> GstEnginePipeline::SetState(const GstState state) {
|
||||
|
||||
qLog(Debug) << "Setting pipeline" << id() << "state to" << GstStateText(state);
|
||||
|
||||
@ -1801,7 +1807,7 @@ QFuture<GstStateChangeReturn> GstEnginePipeline::SetStateAsync(const GstState st
|
||||
QObject::connect(watcher, &QFutureWatcher<GstStateChangeReturn>::finished, this, [this, watcher, state]() {
|
||||
const GstStateChangeReturn state_change_return = watcher->result();
|
||||
watcher->deleteLater();
|
||||
SetStateAsyncFinished(state, state_change_return);
|
||||
SetStateFinishedSlot(state, state_change_return);
|
||||
});
|
||||
QFuture<GstStateChangeReturn> future = QtConcurrent::run(&set_state_threadpool_, &gst_element_set_state, pipeline_, state);
|
||||
watcher->setFuture(future);
|
||||
@ -1810,7 +1816,7 @@ QFuture<GstStateChangeReturn> GstEnginePipeline::SetStateAsync(const GstState st
|
||||
|
||||
}
|
||||
|
||||
void GstEnginePipeline::SetStateAsyncFinished(const GstState state, const GstStateChangeReturn state_change_return) {
|
||||
void GstEnginePipeline::SetStateFinishedSlot(const GstState state, const GstStateChangeReturn state_change_return) {
|
||||
|
||||
switch (state_change_return) {
|
||||
case GST_STATE_CHANGE_SUCCESS:
|
||||
@ -1840,7 +1846,7 @@ QFuture<GstStateChangeReturn> GstEnginePipeline::Play(const bool pause, const qu
|
||||
pending_state_ = GST_STATE_PLAYING;
|
||||
}
|
||||
|
||||
return SetStateAsync(GST_STATE_PAUSED);
|
||||
return SetState(GST_STATE_PAUSED);
|
||||
|
||||
}
|
||||
|
||||
@ -1858,7 +1864,7 @@ bool GstEnginePipeline::Seek(const qint64 nanosec) {
|
||||
|
||||
if (next_uri_set_.value()) {
|
||||
pending_seek_nanosec_ = nanosec;
|
||||
SetStateAsync(GST_STATE_READY);
|
||||
SetState(GST_STATE_READY);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1873,7 +1879,7 @@ bool GstEnginePipeline::Seek(const qint64 nanosec) {
|
||||
qLog(Debug) << "Seek succeeded";
|
||||
if (pending_state_.value() != GST_STATE_NULL) {
|
||||
qLog(Debug) << "Setting state from pending state" << GstStateText(pending_state_.value());
|
||||
SetStateAsync(pending_state_.value());
|
||||
SetState(pending_state_.value());
|
||||
pending_state_ = GST_STATE_NULL;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class GstEnginePipeline : public QObject {
|
||||
void RemoveAllBufferConsumers();
|
||||
|
||||
// Control the music playback
|
||||
Q_INVOKABLE QFuture<GstStateChangeReturn> SetStateAsync(const GstState state);
|
||||
Q_INVOKABLE QFuture<GstStateChangeReturn> SetState(const GstState state);
|
||||
Q_INVOKABLE QFuture<GstStateChangeReturn> Play(const bool pause, const quint64 offset_nanosec);
|
||||
Q_INVOKABLE bool Seek(const qint64 nanosec);
|
||||
void SeekAsync(const qint64 nanosec);
|
||||
@ -165,6 +165,7 @@ class GstEnginePipeline : public QObject {
|
||||
bool IsStateNull() const;
|
||||
bool InitAudioBin(QString &error);
|
||||
void SetupVolume(GstElement *element);
|
||||
void SetStateAsync(const GstState state);
|
||||
|
||||
// Static callbacks. The GstEnginePipeline instance is passed in the last argument.
|
||||
static GstPadProbeReturn UpstreamEventsProbeCallback(GstPad *pad, GstPadProbeInfo *info, gpointer self);
|
||||
@ -199,7 +200,7 @@ class GstEnginePipeline : public QObject {
|
||||
void ResumeFaderAsync();
|
||||
|
||||
private Q_SLOTS:
|
||||
void SetStateAsyncFinished(const GstState state, const GstStateChangeReturn state_change_return);
|
||||
void SetStateFinishedSlot(const GstState state, const GstStateChangeReturn state_change_return);
|
||||
void SetFaderVolume(const qreal volume);
|
||||
void FaderTimelineStateChanged(const QTimeLine::State state);
|
||||
void FaderTimelineFinished();
|
||||
|
Loading…
x
Reference in New Issue
Block a user