From 1980f1673109fe209e48b5bc4b0bf32940b74ac6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 27 Sep 2006 13:52:14 +0000 Subject: [PATCH] gst-libs/gst/audio/gstbaseaudiosink.c: Add some more info in a WARNING. Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_render): Add some more info in a WARNING. * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_create): Handle PAUSE in create function, use new -core addition to wait for playing. Fixes pausing and resuming capture from an audiosrc. * gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_commit), (gst_ring_buffer_read): Constify some more. Caller supports interrupted reads now. --- ChangeLog | 17 +++++++++++++++++ gst-libs/gst/audio/gstbaseaudiosink.c | 1 + gst-libs/gst/audio/gstbaseaudiosrc.c | 22 +++++++++++++++++----- gst-libs/gst/audio/gstringbuffer.c | 7 +++---- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b1ac5804f..92846166d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2006-09-27 Wim Taymans + + * gst-libs/gst/audio/gstbaseaudiosink.c: + (gst_base_audio_sink_render): + Add some more info in a WARNING. + + * gst-libs/gst/audio/gstbaseaudiosrc.c: + (gst_base_audio_src_create): + Handle PAUSE in create function, use new -core addition to + wait for playing. Fixes pausing and resuming capture from an + audiosrc. + + * gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_commit), + (gst_ring_buffer_read): + Constify some more. + Caller supports interrupted reads now. + 2006-09-27 Tim-Philipp Müller * tests/check/Makefile.am: diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index d7de64d00f..ed7dd55082 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -649,6 +649,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) } no_align: + /* crate contains diff against the clock we are using in the pipeline. */ crate = gst_guint64_to_gdouble (crate_num) / gst_guint64_to_gdouble (crate_denom); GST_DEBUG_OBJECT (sink, diff --git a/gst-libs/gst/audio/gstbaseaudiosrc.c b/gst-libs/gst/audio/gstbaseaudiosrc.c index 6f6410efb7..7cc750c52d 100644 --- a/gst-libs/gst/audio/gstbaseaudiosrc.c +++ b/gst-libs/gst/audio/gstbaseaudiosrc.c @@ -449,10 +449,10 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, GstBuffer *buf; guchar *data; guint samples; - guint res; guint64 sample; gint bps; GstRingBuffer *ringbuffer; + guint read; ringbuffer = src->ringbuffer; @@ -488,10 +488,22 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, buf = gst_buffer_new_and_alloc (length); data = GST_BUFFER_DATA (buf); - /* read the sample */ - res = gst_ring_buffer_read (ringbuffer, sample, data, samples); - if (G_UNLIKELY (res == -1)) - goto stopped; + do { + read = gst_ring_buffer_read (ringbuffer, sample, data, samples); + GST_DEBUG_OBJECT (src, "read %u of %u", read, samples); + /* if we read all, we're done */ + if (read == samples) + break; + + /* else something interrupted us and we wait for playing again. */ + if (gst_base_src_wait_playing (bsrc) != GST_FLOW_OK) + goto stopped; + + /* read next samples */ + sample += read; + samples -= read; + data += read * bps; + } while (TRUE); /* mark discontinuity if needed */ if (G_UNLIKELY (sample != src->next_sample) && src->next_sample != -1) { diff --git a/gst-libs/gst/audio/gstringbuffer.c b/gst-libs/gst/audio/gstringbuffer.c index ea20c3aecd..fb2c799595 100644 --- a/gst-libs/gst/audio/gstringbuffer.c +++ b/gst-libs/gst/audio/gstringbuffer.c @@ -134,8 +134,8 @@ gst_ring_buffer_finalize (GObject * object) typedef struct { - GstBufferFormat format; - guint8 silence[4]; + const GstBufferFormat format; + const guint8 silence[4]; } FormatDef; static const FormatDef linear_defs[4 * 2 * 2] = { @@ -1387,8 +1387,7 @@ gst_ring_buffer_read (GstRingBuffer * buf, guint64 sample, guchar * data, not_started: { GST_DEBUG_OBJECT (buf, "stopped processing"); - /* FIXME, return len - to_read after fixing caller */ - return -1; + return len - to_read; } }