Async  1.3.1
AsyncAudioMixer.h
Go to the documentation of this file.
1 
28 #ifndef ASYNC_AUDIO_MIXER_INCLUDED
29 #define ASYNC_AUDIO_MIXER_INCLUDED
30 
31 
32 /****************************************************************************
33  *
34  * System Includes
35  *
36  ****************************************************************************/
37 
38 #include <list>
39 
40 
41 /****************************************************************************
42  *
43  * Project Includes
44  *
45  ****************************************************************************/
46 
47 #include <AsyncAudioSource.h>
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 
72 namespace Async
73 {
74 
75 
76 /****************************************************************************
77  *
78  * Forward declarations of classes inside of the declared namespace
79  *
80  ****************************************************************************/
81 
82 class Timer;
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 
114 class AudioMixer : public sigc::trackable, public Async::AudioSource
115 {
116  public:
120  AudioMixer(void);
121 
125  ~AudioMixer(void);
126 
131  void addSource(AudioSource *source);
132 
140  void resumeOutput(void);
141 
142 
143  protected:
151  void allSamplesFlushed(void);
152 
153 
154  private:
155  class MixerSrc;
156 
157  static const int OUTBUF_SIZE = 256;
158 
159  std::list<MixerSrc *> sources;
160  Timer *delayed_exec_timer;
161  float outbuf[OUTBUF_SIZE];
162  unsigned outbuf_pos;
163  unsigned outbuf_cnt;
164  bool is_flushed;
165  bool output_stopped;
166 
167  AudioMixer(const AudioMixer&);
168  AudioMixer& operator=(const AudioMixer&);
169 
170  void setAudioAvailable(void);
171  void flushSamples(void);
172  void outputHandler(Timer *t);
173  void checkFlush(void);
174 
175  friend class MixerSrc;
176 
177 }; /* class AudioMixer */
178 
179 
180 } /* namespace */
181 
182 #endif /* ASYNC_AUDIO_MIXER_INCLUDED */
183 
184 
185 
186 /*
187  * This file has not been truncated
188  */
189 
void resumeOutput(void)
Resume audio output to the sink.
A class for mixing audio streams.
This file contains the base class for an audio source.
AudioMixer(void)
Default constuctor.
A class that produces timer events.
Definition: AsyncTimer.h:116
friend class MixerSrc
Namespace for the asynchronous programming classes.
void addSource(AudioSource *source)
Add an audio source to the mixer.
~AudioMixer(void)
Destructor.
The base class for an audio source.
void allSamplesFlushed(void)
The registered sink has flushed all samples.