Async 1.8.0
AsyncAudioSink.h
Go to the documentation of this file.
1
28#ifndef ASYNC_AUDIO_SINK_INCLUDED
29#define ASYNC_AUDIO_SINK_INCLUDED
30
31
32/****************************************************************************
33 *
34 * System Includes
35 *
36 ****************************************************************************/
37
38
39#include <cassert>
40
41
42/****************************************************************************
43 *
44 * Project Includes
45 *
46 ****************************************************************************/
47
48
49
50/****************************************************************************
51 *
52 * Local Includes
53 *
54 ****************************************************************************/
55
56
57
58/****************************************************************************
59 *
60 * Forward declarations
61 *
62 ****************************************************************************/
63
64
65
66/****************************************************************************
67 *
68 * Namespace
69 *
70 ****************************************************************************/
71
72namespace Async
73{
74
75
76/****************************************************************************
77 *
78 * Forward declarations of classes inside of the declared namespace
79 *
80 ****************************************************************************/
81
82class AudioSource;
83
84
85/****************************************************************************
86 *
87 * Defines & typedefs
88 *
89 ****************************************************************************/
90
91
92
93/****************************************************************************
94 *
95 * Exported Global Variables
96 *
97 ****************************************************************************/
98
99
100
101/****************************************************************************
102 *
103 * Class definitions
104 *
105 ****************************************************************************/
106
116{
117 public:
121 AudioSink(void) : m_source(0), m_handler(0), m_auto_unreg_sink(false) {}
122
126 virtual ~AudioSink(void);
127
134
139
144 bool isRegistered(void) const { return m_source != 0; }
145
151 AudioSource *source(void) const { return m_source; }
152
164 virtual int writeSamples(const float *samples, int count)
165 {
166 assert(m_handler != 0);
167 return m_handler->writeSamples(samples, count);
168 }
169
178 virtual void flushSamples(void)
179 {
180 assert(m_handler != 0);
181 m_handler->flushSamples();
182 }
183
184
185 protected:
190
200
211
215 void clearHandler(void);
216
217 /*
218 * @brief Return the handler
219 * @return Returns the handler previously set with setHandler or 0
220 * if none have been set
221 */
222 AudioSink *handler(void) const { return m_handler; }
223
224
225 private:
226 AudioSource *m_source;
227 AudioSink *m_handler;
228 bool m_auto_unreg_sink;
229
230 bool registerSourceInternal(AudioSource *source, bool reg_sink);
231
232}; /* class AudioSink */
233
234
235} /* namespace */
236
237#endif /* ASYNC_AUDIO_SINK_INCLUDED */
238
239
240
241/*
242 * This file has not been truncated
243 */
244
The base class for an audio sink.
void clearHandler(void)
Clear a handler that was previously setup with setHandler.
void sourceAllSamplesFlushed(void)
Tell the source that all samples have been flushed.
bool registerSource(AudioSource *source)
Register an audio source to provide samples to this sink.
void unregisterSource(void)
Unregister the previously registered audio source.
virtual int writeSamples(const float *samples, int count)
Write samples into this audio sink.
void sourceResumeOutput(void)
Tell the source that we are ready to accept more samples.
AudioSource * source(void) const
Get the registered audio source.
virtual void flushSamples(void)
Tell the sink to flush the previously written samples.
AudioSink(void)
Default constuctor.
bool isRegistered(void) const
Check if an audio source has been registered.
AudioSink * handler(void) const
bool setHandler(AudioSink *handler)
Setup another sink to handle the incoming audio.
virtual ~AudioSink(void)
Destructor.
The base class for an audio source.
Namespace for the asynchronous programming classes.