## gstaudioclock

gstaudioclock — Helper object for implementing audio clocks

## Synopsis

    #include <gst/audio/gstaudioclock.h>

    struct              GstAudioClock;
    GstClockTime        (*GstAudioClockGetTimeFunc)         (GstClock *clock,
                                                             gpointer user_data);
    GstClock *          gst_audio_clock_new                 (const gchar *name,
                                                             GstAudioClockGetTimeFunc func,
                                                             gpointer user_data);
    GstClock *          gst_audio_clock_new_full            (const gchar *name,
                                                             GstAudioClockGetTimeFunc func,
                                                             gpointer user_data,
                                                             GDestroyNotify destroy_notify);
    GstClockTime        gst_audio_clock_adjust              (GstClock *clock,
                                                             GstClockTime time);
    GstClockTime        gst_audio_clock_get_time            (GstClock *clock);
    void                gst_audio_clock_reset               (GstAudioClock *clock,
                                                             GstClockTime time);
    void                gst_audio_clock_invalidate          (GstClock *clock);

## Object Hierarchy

      GObject
       +----GstObject
             +----GstClock
                   +----GstSystemClock
                         +----GstAudioClock

## Description

GstAudioClock makes it easy for elements to implement a GstClock, they simply need to provide a function that returns the current clock time.

This object is internally used to implement the clock in GstBaseAudioSink.

Last reviewed on 2006-09-27 (0.10.12)

## Details

### struct GstAudioClock

    struct GstAudioClock;

Opaque GstAudioClock.

### GstAudioClockGetTimeFunc ()

    GstClockTime        (*GstAudioClockGetTimeFunc)         (GstClock *clock,
                                                             gpointer user_data);

This function will be called whenever the current clock time needs to be calculated. If this function returns GST_CLOCK_TIME_NONE, the last reported time will be returned by the clock.

`clock` : | the GstAudioClock
`user_data` : | user data
Returns : | the current time or GST_CLOCK_TIME_NONE if the previous time should be used.

### gst_audio_clock_new ()

    GstClock *          gst_audio_clock_new                 (const gchar *name,
                                                             GstAudioClockGetTimeFunc func,
                                                             gpointer user_data);

Create a new GstAudioClock instance. Whenever the clock time should be calculated it will call `func` with `user_data`. When `func` returns GST_CLOCK_TIME_NONE, the clock will return the last reported time.

`name` : | the name of the clock
`func` : | a function
`user_data` : | user data
Returns : | a new GstAudioClock casted to a GstClock.

### gst_audio_clock_new_full ()

    GstClock *          gst_audio_clock_new_full            (const gchar *name,
                                                             GstAudioClockGetTimeFunc func,
                                                             gpointer user_data,
                                                             GDestroyNotify destroy_notify);

Create a new GstAudioClock instance. Whenever the clock time should be calculated it will call `func` with `user_data`. When `func` returns GST_CLOCK_TIME_NONE, the clock will return the last reported time.

`name` : | the name of the clock
`func` : | a function
`user_data` : | user data
`destroy_notify` : | GDestroyNotify for `user_data`
Returns : | a new GstAudioClock casted to a GstClock.

Since 0.10.31

### gst_audio_clock_adjust ()

    GstClockTime        gst_audio_clock_adjust              (GstClock *clock,
                                                             GstClockTime time);

Adjust `time` with the internal offset of the audio clock.

`clock` : | a GstAudioClock
`time` : | a GstClockTime
Returns : | `time` adjusted with the internal offset.

Since 0.10.23

### gst_audio_clock_get_time ()

    GstClockTime        gst_audio_clock_get_time            (GstClock *clock);

Report the time as returned by the GstAudioClockGetTimeFunc without applying any offsets.

`clock` : | a GstAudioClock
Returns : | the time as reported by the time function of the audio clock

Since 0.10.23

### gst_audio_clock_reset ()

    void                gst_audio_clock_reset               (GstAudioClock *clock,
                                                             GstClockTime time);

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.

`clock` : | a GstAudioClock
`time` : | a GstClockTime

### gst_audio_clock_invalidate ()

    void                gst_audio_clock_invalidate          (GstClock *clock);

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.

`clock` : | a GstAudioClock

Since 0.10.31

## See Also

GstBaseAudioSink, GstSystemClock