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:
parent
33614533d8
commit
9b224fd87d
@ -358,19 +358,28 @@ void GstEnginePipeline::UpdateVolume() {
|
|||||||
void GstEnginePipeline::StartFader(int duration_msec,
|
void GstEnginePipeline::StartFader(int duration_msec,
|
||||||
QTimeLine::Direction direction,
|
QTimeLine::Direction direction,
|
||||||
QTimeLine::CurveShape shape) {
|
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);
|
fader_.reset(new QTimeLine(duration_msec, this));
|
||||||
connect(fader_, SIGNAL(valueChanged(qreal)), SLOT(SetVolumeModifier(qreal)));
|
connect(fader_.get(), SIGNAL(valueChanged(qreal)), SLOT(SetVolumeModifier(qreal)));
|
||||||
connect(fader_, SIGNAL(finished()), SLOT(FaderTimelineFinished()));
|
connect(fader_.get(), SIGNAL(finished()), SLOT(FaderTimelineFinished()));
|
||||||
fader_->setDirection(direction);
|
fader_->setDirection(direction);
|
||||||
fader_->setCurveShape(shape);
|
fader_->setCurveShape(shape);
|
||||||
fader_->start();
|
fader_->setCurrentTime(start_time);
|
||||||
|
fader_->resume();
|
||||||
|
|
||||||
|
fader_fudge_timer_.stop();
|
||||||
|
|
||||||
SetVolumeModifier(fader_->currentValue());
|
SetVolumeModifier(fader_->currentValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GstEnginePipeline::FaderTimelineFinished() {
|
void GstEnginePipeline::FaderTimelineFinished() {
|
||||||
|
fader_.reset();
|
||||||
|
|
||||||
// Wait a little while longer before emitting the finished signal (and
|
// Wait a little while longer before emitting the finished signal (and
|
||||||
// probably distroying the pipeline) to account for delays in the audio
|
// probably distroying the pipeline) to account for delays in the audio
|
||||||
// server/driver.
|
// server/driver.
|
||||||
@ -379,6 +388,7 @@ void GstEnginePipeline::FaderTimelineFinished() {
|
|||||||
|
|
||||||
void GstEnginePipeline::timerEvent(QTimerEvent* e) {
|
void GstEnginePipeline::timerEvent(QTimerEvent* e) {
|
||||||
if (e->timerId() == fader_fudge_timer_.timerId()) {
|
if (e->timerId() == fader_fudge_timer_.timerId()) {
|
||||||
|
fader_fudge_timer_.stop();
|
||||||
emit FaderFinished();
|
emit FaderFinished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QBasicTimer>
|
#include <QBasicTimer>
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
#include "engine_fwd.h"
|
#include "engine_fwd.h"
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ class GstEnginePipeline : public QObject {
|
|||||||
int volume_percent_;
|
int volume_percent_;
|
||||||
qreal volume_modifier_;
|
qreal volume_modifier_;
|
||||||
|
|
||||||
QTimeLine* fader_;
|
boost::scoped_ptr<QTimeLine> fader_;
|
||||||
QBasicTimer fader_fudge_timer_;
|
QBasicTimer fader_fudge_timer_;
|
||||||
|
|
||||||
GstElement* pipeline_;
|
GstElement* pipeline_;
|
||||||
|
Loading…
Reference in New Issue
Block a user