gst-libs/gst/audio/gstaudioclock.c: Fix clock name.

Original commit message from CVS:
* gst-libs/gst/audio/gstaudioclock.c: (gst_audio_clock_init),
(gst_audio_clock_new):
Fix clock name.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_init), (gst_base_audio_sink_query):
* gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_init),
(gst_base_audio_src_query), (gst_base_audio_src_get_offset),
(gst_base_audio_src_create):
Improve latency query code.
Use proper clock names.
This commit is contained in:
Wim Taymans 2007-02-28 15:02:25 +00:00
parent 561f78ed7f
commit 3c94c06c5a
4 changed files with 41 additions and 11 deletions

View file

@ -1,3 +1,17 @@
2007-02-28 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstaudioclock.c: (gst_audio_clock_init),
(gst_audio_clock_new):
Fix clock name.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_init), (gst_base_audio_sink_query):
* gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_init),
(gst_base_audio_src_query), (gst_base_audio_src_get_offset),
(gst_base_audio_src_create):
Improve latency query code.
Use proper clock names.
2007-02-28 Thomas Vander Stichele <thomas at apestaart dot org>
* tests/check/generic/states.c: (GST_START_TEST):

View file

@ -93,8 +93,6 @@ gst_audio_clock_class_init (GstAudioClockClass * klass)
static void
gst_audio_clock_init (GstAudioClock * clock)
{
gst_object_set_name (GST_OBJECT (clock), "GstAudioClock");
clock->last_time = 0;
GST_OBJECT_FLAG_SET (clock, GST_CLOCK_FLAG_CAN_SET_MASTER);
}
@ -116,7 +114,7 @@ gst_audio_clock_new (gchar * name, GstAudioClockGetTimeFunc func,
gpointer user_data)
{
GstAudioClock *aclock =
GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, NULL));
GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, "name", name, NULL));
aclock->func = func;
aclock->user_data = user_data;

View file

@ -174,7 +174,7 @@ gst_base_audio_sink_init (GstBaseAudioSink * baseaudiosink,
baseaudiosink->latency_time = DEFAULT_LATENCY_TIME;
baseaudiosink->provide_clock = DEFAULT_PROVIDE_CLOCK;
baseaudiosink->provided_clock = gst_audio_clock_new ("clock",
baseaudiosink->provided_clock = gst_audio_clock_new ("GstAudioSinkClock",
(GstAudioClockGetTimeFunc) gst_base_audio_sink_get_time, baseaudiosink);
GST_BASE_SINK (baseaudiosink)->can_activate_push = TRUE;
@ -257,6 +257,13 @@ gst_base_audio_sink_query (GstElement * element, GstQuery * query)
GST_DEBUG_OBJECT (basesink, "latency query");
if (!basesink->ringbuffer || !basesink->ringbuffer->spec.rate) {
GST_DEBUG_OBJECT (basesink,
"we are not yet negotiated, can't report latency yet");
res = FALSE;
goto done;
}
/* ask parent first, it will do an upstream query for us. */
if ((res =
gst_base_sink_query_latency (GST_BASE_SINK_CAST (basesink), &live,
@ -264,16 +271,19 @@ gst_base_audio_sink_query (GstElement * element, GstQuery * query)
GstClockTime min_latency, max_latency;
/* we and upstream are both live, adjust the min_latency */
if (live && us_live && basesink->ringbuffer
&& basesink->ringbuffer->spec.rate) {
if (live && us_live) {
GstRingBufferSpec *spec;
spec = &basesink->ringbuffer->spec;
max_latency =
spec->segtotal * spec->segsize * GST_SECOND / (spec->rate *
spec->bytes_per_sample);
min_latency = MAX (max_latency, min_l);
min_latency =
gst_util_uint64_scale_int (spec->segtotal * spec->segsize,
GST_SECOND, spec->rate * spec->bytes_per_sample);
/* we cannot go lower than the buffer size */
min_latency = MAX (min_latency, min_l);
/* the max latency is the max of the peer, we can delay an infinite
* amount of time. */
max_latency = max_l;
GST_DEBUG_OBJECT (basesink,
"peer min %" GST_TIME_FORMAT ", our min latency: %"
@ -294,6 +304,7 @@ gst_base_audio_sink_query (GstElement * element, GstQuery * query)
break;
}
done:
return res;
}

View file

@ -152,7 +152,7 @@ gst_base_audio_src_init (GstBaseAudioSrc * baseaudiosrc,
* value based on negotiated format. */
GST_BASE_SRC (baseaudiosrc)->blocksize = 0;
baseaudiosrc->clock = gst_audio_clock_new ("clock",
baseaudiosrc->clock = gst_audio_clock_new ("GstAudioSrcClock",
(GstAudioClockGetTimeFunc) gst_base_audio_src_get_time, baseaudiosrc);
/* we are always a live source */
@ -419,9 +419,11 @@ gst_base_audio_src_query (GstBaseSrc * bsrc, GstQuery * query)
spec = &src->ringbuffer->spec;
/* we have at least 1 segment of latency */
min_latency =
gst_util_uint64_scale_int (spec->segsize, GST_SECOND,
spec->rate * spec->bytes_per_sample);
/* we cannot delay more than the buffersize else we lose data */
max_latency =
gst_util_uint64_scale_int (spec->segtotal * spec->segsize, GST_SECOND,
spec->rate * spec->bytes_per_sample);
@ -493,11 +495,14 @@ gst_base_audio_src_get_offset (GstBaseAudioSrc * src)
segdone = g_atomic_int_get (&src->ringbuffer->segdone)
- src->ringbuffer->segbase;
GST_DEBUG_OBJECT (src, "reading from %d, we are at %d", readseg, segdone);
/* see how far away it is from the read segment, normally segdone (where new
* data is written in the ringbuffer) is bigger than readseg (where we are
* reading). */
diff = segdone - readseg;
if (diff >= segtotal) {
GST_DEBUG_OBJECT (src, "dropped, align to segment %d", segdone);
/* sample would be dropped, position to next playable position */
sample = (segdone - segtotal + 1) * sps;
}
@ -574,6 +579,8 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
GST_WARNING_OBJECT (src,
"create DISCONT of %" G_GUINT64_FORMAT " samples at sample %"
G_GUINT64_FORMAT, sample - src->next_sample, sample);
GST_ELEMENT_WARNING (src, CORE, CLOCK, (NULL),
("dropped %" G_GUINT64_FORMAT " samples", sample - src->next_sample));
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
}