Async  0.18.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
Async::AudioDevice Class Reference

Base class for handling audio devices. More...

#include <AsyncAudioDevice.h>

List of all members.

Public Types

Public Member Functions

Static Public Member Functions

Protected Member Functions

Protected Attributes

Static Protected Attributes


Detailed Description

Base class for handling audio devices.

Author:
Tobias Blomberg / SM0SVX
Date:
2004-03-20

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.


Member Enumeration Documentation

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.


Constructor & Destructor Documentation

Async::AudioDevice::AudioDevice ( const std::string &  dev_name) [explicit, protected]

Constuctor.

Parameters:
dev_nameThe name of the device to associate this object with
virtual Async::AudioDevice::~AudioDevice ( void  ) [protected, virtual]

Destructor.


Member Function Documentation

virtual void Async::AudioDevice::audioToWriteAvailable ( void  ) [pure virtual]

Tell the audio device handler that there are audio to be written in the buffer.

virtual int Async::AudioDevice::blocksize ( void  ) [pure virtual]

Find out what the blocksize is set to.

Returns:
Returns the currently set blocksize in samples per channel
void Async::AudioDevice::close ( void  )

Close the audio device.

virtual void Async::AudioDevice::closeDevice ( void  ) [protected, pure virtual]

Close the audio device.

const std::string& Async::AudioDevice::devName ( void  ) const [inline]

Return the device name.

Returns:
Returns the device name

Definition at line 283 of file AsyncAudioDevice.h.

References dev_name.

virtual void Async::AudioDevice::flushSamples ( void  ) [pure virtual]
int Async::AudioDevice::getBlocks ( int16_t *  buf,
int  block_cnt 
) [protected]
virtual bool Async::AudioDevice::isFullDuplexCapable ( void  ) [pure virtual]

Check if the audio device has full duplex capability.

Returns:
Returns true if the device has full duplex capability or else false
Mode Async::AudioDevice::mode ( void  ) const [inline]

Get the current operating mode of this audio device.

Returns:
Returns the current mode (See AudioIO::Mode)

Definition at line 248 of file AsyncAudioDevice.h.

Open the audio device.

Parameters:
modeThe mode to open the audio device in (See AudioIO::Mode)
Returns:
Returns true on success or else false
virtual bool Async::AudioDevice::openDevice ( Mode  mode) [protected, pure virtual]

Open the audio device.

Parameters:
modeThe mode to open the audio device in (See AudioIO::Mode)
Returns:
Returns true on success or else false
void Async::AudioDevice::putBlocks ( int16_t *  buf,
int  frame_cnt 
) [protected]
static AudioDevice* Async::AudioDevice::registerAudioIO ( const std::string &  dev_designator,
AudioIO audio_io 
) [static]

Register an AudioIO object with the given device name.

Parameters:
dev_nameThe name of the audio device
audio_ioA previously created AudioIO object
Returns:
Returns an AudioDevice object associated with the given device

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 returns. If there is no AudioDevice object for the given device, a new one is created.

int Async::AudioDevice::sampleRate ( void  ) const [inline]

Return the sample rate.

Returns:
Returns the sample rate

Definition at line 277 of file AsyncAudioDevice.h.

References sample_rate.

virtual int Async::AudioDevice::samplesToWrite ( void  ) const [pure virtual]

Find out how many samples there are in the output buffer.

Returns:
Returns the number of samples in the output buffer on success or -1 on failure.

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.

static void Async::AudioDevice::setBlockCount ( int  count) [inline, static]

Set the buffer count used when opening audio devices.

Parameters:
countThe buffer count to use
Returns:
Returns the buffer count actually set

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.

static void Async::AudioDevice::setBlocksize ( int  size) [inline, static]

Set the blocksize used when opening audio devices.

Parameters:
sizeThe blocksize, in samples per channel, to use
Returns:
Returns the blocksize actually set

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.

static void Async::AudioDevice::setChannels ( int  channels) [inline, static]

Set the number of channels used when doing future opens.

Parameters:
channelsThe 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.

static void Async::AudioDevice::setSampleRate ( int  rate) [inline, static]

Set the sample rate used when doing future opens.

Parameters:
rateThe 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 void Async::AudioDevice::unregisterAudioIO ( AudioIO audio_io) [static]

Unregister a previously registered AudioIO object.

Parameters:
audio_ioA previously registered AudioIO object

Member Data Documentation

int Async::AudioDevice::block_count_hint [static, protected]

Definition at line 289 of file AsyncAudioDevice.h.

Referenced by setBlockCount().

int Async::AudioDevice::block_size_hint [static, protected]

Definition at line 288 of file AsyncAudioDevice.h.

Referenced by setBlocksize().

int Async::AudioDevice::channels [static, protected]

Definition at line 290 of file AsyncAudioDevice.h.

Referenced by setChannels().

std::string Async::AudioDevice::dev_name [protected]

Definition at line 292 of file AsyncAudioDevice.h.

Referenced by devName().

int Async::AudioDevice::sample_rate [static, protected]

Definition at line 287 of file AsyncAudioDevice.h.

Referenced by sampleRate(), and setSampleRate().


The documentation for this class was generated from the following file: