From c7972692d3073a5d06a42bb8adadded96db8cc40 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 7 Sep 2010 18:06:27 +0200 Subject: [PATCH] audioclock: add a function to invalidate the clock Add a function to invalidate the time function of a clock. Useful for when the function becomes invalid. --- docs/libs/gst-plugins-base-libs-sections.txt | 1 + gst-libs/gst/audio/gstaudioclock.c | 29 ++++++++++++++++++++ gst-libs/gst/audio/gstaudioclock.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index d55a43a153..f9d09902fa 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -111,6 +111,7 @@ gst_audio_clock_new_full gst_audio_clock_adjust gst_audio_clock_get_time gst_audio_clock_reset +gst_audio_clock_invalidate GstAudioClockClass GST_AUDIO_CLOCK diff --git a/gst-libs/gst/audio/gstaudioclock.c b/gst-libs/gst/audio/gstaudioclock.c index 5b324d6329..95a8a0d8ee 100644 --- a/gst-libs/gst/audio/gstaudioclock.c +++ b/gst-libs/gst/audio/gstaudioclock.c @@ -201,6 +201,12 @@ gst_audio_clock_reset (GstAudioClock * clock, GstClockTime time) GST_TIME_ARGS (time_offset)); } +static GstClockTime +gst_audio_clock_func_invalid (GstClock * clock, gpointer user_data) +{ + return GST_CLOCK_TIME_NONE; +} + static GstClockTime gst_audio_clock_get_internal_time (GstClock * clock) { @@ -283,3 +289,26 @@ gst_audio_clock_adjust (GstClock * clock, GstClockTime time) return result; } + +/** + * gst_audio_clock_invalidate: + * @clock: a #GstAudioClock + * + * Invalidate the clock function. Call this function when the provided + * #GstAudioClockGetTimeFunc cannot be called anymore, for example, when the + * user_data becomes invalid. + * + * After calling this function, @clock will return the last returned time for + * the rest of its lifetime. + * + * Since: 0.10.31 + */ +void +gst_audio_clock_invalidate (GstClock * clock) +{ + GstAudioClock *aclock; + + aclock = GST_AUDIO_CLOCK_CAST (clock); + + aclock->func = gst_audio_clock_func_invalid; +} diff --git a/gst-libs/gst/audio/gstaudioclock.h b/gst-libs/gst/audio/gstaudioclock.h index cdbe474511..fb50bcf6b9 100644 --- a/gst-libs/gst/audio/gstaudioclock.h +++ b/gst-libs/gst/audio/gstaudioclock.h @@ -101,6 +101,8 @@ void gst_audio_clock_reset (GstAudioClock *clock, GstClockT GstClockTime gst_audio_clock_get_time (GstClock * clock); GstClockTime gst_audio_clock_adjust (GstClock * clock, GstClockTime time); +void gst_audio_clock_invalidate (GstClock * clock); + G_END_DECLS #endif /* __GST_AUDIO_CLOCK_H__ */