1 // Generated by gmmproc 2.50.1 -- DO NOT MODIFY!
2 #ifndef _GSTREAMERMM_AUDIORINGBUFFER_H
3 #define _GSTREAMERMM_AUDIORINGBUFFER_H
4 
5 
6 #include <glibmm/ustring.h>
7 #include <sigc++/sigc++.h>
8 
9 /* gstreamermm - a C++ wrapper for gstreamer
10  *
11  * Copyright 2008-2016 The gstreamermm Development Team
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free
25  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26  */
27 
28 #include <gst/audio/audio.h>
29 #include <gst/audio/gstaudioringbuffer.h>
30 #include <gstreamermm/caps.h>
31 #include <gstreamermm/object.h>
32 #include <gstreamermm/format.h>
33 #include <gstreamermm/clock.h>
34 #include <glibmm/arrayhandle.h>
35 #include <memory>
36 
37 
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 using GstAudioRingBuffer = struct _GstAudioRingBuffer;
40 using GstAudioRingBufferClass = struct _GstAudioRingBufferClass;
41 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
42 
43 
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 namespace Gst
46 { class AudioRingBuffer_Class; } // namespace Gst
47 #endif //DOXYGEN_SHOULD_SKIP_THIS
48 
49 namespace Gst
50 {
51 
52 /** @addtogroup gstreamermmEnums gstreamermm Enums and Flags */
53 
54 /**
55  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_MONO
56  * Mono without direction;
57  * can only be used with 1 channel.
58  *
59  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_FRONT_LEFT
60  * Front left.
61  *
62  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_FRONT_RIGHT
63  * Front right.
64  *
65  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_FRONT_CENTER
66  * Front center.
67  *
68  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_LFE1
69  * Low-frequency effects 1 (subwoofer).
70  *
71  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_REAR_LEFT
72  * Rear left.
73  *
74  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_REAR_RIGHT
75  * Rear right.
76  *
77  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER
78  * Front left of center.
79  *
80  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER
81  * Front right of center.
82  *
83  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_REAR_CENTER
84  * Rear center.
85  *
86  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_LFE2
87  * Low-frequency effects 2 (subwoofer).
88  *
89  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_SIDE_LEFT
90  * Side left.
91  *
92  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_SIDE_RIGHT
93  * Side right.
94  *
95  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT
96  * Top front left.
97  *
98  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT
99  * Top front right.
100  *
101  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER
102  * Top front center.
103  *
104  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_CENTER
105  * Top center.
106  *
107  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT
108  * Top rear left.
109  *
110  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT
111  * Top rear right.
112  *
113  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT
114  * Top side right.
115  *
116  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT
117  * Top rear right.
118  *
119  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER
120  * Top rear center.
121  *
122  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER
123  * Bottom front center.
124  *
125  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT
126  * Bottom front left.
127  *
128  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT
129  * Bottom front right.
130  *
131  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_WIDE_LEFT
132  * Wide left (between front left and side left).
133  *
134  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_WIDE_RIGHT
135  * Wide right (between front right and side right).
136  *
137  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_SURROUND_LEFT
138  * Surround left (between rear left and side left).
139  *
140  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_SURROUND_RIGHT
141  * Surround right (between rear right and side right).
142  *
143  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_NONE
144  * Used for position-less channels, e.g.
145  * from a sound card that records 1024 channels; mutually exclusive with
146  * any other channel position.
147  *
148  *  @var AudioChannelPosition AUDIO_CHANNEL_POSITION_INVALID
149  * Invalid position.
150  *
151  *  @enum AudioChannelPosition
152  *
153  * Audio channel positions.
154  *
155  * These are the channels defined in SMPTE 2036-2-2008
156  * Table 1 for 22.2 audio systems with the Surround and Wide channels from
157  * DTS Coherent Acoustics (v.1.3.1) and 10.2 and 7.1 layouts. In the caps the
158  * actual channel layout is expressed with a channel count and a channel mask,
159  * which describes the existing channels. The positions in the bit mask correspond
160  * to the enum values.
161  * For negotiation it is allowed to have more bits set in the channel mask than
162  * the number of channels to specify the allowed channel positions but this is
163  * not allowed in negotiated caps. It is not allowed in any situation other
164  * than the one mentioned below to have less bits set in the channel mask than
165  * the number of channels.
166  *
167  *  @a GST_AUDIO_CHANNEL_POSITION_MONO can only be used with a single mono channel that
168  * has no direction information and would be mixed into all directional channels.
169  * This is expressed in caps by having a single channel and no channel mask.
170  *
171  *  @a GST_AUDIO_CHANNEL_POSITION_NONE can only be used if all channels have this position.
172  * This is expressed in caps by having a channel mask with no bits set.
173  *
174  * As another special case it is allowed to have two channels without a channel mask.
175  * This implicitely means that this is a stereo stream with a front left and front right
176  * channel.
177  *
178  * @ingroup gstreamermmEnums
179  */
180 enum AudioChannelPosition
181 {
182   AUDIO_CHANNEL_POSITION_NONE = -3,
183   AUDIO_CHANNEL_POSITION_MONO,
184   AUDIO_CHANNEL_POSITION_INVALID,
185   AUDIO_CHANNEL_POSITION_FRONT_LEFT,
186   AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
187   AUDIO_CHANNEL_POSITION_FRONT_CENTER,
188   AUDIO_CHANNEL_POSITION_LFE1,
189   AUDIO_CHANNEL_POSITION_REAR_LEFT,
190   AUDIO_CHANNEL_POSITION_REAR_RIGHT,
191   AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
192   AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
193   AUDIO_CHANNEL_POSITION_REAR_CENTER,
194   AUDIO_CHANNEL_POSITION_LFE2,
195   AUDIO_CHANNEL_POSITION_SIDE_LEFT,
196   AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
197   AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT,
198   AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT,
199   AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER,
200   AUDIO_CHANNEL_POSITION_TOP_CENTER,
201   AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT,
202   AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT,
203   AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT,
204   AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT,
205   AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER,
206   AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER,
207   AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT,
208   AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT,
209   AUDIO_CHANNEL_POSITION_WIDE_LEFT,
210   AUDIO_CHANNEL_POSITION_WIDE_RIGHT,
211   AUDIO_CHANNEL_POSITION_SURROUND_LEFT,
212   AUDIO_CHANNEL_POSITION_SURROUND_RIGHT
213 };
214 
215 } // namespace Gst
216 
217 #ifndef DOXYGEN_SHOULD_SKIP_THIS
218 namespace Glib
219 {
220 
221 template <>
222 class Value<Gst::AudioChannelPosition> : public Glib::Value_Enum<Gst::AudioChannelPosition>
223 {
224 public:
225   static GType value_type() G_GNUC_CONST;
226 };
227 
228 } // namespace Glib
229 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
230 
231 namespace Gst
232 {
233 
234 /**
235  *  @var AudioRingBufferState AUDIO_RING_BUFFER_STATE_STOPPED
236  * The ringbuffer is stopped.
237  *
238  *  @var AudioRingBufferState AUDIO_RING_BUFFER_STATE_PAUSED
239  * The ringbuffer is paused.
240  *
241  *  @var AudioRingBufferState AUDIO_RING_BUFFER_STATE_STARTED
242  * The ringbuffer is started.
243  *
244  *  @var AudioRingBufferState AUDIO_RING_BUFFER_STATE_ERROR
245  * The ringbuffer has encountered an
246  * error after it has been started, e.g. because the device was
247  * disconnected (Since 1.2).
248  *
249  *  @enum AudioRingBufferState
250  *
251  * The state of the ringbuffer.
252  *
253  * @ingroup gstreamermmEnums
254  */
255 enum AudioRingBufferState
256 {
257   AUDIO_RING_BUFFER_STATE_STOPPED,
258   AUDIO_RING_BUFFER_STATE_PAUSED,
259   AUDIO_RING_BUFFER_STATE_STARTED,
260   AUDIO_RING_BUFFER_STATE_ERROR
261 };
262 
263 } // namespace Gst
264 
265 #ifndef DOXYGEN_SHOULD_SKIP_THIS
266 namespace Glib
267 {
268 
269 template <>
270 class Value<Gst::AudioRingBufferState> : public Glib::Value_Enum<Gst::AudioRingBufferState>
271 {
272 public:
273   static GType value_type() G_GNUC_CONST;
274 };
275 
276 } // namespace Glib
277 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
278 
279 namespace Gst
280 {
281 
282 /**
283  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_RAW
284  * Samples in linear or float.
285  *
286  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW
287  * Samples in mulaw.
288  *
289  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW
290  * Samples in alaw.
291  *
292  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_IMA_ADPCM
293  * Samples in ima adpcm.
294  *
295  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG
296  * Samples in mpeg audio (but not AAC) format.
297  *
298  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_GSM
299  * Samples in gsm format.
300  *
301  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_IEC958
302  * Samples in IEC958 frames (e.g. AC3).
303  *
304  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_AC3
305  * Samples in AC3 format.
306  *
307  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3
308  * Samples in EAC3 format.
309  *
310  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_DTS
311  * Samples in DTS format.
312  *
313  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC
314  * Samples in MPEG-2 AAC format.
315  *
316  *  @var AudioRingBufferFormatType AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC
317  * Samples in MPEG-4 AAC format.
318  *
319  *  @enum AudioRingBufferFormatType
320  *
321  * The format of the samples in the ringbuffer.
322  *
323  * @ingroup gstreamermmEnums
324  */
325 enum AudioRingBufferFormatType
326 {
327   AUDIO_RING_BUFFER_FORMAT_TYPE_RAW,
328   AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW,
329   AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW,
330   AUDIO_RING_BUFFER_FORMAT_TYPE_IMA_ADPCM,
331   AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG,
332   AUDIO_RING_BUFFER_FORMAT_TYPE_GSM,
333   AUDIO_RING_BUFFER_FORMAT_TYPE_IEC958,
334   AUDIO_RING_BUFFER_FORMAT_TYPE_AC3,
335   AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3,
336   AUDIO_RING_BUFFER_FORMAT_TYPE_DTS,
337   AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC,
338   AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC
339 };
340 
341 } // namespace Gst
342 
343 #ifndef DOXYGEN_SHOULD_SKIP_THIS
344 namespace Glib
345 {
346 
347 template <>
348 class Value<Gst::AudioRingBufferFormatType> : public Glib::Value_Enum<Gst::AudioRingBufferFormatType>
349 {
350 public:
351   static GType value_type() G_GNUC_CONST;
352 };
353 
354 } // namespace Glib
355 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
356 
357 namespace Gst
358 {
359 
360 
361 /** A class containing the format specification of a Gst::AudioRingBuffer.
362  * Gst::AudioRingBufferSpec contains the format specification of a
363  * Gst::AudioRingBuffer.  The "in" members should be specified by the caller of
364  * the acquire() method while the "in/out" members may be
365  * set by the caller but are also modifiable by
366  * acquire().  The "out" members are generated as a
367  * result of the call to acquire().
368  * @see acquire().
369  */
370 class AudioRingBufferSpec
371 {
372   public:
373 #ifndef DOXYGEN_SHOULD_SKIP_THIS
374   using CppObjectType = AudioRingBufferSpec;
375   using BaseObjectType = GstAudioRingBufferSpec;
376 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
377 
378 private:
379 
380 public:
381   /** Default constructor.
382    * @throw std::runtime_error if memory is unavailable for the new
383    * Gst::AudioRingBufferSpec.
384    */
385   AudioRingBufferSpec();
386 
387   /** Fully construct a Gst::AudioRingBufferSpec.  Only the "(in)" parameters
388    * are required.  The "(in/out)" parameters are optional and may be modified
389    * by the call to the Gst::AudioRingBuffer::acquire() method.
390    * @param caps The caps of the buffer (in).
391    * @param type The sample type (in/out).
392    * @param latency_time The latency in microseconds (in/out).
393    * @param buffer_time The total buffer size in microseconds (in/out).
394    * @param segsize The size of one segment in bytes (in/out).
395    * @param segtotal The total number of segments (in/out).
396    * @param seglatency Number of segments queued in the lower level device,
397    * defaults to @a segtotal in the C API (in/out).
398    *
399    * @throw std::runtime_error if memory is unavailable for the new
400    * Gst::AudioRingBufferSpec.
401    */
402   AudioRingBufferSpec(const Glib::RefPtr<Gst::Caps>& caps,
403     Gst::AudioRingBufferFormatType type = Gst::AUDIO_RING_BUFFER_FORMAT_TYPE_RAW,
404     guint64 latency_time = 0,
405     guint64 buffer_time = 0,
406     int segsize = 0, int segtotal = 0, int seglatency = 0);
407 
408   /// Construct a Gst::AudioRingBufferSpec from a GstAudioRingBufferSpec.
409   explicit AudioRingBufferSpec(GstAudioRingBufferSpec& castitem,
410     bool take_ownership = false);
411 
412   /** Copy constructor.
413    *
414    * @throw std::runtime_error if memory is unavailable for the new
415    * Gst::AudioRingBufferSpec.
416    */
417   AudioRingBufferSpec(const AudioRingBufferSpec& other);
418 
419   /// Assignment operator.
420   AudioRingBufferSpec& operator=(const AudioRingBufferSpec& other);
421 
422   /// Destructor.
423   virtual ~AudioRingBufferSpec();
424 
425   void swap(AudioRingBufferSpec& other);
426 
427   /// Gets the underlying gobject.
gobj()428   GstAudioRingBufferSpec* gobj() { return m_spec; };
429 
430   /// Gets the underlying gobject.
gobj()431   const GstAudioRingBufferSpec* gobj() const { return m_spec; };
432 
433   /** Get the caps of the buffer (in). */
434   Glib::RefPtr<Gst::Caps> get_caps();
435   Glib::RefPtr<const Gst::Caps> get_caps() const;
436 
437   /** Set the caps of the buffer (in). */
438   void set_caps(const Glib::RefPtr<Gst::Caps>& value);
439 
440   /** Get the sample type (in/out).
441    */
442   Gst::AudioRingBufferFormatType get_type() const;
443 
444   /** Set the sample type (in/out).
445    */
446   void set_type(const Gst::AudioRingBufferFormatType& value);
447 
448   /** Get the latency in microseconds (in/out).
449    */
450   guint64 get_latency_time() const;
451 
452   /** Set the latency in microseconds (in/out).
453    */
454   void set_latency_time(const guint64& value);
455 
456   /** Get the total buffer size in microseconds (in/out).
457    */
458   guint64 get_buffer_time() const;
459 
460   /** Set the total buffer size in microseconds (in/out).
461    */
462   void set_buffer_time(const guint64& value);
463 
464   /** Get the size of one segment in bytes (in/out).
465    */
466   int get_segsize() const;
467 
468   /** Set the size of one segment in bytes (in/out).
469    */
470   void set_segsize(const int& value);
471 
472   /** Get the total number of segments (in/out).
473    */
474   int get_segtotal() const;
475 
476   /** Set the total number of segments (in/out).
477    */
478   void set_segtotal(const int& value);
479 
480   /** Get the number of segments queued in the lower level device, defaults to
481    * segtotal (in/out).
482    */
483   int get_seglatency() const;
484 
485   /** Set the number of segments queued in the lower level device, defaults to
486    * segtotal (in/out).
487    */
488   void set_seglatency(const int& value);
489 
490 
491 protected:
492 #ifndef DOXYGEN_SHOULD_SKIP_THIS
493   GstAudioRingBufferSpec* m_spec;
494   // Tells whether the m_spec member should be freed upon destruction.
495   bool take_ownership;
496 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
497 
498 
499 };
500 
501 /** A base class for audio audioringbuffer implementations.
502  * This object is the base class for audio ringbuffers used by the base audio
503  * source and sink classes.
504  *
505  * The audioringbuffer abstracts a circular buffer of data. One reader and one
506  * writer can operate on the data from different threads in a lockfree manner.
507  * The base class is sufficiently flexible to be used as an abstraction for
508  * DMA based audioringbuffer as well as a pure software implementations.
509  *
510  * Last reviewed on 2016-04-23 (1.8.0).
511  * @ingroup GstBaseClasses
512  */
513 
514 class AudioRingBuffer : public Gst::Object
515 {
516 
517 #ifndef DOXYGEN_SHOULD_SKIP_THIS
518 
519 public:
520   using CppObjectType = AudioRingBuffer;
521   using CppClassType = AudioRingBuffer_Class;
522   using BaseObjectType = GstAudioRingBuffer;
523   using BaseClassType = GstAudioRingBufferClass;
524 
525   // noncopyable
526   AudioRingBuffer(const AudioRingBuffer&) = delete;
527   AudioRingBuffer& operator=(const AudioRingBuffer&) = delete;
528 
529 private:  friend class AudioRingBuffer_Class;
530   static CppClassType audioringbuffer_class_;
531 
532 protected:
533   explicit AudioRingBuffer(const Glib::ConstructParams& construct_params);
534   explicit AudioRingBuffer(GstAudioRingBuffer* castitem);
535 
536 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
537 
538 public:
539 
540   AudioRingBuffer(AudioRingBuffer&& src) noexcept;
541   AudioRingBuffer& operator=(AudioRingBuffer&& src) noexcept;
542 
543   ~AudioRingBuffer() noexcept override;
544 
545   /** Get the GType for this class, for use with the underlying GObject type system.
546    */
547   static GType get_type()      G_GNUC_CONST;
548 
549 #ifndef DOXYGEN_SHOULD_SKIP_THIS
550 
551 
552   static GType get_base_type() G_GNUC_CONST;
553 #endif
554 
555   ///Provides access to the underlying C GObject.
gobj()556   GstAudioRingBuffer*       gobj()       { return reinterpret_cast<GstAudioRingBuffer*>(gobject_); }
557 
558   ///Provides access to the underlying C GObject.
gobj()559   const GstAudioRingBuffer* gobj() const { return reinterpret_cast<GstAudioRingBuffer*>(gobject_); }
560 
561   ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
562   GstAudioRingBuffer* gobj_copy();
563 
564 private:
565 
566 
567 public:
568   /** For example,
569    * bool on_fill(const Glib::RefPtr<Gst::AudioRingBuffer>& rbuf,
570    * const std::vector<guint8>& data, guint len);.
571    * This slot is set with set_fill_slot() and is called to fill the memory at
572    * data with len bytes of samples.
573    */
574   typedef sigc::slot<void, const Glib::ArrayHandle<guint8>&, guint> SlotFill;
575 
576   //TODO: _MEMBER_GET(cond, cond, Glib::Cond, GCond*)
577 
578   /** Sets the given fill slot on the buffer. The slot will be called every
579    * time a segment has been written to a device.
580    *
581    * MT safe.
582    *
583    * @param slot The fill slot to set.
584    */
585   void set_fill_slot(const SlotFill& slot);
586 
587 
588   /** Allocate the resources for the ringbuffer. This function fills
589    * in the data pointer of the ring buffer with a valid Gst::Buffer
590    * to which samples can be written.
591    *
592    * @param spec The specs of the buffer.
593    * @return <tt>true</tt> if the device could be acquired, <tt>false</tt> on error.
594    *
595    * MT safe.
596    */
597   bool acquire(Gst::AudioRingBufferSpec& spec);
598 
599   /** Free the resources of the ringbuffer.
600    *
601    * @return <tt>true</tt> if the device could be released, <tt>false</tt> on error.
602    *
603    * MT safe.
604    */
605   bool release();
606 
607   /** Check if the ringbuffer is acquired and ready to use.
608    *
609    * @return <tt>true</tt> if the ringbuffer is acquired, <tt>false</tt> on error.
610    *
611    * MT safe.
612    */
613   bool is_acquired() const;
614 
615   /** Activate @a buf to start or stop pulling data.
616    *
617    * MT safe.
618    *
619    * @param active The new mode.
620    * @return <tt>true</tt> if the device could be activated in the requested mode,
621    * <tt>false</tt> on error.
622    */
623   bool activate(bool active);
624 
625   /** Check if @a buf is activated.
626    *
627    * MT safe.
628    *
629    * @return <tt>true</tt> if the device is active.
630    */
631   bool is_active() const;
632 
633   /** Start processing samples from the ringbuffer.
634    *
635    * @return <tt>true</tt> if the device could be started, <tt>false</tt> on error.
636    *
637    * MT safe.
638    */
639   bool start();
640 
641   /** Pause processing samples from the ringbuffer.
642    *
643    * @return <tt>true</tt> if the device could be paused, <tt>false</tt> on error.
644    *
645    * MT safe.
646    */
647   bool pause();
648 
649   /** Stop processing samples from the ringbuffer.
650    *
651    * @return <tt>true</tt> if the device could be stopped, <tt>false</tt> on error.
652    *
653    * MT safe.
654    */
655   bool stop();
656 
657   /** Get the number of samples queued in the audio device. This is
658    * usually less than the segment size but can be bigger when the
659    * implementation uses another internal buffer between the audio
660    * device.
661    *
662    * For playback ringbuffers this is the amount of samples transfered from the
663    * ringbuffer to the device but still not played.
664    *
665    * For capture ringbuffers this is the amount of samples in the device that are
666    * not yet transfered to the ringbuffer.
667    *
668    * @return The number of samples queued in the audio device.
669    *
670    * MT safe.
671    */
672   guint get_delay() const;
673 
674   /** Get the number of samples that were processed by the ringbuffer
675    * since it was last started. This does not include the number of samples not
676    * yet processed (see delay()).
677    *
678    * @return The number of samples processed by the ringbuffer.
679    *
680    * MT safe.
681    */
682   guint64 get_samples_done() const;
683 
684   /** Make sure that the next sample written to the device is
685    * accounted for as being the @a sample sample written to the
686    * device. This value will be used in reporting the current
687    * sample position of the ringbuffer.
688    *
689    * This function will also clear the buffer with silence.
690    *
691    * MT safe.
692    *
693    * @param sample The sample number to set.
694    */
695   void set_sample(guint64 sample);
696 
697   /** Tell the ringbuffer about the device's channel positions. This must
698    * be called in when the ringbuffer is acquired.
699    *
700    * @param position The device channel positions.
701    */
702   void set_channel_position(const Gst::AudioChannelPosition& position);
703 
704   /** Check if @a buf is flushing.
705    *
706    * MT safe.
707    *
708    * @return <tt>true</tt> if the device is flushing.
709    */
710   gboolean is_flushing();
711 
712   void set_timestamp(gint readseg, ClockTime timestamp);
713 
714 
715   /** Commit @a in_samples samples pointed to by @a data to the ringbuffer @a buf.
716    *
717    *  @a in_samples and @a out_samples define the rate conversion to perform on the
718    * samples in @a data. For negative rates, @a out_samples must be negative and
719    *  @a in_samples positive.
720    *
721    * When @a out_samples is positive, the first sample will be written at position @a sample
722    * in the ringbuffer. When @a out_samples is negative, the last sample will be written to
723    *  @a sample in reverse order.
724    *
725    *  @a out_samples does not need to be a multiple of the segment size of the ringbuffer
726    * although it is recommended for optimal performance.
727    *
728    *  @a accum will hold a temporary accumulator used in rate conversion and should be
729    * set to 0 when this function is first called. In case the commit operation is
730    * interrupted, one can resume the processing by passing the previously returned
731    *  @a accum value back to this function.
732    *
733    * MT safe.
734    *
735    * @param sample The sample position of the data.
736    * @param data The data to commit.
737    * @param in_samples The number of samples in the data to commit.
738    * @param out_samples The number of samples to write to the ringbuffer.
739    * @param accum Accumulator for rate conversion.
740    * @return The number of samples written to the ringbuffer or -1 on error. The
741    * number of samples written can be less than @a out_samples when @a buf was interrupted
742    * with a flush or stop.
743    */
744   guint commit(guint64& sample, const std::vector<guint8>& data, int in_samples, int out_samples, int& accum);
745 
746 
747   /** Convert @a src_val in @a src_fmt to the equivalent value in @a dest_fmt. The result
748    * will be put in @a dest_val.
749    *
750    * @param src_fmt The source format.
751    * @param src_val The source value.
752    * @param dest_fmt The destination format.
753    * @param dest_val A location to store the converted value.
754    * @return <tt>true</tt> if the conversion succeeded.
755    */
756   bool convert(Gst::Format src_fmt, gint64 src_val, Gst::Format dest_fmt, gint64& dest_val) const;
757 
758 
759   /** Returns a pointer to memory where the data from segment @a segment
760    * can be found. This function is mostly used by subclasses.
761    *
762    * @param segment The segment to read.
763    * @param readptr The pointer to the memory where samples can be read.
764    * @param len The number of bytes to read.
765    * @return <tt>false</tt> if the buffer is not started.
766    *
767    * MT safe.
768    */
769 
770   bool prepare_read(int& segment, std::vector<guint8>& readptr, int& len);
771 
772 
773   /** Read @a len samples from the ringbuffer into the memory pointed
774    * to by @a data.
775    * The first sample should be read from position @a sample in
776    * the ringbuffer.
777    *
778    *  @a len should not be a multiple of the segment size of the ringbuffer
779    * although it is recommended.
780    *
781    *  @a timestamp will return the timestamp associated with the data returned.
782    *
783    * @param sample The sample position of the data.
784    * @param data Where the data should be read.
785    * @param len The number of samples in data to read.
786    * @param timestamp Where the timestamp is returned.
787    * @return The number of samples read from the ringbuffer or -1 on
788    * error.
789    *
790    * MT safe.
791    */
792   guint read(guint64 sample, const std::vector<guint8>& data, guint len, Gst::ClockTime& timestamp);
793 
794 
795   /** Clear the given segment of the buffer with silence samples.
796    * This function is used by subclasses.
797    *
798    * MT safe.
799    *
800    * @param segment The segment to clear.
801    */
802   void clear(int segment);
803 
804   /** Fill the ringbuffer with silence.
805    *
806    * MT safe.
807    */
808   void clear_all();
809 
810   /** Subclasses should call this function to notify the fact that
811    *  @a advance segments are now processed by the device.
812    *
813    * MT safe.
814    *
815    * @param advance The number of segments written.
816    */
817   void advance(guint advance);
818 
819   /** Close the audio device associated with the ring buffer. The ring buffer
820    * should already have been released via release().
821    *
822    * @return <tt>true</tt> if the device could be closed, <tt>false</tt> on error.
823    *
824    * MT safe.
825    */
826   bool close_device();
827 
828   /** Open the audio device associated with the ring buffer. Does not perform any
829    * setup on the device. You must open the device before acquiring the ring
830    * buffer.
831    *
832    * @return <tt>true</tt> if the device could be opened, <tt>false</tt> on error.
833    *
834    * MT safe.
835    */
836   bool open_device();
837 
838   /** Checks the status of the device associated with the ring buffer.
839    *
840    * @return <tt>true</tt> if the device was open, <tt>false</tt> if it was closed.
841    *
842    * MT safe.
843    */
844   bool device_is_open() const;
845 
846   /** Tell the ringbuffer that it is allowed to start playback when
847    * the ringbuffer is filled with samples.
848    *
849    * MT safe.
850    *
851    * @param allowed The new value.
852    */
853   void set_may_start(bool allowed);
854 
855   /** Parse @a caps into @a p1.
856    *
857    * @param p1 A spec.
858    * @param caps A Gst::Caps.
859    * @return <tt>true</tt> if the caps could be parsed.
860    */
861   static bool parse_caps(Gst::AudioRingBufferSpec& p1, const Glib::RefPtr<Gst::Caps>& caps);
862 
863   /** Set the ringbuffer to flushing mode or normal mode.
864    *
865    * MT safe.
866    *
867    * @param flushing The new mode.
868    */
869   void set_flushing(bool flushing);
870 
871   /** Virtual function to open the device.  Don't set any params or allocate
872    * anything.
873    */
874     virtual bool open_device_vfunc();
875 
876 
877   /** Virtual function to allocate the resources for the ring buffer using the
878    * given spec.
879    */
880   virtual bool acquire_vfunc(Gst::AudioRingBufferSpec& spec);
881 
882   /** Virtual function to free resources of the ring buffer.
883    */
884     virtual bool release_vfunc();
885 
886 
887   /** Virtual function to close the device.
888    */
889     virtual bool close_device_vfunc();
890 
891 
892   /** Virtual function to start processing of samples.
893    */
894     virtual bool start_vfunc();
895 
896 
897   /** Virtual function to pause processing of samples.
898    */
899     virtual bool pause_vfunc();
900 
901 
902   /** Virtual function to resume processing of samples after pause.
903    */
904     virtual bool resume_vfunc();
905 
906 
907   /** Virtual function to stop processing of samples.
908    */
909     virtual bool stop_vfunc();
910 
911 
912   /** Virtual function to get number of samples queued in device.
913    */
914     virtual guint delay_vfunc();
915 
916 
917   /** Virtual function to activate the thread that starts pulling and
918    * monitoring the consumed segments in the device. Since 0.10.22.
919    */
920     virtual bool activate_vfunc(bool active);
921 
922 
923   /** Virtual function to write samples into the ring buffer.
924    */
925   virtual guint commit_vfunc(guint64& sample, const std::vector<guint8>& data,
926     int in_samples, int out_samples, int& accum);
927 
928   /** Virtual function to clear the entire audioringbuffer Since 0.10.24.
929    */
930     virtual void clear_all_vfunc();
931 
932 
933 protected:
934 
935 
936 #ifndef DOXYGEN_SHOULD_SKIP_THIS
937 private:
938   // todo this slot should be moved in move constructor, but for now it's
939   // impossible to provide custom move constructor
940   // (see https://bugzilla.gnome.org/show_bug.cgi?id=756593).
941   // However, task should be managed by RefPtr class, so move constructor
942   // and move assignment operator will never be called.
943   std::unique_ptr<SlotFill> m_slot;
944 #endif
945 
946 
947 public:
948 
949 public:
950   //C++ methods used to invoke GTK+ virtual functions:
951 
952 protected:
953   //GTK+ Virtual Functions (override these to change behaviour):
954 
955   //Default Signal Handlers::
956 
957 
958 };
959 
960 } // namespace Gst
961 
962 
963 namespace Glib
964 {
965   /** A Glib::wrap() method for this object.
966    *
967    * @param object The C instance.
968    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
969    * @result A C++ instance that wraps this C instance.
970    *
971    * @relates Gst::AudioRingBuffer
972    */
973   Glib::RefPtr<Gst::AudioRingBuffer> wrap(GstAudioRingBuffer* object, bool take_copy = false);
974 }
975 
976 
977 #endif /* _GSTREAMERMM_AUDIORINGBUFFER_H */
978 
979