GstEnginePipeline: Save fader state
This commit is contained in:
parent
0d2e933ed1
commit
65b6e6d540
@ -140,6 +140,7 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
|
|||||||
volume_internal_(-1.0),
|
volume_internal_(-1.0),
|
||||||
volume_percent_(100),
|
volume_percent_(100),
|
||||||
fader_active_(false),
|
fader_active_(false),
|
||||||
|
fader_running_(false),
|
||||||
use_fudge_timer_(false),
|
use_fudge_timer_(false),
|
||||||
pipeline_(nullptr),
|
pipeline_(nullptr),
|
||||||
audiobin_(nullptr),
|
audiobin_(nullptr),
|
||||||
@ -323,6 +324,7 @@ void GstEnginePipeline::Disconnect() {
|
|||||||
|
|
||||||
if (fader_) {
|
if (fader_) {
|
||||||
fader_active_ = false;
|
fader_active_ = false;
|
||||||
|
fader_running_ = false;
|
||||||
if (fader_->state() != QTimeLine::NotRunning) {
|
if (fader_->state() != QTimeLine::NotRunning) {
|
||||||
fader_->stop();
|
fader_->stop();
|
||||||
}
|
}
|
||||||
@ -1690,7 +1692,7 @@ void GstEnginePipeline::StateChangedMessageReceived(GstMessage *msg) {
|
|||||||
SetStateAsync(pending_state_.value());
|
SetStateAsync(pending_state_.value());
|
||||||
pending_state_ = GST_STATE_NULL;
|
pending_state_ = GST_STATE_NULL;
|
||||||
}
|
}
|
||||||
if (fader_ && fader_->state() != QTimeLine::State::Running && new_state == GST_STATE_PLAYING) {
|
if (fader_ && fader_active_.value() && !fader_running_.value() && new_state == GST_STATE_PLAYING) {
|
||||||
qLog(Debug) << "Resuming fader";
|
qLog(Debug) << "Resuming fader";
|
||||||
ResumeFaderAsync();
|
ResumeFaderAsync();
|
||||||
}
|
}
|
||||||
@ -1993,6 +1995,7 @@ void GstEnginePipeline::StartFader(const qint64 duration_nanosec, const QTimeLin
|
|||||||
timeline->deleteLater();
|
timeline->deleteLater();
|
||||||
});
|
});
|
||||||
QObject::connect(&*fader_, &QTimeLine::valueChanged, this, &GstEnginePipeline::SetFaderVolume);
|
QObject::connect(&*fader_, &QTimeLine::valueChanged, this, &GstEnginePipeline::SetFaderVolume);
|
||||||
|
QObject::connect(&*fader_, &QTimeLine::stateChanged, this, &GstEnginePipeline::FaderTimelineStateChanged);
|
||||||
QObject::connect(&*fader_, &QTimeLine::finished, this, &GstEnginePipeline::FaderTimelineFinished);
|
QObject::connect(&*fader_, &QTimeLine::finished, this, &GstEnginePipeline::FaderTimelineFinished);
|
||||||
fader_->setDirection(direction);
|
fader_->setDirection(direction);
|
||||||
fader_->setEasingCurve(shape);
|
fader_->setEasingCurve(shape);
|
||||||
@ -2021,17 +2024,25 @@ void GstEnginePipeline::SetFaderVolume(const qreal volume) {
|
|||||||
|
|
||||||
void GstEnginePipeline::ResumeFaderAsync() {
|
void GstEnginePipeline::ResumeFaderAsync() {
|
||||||
|
|
||||||
if (fader_active_.value()) {
|
if (fader_active_.value() && !fader_running_.value()) {
|
||||||
QMetaObject::invokeMethod(&*fader_, "resume", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(&*fader_, &QTimeLine::resume, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GstEnginePipeline::FaderTimelineStateChanged(const QTimeLine::State state) {
|
||||||
|
|
||||||
|
fader_running_ = state == QTimeLine::Running;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void GstEnginePipeline::FaderTimelineFinished() {
|
void GstEnginePipeline::FaderTimelineFinished() {
|
||||||
|
|
||||||
qLog(Debug) << "Pipeline" << id() << "finished fading";
|
qLog(Debug) << "Pipeline" << id() << "finished fading";
|
||||||
|
|
||||||
fader_active_ = false;
|
fader_active_ = false;
|
||||||
|
fader_running_ = false;
|
||||||
|
|
||||||
fader_.reset();
|
fader_.reset();
|
||||||
|
|
||||||
// Wait a little while longer before emitting the finished signal (and probably destroying the pipeline) to account for delays in the audio server/driver.
|
// Wait a little while longer before emitting the finished signal (and probably destroying the pipeline) to account for delays in the audio server/driver.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user