gstreamer with playbin: how to pause 'now' or pause at exact time
Tim-Philipp Müller
t.i.m at zen.co.uk
Thu Sep 26 13:59:50 PDT 2013
On Thu, 2013-09-26 at 22:48 +0200, Alexandru Munteanu wrote:
Hi,
> I am using gstreamer 1.0.10 (packages from debian testing) with the playbin element
> (for mp3splt-gtk).
>
> When I set the element to GST_STATE_PAUSED, I always have a lag between the moment I call
> gst_element_set_state() and the time when the pause occurs.
> Is there a way to "pause right now" or "pause at a precise time in the future" ?
Sorry for not answering your question, but let me ask you first: what
are you trying to achieve with that? What's the big picture?
Cheers
-Tim
> Details follow.
>
> I have those two functions:
>
> void gstreamer_get_time_elapsed(ui_state *ui)
> {
> GstQuery *query = gst_query_new_position(GST_FORMAT_TIME);
> gint64 time = 0;
>
> if (gst_element_query(ui->pi->play, query))
> {
> gst_query_parse_position(query, NULL, &time);
> }
>
> gst_query_unref(query);
>
> fprintf(stdout, "position = %ld\n", time);
> fprintf(stdout, "position / MSECOND = %ld\n", time / GST_MSECOND);
> fflush(stdout);
> }
>
> void gstreamer_pause(ui_state *ui)
> {
> GstState state;
> gst_element_get_state(ui->pi->play, &state, NULL, GST_CLOCK_TIME_NONE);
>
> fprintf(stdout, "time before pause\n");
> gstreamer_get_time_elapsed(ui);
>
> fprintf(stdout, "setting pause ...\n");
> fflush(stdout);
> GstStateChangeReturn ret = gst_element_set_state(ui->pi->play, GST_STATE_PAUSED);
> if (ret == GST_STATE_CHANGE_ASYNC)
> {
> fprintf(stdout, "async!\n");
> fflush(stdout);
> }
> else if (ret == GST_STATE_CHANGE_SUCCESS)
> {
> fprintf(stdout, "success!\n");
> fflush(stdout);
> }
>
> fprintf(stdout, "time after pause ...\n");
> fflush(stdout);
> gstreamer_get_time_elapsed(ui);
> }
>
> and when I call gstreamer_pause(), I get the following output:
>
> time before pause
> position = 90017369614
> position / MSECOND = 90017
> setting pause ...
> success!
> time after pause ...
> position = 90343673468
> position / MSECOND = 90343
>
> There is a difference of about 0.3 second between the moment just before I pause
> and the moment the pause is triggered.
> Any idea how I can handle this issue ?
>
> Thank you.
>
More information about the gstreamer-devel
mailing list