+2006-10-12 Julien MOUTTE <julien@moutte.net>
+
+ * tests/examples/seek/seek.c: (do_seek), (start_seek), (stop_seek),
+ (play_cb), (pause_cb), (stop_cb), (rate_spinbutton_changed_cb),
+ (msg_state_changed), (main): Use state-changed messages to trigger
+ start/stop of scale update timer. Indeed the scale slider was
+ jumping here and there because the update timer was activated
+ before seek completed. This fixes instant applying of rate changes
+ by pressing the spinbutton like a crazy man !
+
2006-10-12 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Sebastien Cote <sebas642 at yahoo.ca>
if (rate >= 0) {
s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_NONE, 0);
+ GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_SET, -1);
} else {
s_event = gst_event_new_seek (rate,
GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, real);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
}
- set_update_scale (FALSE);
-
if (changed_id == 0 && flush_seek && scrub) {
changed_id = gtk_signal_connect (GTK_OBJECT (hscale),
"value_changed", G_CALLBACK (seek_cb), pipeline);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
}
- set_update_scale (TRUE);
return FALSE;
}
if (ret == GST_STATE_CHANGE_FAILURE)
goto failed;
- set_update_scale (TRUE);
state = GST_STATE_PLAYING;
}
return;
if (ret == GST_STATE_CHANGE_FAILURE)
goto failed;
- set_update_scale (FALSE);
state = GST_STATE_PAUSED;
}
return;
goto failed;
gtk_adjustment_set_value (adjustment, 0.0);
- set_update_scale (FALSE);
state = GST_STATE_READY;
}
{
play_scrub = gtk_toggle_button_get_active (button);
}
+
static void
rate_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
{
if (loop_seek)
flags |= GST_SEEK_FLAG_SEGMENT;
- s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_NONE, 0, GST_SEEK_TYPE_NONE, 0);
+ if (rate >= 0) {
+ s_event = gst_event_new_seek (rate,
+ GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
+ GST_SEEK_TYPE_SET, -1);
+ } else {
+ s_event = gst_event_new_seek (rate,
+ GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET,
+ position);
+ }
res = send_event (s_event);
} else
g_print ("seek failed\n");
}
+
static void
segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
{
}
}
+static void
+msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
+{
+ const GstStructure *s;
+
+ s = gst_message_get_structure (message);
+
+ /* We only care about state changed on the pipeline */
+ if (s && GST_MESSAGE_SRC (message) == GST_OBJECT_CAST (pipeline)) {
+ GstState old, new, pending;
+
+ gst_message_parse_state_changed (message, &old, &new, &pending);
+
+ /* When state of the pipeline changes to playing we start updating scale */
+ if (new == GST_STATE_PLAYING) {
+ set_update_scale (TRUE);
+ } else {
+ set_update_scale (FALSE);
+ }
+ }
+}
typedef struct
{
pipeline);
g_signal_connect (bus, "message::segment-done",
(GCallback) message_received, pipeline);
+ g_signal_connect (bus, "message::state-changed",
+ (GCallback) msg_state_changed, pipeline);
g_signal_connect (bus, "message::segment-done", (GCallback) segment_done,
pipeline);
}