## gstaudiosink

gstaudiosink — Simple base class for audio sinks

## Synopsis

    #include <gst/audio/gstaudiosink.h>

                        GstAudioSink;
                        GstAudioSinkClass;

## Object Hierarchy

      GObject
       +----GstObject
             +----GstElement
                   +----GstBaseSink
                         +----GstBaseAudioSink
                               +----GstAudioSink

## Description

This is the most simple base class for audio sinks that only requires subclasses to implement a set of simple functions:

`open()` | Open the device.
`prepare()` | Configure the device with the specified format.
`write()` | Write samples to the device.
`reset()` | Unblock writes and flush the device.
`delay()` | Get the number of samples written but not yet played by the device.
`unprepare()` | Undo operations done by prepare.
`close()` | Close the device.

All scheduling of samples and timestamps is done in this base class together with GstBaseAudioSink using a default implementation of a GstRingBuffer that uses threads.

Last reviewed on 2006-09-27 (0.10.12)

## Details

### GstAudioSink

    typedef struct _GstAudioSink GstAudioSink;

Opaque GstAudioSink.

### GstAudioSinkClass

    typedef struct {
      GstBaseAudioSinkClass parent_class;

      /* vtable */

      /* open the device with given specs */
      gboolean (*open)      (GstAudioSink *sink);
      /* prepare resources and state to operate with the given specs */
      gboolean (*prepare)   (GstAudioSink *sink, GstRingBufferSpec *spec);
      /* undo anything that was done in prepare() */
      gboolean (*unprepare) (GstAudioSink *sink);
      /* close the device */
      gboolean (*close)     (GstAudioSink *sink);
      /* write samples to the device */
      /* FIXME 0.11: change return value to gint, as most implementation use that
       * already anyway */
      guint    (*write)     (GstAudioSink *sink, gpointer data, guint length);
      /* get number of samples queued in the device */
      guint    (*delay)     (GstAudioSink *sink);
      /* reset the audio device, unblock from a write */
      void     (*reset)     (GstAudioSink *sink);
    } GstAudioSinkClass;

GstAudioSink class. Override the vmethods to implement functionality.

GstBaseAudioSinkClass `parent_class`; | the parent class structure.
`open` () | Open the device. No configuration needs to be done at this point. This function is also used to check if the device is available.
`prepare` () | Prepare the device to operate with the specified parameters.
`unprepare` () | Undo operations done in prepare.
`close` () | Close the device.
`write` () | Write data to the device.
`delay` () | Return how many samples are still in the device. This is used to drive the synchronisation.
`reset` () | Returns as quickly as possible from a write and flush any pending samples from the device.

## See Also

GstBaseAudioSink, GstRingBuffer, GstAudioSink.