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.
This commit is contained in:
Wim Taymans 2010-09-07 18:06:27 +02:00
parent 5f5c52cbc5
commit c7972692d3
3 changed files with 32 additions and 0 deletions

View file

@ -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
<SUBSECTION Standard>
GstAudioClockClass
GST_AUDIO_CLOCK

View file

@ -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;
}

View file

@ -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__ */