From 09f7dee84d0c8dfe75f9c0b75b191f17ef701440 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 7 May 2008 15:47:03 +0000 Subject: [PATCH] gst-libs/gst/audio/gstbaseaudiosink.c: Report the latency with the new seglatency parameter. Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_query): Report the latency with the new seglatency parameter. * gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_debug_spec_buff), (gst_ring_buffer_parse_caps), (gst_ring_buffer_acquire): * gst-libs/gst/audio/gstringbuffer.h: Add new field to the ringbufferspec to specify the expected latency between the underlying device read/write pointer, this is needed when writing sinks that sit a little closer to the hardware. Add some more docs for other fields. --- ChangeLog | 15 +++++++++++++++ gst-libs/gst/audio/gstbaseaudiosink.c | 2 +- gst-libs/gst/audio/gstringbuffer.c | 9 +++++++++ gst-libs/gst/audio/gstringbuffer.h | 25 +++++++++++++++++++------ 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c32c2fb44..c8e172419b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-05-07 Wim Taymans + + * gst-libs/gst/audio/gstbaseaudiosink.c: + (gst_base_audio_sink_query): + Report the latency with the new seglatency parameter. + + * gst-libs/gst/audio/gstringbuffer.c: + (gst_ring_buffer_debug_spec_buff), (gst_ring_buffer_parse_caps), + (gst_ring_buffer_acquire): + * gst-libs/gst/audio/gstringbuffer.h: + Add new field to the ringbufferspec to specify the expected latency + between the underlying device read/write pointer, this is needed + when writing sinks that sit a little closer to the hardware. + Add some more docs for other fields. + 2008-05-06 Sebastian Dröge * gst/volume/gstvolume.c: (volume_transform_ip): diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index 512ad1649c..c889c69e26 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -333,7 +333,7 @@ gst_base_audio_sink_query (GstElement * element, GstQuery * query) basesink->priv->us_latency = min_l; min_latency = - gst_util_uint64_scale_int (spec->segtotal * spec->segsize, + gst_util_uint64_scale_int (spec->seglatency * spec->segsize, GST_SECOND, spec->rate * spec->bytes_per_sample); /* we cannot go lower than the buffer size and the min peer latency */ diff --git a/gst-libs/gst/audio/gstringbuffer.c b/gst-libs/gst/audio/gstringbuffer.c index f02606fd58..4649e3a20c 100644 --- a/gst-libs/gst/audio/gstringbuffer.c +++ b/gst-libs/gst/audio/gstringbuffer.c @@ -258,6 +258,7 @@ gst_ring_buffer_debug_spec_buff (GstRingBufferSpec * spec) GST_DEBUG ("acquire ringbuffer: latency time: %" G_GINT64_FORMAT " usec", spec->latency_time); GST_DEBUG ("acquire ringbuffer: total segments: %d", spec->segtotal); + GST_DEBUG ("acquire ringbuffer: latency segments: %d", spec->seglatency); GST_DEBUG ("acquire ringbuffer: segment size: %d bytes = %d samples", spec->segsize, spec->segsize / spec->bytes_per_sample); GST_DEBUG ("acquire ringbuffer: buffer size: %d bytes = %d samples", @@ -414,6 +415,9 @@ gst_ring_buffer_parse_caps (GstRingBufferSpec * spec, GstCaps * caps) spec->segsize -= spec->segsize % spec->bytes_per_sample; spec->segtotal = spec->buffer_time / spec->latency_time; + /* leave the latency undefined now, implementations can change it but if it's + * not changed, we assume the same value as segtotal */ + spec->seglatency = -1; gst_ring_buffer_debug_spec_caps (spec); gst_ring_buffer_debug_spec_buff (spec); @@ -649,6 +653,11 @@ gst_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec) if (G_UNLIKELY ((bps = buf->spec.bytes_per_sample) == 0)) goto invalid_bps; + /* if the seglatency was overwritten with something else than -1, use it, else + * assume segtotal as the latency */ + if (buf->spec.seglatency == -1) + buf->spec.seglatency = buf->spec.segtotal; + segsize = buf->spec.segsize; buf->samples_per_seg = segsize / bps; diff --git a/gst-libs/gst/audio/gstringbuffer.h b/gst-libs/gst/audio/gstringbuffer.h index fa6dc72be0..e4a03bc4d6 100644 --- a/gst-libs/gst/audio/gstringbuffer.h +++ b/gst-libs/gst/audio/gstringbuffer.h @@ -200,17 +200,30 @@ struct _GstRingBufferSpec gint rate; gint channels; - guint64 latency_time; /* the required/actual latency time */ - guint64 buffer_time; /* the required/actual time of the buffer */ - gint segsize; /* size of one buffer segment in bytes */ - gint segtotal; /* total number of segments */ - + guint64 latency_time; /* the required/actual latency time, this is the + * actual the size of one segment and the + * minimum possible latency we can achieve. */ + guint64 buffer_time; /* the required/actual time of the buffer, this is + * the total size of the buffer and maximum + * latency we can compensate for. */ + gint segsize; /* size of one buffer segment in bytes, this value + * should be chosen to match latency_time as + * well as possible. */ + gint segtotal; /* total number of segments, this value is the + * number of segments of @segsize and should be + * chosen so that it matches buffer_time as + * close as possible. */ /* out */ gint bytes_per_sample; /* number of bytes of one sample */ guint8 silence_sample[32]; /* bytes representing silence */ + /* ABI added 0.10.20 */ + gint seglatency; /* number of segments queued in the lower + * level device, defaults to segtotal. */ + /*< private >*/ - gpointer _gst_reserved[GST_PADDING]; + /* gpointer _gst_reserved[GST_PADDING]; */ + guint8 _gst_reserved[(sizeof (gpointer) * GST_PADDING) - sizeof (gint)]; }; #define GST_RING_BUFFER_GET_COND(buf) (((GstRingBuffer *)buf)->cond)