Merge pull request #4930 from eduardosm/esm-branch1

Fix song continuously rewinding when seeking using keyboard arrow keys.
This commit is contained in:
John Maguire 2015-07-02 06:41:35 -04:00
commit 625a995751
5 changed files with 12 additions and 3 deletions

0
src/engines/enginebase.h Executable file → Normal file
View File

0
src/engines/gstengine.cpp Executable file → Normal file
View File

0
src/engines/gstengine.h Executable file → Normal file
View File

View File

@ -77,6 +77,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
pipeline_is_initialised_(false),
pipeline_is_connected_(false),
pending_seek_nanosec_(-1),
last_known_position_ns_(0),
volume_percent_(100),
volume_modifier_(1.0),
pipeline_(nullptr),
@ -976,10 +977,10 @@ void GstEnginePipeline::TransitionToNext() {
}
qint64 GstEnginePipeline::position() const {
gint64 value = 0;
gst_element_query_position(pipeline_, GST_FORMAT_TIME, &value);
if (pipeline_is_initialised_)
gst_element_query_position(pipeline_, GST_FORMAT_TIME, &last_known_position_ns_);
return value;
return last_known_position_ns_;
}
qint64 GstEnginePipeline::length() const {
@ -1033,6 +1034,7 @@ bool GstEnginePipeline::Seek(qint64 nanosec) {
}
pending_seek_nanosec_ = -1;
last_known_position_ns_ = nanosec;
return gst_element_seek_simple(pipeline_, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH, nanosec);
}

View File

@ -258,6 +258,13 @@ signals:
bool pipeline_is_connected_;
qint64 pending_seek_nanosec_;
// We can only use gst_element_query_position() when the pipeline is in
// PAUSED nor PLAYING state. Whenever we get a new position (e.g. after a
// correct call to gst_element_query_position() or after a seek), we store
// it here so that we can use it when using gst_element_query_position() is
// not possible.
mutable gint64 last_known_position_ns_;
int volume_percent_;
qreal volume_modifier_;