Commit e846919f authored by Edgard Lima's avatar Edgard Lima Committed by Wim Taymans
Browse files

gst-libs/gst/audio/: Fixed gstbaseaudiosrc adding ring buffer sync to it.

Original commit message from CVS:
* gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_event),
(gst_base_audio_src_create), (gst_base_audio_src_change_state):
* gst-libs/gst/audio/gstbaseaudiosrc.h:
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_read):
patch from Edgard Lima <edgard.lima@indt.org.br>
Fixed gstbaseaudiosrc adding ring buffer sync to it.
parent a872aac9
2005-10-06 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_event),
(gst_base_audio_src_create), (gst_base_audio_src_change_state):
* gst-libs/gst/audio/gstbaseaudiosrc.h:
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_read):
patch from Edgard Lima <edgard.lima@indt.org.br>
Fixed gstbaseaudiosrc adding ring buffer sync to it.
2005-10-06 Wim Taymans <wim@fluendo.com>
 
* ext/ogg/gstoggdemux.c: (gst_ogg_demux_loop):
......
......@@ -289,8 +289,12 @@ gst_base_audio_src_event (GstBaseSrc * bsrc, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
gst_ring_buffer_pause (src->ringbuffer);
gst_ring_buffer_clear_all (src->ringbuffer);
break;
case GST_EVENT_FLUSH_STOP:
/* always resync on sample after a flush */
src->next_sample = -1;
gst_ring_buffer_clear_all (src->ringbuffer);
break;
default:
break;
......@@ -306,6 +310,7 @@ gst_base_audio_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
guchar *data;
guint len;
guint res;
guint64 sample;
if (!gst_ring_buffer_is_acquired (src->ringbuffer))
goto wrong_state;
......@@ -315,10 +320,18 @@ gst_base_audio_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
data = GST_BUFFER_DATA (buf);
len = GST_BUFFER_SIZE (buf);
res = gst_ring_buffer_read (src->ringbuffer, -1, data, len);
if (src->next_sample != -1) {
sample = src->next_sample;
} else {
sample = 0;
}
res = gst_ring_buffer_read (src->ringbuffer, sample, data, len);
if (res == -1)
goto stopped;
src->next_sample = sample + len / src->ringbuffer->spec.bytes_per_sample;
gst_buffer_set_caps (buf, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)));
*outbuf = buf;
......@@ -378,6 +391,7 @@ gst_base_audio_src_change_state (GstElement * element,
}
if (!gst_ring_buffer_open_device (src->ringbuffer))
return GST_STATE_CHANGE_FAILURE;
src->next_sample = 0;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
......@@ -394,8 +408,8 @@ gst_base_audio_src_change_state (GstElement * element,
gst_ring_buffer_pause (src->ringbuffer);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_ring_buffer_stop (src->ringbuffer);
gst_ring_buffer_release (src->ringbuffer);
src->next_sample = 0;
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_ring_buffer_close_device (src->ringbuffer);
......
......@@ -57,6 +57,9 @@ struct _GstBaseAudioSrc {
GstClockTime buffer_time;
GstClockTime latency_time;
/* the next sample to write */
guint64 next_sample;
/* clock */
GstClock *clock;
......
......@@ -1065,9 +1065,10 @@ gst_ring_buffer_read (GstRingBuffer * buf, guint64 sample, guchar * data,
/* segment too far ahead, we need to drop */
if (diff < 0) {
/* we need to drop one segment at a time, pretend we wrote a
* segment. */
/* we need to drop one segment at a time, pretend we read an
* empty segment. */
readlen = MIN (segsize, len);
memcpy (data, buf->empty_seg, readlen);
goto next;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment