Blender  V2.59
Public Member Functions | Protected Member Functions | Protected Attributes
AUD_SoftwareDevice Class Reference

#include <AUD_SoftwareDevice.h>

Inheritance diagram for AUD_SoftwareDevice:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual AUD_DeviceSpecs getSpecs () const
virtual AUD_Handleplay (AUD_IReader *reader, bool keep=false)
virtual AUD_Handleplay (AUD_IFactory *factory, bool keep=false)
virtual bool pause (AUD_Handle *handle)
virtual bool resume (AUD_Handle *handle)
virtual bool stop (AUD_Handle *handle)
virtual bool getKeep (AUD_Handle *handle)
virtual bool setKeep (AUD_Handle *handle, bool keep)
virtual bool seek (AUD_Handle *handle, float position)
virtual float getPosition (AUD_Handle *handle)
virtual AUD_Status getStatus (AUD_Handle *handle)
virtual void lock ()
virtual void unlock ()
virtual float getVolume () const
virtual void setVolume (float volume)
virtual float getVolume (AUD_Handle *handle)
virtual bool setVolume (AUD_Handle *handle, float volume)
virtual float getPitch (AUD_Handle *handle)
virtual bool setPitch (AUD_Handle *handle, float pitch)
virtual int getLoopCount (AUD_Handle *handle)
virtual bool setLoopCount (AUD_Handle *handle, int count)
virtual bool setStopCallback (AUD_Handle *handle, stopCallback callback=NULL, void *data=NULL)

Protected Member Functions

void create ()
void destroy ()
void mix (data_t *buffer, int length)
virtual void playing (bool playing)=0

Protected Attributes

AUD_DeviceSpecs m_specs
AUD_Mixerm_mixer

Detailed Description

This device plays is a generic device with software mixing. Classes implementing this have to:

Definition at line 51 of file AUD_SoftwareDevice.h.


Member Function Documentation

void AUD_SoftwareDevice::create ( ) [protected]

Initializes member variables.

Definition at line 64 of file AUD_SoftwareDevice.cpp.

References m_mixer, and m_specs.

Referenced by AUD_JackDevice::AUD_JackDevice(), AUD_ReadDevice::AUD_ReadDevice(), and AUD_SDLDevice::AUD_SDLDevice().

void AUD_SoftwareDevice::destroy ( ) [protected]
bool AUD_SoftwareDevice::getKeep ( AUD_Handle handle) [virtual]

Gets the behaviour of the device for a played back sound when the sound doesn't return any more samples.

Parameters:
handleThe handle returned by the play function.
Returns:
  • true if the source will be paused when it's end is reached
  • false if the handle won't kept or is invalid.

Implements AUD_IDevice.

Definition at line 340 of file AUD_SoftwareDevice.cpp.

References lock(), and unlock().

int AUD_SoftwareDevice::getLoopCount ( AUD_Handle handle) [virtual]

Retrieves the loop count of a playing sound. A negative value indicates infinity.

Returns:
The remaining loop count.

Implements AUD_IDevice.

Definition at line 489 of file AUD_SoftwareDevice.cpp.

References lock(), and unlock().

float AUD_SoftwareDevice::getPitch ( AUD_Handle handle) [virtual]

Retrieves the pitch of a playing sound.

Returns:
The pitch.

Implements AUD_IDevice.

Definition at line 479 of file AUD_SoftwareDevice.cpp.

float AUD_SoftwareDevice::getPosition ( AUD_Handle handle) [virtual]

Retrieves the current playback position of a sound.

Parameters:
handleThe handle returned by the play function.
Returns:
The playback position in seconds, or 0.0 if the handle is invalid.

Implements AUD_IDevice.

Definition at line 389 of file AUD_SoftwareDevice.cpp.

References AUD_IReader::getPosition(), lock(), m_specs, AUD_DeviceSpecs::rate, AUD_SoftwareHandle::reader, and unlock().

AUD_DeviceSpecs AUD_SoftwareDevice::getSpecs ( ) const [virtual]

Returns the specification of the device.

Implements AUD_IDevice.

Definition at line 211 of file AUD_SoftwareDevice.cpp.

References m_specs.

