ocarina: Don't set progress bar to a value greater than pipeline
duration This can happen because of gapless playback in the gstreamer pipeline. It fails a gstreamer assertion, so I need to look out for it.
This commit is contained in:
parent
b2f72df146
commit
4c36e0b7e2
|
@ -11,10 +11,21 @@ static GtkWidget *duration = NULL; /* gtk label */
|
|||
|
||||
static gboolean update_progress(gpointer data)
|
||||
{
|
||||
gint64 pos = libsaria::audio::position();
|
||||
gint64 dur = libsaria::audio::duration() + 1;
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(position), libsaria::audio::posstr().c_str());
|
||||
gtk_label_set_text(GTK_LABEL(duration), libsaria::audio::durstr().c_str());
|
||||
gtk_range_set_range(GTK_RANGE(progress), 0, libsaria::audio::duration() + 1);
|
||||
gtk_range_set_value(GTK_RANGE(progress), libsaria::audio::position());
|
||||
gtk_range_set_range(GTK_RANGE(progress), 0, dur);
|
||||
|
||||
/*
|
||||
* This happens when gstreamer's "about-to-finish" signal
|
||||
* is emitted and we queue up a shorter song before the
|
||||
* pipeline finishes.
|
||||
*/
|
||||
if (pos > dur)
|
||||
pos = 0;
|
||||
gtk_range_set_value(GTK_RANGE(progress), pos);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue