mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
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.
This commit is contained in:
parent
dd42d7ba98
commit
45e06fe704
5 changed files with 54 additions and 32 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
||||||
|
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>
|
2006-06-02 Michael Smith <msmith@fluendo.com>
|
||||||
|
|
||||||
* tests/check/elements/audioconvert.c: (set_channel_positions),
|
* tests/check/elements/audioconvert.c: (set_channel_positions),
|
||||||
|
|
|
@ -39,12 +39,13 @@ enum
|
||||||
* and sample offset position.
|
* and sample offset position.
|
||||||
* This is an emergency resync fallback since buffers marked as DISCONT will
|
* This is an emergency resync fallback since buffers marked as DISCONT will
|
||||||
* always lock to the correct timestamp immediatly and buffers not marked as
|
* 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 DIFF_TOLERANCE 2
|
||||||
|
|
||||||
#define DEFAULT_BUFFER_TIME 200 * GST_USECOND
|
/* FIXME: 0.11, store the buffer_time and latency_time in nanoseconds */
|
||||||
#define DEFAULT_LATENCY_TIME 10 * GST_USECOND
|
#define DEFAULT_BUFFER_TIME ((200 * GST_MSECOND) / GST_USECOND)
|
||||||
|
#define DEFAULT_LATENCY_TIME ((10 * GST_MSECOND) / GST_USECOND)
|
||||||
#define DEFAULT_PROVIDE_CLOCK TRUE
|
#define DEFAULT_PROVIDE_CLOCK TRUE
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -100,8 +101,6 @@ gst_base_audio_sink_base_init (gpointer g_class)
|
||||||
static void
|
static void
|
||||||
gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass)
|
gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass)
|
||||||
{
|
{
|
||||||
gchar *longdesc;
|
|
||||||
|
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
GstElementClass *gstelement_class;
|
||||||
GstBaseSinkClass *gstbasesink_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);
|
GST_DEBUG_FUNCPTR (gst_base_audio_sink_get_property);
|
||||||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_base_audio_sink_dispose);
|
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_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_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_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_MAXINT64, DEFAULT_LATENCY_TIME, G_PARAM_READWRITE));
|
||||||
g_free (longdesc);
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PROVIDE_CLOCK,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PROVIDE_CLOCK,
|
||||||
g_param_spec_boolean ("provide-clock", "Provide Clock",
|
g_param_spec_boolean ("provide-clock", "Provide Clock",
|
||||||
"Provide a clock to be used as the global pipeline 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))
|
if (!gst_ring_buffer_acquire (sink->ringbuffer, spec))
|
||||||
goto acquire_error;
|
goto acquire_error;
|
||||||
|
|
||||||
/* calculate actual latency and buffer times */
|
/* calculate actual latency and buffer times.
|
||||||
spec->latency_time =
|
* FIXME: In 0.11, store the latency_time internally in ns */
|
||||||
spec->segsize * GST_MSECOND / (spec->rate * spec->bytes_per_sample);
|
spec->latency_time = gst_util_uint64_scale (spec->segsize,
|
||||||
spec->buffer_time =
|
(GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
|
||||||
spec->segtotal * spec->segsize * GST_MSECOND / (spec->rate *
|
|
||||||
spec->bytes_per_sample);
|
spec->buffer_time = spec->segtotal * spec->latency_time;
|
||||||
|
|
||||||
gst_ring_buffer_debug_spec_buff (spec);
|
gst_ring_buffer_debug_spec_buff (spec);
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,9 @@ struct _GstBaseAudioSink {
|
||||||
/* our ringbuffer */
|
/* our ringbuffer */
|
||||||
GstRingBuffer *ringbuffer;
|
GstRingBuffer *ringbuffer;
|
||||||
|
|
||||||
/* required buffer and latency */
|
/* required buffer and latency in microseconds */
|
||||||
GstClockTime buffer_time;
|
guint64 buffer_time;
|
||||||
GstClockTime latency_time;
|
guint64 latency_time;
|
||||||
|
|
||||||
/* the next sample to write */
|
/* the next sample to write */
|
||||||
guint64 next_sample;
|
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);
|
g_return_val_if_fail (spec->latency_time != 0, FALSE);
|
||||||
|
|
||||||
/* calculate suggested segsize and segtotal */
|
/* calculate suggested segsize and segtotal. segsize should be one unit
|
||||||
spec->segsize =
|
* of 'latency_time' samples, scaling for the fact that latency_time is
|
||||||
spec->rate * spec->bytes_per_sample * spec->latency_time / GST_MSECOND;
|
* 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;
|
spec->segtotal = spec->buffer_time / spec->latency_time;
|
||||||
|
|
||||||
gst_ring_buffer_debug_spec_caps (spec);
|
gst_ring_buffer_debug_spec_caps (spec);
|
||||||
|
@ -1003,6 +1008,8 @@ gst_ring_buffer_samples_done (GstRingBuffer * buf)
|
||||||
|
|
||||||
if (G_LIKELY (samples >= delay))
|
if (G_LIKELY (samples >= delay))
|
||||||
samples -= delay;
|
samples -= delay;
|
||||||
|
else
|
||||||
|
samples = 0;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (buf, "processed samples: raw %llu, delay %u, real %llu",
|
GST_DEBUG_OBJECT (buf, "processed samples: raw %llu, delay %u, real %llu",
|
||||||
raw, delay, samples);
|
raw, delay, samples);
|
||||||
|
|
|
@ -156,8 +156,8 @@ typedef enum
|
||||||
* @depth: th depth of the samples
|
* @depth: th depth of the samples
|
||||||
* @rate: the samplerate
|
* @rate: the samplerate
|
||||||
* @channels: the number of channels
|
* @channels: the number of channels
|
||||||
* @latency_time: the latency in time units
|
* @latency_time: the latency in microseconds
|
||||||
* @buffer_time: the total buffer size in time units
|
* @buffer_time: the total buffer size in microseconds
|
||||||
* @segsize: the size of one segment in bytes
|
* @segsize: the size of one segment in bytes
|
||||||
* @segtotal: the total number of segments
|
* @segtotal: the total number of segments
|
||||||
* @bytes_per_sample: number of bytes in one sample
|
* @bytes_per_sample: number of bytes in one sample
|
||||||
|
@ -181,8 +181,8 @@ struct _GstRingBufferSpec
|
||||||
gint rate;
|
gint rate;
|
||||||
gint channels;
|
gint channels;
|
||||||
|
|
||||||
GstClockTime latency_time; /* the required/actual latency time */
|
guint64 latency_time; /* the required/actual latency time */
|
||||||
GstClockTime buffer_time; /* the required/actual time of the buffer */
|
guint64 buffer_time; /* the required/actual time of the buffer */
|
||||||
gint segsize; /* size of one buffer segement */
|
gint segsize; /* size of one buffer segement */
|
||||||
gint segtotal; /* total number of segments */
|
gint segtotal; /* total number of segments */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue