Async
0.18.0
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
include
AsyncAudioIO.h
Go to the documentation of this file.
1
36
#ifndef ASYNC_AUDIO_IO_INCLUDED
37
#define ASYNC_AUDIO_IO_INCLUDED
38
39
40
/****************************************************************************
41
*
42
* System Includes
43
*
44
****************************************************************************/
45
46
#include <cstdio>
47
#include <string>
48
49
50
/****************************************************************************
51
*
52
* Project Includes
53
*
54
****************************************************************************/
55
56
#include <
AsyncFdWatch.h
>
57
#include <
AsyncTimer.h
>
58
#include <
AsyncAudioSink.h
>
59
#include <
AsyncAudioSource.h
>
60
61
62
/****************************************************************************
63
*
64
* Local Includes
65
*
66
****************************************************************************/
67
68
69
70
/****************************************************************************
71
*
72
* Forward declarations
73
*
74
****************************************************************************/
75
76
77
78
/****************************************************************************
79
*
80
* Namespace
81
*
82
****************************************************************************/
83
84
namespace
Async
85
{
86
87
/****************************************************************************
88
*
89
* Forward declarations of classes inside of the declared namespace
90
*
91
****************************************************************************/
92
93
class
AudioDevice;
94
class
AudioValve;
95
class
AudioFifo;
96
97
98
/****************************************************************************
99
*
100
* Defines & typedefs
101
*
102
****************************************************************************/
103
104
105
106
/****************************************************************************
107
*
108
* Exported Global Variables
109
*
110
****************************************************************************/
111
112
113
114
/****************************************************************************
115
*
116
* Class definitions
117
*
118
****************************************************************************/
119
134
class
AudioIO
:
public
Async::AudioSource
,
public
Async::AudioSink
135
{
136
public
:
140
typedef
enum
141
{
142
MODE_NONE
,
143
MODE_RD
,
144
MODE_WR
,
145
MODE_RDWR
146
}
Mode
;
147
157
static
void
setSampleRate
(
int
rate);
158
172
static
void
setBlocksize
(
int
size);
173
178
int
blocksize
(
void
);
179
192
static
void
setBlockCount
(
int
count);
193
203
static
void
setChannels
(
int
channels);
204
210
AudioIO
(
const
std::string& dev_name,
int
channel
);
211
215
~AudioIO
(
void
);
216
222
bool
isFullDuplexCapable
(
void
);
223
230
bool
open
(
Mode
mode
);
231
235
void
close
(
void
);
236
247
//int samplesToWrite(void) const;
248
249
/*
250
* @brief Call this method to clear all samples in the buffer
251
*
252
* This method is used to clear all the samples that are in the buffer.
253
* That is, all samples in the buffer will be thrown away. Remaining
254
* samples that have already been written to the sound card will be
255
* flushed and when finished, the allSamplesFlushed signal is emitted.
256
*/
257
//void clearSamples(void);
258
259
/*
260
* @brief Check if the audio device is busy flushing samples
261
* @return Returns \em true if flushing the buffer or else \em false
262
*/
263
//bool isFlushing(void) const { return is_flushing; }
264
265
/*
266
* @brief Find out the current IO mode
267
* @return Returns the current IO mode
268
*/
269
Mode
mode
(
void
)
const
{
return
io_mode; }
270
280
void
setGain
(
float
gain
) { m_gain =
gain
; }
281
286
float
gain
(
void
)
const
{
return
m_gain; }
287
292
int
sampleRate
(
void
)
const
{
return
sample_rate; }
293
298
int
channel
(
void
)
const
{
return
m_channel; }
299
307
void
resumeOutput
(
void
) {}
308
316
void
allSamplesFlushed
(
void
) {}
317
318
#if 0
319
325
int
writeSamples
(
const
float
*samples,
int
count);
326
334
void
flushSamples
(
void
);
335
#endif
336
337
338
protected
:
339
340
private
:
341
class
InputFifo;
342
class
DelayedFlushAudioReader;
343
344
Mode
io_mode;
345
AudioDevice
*audio_dev;
346
float
m_gain;
347
int
sample_rate;
348
int
m_channel;
349
AudioValve
*input_valve;
350
InputFifo *input_fifo;
351
DelayedFlushAudioReader *audio_reader;
352
353
// Methods accessed by the Async::AudioDevice class
354
friend
class
AudioDevice
;
355
AudioDevice
*device(
void
)
const
{
return
audio_dev; }
356
int
readSamples(
float
*samples,
int
count);
357
bool
doFlush(
void
)
const
;
358
bool
isIdle(
void
)
const
;
359
int
audioRead(
float
*samples,
int
count);
360
unsigned
samplesAvailable(
void
);
361
362
};
/* class AudioIO */
363
364
365
}
/* namespace */
366
367
#endif
/* ASYNC_AUDIO_IO_INCLUDED */
368
369
370
/*
371
* This file has not been truncated
372
*/
373
Generated by
1.8.4