Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeAudioPlayer Class Reference

the Cascade way to playback audio More...

#include <cascade/av/CascadeAudioPlayer.h>

Inheritance diagram for CascadeAudioPlayer:

CascadeObject List of all members.

Public Types

enum  { kOutputFlagAnalog = (1 << 0), kOutputFlagSPDIF = (1 << 1) }
enum  PlaybackResult {
  kNormalCompletion = 0, kPlaybackStopped, kErrorUnknown, kErrorOutOfMemory,
  kErrorUnsupportedSampleRate, kErrorUnsupportedBitsPerSample, kErrorUnsupportedNumChannels, kErrorUnsupportedSamplePolarity,
  kErrorUnsupportedSampleEndianness, kErrorUnsupportedSampleOrder, kErrorUnknownAudioType, kErrorCodecInputFailure,
  kErrorStreamReadFailure, kErrorDeviceNonexistant, kErrorDeviceFailure, kErrorDeviceUnavailable,
  kErrorUnsupportedOutputFlags
}

Public Member Functions

 CascadeAudioPlayer ()
virtual ~CascadeAudioPlayer ()
virtual bool Open (Client *pClient=NULL)
virtual void Close ()
virtual bool IsOpen ()
virtual bool QueueStream (CascadeStream &stream, const char *pType=NULL, u32 nOutputFlags=(kOutputFlagAnalog|kOutputFlagSPDIF))
virtual bool Stop ()
virtual bool Pause ()
virtual bool Resume ()
virtual bool SetVolume (u16 nVolume)
virtual bool SetVolumePercent (u8 nVolume)
virtual bool IsPlaying ()
virtual bool IsStopped ()
virtual bool IsPaused ()
virtual bool AttachDevice (CascadeAudioPlaybackDevice &device)
virtual bool DetachDevice ()

Static Public Member Functions

static const char * PlaybackResultToString (PlaybackResult result)

Friends

class CascadePrivate::CascadeAudioPlayerInitializer

Classes

class  Client
class  SampleSet

Detailed Description

the Cascade way to playback audio

Skip the description

CascadeAudioPlayer is a class that allows easy playback of audio streams of all sources, types, and durations.

Use: CascadeStream stream; CascadeAudioPlayer player; player.PlayStream(stream);


class CascadeAudioPlayer


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
kOutputFlagAnalog 
kOutputFlagSPDIF 

enum CascadeAudioPlayer::PlaybackResult
 

represents a type of playback result

PlaybackResult represents the types of playback results that can occur. A variable of this type is provided to the virtual function OnPlaybackEndDT() to indicate the result of the playback.

See also:
CascadeAudioPlayer::Client::OnAudioPlaybackEndDT()
Enumeration values:
kNormalCompletion  indicates normal completion
kPlaybackStopped 
kErrorUnknown  1 <indicates Stop() was called
kErrorOutOfMemory  2 <indicates an unknown error occurred
kErrorUnsupportedSampleRate  3 <indicates an out of memory error occurred
kErrorUnsupportedBitsPerSample  4 <indicates an unsupported sample rate
kErrorUnsupportedNumChannels  5 <indicates an unsupported number of bits per sample
kErrorUnsupportedSamplePolarity  6 <indicates an unsupported number of channels
kErrorUnsupportedSampleEndianness  7 <indicates an unsupported sample polarity (signed vs. unsigned)
kErrorUnsupportedSampleOrder  8 <indicates an unsupported sample endianness (little vs. big)
kErrorUnknownAudioType  9 <indicates an unsupported sample order (leftRight vs. rightLeft)
kErrorCodecInputFailure  10 <indicates an inability to determine audio input format
kErrorStreamReadFailure  11 <indicates codec reported an error setting the input stream
kErrorDeviceNonexistant  12 <indicates an error reading from the stream
kErrorDeviceFailure  13 <indicates an absence of any playback devices
kErrorDeviceUnavailable  14 <indicates a device error failure
kErrorUnsupportedOutputFlags  15 <indicates the device is unavailable (already open by someone else)


Constructor & Destructor Documentation

CascadeAudioPlayer::CascadeAudioPlayer  ) 
 

the default constructor - lightweight

This default constructor is lightweight.

virtual CascadeAudioPlayer::~CascadeAudioPlayer  )  [virtual]
 

destructor

The destructor.


Member Function Documentation

virtual bool CascadeAudioPlayer::AttachDevice CascadeAudioPlaybackDevice device  )  [virtual]
 

attaches a custom playback device (not required)

AttachDevice() may be used to attach a custom (non-default) audio playback device for use by the player.

If no device is ever attached with this function, the default system playback device is used.

The player must be in the stopped state for this function to succeed.

Parameters:
device the device to attach
Returns:
whether or not the attachment was successful

virtual void CascadeAudioPlayer::Close  )  [virtual]
 

closes the audio player

