Commit 45e06fe7 authored by Jan Schmidt's avatar Jan Schmidt
Browse files

gst-libs/gst/audio/: Document better the fact that latency_time and...

gst-libs/gst/audio/: Document better the fact that latency_time and buffer_time are values stored in microseconds, an...

Original commit message from CVS:
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_class_init), (gst_base_audio_sink_setcaps):
* gst-libs/gst/audio/gstbaseaudiosink.h:
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_parse_caps),
(gst_ring_buffer_samples_done):
* gst-libs/gst/audio/gstringbuffer.h:
Document better the fact that latency_time and buffer_time are values
stored in microseconds, and not the usual GStreamer nanoseconds.
Change the variables (compatibly) that store them from GstClockTime
to guint64 to make it more clear that they're not storing clock times.
Also, remove the bogus property description that says the user can
specify -1 to get the default value, since that's never been the case.
When computing the default segment size for the ring buffer, make it
an integer number of samples.
When the sub-class indicates a delay greater than the number of
samples we've written return 0 from the audio sink get_time method.
parent dd42d7ba
2006-06-03 Jan Schmidt <thaytan@mad.scientist.com>
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_class_init), (gst_base_audio_sink_setcaps):
* gst-libs/gst/audio/gstbaseaudiosink.h:
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_parse_caps),
(gst_ring_buffer_samples_done):
* gst-libs/gst/audio/gstringbuffer.h:
Document better the fact that latency_time and buffer_time are values
stored in microseconds, and not the usual GStreamer nanoseconds.
Change the variables (compatibly) that store them from GstClockTime
to guint64 to make it more clear that they're not storing clock times.
Also, remove the bogus property description that says the user can
specify -1 to get the default value, since that's never been the case.
When computing the default segment size for the ring buffer, make it
an integer number of samples.
When the sub-class indicates a delay greater than the number of
samples we've written return 0 from the audio sink get_time method.
2006-06-02 Michael Smith <msmith@fluendo.com>
 
