diff --git a/ChangeLog b/ChangeLog index 73c6a2e114..94f6303117 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-06-14 David Schleef + + * ext/cdparanoia/gstcdparanoia.c: (cdparanoia_init), + (cdparanoia_get), (cdparanoia_open), (cdparanoia_change_state): + Send discont events and change timestamps appropriately when + we get a seek event. (bug #144240) + * ext/cdparanoia/gstcdparanoia.h: + 2004-06-14 Benjamin Otte * ext/alsa/gstalsa.c: Use snd_pcm_hw_params_set_rate _near instead of diff --git a/ext/cdparanoia/gstcdparanoia.c b/ext/cdparanoia/gstcdparanoia.c index d75ff57862..f47deba503 100644 --- a/ext/cdparanoia/gstcdparanoia.c +++ b/ext/cdparanoia/gstcdparanoia.c @@ -318,7 +318,7 @@ cdparanoia_init (CDParanoia * cdparanoia) cdparanoia->abort_on_skip = FALSE; cdparanoia->total_seconds = 0; - cdparanoia->discont_pending = FALSE; + cdparanoia->discont_sent = FALSE; } @@ -476,13 +476,27 @@ cdparanoia_get (GstPad * pad) gint64 timestamp; GstFormat format; - /* read a sector */ - cdda_buf = paranoia_read (src->p, cdparanoia_callback); - /* convert the sequence sector number to a timestamp */ format = GST_FORMAT_TIME; timestamp = 0LL; - gst_pad_convert (src->srcpad, sector_format, src->seq, &format, ×tamp); + gst_pad_convert (src->srcpad, sector_format, src->cur_sector, &format, + ×tamp); + + if (!src->discont_sent && src->prev_sec != src->cur_sector) { + GstEvent *discont_ev; + + discont_ev = + gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, timestamp, + GST_FORMAT_UNDEFINED); + + src->discont_sent = TRUE; + return GST_DATA (discont_ev); + } + + src->discont_sent = FALSE; + + /* read a sector */ + cdda_buf = paranoia_read (src->p, cdparanoia_callback); /* have to copy the buffer for now since we don't own it... */ /* FIXME must ask monty about allowing ownership transfer */ @@ -492,7 +506,7 @@ cdparanoia_get (GstPad * pad) /* update current sector */ src->cur_sector++; - src->seq++; + src->prev_sec = src->cur_sector; } /* we're done, push the buffer off now */ @@ -710,6 +724,7 @@ cdparanoia_open (CDParanoia * src) } src->cur_sector = src->first_sector; + src->prev_sec = src->cur_sector; paranoia_seek (src->p, src->cur_sector, SEEK_SET); GST_DEBUG ("successfully seek'd to beginning of disk"); @@ -757,7 +772,6 @@ cdparanoia_change_state (GstElement * element) g_warning ("cdparanoia: failed opening cd"); return GST_STATE_FAILURE; } - cdparanoia->seq = 0; break; case GST_STATE_READY_TO_PAUSED: break; diff --git a/ext/cdparanoia/gstcdparanoia.h b/ext/cdparanoia/gstcdparanoia.h index 7b05b3bb09..215ba9644a 100644 --- a/ext/cdparanoia/gstcdparanoia.h +++ b/ext/cdparanoia/gstcdparanoia.h @@ -102,8 +102,8 @@ struct _CDParanoia { gint64 offsets[MAXTRK]; gint64 total_seconds; - gint seq; - gboolean discont_pending; + gint prev_sec; + gboolean discont_sent; }; struct _CDParanoiaClass {