Homepage Demos Overview Downloads Tutorials Reference
Credits

SoundPlay Class Reference

#include <SoundPlay.h>

Inheritance diagram for SoundPlay:

Inheritance graph
[legend]
List of all members.

Detailed Description

The process (a.k.a. OObject), which is responsible for sending sound buffers to the system to play.

This sound process will purposely starve the system of sound buffers when nothing is playing, both to eliminate needless zeroing of entire buffers, as well as to reduce system overhead of playing empty buffers.

If you want to know how to play sounds, you should be looking at SoundManager's documentation.

Basically a slightly modified version of the SoundPlay example code from Sony. Here's their license: Copyright 2002,2003 Sony Corporation

Permission to use, copy, modify, and redistribute this software for non-commercial use is hereby granted.

This software is provided "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of fitness for a particular purpose.

Definition at line 28 of file SoundPlay.h.

Public Member Functions

 SoundPlay ()
 constructor
virtual ~SoundPlay ()
 destructor
virtual OStatus DoInit (const OSystemEvent &event)
 called by system when time to do init
virtual OStatus DoStart (const OSystemEvent &event)
 called by system when time to start running
virtual OStatus DoStop (const OSystemEvent &event)
 called by system when time to stop running
virtual OStatus DoDestroy (const OSystemEvent &event)
 called by system when time to free
void ReadySendSound (const OReadyEvent &event)
 called by system when it's ready for another sound buffer
void ReadyRegisterSoundManager (const OReadyEvent &event)
 called by system when observers are ready to receive the SoundManager
void GotEventTranslatorQueue (const ONotifyEvent &event)
 called by system when the queue for sending events to Main is being published
void GotSoundMsg (const ONotifyEvent &event)
 called by system when SoundManager has sent itself a message on a different process (either to add or remove sounds from memory)

Public Attributes

OSubject * subject [numOfSubject]
 array of subject IDs, used to identify outgoing data
OObserver * observer [numOfObserver]
 array of observer IDs, used to identify what's ready

Private Member Functions

void doSendSound ()
 called to send sound buffer(s) to system
void OpenSpeaker ()
 initializes speaker
void NewSoundVectorData ()
 sets up sound buffers
void SetPowerAndVolume ()
 sets volume to max
RCRegion * InitRegion (unsigned int size)
 inits each buffer
RCRegion * FindFreeRegion ()
 finds the first sound buffer which system isn't using (buffers are recycled)
 SoundPlay (const SoundPlay &)
 don't call
SoundPlayoperator= (const SoundPlay &)
 don't call

Private Attributes

unsigned int active
 number of active sound channels - if it's 0, we'll purposely starve system of sound buffers
RCRegion * soundManagerMemRgn
 SoundPlay creates, Main & Motion receive - Shared region used by SoundManager.
RCRegion * eventTranslatorQueueMemRgn
 Main creates, Motion (& SoundPlay) receive.
EventTranslator etrans
 will be given all events created by SoundManager to be forwarded to Main
OPrimitiveID speakerID
 ID returned to system after opening SPEAKER_LOCATOR.
RCRegion * region [SOUND_NUM_BUFFER]
 holds references to shared regions holding sound clips

Static Private Attributes

const size_t SOUND_NUM_BUFFER = 2
 number of buffers to use


Constructor & Destructor Documentation

SoundPlay::SoundPlay  ) 
 

constructor

Definition at line 27 of file SoundPlay.cc.

virtual SoundPlay::~SoundPlay  )  [inline, virtual]
 

destructor

Definition at line 31 of file SoundPlay.h.

SoundPlay::SoundPlay const SoundPlay  )  [private]
 

don't call


Member Function Documentation

OStatus SoundPlay::DoDestroy const OSystemEvent &  event  )  [virtual]
 

called by system when time to free

Definition at line 93 of file SoundPlay.cc.

OStatus SoundPlay::DoInit const OSystemEvent &  event  )  [virtual]
 

called by system when time to do init

Definition at line 35 of file SoundPlay.cc.

void SoundPlay::doSendSound  )  [private]
 

called to send sound buffer(s) to system

Definition at line 147 of file SoundPlay.cc.

Referenced by GotSoundMsg(), and ReadySendSound().

OStatus SoundPlay::DoStart const OSystemEvent &  event  )  [virtual]
 

called by system when time to start running

