1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 19:31:02 +01:00

Fix the fader behaviour a bit

This commit is contained in:
David Sansome 2010-05-19 13:26:23 +00:00
parent 33614533d8
commit 9b224fd87d
2 changed files with 17 additions and 6 deletions

View File

@ -358,19 +358,28 @@ void GstEnginePipeline::UpdateVolume() {
void GstEnginePipeline::StartFader(int duration_msec,
QTimeLine::Direction direction,
QTimeLine::CurveShape shape) {
delete fader_;
// If there's already another fader running then start from the same time
// that one was already at.
int start_time = direction == QTimeLine::Forward ? 0 : duration_msec;
if (fader_ && fader_->state() == QTimeLine::Running)
start_time = fader_->currentTime();
fader_ = new QTimeLine(duration_msec, this);
connect(fader_, SIGNAL(valueChanged(qreal)), SLOT(SetVolumeModifier(qreal)));
connect(fader_, SIGNAL(finished()), SLOT(FaderTimelineFinished()));
fader_.reset(new QTimeLine(duration_msec, this));
connect(fader_.get(), SIGNAL(valueChanged(qreal)), SLOT(SetVolumeModifier(qreal)));
connect(fader_.get(), SIGNAL(finished()), SLOT(FaderTimelineFinished()));
fader_->setDirection(direction);
fader_->setCurveShape(shape);
fader_->start();
fader_->setCurrentTime(start_time);
fader_->resume();
fader_fudge_timer_.stop();
SetVolumeModifier(fader_->currentValue());
}
void GstEnginePipeline::FaderTimelineFinished() {
fader_.reset();
// Wait a little while longer before emitting the finished signal (and
// probably distroying the pipeline) to account for delays in the audio
// server/driver.
@ -379,6 +388,7 @@ void GstEnginePipeline::FaderTimelineFinished() {
void GstEnginePipeline::timerEvent(QTimerEvent* e) {
if (e->timerId() == fader_fudge_timer_.timerId()) {
fader_fudge_timer_.stop();
emit FaderFinished();
return;
}

View File

@ -23,6 +23,7 @@
#include <QBasicTimer>
#include <gst/gst.h>
#include <boost/scoped_ptr.hpp>
#include "engine_fwd.h"
@ -115,7 +116,7 @@ class GstEnginePipeline : public QObject {
int volume_percent_;
qreal volume_modifier_;
QTimeLine* fader_;
boost::scoped_ptr<QTimeLine> fader_;
QBasicTimer fader_fudge_timer_;
GstElement* pipeline_;