Async 1.8.0
AsyncAudioSelector.h
Go to the documentation of this file.
1
28#ifndef ASYNC_AUDIO_SELECTOR_INCLUDED
29#define ASYNC_AUDIO_SELECTOR_INCLUDED
30
31
32/****************************************************************************
33 *
34 * System Includes
35 *
36 ****************************************************************************/
37
38#include <map>
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
72namespace Async
73{
74
75
76/****************************************************************************
77 *
78 * Forward declarations of classes inside of the declared namespace
79 *
80 ****************************************************************************/
81
82
83
84/****************************************************************************
85 *
86 * Defines & typedefs
87 *
88 ****************************************************************************/
89
90
91
92/****************************************************************************
93 *
94 * Exported Global Variables
95 *
96 ****************************************************************************/
97
98
99
100/****************************************************************************
101 *
102 * Class definitions
103 *
104 ****************************************************************************/
105
115{
116 public:
121
126
131 void addSource(AudioSource *source);
132
138
144 void setSelectionPrio(AudioSource *source, int prio);
145
151 void enableAutoSelect(AudioSource *source, int prio);
152
158
165 bool autoSelectEnabled(const AudioSource *source) const;
166
172
178
192 void setFlushWait(AudioSource *source, bool flush_wait);
193
201 virtual void resumeOutput(void);
202
203 protected:
204 virtual void allSamplesFlushed(void);
205
206 private:
207 typedef enum
208 {
209 STATE_IDLE, STATE_WRITING, STATE_STOPPED, STATE_FLUSHING
210 } StreamState;
211
212 class Branch;
213 typedef std::map<Async::AudioSource *, Branch *> BranchMap;
214
215 BranchMap m_branch_map;
216 Branch * m_selected_branch;
217 StreamState m_stream_state;
218
220 AudioSelector& operator=(const AudioSelector&);
221 void selectBranch(Branch *branch);
222 Branch *selectedBranch(void) const { return m_selected_branch; }
223 void selectHighestPrioActiveBranch(bool clear_if_no_active);
224 int branchWriteSamples(const float *samples, int count);
225 void branchFlushSamples(void);
226
227 friend class Branch;
228
229}; /* class AudioSelector */
230
231
232} /* namespace */
233
234#endif /* ASYNC_AUDIO_SELECTOR_INCLUDED */
235
236
237
238/*
239 * This file has not been truncated
240 */
241
This file contains the base class for an audio source.
This class is used to select one of many audio streams.
~AudioSelector(void)
Destructor.
virtual void allSamplesFlushed(void)
The registered sink has flushed all samples.
void disableAutoSelect(AudioSource *source)
Disable autoselection on the given source.
bool autoSelectEnabled(const AudioSource *source) const
Find out if auto select is enabled or not for the given source.
void addSource(AudioSource *source)
Add an audio source to the selector.
void setSelectionPrio(AudioSource *source, int prio)
Set the prio to be used for selection.
AudioSource * selectedSource(void) const
Find out which source that is currently selected.
virtual void resumeOutput(void)
Resume audio output to the sink.
void enableAutoSelect(AudioSource *source, int prio)
Enable autoselection on the given source.
void selectSource(AudioSource *source)
Select one of the previously added audio sources.
void setFlushWait(AudioSource *source, bool flush_wait)
Set if this souce want to wait for allSamplesFlushed.
AudioSelector(void)
Default constuctor.
void removeSource(AudioSource *source)
Remove a previously added audio source from the selector.
The base class for an audio source.
Namespace for the asynchronous programming classes.