Definition at line 69 of file SoundPlay.cc.

OStatus SoundPlay::DoStop const OSystemEvent &  event  )  [virtual]
 

called by system when time to stop running

Definition at line 80 of file SoundPlay.cc.

RCRegion * SoundPlay::FindFreeRegion  )  [private]
 

finds the first sound buffer which system isn't using (buffers are recycled)

Definition at line 247 of file SoundPlay.cc.

Referenced by doSendSound().

void SoundPlay::GotEventTranslatorQueue const ONotifyEvent &  event  ) 
 

called by system when the queue for sending events to Main is being published

Definition at line 122 of file SoundPlay.cc.

void SoundPlay::GotSoundMsg const ONotifyEvent &  event  ) 
 

called by system when SoundManager has sent itself a message on a different process (either to add or remove sounds from memory)

Definition at line 134 of file SoundPlay.cc.

RCRegion * SoundPlay::InitRegion unsigned int  size  )  [private]
 

inits each buffer

Will round up size to the nearest page

Definition at line 238 of file SoundPlay.cc.

Referenced by DoInit().

void SoundPlay::NewSoundVectorData  )  [private]
 

sets up sound buffers

Definition at line 180 of file SoundPlay.cc.

Referenced by DoInit().

void SoundPlay::OpenSpeaker  )  [private]
 

initializes speaker

Definition at line 172 of file SoundPlay.cc.

Referenced by DoInit().

SoundPlay& SoundPlay::operator= const SoundPlay  )  [private]
 

don't call

void SoundPlay::ReadyRegisterSoundManager const OReadyEvent &  event  ) 
 

called by system when observers are ready to receive the SoundManager

Definition at line 111 of file SoundPlay.cc.

void SoundPlay::ReadySendSound const OReadyEvent &  event  ) 
 

called by system when it's ready for another sound buffer

Definition at line 104 of file SoundPlay.cc.

void SoundPlay::SetPowerAndVolume  )  [private]
 

sets volume to max

Definition at line 215 of file SoundPlay.cc.

Referenced by DoInit().


Member Data Documentation

unsigned int SoundPlay::active [private]
 

number of active sound channels - if it's 0, we'll purposely starve system of sound buffers

Definition at line 57 of file SoundPlay.h.

Referenced by doSendSound(), and GotSoundMsg().

EventTranslator SoundPlay::etrans [private]
 

will be given all events created by SoundManager to be forwarded to Main

Definition at line 61 of file SoundPlay.h.

Referenced by GotEventTranslatorQueue().

RCRegion* SoundPlay::eventTranslatorQueueMemRgn [private]
 

Main creates, Motion (& SoundPlay) receive.

Definition at line 60 of file SoundPlay.h.

Referenced by DoDestroy(), and GotEventTranslatorQueue().

OObserver* SoundPlay::observer[numOfObserver]
 

array of observer IDs, used to identify what's ready

Definition at line 45 of file SoundPlay.h.

Referenced by DoInit(), GotEventTranslatorQueue(), and GotSoundMsg().

RCRegion* SoundPlay::region[SOUND_NUM_BUFFER] [private]
 

holds references to shared regions holding sound clips

Definition at line 64 of file SoundPlay.h.

const size_t SoundPlay::SOUND_NUM_BUFFER = 2 [static, private]
 

number of buffers to use

Definition at line 55 of file SoundPlay.h.

Referenced by doSendSound().

RCRegion* SoundPlay::soundManagerMemRgn [private]
 

SoundPlay creates, Main & Motion receive - Shared region used by SoundManager.

Definition at line 59 of file SoundPlay.h.

Referenced by DoInit(), and ReadyRegisterSoundManager().

OPrimitiveID SoundPlay::speakerID [private]
 

ID returned to system after opening SPEAKER_LOCATOR.

Definition at line 63 of file SoundPlay.h.

Referenced by NewSoundVectorData(), OpenSpeaker(), and SetPowerAndVolume().

OSubject* SoundPlay::subject[numOfSubject]
 

array of subject IDs, used to identify outgoing data

Definition at line 44 of file SoundPlay.h.

Referenced by DoInit(), doSendSound(), and ReadyRegisterSoundManager().


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

Tekkotsu v2.2.1
Generated Tue Nov 23 16:37:52 2004 by Doxygen 1.3.9.1