Audaspace 1.7.0
A high level audio library.
Loading...
Searching...
No Matches
IDevice Interface Referenceabstract

The IDevice interface represents an output device for sound sources. More...

#include <IDevice.h>

Inheritance diagram for IDevice:

Public Types

typedef void(* syncFunction) (void *, int, float)
 The syncFunction is called when a synchronization event happens.

Public Member Functions

virtual ~IDevice ()
 Destroys the device.
virtual DeviceSpecs getSpecs () const =0
 Returns the specification of the device.
virtual std::shared_ptr< IHandleplay (std::shared_ptr< IReader > reader, bool keep=false)=0
 Plays a sound source.
virtual std::shared_ptr< IHandleplay (std::shared_ptr< ISound > sound, bool keep=false)=0
 Plays a sound source.
virtual void stopAll ()=0
 Stops all playing sounds.
virtual void lock ()=0
 Locks the device.
virtual void unlock ()=0
 Unlocks the previously locked device.
virtual float getVolume () const =0
 Retrieves the overall device volume.
virtual void setVolume (float volume)=0
 Sets the overall device volume.
virtual void seekSynchronizer (double time)=0
virtual double getSynchronizerPosition ()=0
virtual void playSynchronizer ()=0
virtual void stopSynchronizer ()=0
virtual void setSyncCallback (syncFunction function, void *data)=0
virtual int isSynchronizerPlaying ()=0

Detailed Description

The IDevice interface represents an output device for sound sources.

Output devices may be several backends such as platform independand like SDL or OpenAL or platform specific like ALSA, but they may also be files, RAM buffers or other types of streams.

Warning
Thread safety must be insured so that no reader is being called twice at the same time.

Member Typedef Documentation

◆ syncFunction

typedef void(* IDevice::syncFunction) (void *, int, float)

The syncFunction is called when a synchronization event happens.

The function awaits three parameters. The first one is a user defined pointer, the second informs about whether playback is on and the third is the current playback time in seconds.

Member Function Documentation

◆ getSpecs()

virtual DeviceSpecs IDevice::getSpecs ( ) const
pure virtual

Returns the specification of the device.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.

◆ getSynchronizerPosition()

virtual double IDevice::getSynchronizerPosition ( )
pure virtual

Implemented in JackDevice.

◆ getVolume()

virtual float IDevice::getVolume ( ) const
pure virtual

Retrieves the overall device volume.

Returns
The overall device volume.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.

◆ isSynchronizerPlaying()

virtual int IDevice::isSynchronizerPlaying ( )
pure virtual

Implemented in JackDevice.

◆ lock()

virtual void IDevice::lock ( )
pure virtual

Locks the device.

Used to make sure that between lock and unlock, no buffers are read, so that it is possible to start, resume, pause, stop or seek several playback handles simultaneously.

Warning
Make sure the locking time is as small as possible to avoid playback delays that result in unexpected noise and cracks.

Implements ILockable.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.

◆ play() [1/2]

virtual std::shared_ptr< IHandle > IDevice::play ( std::shared_ptr< IReader > reader,
bool keep = false )
pure virtual

Plays a sound source.

Parameters
readerThe reader to play.
keepWhen keep is true the sound source will not be deleted but set to paused when its end has been reached.
Returns
Returns a handle with which the playback can be controlled. This is nullptr if the sound couldn't be played back.
Exceptions
ExceptionThrown if there's an unexpected (from the device side) error during creation of the reader.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.

◆ play() [2/2]

virtual std::shared_ptr< IHandle > IDevice::play ( std::shared_ptr< ISound > sound,
bool keep = false )
pure virtual

Plays a sound source.

Parameters
soundThe sound to create the reader for the sound source.
keepWhen keep is true the sound source will not be deleted but set to paused when its end has been reached.
Returns
Returns a handle with which the playback can be controlled. This is nullptr if the sound couldn't be played back.
Exceptions
ExceptionThrown if there's an unexpected (from the device side) error during creation of the reader.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.

◆ playSynchronizer()

virtual void IDevice::playSynchronizer ( )
pure virtual

Implemented in JackDevice.

◆ seekSynchronizer()

virtual void IDevice::seekSynchronizer ( double time)
pure virtual

Implemented in JackDevice.

◆ setSyncCallback()

virtual void IDevice::setSyncCallback ( syncFunction function,
void * data )
pure virtual

Implemented in JackDevice.

◆ setVolume()

virtual void IDevice::setVolume ( float volume)
pure virtual

Sets the overall device volume.

Parameters
volumeThe overall device volume.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.

◆ stopAll()

virtual void IDevice::stopAll ( )
pure virtual

Stops all playing sounds.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.

◆ stopSynchronizer()

virtual void IDevice::stopSynchronizer ( )
pure virtual

Implemented in JackDevice.

◆ unlock()

virtual void IDevice::unlock ( )
pure virtual

Unlocks the previously locked device.

Implements ILockable.

Implemented in NULLDevice, OpenALDevice, and SoftwareDevice.


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