Async
1.4.0
|
Base class for handling audio devices. More...
#include <AsyncAudioDevice.h>
Public Types | |
enum | Mode { MODE_NONE, MODE_RD, MODE_WR, MODE_RDWR } |
The different modes to open a device in. More... | |
Public Member Functions | |
virtual int | blocksize (void)=0 |
Find out what the blocksize is set to. More... | |
virtual bool | isFullDuplexCapable (void)=0 |
Check if the audio device has full duplex capability. More... | |
bool | open (Mode mode) |
Open the audio device. More... | |
void | close (void) |
Close the audio device. More... | |
Mode | mode (void) const |
Get the current operating mode of this audio device. More... | |
virtual void | audioToWriteAvailable (void)=0 |
Tell the audio device handler that there are audio to be written in the buffer. More... | |
virtual void | flushSamples (void)=0 |
virtual int | samplesToWrite (void) const =0 |
Find out how many samples there are in the output buffer. More... | |
int | sampleRate (void) const |
Return the sample rate. More... | |
const std::string & | devName (void) const |
Return the device name. More... | |
Static Public Member Functions | |
static AudioDevice * | registerAudioIO (const std::string &dev_designator, AudioIO *audio_io) |
Register an AudioIO object with the given device name. More... | |
static void | unregisterAudioIO (AudioIO *audio_io) |
Unregister a previously registered AudioIO object. More... | |
static void | setSampleRate (int rate) |
Set the sample rate used when doing future opens. More... | |
static void | setBlocksize (int size) |
Set the blocksize used when opening audio devices. More... | |
static void | setBlockCount (int count) |
Set the buffer count used when opening audio devices. More... | |
static void | setChannels (int channels) |
Set the number of channels used when doing future opens. More... | |
Protected Member Functions | |
AudioDevice (const std::string &dev_name) | |
Constuctor. More... | |
virtual | ~AudioDevice (void) |
Destructor. More... | |
virtual bool | openDevice (Mode mode)=0 |
Open the audio device. More... | |
virtual void | closeDevice (void)=0 |
Close the audio device. More... | |
void | putBlocks (int16_t *buf, int frame_cnt) |
int | getBlocks (int16_t *buf, int block_cnt) |
Protected Attributes | |
std::string | dev_name |
Static Protected Attributes | |
static int | sample_rate |
static int | block_size_hint |
static int | block_count_hint |
static int | channels |
Base class for handling audio devices.
This class implements a base class for supporting different audio devices. This class is not intended to be used by the end user of the Async library. It is used by the Async::AudioIO class, which is the Async API frontend for using audio in an application.
Definition at line 122 of file AsyncAudioDevice.h.
The different modes to open a device in.
Enumerator | |
---|---|
MODE_NONE |
No mode. The same as close. |
MODE_RD |
Read. |
MODE_WR |
Write. |
MODE_RDWR |
Both read and write. |
Definition at line 128 of file AsyncAudioDevice.h.
|
explicitprotected |
Constuctor.
dev_name | The name of the device to associate this object with |
|
protectedvirtual |
Destructor.
|
pure virtual |
Tell the audio device handler that there are audio to be written in the buffer.
Referenced by mode().
|
pure virtual |
Find out what the blocksize is set to.
Referenced by setBlocksize().
void Async::AudioDevice::close | ( | void | ) |
Close the audio device.
Referenced by setChannels().
|
protectedpure virtual |
Close the audio device.
|
inline |
Return the device name.
Definition at line 283 of file AsyncAudioDevice.h.
References dev_name.
|
pure virtual |
Referenced by mode().
|
protected |
|
pure virtual |
Check if the audio device has full duplex capability.
Referenced by setChannels().
|
inline |
Get the current operating mode of this audio device.
Definition at line 248 of file AsyncAudioDevice.h.
References audioToWriteAvailable(), flushSamples(), and samplesToWrite().
Referenced by setChannels().
bool Async::AudioDevice::open | ( | Mode | mode | ) |
Open the audio device.
mode | The mode to open the audio device in (See AudioIO::Mode) |
Referenced by setChannels().
|
protectedpure virtual |
Open the audio device.
mode | The mode to open the audio device in (See AudioIO::Mode) |
|
protected |
|
static |
Register an AudioIO object with the given device name.
dev_designator | The name of the audio device |
audio_io | A previously created AudioIO object |
This function is used to register an AudioIO object with the given audio device. If an AudioDevice object already exist for the given device, it is returned. If there is no AudioDevice object for the given device, a new one is created.
|
inline |
Return the sample rate.
Definition at line 277 of file AsyncAudioDevice.h.
References sample_rate.
|
pure virtual |
Find out how many samples there are in the output buffer.
This function can be used to find out how many samples there are in the output buffer at the moment. This can for example be used to find out how long it will take before the output buffer has been flushed.
Referenced by mode().
|
inlinestatic |
Set the buffer count used when opening audio devices.
count | The buffer count to use |
Use this function to set the buffer count used when opening audio devices. The buffer count is the maximum number of blocks the driver will buffer when reading and writing audio to/from the sound card. Lower numbers give less delay but could cause choppy audio if the computer is too slow. This is a global setting so all sound cards will be affected. Already opened sound cards will not be affected.
Definition at line 205 of file AsyncAudioDevice.h.
References block_count_hint.
|
inlinestatic |
Set the blocksize used when opening audio devices.
size | The blocksize, in samples per channel, to use |
Use this function to set the block size used when opening audio devices. The block size is the size of the blocks used when reading and writing audio to/from the sound card. Smaller blocks give less delay but could cause choppy audio if the computer is too slow. The blocksize is set as samples per channel. For example, a blocksize of 256 samples at 8kHz sample rate will give a delay of 256/8000 = 32ms. This is a global setting so all sound cards will be affected. Already opened sound cards will not be affected.
Definition at line 181 of file AsyncAudioDevice.h.
References block_size_hint, and blocksize().
|
inlinestatic |
Set the number of channels used when doing future opens.
channels | The number of channels to use |
Use this function to set the number of channels used when opening audio devices. This is a global setting so all sound cards will be affected. Already opened sound cards will not be affected.
Definition at line 219 of file AsyncAudioDevice.h.
References channels, close(), isFullDuplexCapable(), mode(), and open().
|
inlinestatic |
Set the sample rate used when doing future opens.
rate | The sampling rate to use |
Use this function to set the sample rate used when opening audio devices. This is a global setting so all sound cards will be affected. Already opened sound cards will not be affected.
Definition at line 165 of file AsyncAudioDevice.h.
References sample_rate.
|
static |
|
staticprotected |
Definition at line 289 of file AsyncAudioDevice.h.
Referenced by setBlockCount().
|
staticprotected |
Definition at line 288 of file AsyncAudioDevice.h.
Referenced by setBlocksize().
|
staticprotected |
Definition at line 290 of file AsyncAudioDevice.h.
Referenced by setChannels().
|
protected |
Definition at line 292 of file AsyncAudioDevice.h.
Referenced by devName().
|
staticprotected |
Definition at line 287 of file AsyncAudioDevice.h.
Referenced by sampleRate(), and setSampleRate().