Close() closes the audio player. Be sure to close (or delete) the audio player when you're done with it so other clients can use it.

virtual bool CascadeAudioPlayer::DetachDevice  )  [virtual]
 

detaches a previously attached custom playback device

DetachDevice() detaches a previously attached custom playback device restoring the player to using the default audio playback device.

The player must be in the stopped state for this function to succeed.

Returns:
whether or not the detachment was successful

virtual bool CascadeAudioPlayer::IsOpen  )  [virtual]
 

determines whether or not the audio player is open

IsOpen() determines whether or not the audio player is open by this instance.

Returns:
whether or not the audio player is open

virtual bool CascadeAudioPlayer::IsPaused  )  [virtual]
 

determines whether or not the file is paused

IsPaused() determines whether or not the mp3 file is paused.

Returns:
whether or not the file is paused

virtual bool CascadeAudioPlayer::IsPlaying  )  [virtual]
 

determines whether or not the file is playing

IsPlaying() determines whether or not the mp3 file is playing.

Returns:
whether or not the file is playing

virtual bool CascadeAudioPlayer::IsStopped  )  [virtual]
 

determines whether or not the file is stopped

IsStopped() determines whether or not the mp3 file is stopped.

Returns:
whether or not the file is stopped

virtual bool CascadeAudioPlayer::Open Client pClient = NULL  )  [virtual]
 

opens the audio player

Open() opens the audio player. The player must be opened succesfully before it can be used. If Open() fails, that means that another client has the audio player opened.

Parameters:
pClient the client to receive notifications
Returns:
whether or not the open succeeded

virtual bool CascadeAudioPlayer::Pause  )  [virtual]
 

pauses playback

Pause() puts the player into a paused state.

Returns:
whether pausing succeeded

static const char* CascadeAudioPlayer::PlaybackResultToString PlaybackResult  result  )  [static]
 

virtual bool CascadeAudioPlayer::QueueStream CascadeStream stream,
const char *  pType = NULL,
u32  nOutputFlags = (kOutputFlagAnalog|kOutputFlagSPDIF)
[virtual]
 

queues a stream for playback

QueueStream() queues a stream for playback, returning a unique id for the queued stream. A major use of queueing is to queue a second stream before the first one is finished to allow seamless playback transitioning. NOTE: if the sample rate changes between streams, then a short delay will take place between streams.

Once a stream has finished playing back, it is removed from the queue. and OnPlaybackComplete() is called with the completion status.

From the time a stream is queued, it is owned by a distinct CascadeAudioPlayer thread and must not be used by the client outside of client notification functions until OnPlaybackEnd() is called at which point the ownership of the stream is returned to the client.

The client may optionally pass in a stream type into this function. If a stream type is passed in, the codec registered for that type will be used, if any. If no codec is found registered to that type, then playback will fail and your OnAudioPlaybackEnd() function will be called to return the stream to you immediately. If NULL or "" is passed in as the type, then auto-select will be engaged and CascadeAudioPlayer will quiz all registered codecs and if it finds one that can handle the stream (based on examination of stream data), it will use it.

The following values for pType are envisioned to be supported:

             NULL           - auto select the type if possible
             ""             - auto select the type if possible
             "MP3"          - an MP3 stream
             "AAC"          - an AAC stream
             "WAV"          - an uncompressed WAV stream
             "AIFF"         - an uncompressed AIFF stream

virtual bool CascadeAudioPlayer::Resume  )  [virtual]
 

resumes playback

Resume() resumes playback of a previously paused stream

Returns:
whether playback resumption succeeded

virtual bool CascadeAudioPlayer::SetVolume u16  nVolume  )  [virtual]
 

sets the playback volume

SetVolume() sets the output volume of audio playback. Legal values for nVolume are 0 - 0xFFFF which is a linear range of volume where 0 is no volume and 0xFFFF is full volume.

Parameters:
nVolume the volume to set
Returns:
whether the volume change succeeded

virtual bool CascadeAudioPlayer::SetVolumePercent u8  nVolume  )  [virtual]
 

sets the playback volume in percent, on a logarithmic scale

SetVolumePercent() sets the output volume of audio playback. Legal values for nVolume are 0 - 100, where 0 is -infinity dB, 1 is -30dB, and 100 is 0dB. The values in between 1 and 100 are on a logarithmic scale to be pleasant to human hearing.

Parameters:
nVolume the volume to set
Returns:
whether the volume change succeeded

virtual bool CascadeAudioPlayer::Stop  )  [virtual]
 

stops playback and purges all queued streams

Stop() stops playback immediately and removes any queued streams from the queue. No further notification functions are called.

Returns:
whether stopping succeeded


Friends And Related Function Documentation

friend class CascadePrivate::CascadeAudioPlayerInitializer [friend]
 


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:18 2005 for Cascade Library by  doxygen 1.4.1