Debian Codegraph @

gstreamer/src/audiosink.hg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008-2016 The gstreamermm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <gstreamermm/audioringbuffer.h>
21 #include <gstreamermm/audiobasesink.h>
22
23 _DEFS(gstreamermm,gst)
24
25 namespace Gst
26 {
27
28 /** A simple base class for audio sinks.
29 * This is the most simple base class for audio sinks that only requires
30 * subclasses to implement a set of simple virtual functions:
31 *
32 * - open_vfunc() - Open the device.
33 * - prepare_vfunc() - Configure the device with the specified format.
34 * - write_vfunc() - Write samples to the device.
35 * - reset_vfunc() - Unblock writes and flush the device.
36 * - get_delay_vfunc() - Get the number of samples written but not yet played
37 * by the device.
38 * - unprepare_vfunc() - Undo operations done by prepare.
39 * - close_vfunc() - Close the device.
40 *
41 * All scheduling of samples and timestamps is done in this base class together
42 * with Gst::AudioBaseSink using a default implementation of a
43 * Gst::AudioRingBuffer that uses threads.
44 *
45 * Last reviewed on 2016-04-23 (1.8.0)
46 *
47 * @ingroup GstBaseClasses
48 */
49 class AudioSink : public Gst::AudioBaseSink
50 {
51 _CLASS_GOBJECT(AudioSink, GstAudioSink, GST_AUDIO_SINK, Gst::AudioBaseSink, GstAudioBaseSink)
52
53 public:
54 /** vfunc to open the device. No configuration needs to be done at this
55 * point. This function is also used to check if the device is available.
56 */
57 _WRAP_VFUNC(bool open(), "open")
58
59 /** vfunc to prepare the device to operate with the specified parameters.
60 */
61 virtual bool prepare_audiosink_vfunc(Gst::AudioRingBufferSpec& spec);
62
63 /** vfunc to undo operations done in prepare.
64 */
65 _WRAP_VFUNC(bool unprepare(), "unprepare")
66
67 /** vfunc to close the device.
68 */
69 _WRAP_VFUNC(bool close(), "close")
70
71 /** vfunc to write data to the device.
72 */
73 _WRAP_VFUNC(int write(gpointer data, guint lenght), "write")
74
75 /** vfunc to return how many samples are still in the device. This is used to
76 * drive the synchronisation.
77 */
78 _WRAP_VFUNC(guint get_delay() const, "delay")
79
80 /** vfunc to return as quickly as possible from a write and flush any pending
81 * samples from the device.
82 */
83 _WRAP_VFUNC(void reset(), "reset")
84
85 protected:
86 #m4begin
87 _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
88 klass->prepare = &prepare_audiosink_vfunc_callback;
89 _SECTION(SECTION_PH_VFUNCS)
90 static gboolean prepare_audiosink_vfunc_callback(GstAudioSink* self, GstAudioRingBufferSpec* spec);
91 _POP()
92 #m4end
93 };
94
95 } // namespace Gst