mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-03 15:06:34 +00:00
audioclock: use GstAudioClock* as first argument in GstAudioClock methods
All the GstAudioClock method declarations required object of GstClock type as a first argument, but in fact, required GstAudioClock object (runtime check in function body). Instead of checking type in run-time, we can change functions declaration, to accept only GstAudioClock methods. Then, runtime check is not necessary anymore, since always GstAudioClock object is passed to a function. https://bugzilla.gnome.org/show_bug.cgi?id=756628
This commit is contained in:
parent
ec447d421f
commit
89e711663f
4 changed files with 23 additions and 30 deletions
|
@ -341,7 +341,7 @@ gst_audio_base_sink_dispose (GObject * object)
|
|||
sink->priv->custom_slaving_cb_notify (sink->priv->custom_slaving_cb_data);
|
||||
|
||||
if (sink->provided_clock) {
|
||||
gst_audio_clock_invalidate (sink->provided_clock);
|
||||
gst_audio_clock_invalidate (GST_AUDIO_CLOCK (sink->provided_clock));
|
||||
gst_object_unref (sink->provided_clock);
|
||||
sink->provided_clock = NULL;
|
||||
}
|
||||
|
@ -1295,8 +1295,9 @@ gst_audio_base_sink_custom_slaving (GstAudioBaseSink * sink,
|
|||
|
||||
/* sample clocks and figure out clock skew */
|
||||
etime = gst_clock_get_time (GST_ELEMENT_CLOCK (sink));
|
||||
itime = gst_audio_clock_get_time (sink->provided_clock);
|
||||
itime = gst_audio_clock_adjust (sink->provided_clock, itime);
|
||||
itime = gst_audio_clock_get_time (GST_AUDIO_CLOCK (sink->provided_clock));
|
||||
itime =
|
||||
gst_audio_clock_adjust (GST_AUDIO_CLOCK (sink->provided_clock), itime);
|
||||
|
||||
GST_DEBUG_OBJECT (sink,
|
||||
"internal %" GST_TIME_FORMAT " external %" GST_TIME_FORMAT
|
||||
|
@ -1442,8 +1443,9 @@ gst_audio_base_sink_skew_slaving (GstAudioBaseSink * sink,
|
|||
|
||||
/* sample clocks and figure out clock skew */
|
||||
etime = gst_clock_get_time (GST_ELEMENT_CLOCK (sink));
|
||||
itime = gst_audio_clock_get_time (sink->provided_clock);
|
||||
itime = gst_audio_clock_adjust (sink->provided_clock, itime);
|
||||
itime = gst_audio_clock_get_time (GST_AUDIO_CLOCK (sink->provided_clock));
|
||||
itime =
|
||||
gst_audio_clock_adjust (GST_AUDIO_CLOCK (sink->provided_clock), itime);
|
||||
|
||||
GST_DEBUG_OBJECT (sink,
|
||||
"internal %" GST_TIME_FORMAT " external %" GST_TIME_FORMAT
|
||||
|
@ -1668,8 +1670,9 @@ gst_audio_base_sink_sync_latency (GstBaseSink * bsink, GstMiniObject * obj)
|
|||
|
||||
/* We might need to take the object lock within gst_audio_clock_get_time(),
|
||||
* so call that before we take it again */
|
||||
itime = gst_audio_clock_get_time (sink->provided_clock);
|
||||
itime = gst_audio_clock_adjust (sink->provided_clock, itime);
|
||||
itime = gst_audio_clock_get_time (GST_AUDIO_CLOCK (sink->provided_clock));
|
||||
itime =
|
||||
gst_audio_clock_adjust (GST_AUDIO_CLOCK (sink->provided_clock), itime);
|
||||
|
||||
GST_OBJECT_LOCK (sink);
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ gst_audio_base_src_dispose (GObject * object)
|
|||
|
||||
GST_OBJECT_LOCK (src);
|
||||
if (src->clock) {
|
||||
gst_audio_clock_invalidate (src->clock);
|
||||
gst_audio_clock_invalidate (GST_AUDIO_CLOCK (src->clock));
|
||||
gst_object_unref (src->clock);
|
||||
src->clock = NULL;
|
||||
}
|
||||
|
@ -1027,7 +1027,7 @@ gst_audio_base_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
|
|||
} else {
|
||||
/* to get the timestamp against the clock we also need to add our
|
||||
* offset */
|
||||
timestamp = gst_audio_clock_adjust (clock, timestamp);
|
||||
timestamp = gst_audio_clock_adjust (GST_AUDIO_CLOCK (clock), timestamp);
|
||||
}
|
||||
|
||||
/* we are not slaved, subtract base_time */
|
||||
|
|
|
@ -184,22 +184,19 @@ gst_audio_clock_get_internal_time (GstClock * clock)
|
|||
* Returns: the time as reported by the time function of the audio clock
|
||||
*/
|
||||
GstClockTime
|
||||
gst_audio_clock_get_time (GstClock * clock)
|
||||
gst_audio_clock_get_time (GstAudioClock * clock)
|
||||
{
|
||||
GstAudioClock *aclock;
|
||||
GstClockTime result;
|
||||
|
||||
aclock = GST_AUDIO_CLOCK_CAST (clock);
|
||||
|
||||
result = aclock->func (clock, aclock->user_data);
|
||||
result = clock->func (GST_CLOCK_CAST (clock), clock->user_data);
|
||||
if (result == GST_CLOCK_TIME_NONE) {
|
||||
GST_DEBUG_OBJECT (clock, "no time, reuse last");
|
||||
result = aclock->last_time - aclock->time_offset;
|
||||
result = clock->last_time - clock->time_offset;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (clock,
|
||||
"result %" GST_TIME_FORMAT ", last_time %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (result), GST_TIME_ARGS (aclock->last_time));
|
||||
GST_TIME_ARGS (result), GST_TIME_ARGS (clock->last_time));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -214,14 +211,11 @@ gst_audio_clock_get_time (GstClock * clock)
|
|||
* Returns: @time adjusted with the internal offset.
|
||||
*/
|
||||
GstClockTime
|
||||
gst_audio_clock_adjust (GstClock * clock, GstClockTime time)
|
||||
gst_audio_clock_adjust (GstAudioClock * clock, GstClockTime time)
|
||||
{
|
||||
GstAudioClock *aclock;
|
||||
GstClockTime result;
|
||||
|
||||
aclock = GST_AUDIO_CLOCK_CAST (clock);
|
||||
|
||||
result = time + aclock->time_offset;
|
||||
result = time + clock->time_offset;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -238,11 +232,7 @@ gst_audio_clock_adjust (GstClock * clock, GstClockTime time)
|
|||
* the rest of its lifetime.
|
||||
*/
|
||||
void
|
||||
gst_audio_clock_invalidate (GstClock * clock)
|
||||
gst_audio_clock_invalidate (GstAudioClock * clock)
|
||||
{
|
||||
GstAudioClock *aclock;
|
||||
|
||||
aclock = GST_AUDIO_CLOCK_CAST (clock);
|
||||
|
||||
aclock->func = gst_audio_clock_func_invalid;
|
||||
clock->func = gst_audio_clock_func_invalid;
|
||||
}
|
||||
|
|
|
@ -94,10 +94,10 @@ GstClock* gst_audio_clock_new (const gchar *name, GstAudioCloc
|
|||
gpointer user_data, GDestroyNotify destroy_notify);
|
||||
void gst_audio_clock_reset (GstAudioClock *clock, GstClockTime time);
|
||||
|
||||
GstClockTime gst_audio_clock_get_time (GstClock * clock);
|
||||
GstClockTime gst_audio_clock_adjust (GstClock * clock, GstClockTime time);
|
||||
GstClockTime gst_audio_clock_get_time (GstAudioClock * clock);
|
||||
GstClockTime gst_audio_clock_adjust (GstAudioClock * clock, GstClockTime time);
|
||||
|
||||
void gst_audio_clock_invalidate (GstClock * clock);
|
||||
void gst_audio_clock_invalidate (GstAudioClock * clock);
|
||||
|
||||
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioClock, gst_object_unref)
|
||||
|
|
Loading…
Reference in a new issue