AUD_Status AUD_SoftwareDevice::getStatus ( AUD_Handle handle) [virtual]

Returns the status of a played back sound.

Parameters:
handleThe handle returned by the play function.
Returns:
  • AUD_STATUS_INVALID if the sound has stopped or the handle is . invalid
  • AUD_STATUS_PLAYING if the sound is currently played back.
  • AUD_STATUS_PAUSED if the sound is currently paused.
See also:
AUD_Status

Implements AUD_IDevice.

Definition at line 406 of file AUD_SoftwareDevice.cpp.

References AUD_STATUS_INVALID, AUD_STATUS_PAUSED, AUD_STATUS_PLAYING, i, lock(), and unlock().

float AUD_SoftwareDevice::getVolume ( ) const [virtual]

Retrieves the overall device volume.

Returns:
The overall device volume.

Implements AUD_IDevice.

Definition at line 449 of file AUD_SoftwareDevice.cpp.

float AUD_SoftwareDevice::getVolume ( AUD_Handle handle) [virtual]

Retrieves the volume of a playing sound.

Parameters:
handleThe sound handle.
Returns:
The volume.

Implements AUD_IDevice.

Definition at line 459 of file AUD_SoftwareDevice.cpp.

References lock(), and unlock().

void AUD_SoftwareDevice::lock ( ) [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 AUD_IDevice.

Definition at line 439 of file AUD_SoftwareDevice.cpp.

Referenced by getKeep(), getLoopCount(), getPosition(), getStatus(), getVolume(), mix(), pause(), play(), resume(), seek(), setKeep(), setLoopCount(), setStopCallback(), setVolume(), stop(), and AUD_SDLDevice::~AUD_SDLDevice().

void AUD_SoftwareDevice::mix ( data_t buffer,
int  length 
) [protected]
bool AUD_SoftwareDevice::pause ( AUD_Handle handle) [virtual]

Pauses a played back sound.

Parameters:
handleThe handle returned by the play function.
Returns:
  • true if the sound has been paused.
  • false if the sound isn't playing back or the handle is invalid.

Implements AUD_IDevice.

Definition at line 247 of file AUD_SoftwareDevice.cpp.

References i, lock(), playing(), and unlock().

Referenced by mix().

AUD_Handle * AUD_SoftwareDevice::play ( AUD_IReader reader,
bool  keep = false 
) [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 NULL if the sound couldn't be played back.
Exceptions:
AUD_ExceptionThrown if there's an unexpected (from the device side) error during creation of the reader.

Implements AUD_IDevice.

Definition at line 216 of file AUD_SoftwareDevice.cpp.

References AUD_SoftwareHandle::keep, lock(), AUD_SoftwareHandle::loopcount, m_mixer, NULL, playing(), AUD_Mixer::prepare(), AUD_SoftwareHandle::reader, AUD_SoftwareHandle::stop, AUD_SoftwareHandle::stop_data, unlock(), and AUD_SoftwareHandle::volume.

Referenced by AUD_playDevice(), and play().

AUD_Handle * AUD_SoftwareDevice::play ( AUD_IFactory factory,
bool  keep = false 
) [virtual]

Plays a sound source.

Parameters:
factoryThe factory 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 NULL if the sound couldn't be played back.
Exceptions:
AUD_ExceptionThrown if there's an unexpected (from the device side) error during creation of the reader.

Implements AUD_IDevice.

Definition at line 242 of file AUD_SoftwareDevice.cpp.

References AUD_IFactory::createReader(), and play().

virtual void AUD_SoftwareDevice::playing ( bool  playing) [protected, pure virtual]

This function tells the device, to start or pause playback.

Parameters:
playingTrue if device should playback.

Implemented in AUD_JackDevice, AUD_SDLDevice, and AUD_ReadDevice.

Referenced by destroy(), pause(), play(), resume(), and stop().

bool AUD_SoftwareDevice::resume ( AUD_Handle handle) [virtual]

Resumes a paused sound.

Parameters:
handleThe handle returned by the play function.
Returns:
  • true if the sound has been resumed.
  • false if the sound isn't paused or the handle is invalid.

Implements AUD_IDevice.

Definition at line 273 of file AUD_SoftwareDevice.cpp.

References i, lock(), playing(), and unlock().

bool AUD_SoftwareDevice::seek ( AUD_Handle handle,
float  position 
) [virtual]

Seeks in a played back sound.

Parameters:
handleThe handle returned by the play function.
positionThe new position from where to play back, in seconds.
Returns:
  • true if the handle is valid.
  • false if the handle is invalid.
Warning:
Whether the seek works or not depends on the sound source.

Implements AUD_IDevice.

Definition at line 371 of file AUD_SoftwareDevice.cpp.

References AUD_IReader::getSpecs(), lock(), AUD_Specs::rate, AUD_IReader::seek(), and unlock().

Referenced by AUD_playDevice().

bool AUD_SoftwareDevice::setKeep ( AUD_Handle handle,
bool  keep 
) [virtual]

Sets the behaviour of the device for a played back sound when the sound doesn't return any more samples.

Parameters:
handleThe handle returned by the play function.
keepTrue when the source should be paused and not deleted.
Returns:
  • true if the behaviour has been changed.
  • false if the handle is invalid.

Implements AUD_IDevice.

Definition at line 354 of file AUD_SoftwareDevice.cpp.

References lock(), and unlock().

bool AUD_SoftwareDevice::setLoopCount ( AUD_Handle handle,
int  count 
) [virtual]

Sets the loop count of a playing sound. A negative value indicates infinity.

Parameters:
handleThe sound handle.
countThe new loop count.
Returns:
  • true if the handle is valid.
  • false if the handle is invalid.

Implements AUD_IDevice.

Definition at line 499 of file AUD_SoftwareDevice.cpp.

References lock(), and unlock().

bool AUD_SoftwareDevice::setPitch ( AUD_Handle handle,
float  pitch 
) [virtual]

Sets the pitch of a playing sound.

Parameters:
handleThe sound handle.
pitchThe pitch.
Returns:
  • true if the handle is valid.
  • false if the handle is invalid.

Implements AUD_IDevice.

Definition at line 484 of file AUD_SoftwareDevice.cpp.

bool AUD_SoftwareDevice::setStopCallback ( AUD_Handle handle,
stopCallback  callback = NULL,
void *  data = NULL 
) [virtual]

Sets the callback function that's called when the end of a playing sound is reached.

Parameters:
handleThe sound handle.
callbackThe callback function.
dataThe data that should be passed to the callback function.
Returns:
  • true if the handle is valid.
  • false if the handle is invalid.

Implements AUD_IDevice.

Definition at line 509 of file AUD_SoftwareDevice.cpp.

References lock(), AUD_SoftwareHandle::stop, AUD_SoftwareHandle::stop_data, and unlock().

void AUD_SoftwareDevice::setVolume ( float  volume) [virtual]

Sets the overall device volume.

Parameters:
handleThe sound handle.
volumeThe overall device volume.

Implements AUD_IDevice.

Definition at line 454 of file AUD_SoftwareDevice.cpp.

Referenced by AUD_setDeviceSoundVolume(), and AUD_setDeviceVolume().

bool AUD_SoftwareDevice::setVolume ( AUD_Handle handle,
float  volume 
) [virtual]

Sets the volume of a playing sound.

Parameters:
handleThe sound handle.
volumeThe volume.
Returns:
  • true if the handle is valid.
  • false if the handle is invalid.

Implements AUD_IDevice.

Definition at line 469 of file AUD_SoftwareDevice.cpp.

References lock(), and unlock().

bool AUD_SoftwareDevice::stop ( AUD_Handle handle) [virtual]

Stops a played back or paused sound. The handle is definitely invalid afterwards.

Parameters:
handleThe handle returned by the play function.
Returns:
  • true if the sound has been stopped.
  • false if the handle is invalid.

Implements AUD_IDevice.

Definition at line 299 of file AUD_SoftwareDevice.cpp.

References i, lock(), playing(), and unlock().

Referenced by mix().

void AUD_SoftwareDevice::unlock ( ) [virtual]

Member Data Documentation

The mixer.

Definition at line 62 of file AUD_SoftwareDevice.h.

Referenced by create(), destroy(), mix(), and play().


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