Async  0.18.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 
59 
60 /****************************************************************************
61  *
62  * Forward declarations
63  *
64  ****************************************************************************/
65 
66 
67 
68 /****************************************************************************
69  *
70  * Namespace
71  *
72  ****************************************************************************/
73 
74 namespace Async
75 {
76 
77 
78 /****************************************************************************
79  *
80  * Forward declarations of classes inside of the declared namespace
81  *
82  ****************************************************************************/
83 
84 
85 
86 /****************************************************************************
87  *
88  * Defines & typedefs
89  *
90  ****************************************************************************/
91 
92 
93 
94 /****************************************************************************
95  *
96  * Exported Global Variables
97  *
98  ****************************************************************************/
99 
100 
101 
102 /****************************************************************************
103  *
104  * Class definitions
105  *
106  ****************************************************************************/
107 
116 class AudioSplitter : public Async::AudioSink, public SigC::Object
117 {
118  public:
122  AudioSplitter(void);
123 
127  ~AudioSplitter(void);
128 
135  void addSink(AudioSink *sink, bool managed=false);
136 
141  void removeSink(AudioSink *sink);
142 
146  void removeAllSinks(void);
147 
154  void enableSink(AudioSink *sink, bool enable);
155 
167  int writeSamples(const float *samples, int len);
168 
177  void flushSamples(void);
178 
179 
180  protected:
181 
182  private:
183  class Branch;
184 
185  std::list<Branch *> branches;
186  float *buf;
187  int buf_size;
188  int buf_len;
189  bool do_flush;
190  bool input_stopped;
191  int flushed_branches;
192  Async::Timer *cleanup_branches_timer;
193 
194  void writeFromBuffer(void);
195  void flushAllBranches(void);
196 
197  friend class Branch;
198  void branchResumeOutput(void);
199  void branchAllSamplesFlushed(void);
200  void cleanupBranches(Async::Timer *t);
201 
202 }; /* class AudioSplitter */
203 
204 
205 } /* namespace */
206 
207 #endif /* ASYNC_AUDIO_SPLITTER_INCLUDED */
208 
209 
210 
211 /*
212  * This file has not been truncated
213  */
214 
void enableSink(AudioSink *sink, bool enable)
Enable or disable audio output to the given audio sink.
void removeAllSinks(void)
Remove all audio sinks from this splitter.
Contains a single shot or periodic timer that emits a signal on timeout.
A class that produces timer events.
Definition: AsyncTimer.h:116
This file contains the base class for an audio sink.
int writeSamples(const float *samples, int len)
Write samples into this audio sink.
void removeSink(AudioSink *sink)
Remove an audio sink from the splitter.
The base class for an audio sink.
void flushSamples(void)
Tell the sink to flush the previously written samples.
AudioSplitter(void)
Default constuctor.
~AudioSplitter(void)
Destructor.
A class that splits an audio stream into multiple streams.
void addSink(AudioSink *sink, bool managed=false)
Add an audio sink to the splitter.