Async  1.5.0
AsyncAudioSplitter.h
Go to the documentation of this file.
1 
28 #ifndef ASYNC_AUDIO_SPLITTER_INCLUDED
29 #define ASYNC_AUDIO_SPLITTER_INCLUDED
30 
31 
32 /****************************************************************************
33  *
34  * System Includes
35  *
36  ****************************************************************************/
37 
38 #include <list>
39 #include <sigc++/sigc++.h>
40 
41 
42 /****************************************************************************
43  *
44  * Project Includes
45  *
46  ****************************************************************************/
47 
48 #include <AsyncTimer.h>
49 
50 
51 /****************************************************************************
52  *
53  * Local Includes
54  *
55  ****************************************************************************/
56 
57 #include <AsyncAudioSink.h>
58 #include <AsyncAudioSource.h>
59 
60 
61 /****************************************************************************
62  *
63  * Forward declarations
64  *
65  ****************************************************************************/
66 
67 
68 
69 /****************************************************************************
70  *
71  * Namespace
72  *
73  ****************************************************************************/
74 
75 namespace Async
76 {
77 
78 
79 /****************************************************************************
80  *
81  * Forward declarations of classes inside of the declared namespace
82  *
83  ****************************************************************************/
84 
85 
86 
87 /****************************************************************************
88  *
89  * Defines & typedefs
90  *
91  ****************************************************************************/
92 
93 
94 
95 /****************************************************************************
96  *
97  * Exported Global Variables
98  *
99  ****************************************************************************/
100 
101 
102 
103 /****************************************************************************
104  *
105  * Class definitions
106  *
107  ****************************************************************************/
108 
117 class AudioSplitter : public Async::AudioSink, public Async::AudioSource,
118  public sigc::trackable
119 {
120  public:
124  AudioSplitter(void);
125 
129  ~AudioSplitter(void);
130 
137  void addSink(AudioSink *sink, bool managed=false);
138 
143  void removeSink(AudioSink *sink);
144 
148  void removeAllSinks(void);
149 
156  void enableSink(AudioSink *sink, bool enable);
157 
169  int writeSamples(const float *samples, int len);
170 
179  void flushSamples(void);
180 
181 
182  protected:
183 
184  private:
185  class Branch;
186 
187  std::list<Branch *> branches;
188  float *buf;
189  int buf_size;
190  int buf_len;
191  bool do_flush;
192  bool input_stopped;
193  int flushed_branches;
194  Branch *main_branch;
195 
196  void writeFromBuffer(void);
197  void flushAllBranches(void);
198 
199  friend class Branch;
200  void branchResumeOutput(void);
201  void branchAllSamplesFlushed(void);
202  void cleanupBranches(void);
203 
204 }; /* class AudioSplitter */
205 
206 
207 } /* namespace */
208 
209 #endif /* ASYNC_AUDIO_SPLITTER_INCLUDED */
210 
211 
212 
213 /*
214  * This file has not been truncated
215  */
Async::AudioSource::sink
AudioSink * sink(void) const
Get the registered audio sink.
Definition: AsyncAudioSource.h:188
AsyncTimer.h
Contains a single shot or periodic timer that emits a signal on timeout.
Async::AudioSplitter::flushSamples
void flushSamples(void)
Tell the sink to flush the previously written samples.
Async::AudioSplitter::writeSamples
int writeSamples(const float *samples, int len)
Write samples into this audio sink.
Async::AudioSplitter::removeSink
void removeSink(AudioSink *sink)
Remove an audio sink from the splitter.
Async::AudioSplitter::AudioSplitter
AudioSplitter(void)
Default constuctor.
Async::AudioSplitter::~AudioSplitter
~AudioSplitter(void)
Destructor.
Async::AudioSplitter::Branch
friend class Branch
Definition: AsyncAudioSplitter.h:255
Async::AudioSource
The base class for an audio source.
Definition: AsyncAudioSource.h:134
Async::AudioSplitter::addSink
void addSink(AudioSink *sink, bool managed=false)
Add an audio sink to the splitter.
Async::AudioSink
The base class for an audio sink.
Definition: AsyncAudioSink.h:135
Async::AudioSplitter::enableSink
void enableSink(AudioSink *sink, bool enable)
Enable or disable audio output to the given audio sink.
Async::AudioSplitter::removeAllSinks
void removeAllSinks(void)
Remove all audio sinks from this splitter.
Async
Namespace for the asynchronous programming classes.
Definition: AsyncApplication.h:75
AsyncAudioSink.h
This file contains the base class for an audio sink.
AsyncAudioSource.h
This file contains the base class for an audio source.