* tests/check/elements/audioconvert.c: (set_channel_positions),
......
......@@ -39,12 +39,13 @@ enum
* and sample offset position.
* This is an emergency resync fallback since buffers marked as DISCONT will
* always lock to the correct timestamp immediatly and buffers not marked as
* DISCONT are contiguous bu definition.
* DISCONT are contiguous by definition.
*/
#define DIFF_TOLERANCE 2
#define DEFAULT_BUFFER_TIME 200 * GST_USECOND
#define DEFAULT_LATENCY_TIME 10 * GST_USECOND
/* FIXME: 0.11, store the buffer_time and latency_time in nanoseconds */
#define DEFAULT_BUFFER_TIME ((200 * GST_MSECOND) / GST_USECOND)
#define DEFAULT_LATENCY_TIME ((10 * GST_MSECOND) / GST_USECOND)
#define DEFAULT_PROVIDE_CLOCK TRUE
enum
......@@ -100,8 +101,6 @@ gst_base_audio_sink_base_init (gpointer g_class)
static void
gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass)
{
gchar *longdesc;
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSinkClass *gstbasesink_class;
......@@ -116,21 +115,16 @@ gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass)
GST_DEBUG_FUNCPTR (gst_base_audio_sink_get_property);
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_base_audio_sink_dispose);
longdesc =
g_strdup_printf
("Size of audio buffer in microseconds (use -1 for default of %"
G_GUINT64_FORMAT " us)", DEFAULT_BUFFER_TIME / GST_USECOND);
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFFER_TIME,
g_param_spec_int64 ("buffer-time", "Buffer Time", longdesc, -1,
g_param_spec_int64 ("buffer-time", "Buffer Time",
"Size of audio buffer in microseconds", 1,
G_MAXINT64, DEFAULT_BUFFER_TIME, G_PARAM_READWRITE));
g_free (longdesc);
longdesc =
g_strdup_printf ("Audio latency in microseconds (use -1 for default of %"
G_GUINT64_FORMAT " us)", DEFAULT_LATENCY_TIME / GST_USECOND);
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LATENCY_TIME,
g_param_spec_int64 ("latency-time", "Latency Time", longdesc, -1,
g_param_spec_int64 ("latency-time", "Latency Time",
"Audio latency in microseconds", 1,
G_MAXINT64, DEFAULT_LATENCY_TIME, G_PARAM_READWRITE));
g_free (longdesc);
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PROVIDE_CLOCK,
g_param_spec_boolean ("provide-clock", "Provide Clock",
"Provide a clock to be used as the global pipeline clock",
......@@ -318,12 +312,12 @@ gst_base_audio_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
if (!gst_ring_buffer_acquire (sink->ringbuffer, spec))
goto acquire_error;
/* calculate actual latency and buffer times */
spec->latency_time =
spec->segsize * GST_MSECOND / (spec->rate * spec->bytes_per_sample);
spec->buffer_time =
spec->segtotal * spec->segsize * GST_MSECOND / (spec->rate *
spec->bytes_per_sample);
/* calculate actual latency and buffer times.
* FIXME: In 0.11, store the latency_time internally in ns */
spec->latency_time = gst_util_uint64_scale (spec->segsize,
(GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
spec->buffer_time = spec->segtotal * spec->latency_time;
gst_ring_buffer_debug_spec_buff (spec);
......
......@@ -76,9 +76,9 @@ struct _GstBaseAudioSink {
/* our ringbuffer */
GstRingBuffer *ringbuffer;
/* required buffer and latency */
GstClockTime buffer_time;
GstClockTime latency_time;
/* required buffer and latency in microseconds */
guint64 buffer_time;
guint64 latency_time;
/* the next sample to write */
guint64 next_sample;
......
......@@ -341,9 +341,14 @@ gst_ring_buffer_parse_caps (GstRingBufferSpec * spec, GstCaps * caps)
g_return_val_if_fail (spec->latency_time != 0, FALSE);
/* calculate suggested segsize and segtotal */
spec->segsize =
spec->rate * spec->bytes_per_sample * spec->latency_time / GST_MSECOND;
/* calculate suggested segsize and segtotal. segsize should be one unit
* of 'latency_time' samples, scaling for the fact that latency_time is
* currently stored in microseconds (FIXME: in 0.11) */
spec->segsize = gst_util_uint64_scale (spec->rate * spec->bytes_per_sample,
spec->latency_time, GST_SECOND / GST_USECOND);
/* Round to an integer number of samples */
spec->segsize -= spec->segsize % spec->bytes_per_sample;
spec->segtotal = spec->buffer_time / spec->latency_time;
gst_ring_buffer_debug_spec_caps (spec);
......@@ -1003,6 +1008,8 @@ gst_ring_buffer_samples_done (GstRingBuffer * buf)
if (G_LIKELY (samples >= delay))
samples -= delay;
else
samples = 0;
GST_DEBUG_OBJECT (buf, "processed samples: raw %llu, delay %u, real %llu",
raw, delay, samples);
......
......@@ -156,8 +156,8 @@ typedef enum
* @depth: th depth of the samples
* @rate: the samplerate
* @channels: the number of channels
* @latency_time: the latency in time units
* @buffer_time: the total buffer size in time units
* @latency_time: the latency in microseconds
* @buffer_time: the total buffer size in microseconds
* @segsize: the size of one segment in bytes
* @segtotal: the total number of segments
* @bytes_per_sample: number of bytes in one sample
......@@ -181,8 +181,8 @@ struct _GstRingBufferSpec
gint rate;
gint channels;
GstClockTime latency_time; /* the required/actual latency time */
GstClockTime buffer_time; /* the required/actual time of the buffer */
guint64 latency_time; /* the required/actual latency time */
guint64 buffer_time; /* the required/actual time of the buffer */
gint segsize; /* size of one buffer segement */
gint segtotal; /* total number of segments */
......
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