mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
gst-libs/gst/audio/gstaudioclock.*: Add method to inform the clock that the time starts from 0 again. We use this inf...
Original commit message from CVS: * gst-libs/gst/audio/gstaudioclock.c: (gst_audio_clock_init), (gst_audio_clock_reset), (gst_audio_clock_get_internal_time): * gst-libs/gst/audio/gstaudioclock.h: Add method to inform the clock that the time starts from 0 again. We use this info to calculate a clock offset so that the time we report in internal_time is monotonically increasing, as required by the clock base class. Fixes #521761. API: GstAudioClock::gst_audio_clock_reset() * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_skew_slaving), (gst_base_audio_sink_change_state): * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_create), (gst_base_audio_src_change_state): Reset reported time when we (re)create the ringbuffer.
This commit is contained in:
parent
dc9eb0d6b8
commit
35e4b75b86
5 changed files with 54 additions and 4 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2008-05-27 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||
|
||||
* gst-libs/gst/audio/gstaudioclock.c: (gst_audio_clock_init),
|
||||
(gst_audio_clock_reset), (gst_audio_clock_get_internal_time):
|
||||
* gst-libs/gst/audio/gstaudioclock.h:
|
||||
Add method to inform the clock that the time starts from 0 again. We use
|
||||
this info to calculate a clock offset so that the time we report in
|
||||
internal_time is monotonically increasing, as required by the clock base
|
||||
class. Fixes #521761.
|
||||
API: GstAudioClock::gst_audio_clock_reset()
|
||||
|
||||
* gst-libs/gst/audio/gstbaseaudiosink.c:
|
||||
(gst_base_audio_sink_skew_slaving),
|
||||
(gst_base_audio_sink_change_state):
|
||||
* gst-libs/gst/audio/gstbaseaudiosrc.c:
|
||||
(gst_base_audio_src_create), (gst_base_audio_src_change_state):
|
||||
Reset reported time when we (re)create the ringbuffer.
|
||||
|
||||
2008-05-27 Tim-Philipp Müller <tim.muller at collabora co uk>
|
||||
|
||||
* ext/alsa/gstalsamixertrack.c:
|
||||
|
|
|
@ -94,6 +94,7 @@ static void
|
|||
gst_audio_clock_init (GstAudioClock * clock)
|
||||
{
|
||||
clock->last_time = 0;
|
||||
clock->abidata.ABI.time_offset = 0;
|
||||
GST_OBJECT_FLAG_SET (clock, GST_CLOCK_FLAG_CAN_SET_MASTER);
|
||||
}
|
||||
|
||||
|
@ -122,17 +123,39 @@ gst_audio_clock_new (gchar * name, GstAudioClockGetTimeFunc func,
|
|||
return (GstClock *) aclock;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_audio_clock_reset:
|
||||
* @clock: a #GstAudioClock
|
||||
* @time: a #GstClockTime
|
||||
*
|
||||
* Inform @clock that future calls to #GstAudioClockGetTimeFunc will return values
|
||||
* starting from @time. The clock will update an internal offset to make sure that
|
||||
* future calls to internal_time will return an increasing result as required by
|
||||
* the #GstClock object.
|
||||
*/
|
||||
void
|
||||
gst_audio_clock_reset (GstAudioClock * clock, GstClockTime time)
|
||||
{
|
||||
if (clock->last_time >= time)
|
||||
clock->abidata.ABI.time_offset = clock->last_time - time;
|
||||
else
|
||||
clock->abidata.ABI.time_offset = -(time - clock->last_time);
|
||||
}
|
||||
|
||||
static GstClockTime
|
||||
gst_audio_clock_get_internal_time (GstClock * clock)
|
||||
{
|
||||
GstAudioClock *aclock = GST_AUDIO_CLOCK (clock);
|
||||
GstAudioClock *aclock;
|
||||
GstClockTime result;
|
||||
|
||||
aclock = GST_AUDIO_CLOCK (clock);
|
||||
|
||||
result = aclock->func (clock, aclock->user_data);
|
||||
if (result == GST_CLOCK_TIME_NONE)
|
||||
result = aclock->last_time;
|
||||
else
|
||||
else {
|
||||
result += aclock->abidata.ABI.time_offset;
|
||||
aclock->last_time = result;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,13 @@ struct _GstAudioClock {
|
|||
GstClockTime last_time;
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
union {
|
||||
struct {
|
||||
GstClockTimeDiff time_offset;
|
||||
} ABI;
|
||||
/* adding + 0 to mark ABI change to be undone later */
|
||||
gpointer _gst_reserved[GST_PADDING + 0];
|
||||
} abidata;
|
||||
};
|
||||
|
||||
struct _GstAudioClockClass {
|
||||
|
@ -84,6 +90,7 @@ struct _GstAudioClockClass {
|
|||
GType gst_audio_clock_get_type (void);
|
||||
GstClock* gst_audio_clock_new (gchar *name, GstAudioClockGetTimeFunc func,
|
||||
gpointer user_data);
|
||||
void gst_audio_clock_reset (GstAudioClock *clock, GstClockTime time);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -1604,6 +1604,7 @@ gst_base_audio_sink_change_state (GstElement * element,
|
|||
switch (transition) {
|
||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||
if (sink->ringbuffer == NULL) {
|
||||
gst_audio_clock_reset (GST_AUDIO_CLOCK (sink->provided_clock), 0);
|
||||
sink->ringbuffer = gst_base_audio_sink_create_ringbuffer (sink);
|
||||
}
|
||||
if (!gst_ring_buffer_open_device (sink->ringbuffer))
|
||||
|
|
|
@ -870,6 +870,7 @@ gst_base_audio_src_change_state (GstElement * element,
|
|||
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||
GST_DEBUG_OBJECT (src, "NULL->READY");
|
||||
if (src->ringbuffer == NULL) {
|
||||
gst_audio_clock_reset (GST_AUDIO_CLOCK (src->clock), 0);
|
||||
src->ringbuffer = gst_base_audio_src_create_ringbuffer (src);
|
||||
}
|
||||
if (!gst_ring_buffer_open_device (src->ringbuffer))
|
||||
|
|
Loading…
Reference in a new issue