Inheritance diagram for AUDIO_IO:
Public Types | |
Public type definitions and constants | |
enum | Io_mode { io_read = 1, io_write = 2, io_readwrite = 4 } |
Input/Output mode. More... | |
Public Member Functions | |
Public functions for handling object managers | |
virtual AUDIO_IO_MANAGER * | create_object_manager (void) const |
Creates an object manager for this audio object type. | |
Constructors and destructors | |
virtual AUDIO_IO * | clone (void) const =0 |
Virtual method that clones the current object and returns a pointer to it. | |
virtual AUDIO_IO * | new_expr (void) const =0 |
Virtual method that creates a new object of current type. | |
AUDIO_IO (const string &name="uninitialized", int mode=io_read) | |
Attribute functions | |
virtual int | supported_io_modes (void) const |
Returns info about supported I/O modes (bitwise-OR). | |
virtual bool | supports_nonblocking_mode (void) const |
Whether device supports non-blocking I/O mode. | |
virtual bool | supports_seeking (void) const |
Whether device supports non-blocking I/O mode. | |
virtual bool | finite_length_stream (void) const |
Whether audio stream has a distinct length. | |
virtual bool | locked_audio_format (void) const |
Whether audio format is locked. | |
Configuration | |
For setting and getting configuration parameters. | |
virtual void | set_buffersize (long int samples)=0 |
Sets the sample buffer size in sample frames. | |
virtual long int | buffersize (void) const =0 |
Returns the current buffersize in sample frames. | |
int | io_mode (void) const |
Returns info about the current I/O mode. | |
const string & | label (void) const |
Returns the current label. | |
string | format_info (void) const |
Returns a string containing info about sample format parameters. | |
void | set_io_mode (int mode) |
Set object input/output-mode. | |
void | set_label (const string &id_label) |
Sets object label. | |
void | toggle_nonblocking_mode (bool value) |
Enable/disbale nonblocking mode. | |
virtual string | parameter_names (void) const |
A comma-separated list of parameters names. | |
virtual void | set_parameter (int param, string value) |
Sets the parameter value. | |
virtual string | get_parameter (int param) const |
Get parameter value. | |
Main functionality | |
virtual void | read_buffer (SAMPLE_BUFFER *sbuf)=0 |
Reads samples and store them to buffer pointed by 'sbuf'. | |
virtual void | write_buffer (SAMPLE_BUFFER *sbuf)=0 |
Writes all data from sample buffer pointed by 'sbuf' to this object. | |
virtual void | open (void) throw (AUDIO_IO::SETUP_ERROR &) |
Opens the audio object (possibly in exclusive mode). | |
virtual void | close (void) |
Closes audio object. | |
Runtime information | |
virtual int | poll_descriptor (void) const |
Returns a file descriptor id suitable for poll() and select() system calls. | |
virtual long int | samples_available (void) const |
If 'supports_nonblocking_mode() == true', this function returns the number of samples frames that is available for reading, or alternatively, how many sample frames can be written without blocking. | |
bool | is_open (void) const |
Has device been opened (with open())? | |
virtual bool | finished (void) const =0 |
Whether all data has been processed? If opened in mode 'io_read', this means that end of stream has been reached. | |
virtual bool | nonblocking_mode (void) const |
Is nonblocking mode is enabled? | |
virtual bool | readable (void) const |
Is the audio object ready for reading? | |
virtual bool | writable (void) const |
Is the audio object ready for writing? | |
virtual string | status (void) const |
Optional status string. | |
ECA_AUDIO_TIME | length (void) const |
If applicable, returns total length of the audio data stored into current audio object. | |
ECA_AUDIO_TIME | position (void) const |
Returns the current position. | |
Functions overridden and reimplemented from | |
SAMPLE_SPECS::sample_rate_t | samples_per_second (void) const |
Overrides the non-virtaul function ECA_SAMPLERATE_AWARE::samples_per_second(), that is present (through inheritance) in both ECA_AUDIO_FORMAT and ECA_AUDIO_POSITION. | |
virtual void | set_samples_per_second (SAMPLE_SPECS::sample_rate_t v) |
virtual void | set_audio_format (const ECA_AUDIO_FORMAT &f_str) |
Sets audio format to that of 'f'. | |
Functions implemented from ECA_AUDIO_POSITION | |
virtual void | seek_position (void) |
Protected Member Functions | |
Functions provided for subclasses. | |
void | position (const ECA_AUDIO_TIME &v) |
Sets the current position. | |
void | length (const ECA_AUDIO_TIME &v) |
Sets the total length of audio object data. | |
Classes | |
class | SETUP_ERROR |
Different types of audio objects include files, audio devices, sound producing program modules, audio server clients, and so on.
The class interface is divided into following sections:
|
Input/Output mode.
Device is opened for input. If opening a file, it must exist. io_write Device is opened for output. If opening a file and and output exists, it is first truncated. io_readwrite Device is opened for both reading and writing. If opening a file, a new file is created if needed. When switching from read to write or vica versa, position should be reset before using the device. |
|
Returns the current buffersize in sample frames.
Implemented in AUDIO_IO_BUFFERED, LOOP_DEVICE, and AUDIO_IO_PROXY. |
|
Virtual method that clones the current object and returns a pointer to it. This must be implemented by all subclasses! Implements DYNAMIC_OBJECT< string >. Implemented in AAC_FORKED_INTERFACE, CDRFILE, AUDIO_IO_DB_CLIENT, EWFFILE, FLAC_FORKED_INTERFACE, LOOP_DEVICE, MIKMOD_INTERFACE, MP3FILE, NULLFILE, OGG_VORBIS_INTERFACE, OSSDEVICE, AUDIO_IO_PROXY, RAWFILE, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, REALTIME_NULL, TIMIDITY_INTERFACE, AUDIO_IO_TYPESELECT, WAVEFILE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, AUDIO_IO_ALSA_PCM_NAMED, ARTS_INTERFACE, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Closes audio object. After calling this routine, all resources (for instance files and devices) must be freed so that they can be used by other processes.
Reimplemented in AAC_FORKED_INTERFACE, CDRFILE, AUDIO_IO_DB_CLIENT, EWFFILE, FLAC_FORKED_INTERFACE, MIKMOD_INTERFACE, MP3FILE, NULLFILE, OGG_VORBIS_INTERFACE, OSSDEVICE, RAWFILE, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, REALTIME_NULL, TIMIDITY_INTERFACE, AUDIO_IO_TYPESELECT, WAVEFILE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, ARTS_INTERFACE, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Creates an object manager for this audio object type.
Reimplemented in AUDIO_IO_JACK. |
|
Whether all data has been processed? If opened in mode 'io_read', this means that end of stream has been reached. If opened in 'io_write' or 'io_readwrite' modes, finished status usually means that an error has occured (no space left, etc). After finished() has returned 'true', further calls to read_buffer() and/or write_buffer() won't process any data. For output for which 'finite_length_stream()' is true, when 'finished()' returns true, that means an error has occured. Otherwise 'finished()' just tells that further attempts to do i/o will fail. Implemented in AAC_FORKED_INTERFACE, CDRFILE, AUDIO_IO_DB_CLIENT, AUDIO_IO_DEVICE, EWFFILE, FLAC_FORKED_INTERFACE, LOOP_DEVICE, MIKMOD_INTERFACE, MP3FILE, NULLFILE, OGG_VORBIS_INTERFACE, AUDIO_IO_PROXY, RAWFILE, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, TIMIDITY_INTERFACE, WAVEFILE, AUDIOFILE_INTERFACE, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Whether audio stream has a distinct length. It's important to note the difference between this attribute and 'supports_seeking()'. For example, a file read through a pipe mechanism is not seekable and its length is not known until 'finished()´ becomes true, but still, it is of finite length. A sine oscillator on the other hand can go on producing a signal forever, and is thus infinite. This attributes directly affects how 'finished()' should to be interpreted.
Reimplemented in EWFFILE, AUDIO_IO_PROXY, AUDIO_IO_RESAMPLE, and AUDIO_IO_REVERSE. |
|
Get parameter value.
Implements DYNAMIC_PARAMETERS< string >. Reimplemented in AAC_FORKED_INTERFACE, FLAC_FORKED_INTERFACE, LOOP_DEVICE, MIKMOD_INTERFACE, MP3FILE, OGG_VORBIS_INTERFACE, AUDIO_IO_PROXY, RAWFILE, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, AUDIO_IO_TYPESELECT, WAVEFILE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, AUDIO_IO_ALSA_PCM_NAMED, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Returns the current label. See documentation for label(const string&). |
|
If applicable, returns total length of the audio data stored into current audio object. In many situations it's impossible enquire the whole length of the object. For instance, if the object is streaming a finite length audio stream audio object from other applications using some type of standard IPC, the actual length won't be known until the whole stream has been read. As a general rule, if 'supports_seeking() == true', length can be known right after initialization. Then again, if 'finite_length_stream() == true', the whole stream must be processed before we know the actual length. In other cases, length is unknown or infinite. |
|
Whether audio format is locked. If this is true, audio object has a known audio format, and doesn't allow overriding it. By default, audio format is not locked. Reimplemented in AAC_FORKED_INTERFACE, CDRFILE, EWFFILE, FLAC_FORKED_INTERFACE, MP3FILE, OGG_VORBIS_INTERFACE, AUDIO_IO_PROXY, WAVEFILE, AUDIOFILE_INTERFACE, ARTS_INTERFACE, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Virtual method that creates a new object of current type. This must be implemented by all subclasses! Implements DYNAMIC_OBJECT< string >. Implemented in AAC_FORKED_INTERFACE, CDRFILE, AUDIO_IO_DB_CLIENT, EWFFILE, FLAC_FORKED_INTERFACE, LOOP_DEVICE, MIKMOD_INTERFACE, MP3FILE, NULLFILE, OGG_VORBIS_INTERFACE, OSSDEVICE, AUDIO_IO_PROXY, RAWFILE, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, REALTIME_NULL, TIMIDITY_INTERFACE, AUDIO_IO_TYPESELECT, WAVEFILE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, AUDIO_IO_ALSA_PCM_NAMED, ARTS_INTERFACE, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Opens the audio object (possibly in exclusive mode). This routine is used for initializing external connections (opening files or devices, loading shared libraries, opening IPC connections). As it's impossible to know in advance what might happen, open() may throw an exception. This way it becomes possible to provide more verbose information about the problem that caused open() to fail. At this point the various audio parameters are used for the first time. Unless locked_audio_format() is 'true', object tries to use the audio format parameters set prior to this call. If object doesn't support the given parameter combination, it can either try adjust them to closest matching, or in the worst case, throw an SETUP_ERROR exception (see above).
Reimplemented in AAC_FORKED_INTERFACE, CDRFILE, AUDIO_IO_DB_CLIENT, EWFFILE, FLAC_FORKED_INTERFACE, MIKMOD_INTERFACE, MP3FILE, NULLFILE, OGG_VORBIS_INTERFACE, OSSDEVICE, RAWFILE, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, REALTIME_NULL, TIMIDITY_INTERFACE, AUDIO_IO_TYPESELECT, WAVEFILE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, ARTS_INTERFACE, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
A comma-separated list of parameters names. Derived classes must implement this. Implements DYNAMIC_PARAMETERS< string >. Reimplemented in AAC_FORKED_INTERFACE, FLAC_FORKED_INTERFACE, LOOP_DEVICE, MIKMOD_INTERFACE, MP3FILE, OGG_VORBIS_INTERFACE, AUDIO_IO_PROXY, RAWFILE, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, AUDIO_IO_TYPESELECT, WAVEFILE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, AUDIO_IO_ALSA_PCM_NAMED, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Returns a file descriptor id suitable for poll() and select() system calls. If polling is not supported, returns value of '-1'. |
|
Reads samples and store them to buffer pointed by 'sbuf'. If necessary, the target buffer will be resized. It's important to note that SAMPLE_BUFFER audio format cannot be changed during processing. This means that audio data must be converted from audio object's internal format to that of 'sbuf' given as argument. SAMPLE_BUFFER class provides tools for all normal conversion operations. If you need direct access to object's data, a lower abstraction level should be used (
Implemented in AUDIO_IO_BUFFERED, AUDIO_IO_DB_CLIENT, EWFFILE, LOOP_DEVICE, AUDIO_IO_PROXY, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, and SNDFILE_INTERFACE. |
|
If 'supports_nonblocking_mode() == true', this function returns the number of samples frames that is available for reading, or alternatively, how many sample frames can be written without blocking. This function can be used for implementing nonblocking input and output with devices supporting it. Note, you should use set_buffersize() for setting how many sample frames read_buffer() will ask from the device. require: supports_nonblocking_mode() == true |
|
Sets the sample buffer size in sample frames. When reading data with read_buffer(), buffersize() determines how many sample frames of data is processed per call. Otherwise buffersize() is only used for initializing devices and data structures. Device should always be able to write all sample data passed to write_buffer(), independently from current buffersize() value.
Implemented in AUDIO_IO_BUFFERED, LOOP_DEVICE, and AUDIO_IO_PROXY. |
|
Set object input/output-mode. If the requested mode isn't supported, the nearest supported mode is used. Because of this, it's wise to afterwards check whether the requested mode was accepted. require: is_open() != true |
|
Sets object label. Label is used to identify the object instance. Unlike ECA_OBJECT::name(), label() is not necessarily unique among different class instances. Device and file names are typical label values. require: is_open() != true |
|
Sets the parameter value. Implementations should be able to handle arbitrary values of 'value'. Argument validity can be tested by a combination of set_parameter() and get_parameter() calls. Parameter value is valid, if get_parameter() returns it without changes.
Implements DYNAMIC_PARAMETERS< string >. Reimplemented in MIKMOD_INTERFACE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, AUDIO_IO_ALSA_PCM_NAMED, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Optional status string. An unformatted text string describing the state and status of the current object. Reimplemented in AUDIO_IO_DEVICE. |
|
Returns info about supported I/O modes (bitwise-OR). By default, all I/O modes are supported. Reimplemented in AAC_FORKED_INTERFACE, FLAC_FORKED_INTERFACE, MIKMOD_INTERFACE, MP3FILE, OGG_VORBIS_INTERFACE, OSSDEVICE, AUDIO_IO_PROXY, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, TIMIDITY_INTERFACE, AUDIOFILE_INTERFACE, AUDIO_IO_ALSA_PCM, ARTS_INTERFACE, AUDIO_IO_JACK, and SNDFILE_INTERFACE. |
|
Whether device supports non-blocking I/O mode. By default, nonblocking mode is not supported. Reimplemented in AUDIO_IO_PROXY, and ARTS_INTERFACE. |
|
Whether device supports non-blocking I/O mode. By default, seeking is supported. Reimplemented in AAC_FORKED_INTERFACE, AUDIO_IO_DEVICE, EWFFILE, FLAC_FORKED_INTERFACE, MIKMOD_INTERFACE, MP3FILE, NULLFILE, OGG_VORBIS_INTERFACE, AUDIO_IO_PROXY, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, TIMIDITY_INTERFACE, and ARTS_INTERFACE. |
|
Enable/disbale nonblocking mode. require: is_open() != true |
|
Writes all data from sample buffer pointed by 'sbuf' to this object. Notes concerning read_buffer() also apply to this routine. Note! The implementations should call set_position_in_samples() or change_position_in_samples() in ECA_AUDIO_POSITION.
Implemented in AUDIO_IO_BUFFERED, AUDIO_IO_DB_CLIENT, EWFFILE, LOOP_DEVICE, AUDIO_IO_PROXY, AUDIO_IO_RESAMPLE, AUDIO_IO_REVERSE, and SNDFILE_INTERFACE. |