[gst-devel] timed playback

Stefan Kost ensonic at hora-obscura.de
Sat Aug 27 05:18:21 CEST 2005

hi all,

to play a song-sequence in buzztard I currently do something like below.
The code runs in an extra thread to not block the UI. It was working in
0.8. Now in 0.9 it blocks the UI (despite running in a separate thread).

I may approach the whole thing totaly wrong. What I want to do is to let
a pipiline run for a given time (e.g. 5 sec) and report the playback
position from time to time (to show that in the UI).
The do {} while() loop is to allow playing with a loop, but that needs
seeking for 0.9 (to reset the timestamp of all involved elements). Which
is something I need to look at too.

I can't use EOS in the way normal file player would use it as the
end-of-stream is reached when the song playlength has passed. All
sources are generator which would be happy to produce sound for hours ;)


--- code snippet ---

if(gst_element_set_state(bin,GST_STATE_PLAYING)!=GST_STATE_FAILURE) {
  do {
    for(;((self->priv->play_pos<self->priv->play_end) &&
(self->priv->is_playing));self->priv->play_pos++) {
      //GST_INFO("Playing sequence : position = %d, time elapsed = %lf
      if((wait_ret=gst_clock_id_wait(clock_id,NULL))!=GST_CLOCK_OK) {
        GST_WARNING("gst_clock_id_wait() returned %d",wait_ret);
  } while((self->priv->loop) && (self->priv->is_playing));

  if(gst_element_set_state(bin,GST_STATE_NULL)==GST_STATE_FAILURE) {
    GST_ERROR("can't stop playing");res=FALSE;
  GST_INFO("  playing done");
else {
  GST_ERROR("can't start playing");res=FALSE;

More information about the gstreamer-devel mailing list