1/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2005 Wim Taymans <wim@fluendo.com>
4 *
5 * gstaudiosink.h:
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifndef __GST_AUDIO_AUDIO_H__
24#include <gst/audio/audio.h>
25#endif
26
27#ifndef __GST_AUDIO_SINK_H__
28#define __GST_AUDIO_SINK_H__
29
30#include <gst/gst.h>
31#include <gst/audio/gstaudiobasesink.h>
32
33G_BEGIN_DECLS
34
35#define GST_TYPE_AUDIO_SINK (gst_audio_sink_get_type())
36#define GST_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_SINK,GstAudioSink))
37#define GST_AUDIO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_SINK,GstAudioSinkClass))
38#define GST_AUDIO_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_SINK,GstAudioSinkClass))
39#define GST_IS_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_SINK))
40#define GST_IS_AUDIO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_SINK))
41
42typedef struct _GstAudioSink GstAudioSink;
43typedef struct _GstAudioSinkClass GstAudioSinkClass;
44typedef struct _GstAudioSinkClassExtension GstAudioSinkClassExtension;
45
46/**
47 * GstAudioSink:
48 *
49 * Opaque #GstAudioSink.
50 */
51struct _GstAudioSink {
52 GstAudioBaseSink element;
53
54 /*< private >*/ /* with LOCK */
55 GThread *thread;
56
57 /*< private >*/
58 gpointer _gst_reserved[GST_PADDING];
59};
60
61/**
62 * GstAudioSinkClass:
63 * @parent_class: the parent class structure.
64 * @open: Open the device. No configuration needs to be done at this point.
65 * This function is also used to check if the device is available.
66 * @prepare: Prepare the device to operate with the specified parameters.
67 * @unprepare: Undo operations done in prepare.
68 * @close: Close the device.
69 * @write: Write data to the device.
70 * This vmethod is allowed to block until all the data is written.
71 * If such is the case then it is expected that pause, stop and
72 * reset will unblock the write when called.
73 * @delay: Return how many frames are still in the device. Participates in
74 * computing the time for audio clocks and drives the synchronisation.
75 * @reset: Returns as quickly as possible from a write and flush any pending
76 * samples from the device.
77 * This vmethod is deprecated. Please provide pause and stop instead.
78 * @pause: Pause the device and unblock write as fast as possible.
79 * For retro compatibility, the audio sink will fallback
80 * to calling reset if this vmethod is not provided. Since: 1.18
81 * @resume: Resume the device. Since: 1.18
82 * @stop: Stop the device and unblock write as fast as possible.
83 * Pending samples are flushed from the device.
84 * For retro compatibility, the audio sink will fallback
85 * to calling reset if this vmethod is not provided. Since: 1.18
86 * @extension: class extension structure. Since: 1.18
87 */
88struct _GstAudioSinkClass {
89 GstAudioBaseSinkClass parent_class;
90
91 /* vtable */
92
93 /* open the device with given specs */
94 gboolean (*open) (GstAudioSink *sink);
95 /* prepare resources and state to operate with the given specs */
96 gboolean (*prepare) (GstAudioSink *sink, GstAudioRingBufferSpec *spec);
97 /* undo anything that was done in prepare() */
98 gboolean (*unprepare) (GstAudioSink *sink);
99 /* close the device */
100 gboolean (*close) (GstAudioSink *sink);
101 /**
102 * GstAudioSinkClass::write:
103 * @data: (type guint8) (array length=length): the sample data
104 *
105 * Write samples to the device.
106 */
107 gint (*write) (GstAudioSink *sink, gpointer data, guint length);
108 /* get number of frames queued in the device */
109 guint (*delay) (GstAudioSink *sink);
110 /* deprecated: reset the audio device, unblock from a write */
111 void (*reset) (GstAudioSink *sink);
112 /* pause the audio device, unblock from a write */
113 void (*pause) (GstAudioSink *sink);
114 /* resume the audio device */
115 void (*resume) (GstAudioSink *sink);
116 /* stop the audio device, unblock from a write */
117 void (*stop) (GstAudioSink *sink);
118
119 GstAudioSinkClassExtension *extension;
120};
121
122/**
123 * GstAudioSinkClassExtension:
124 * @clear-all: Clear the device. Since: 1.18
125 */
126struct _GstAudioSinkClassExtension
127{
128 /* clear the audio device */
129 void (*clear_all) (GstAudioSink *sink);
130
131 /* no padding needed */
132};
133
134GST_AUDIO_API
135GType gst_audio_sink_get_type(void);
136
137G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioSink, gst_object_unref)
138
139G_END_DECLS
140
141#endif /* __GST_AUDIO_SINK_H__ */
142

source code of include/gstreamer-1.0/gst/audio/gstaudiosink.h