mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
Wait 2 seconds after the fadeout finished before destroying the pipeline, to allow for delays in the sound server/driver. Fixes issue #294.
This commit is contained in:
parent
f7c08d375a
commit
694c5e9f9e
@ -20,6 +20,9 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
const int GstEnginePipeline::kGstStateTimeoutNanosecs = 10000000;
|
||||
const int GstEnginePipeline::kFaderFudgeMsec = 2000;
|
||||
|
||||
GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
||||
: QObject(NULL),
|
||||
engine_(engine),
|
||||
@ -359,10 +362,26 @@ void GstEnginePipeline::StartFader(int duration_msec,
|
||||
|
||||
fader_ = new QTimeLine(duration_msec, this);
|
||||
connect(fader_, SIGNAL(valueChanged(qreal)), SLOT(SetVolumeModifier(qreal)));
|
||||
connect(fader_, SIGNAL(finished()), SIGNAL(FaderFinished()));
|
||||
connect(fader_, SIGNAL(finished()), SLOT(FaderTimelineFinished()));
|
||||
fader_->setDirection(direction);
|
||||
fader_->setCurveShape(shape);
|
||||
fader_->start();
|
||||
|
||||
SetVolumeModifier(fader_->currentValue());
|
||||
}
|
||||
|
||||
void GstEnginePipeline::FaderTimelineFinished() {
|
||||
// Wait a little while longer before emitting the finished signal (and
|
||||
// probably distroying the pipeline) to account for delays in the audio
|
||||
// server/driver.
|
||||
fader_fudge_timer_.start(kFaderFudgeMsec, this);
|
||||
}
|
||||
|
||||
void GstEnginePipeline::timerEvent(QTimerEvent* e) {
|
||||
if (e->timerId() == fader_fudge_timer_.timerId()) {
|
||||
emit FaderFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
QObject::timerEvent(e);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include <QTimeLine>
|
||||
#include <QBasicTimer>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
@ -74,6 +75,9 @@ class GstEnginePipeline : public QObject {
|
||||
void Error(const QString& message);
|
||||
void FaderFinished();
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *);
|
||||
|
||||
private:
|
||||
// Static callbacks. The GstEnginePipeline instance is passed in the last
|
||||
// argument.
|
||||
@ -91,8 +95,12 @@ class GstEnginePipeline : public QObject {
|
||||
void UpdateVolume();
|
||||
bool ReplaceDecodeBin(const QUrl& url);
|
||||
|
||||
private slots:
|
||||
void FaderTimelineFinished();
|
||||
|
||||
private:
|
||||
static const int kGstStateTimeoutNanosecs = 10000000;
|
||||
static const int kGstStateTimeoutNanosecs;
|
||||
static const int kFaderFudgeMsec;
|
||||
|
||||
GstEngine* engine_;
|
||||
|
||||
@ -108,6 +116,7 @@ class GstEnginePipeline : public QObject {
|
||||
qreal volume_modifier_;
|
||||
|
||||
QTimeLine* fader_;
|
||||
QBasicTimer fader_fudge_timer_;
|
||||
|
||||
GstElement* pipeline_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user