Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <SoundPlay.h>
Inheritance diagram for SoundPlay:
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) | |
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 char *const | SPEAKER_LOCATOR = "PRM:/r1/c1/c2/c3/s1-Speaker:S1" |
ID for speaker in system. | |
const size_t | SOUND_NUM_BUFFER = 2 |
number of buffers to use |
|
constructor
Definition at line 26 of file SoundPlay.cc. References region, and SOUND_NUM_BUFFER. |
|
destructor
Definition at line 31 of file SoundPlay.h. |
|
called by system when time to free
Definition at line 90 of file SoundPlay.cc. References config, erouter, eventTranslatorQueueMemRgn, Config::sound_config::preload, SoundManager::ReleaseFile(), sndman, and Config::sound. |
|
called by system when time to do init
Definition at line 34 of file SoundPlay.cc. References config, erouter, SoundManager::InitAccess(), InitRegion(), SoundManager::LoadFile(), SoundManager::MAX_SND, NewSoundVectorData(), observer, OpenSpeaker(), Config::sound_config::preload, ProcessID::setID(), SetPowerAndVolume(), sndman, Config::sound, soundManagerMemRgn, ProcessID::SoundProcess, and subject. |
|
called to send sound buffer(s) to system
Definition at line 144 of file SoundPlay.cc. References active, SoundManager::CopyTo(), FindFreeRegion(), SoundManager::GetNumPlaying(), sndman, SOUND_NUM_BUFFER, and subject. |
|
called by system when time to start running
Definition at line 68 of file SoundPlay.cc. |
|
called by system when time to stop running
Definition at line 79 of file SoundPlay.cc. |
|
finds the first sound buffer which system isn't using (buffers are recycled)
Definition at line 244 of file SoundPlay.cc. References region, and SOUND_NUM_BUFFER. |
|
called by system when the queue for sending events to Main is being published
Definition at line 119 of file SoundPlay.cc. References EventRouter::addTrapper(), ASSERT, erouter, etrans, eventTranslatorQueueMemRgn, observer, and EventTranslator::setQueue(). |
|
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 131 of file SoundPlay.cc. References active, doSendSound(), SoundManager::GetNumPlaying(), observer, SoundManager::ReceivedMsg(), and sndman. |
|
inits each buffer Will round up size to the nearest page Definition at line 235 of file SoundPlay.cc. References ASSERT. |
|
sets up sound buffers
Definition at line 177 of file SoundPlay.cc. References config, region, Config::sound_config::sample_bits, Config::sound_config::sample_rate, Config::sound, SOUND_NUM_BUFFER, ERS210Info::SoundBufferTime, and speakerID. |
|
initializes speaker
Definition at line 169 of file SoundPlay.cc. References SPEAKER_LOCATOR, and speakerID. |
|
called by system when observers are ready to receive the SoundManager
Definition at line 108 of file SoundPlay.cc. References soundManagerMemRgn, and subject. |
|
called by system when it's ready for another sound buffer
Definition at line 101 of file SoundPlay.cc. References doSendSound(). |
|
sets volume to max
Definition at line 212 of file SoundPlay.cc. References config, Config::sound_config::sample_bits, Config::sound_config::sample_rate, Config::sound, and speakerID. |
|
number of active sound channels - if it's 0, we'll purposely starve system of sound buffers
Definition at line 58 of file SoundPlay.h. |
|
will be given all events created by SoundManager to be forwarded to Main
Definition at line 62 of file SoundPlay.h. |
|
Main creates, Motion (& SoundPlay) receive.
Definition at line 61 of file SoundPlay.h. |
|
array of observer IDs, used to identify what's ready
Definition at line 45 of file SoundPlay.h. |
|
holds references to shared regions holding sound clips
Definition at line 65 of file SoundPlay.h. |
|
number of buffers to use
Definition at line 56 of file SoundPlay.h. |
|
SoundPlay creates, Main & Motion receive - Shared region used by SoundManager.
Definition at line 60 of file SoundPlay.h. |
|
ID for speaker in system.
Definition at line 55 of file SoundPlay.h. |
|
ID returned to system after opening SPEAKER_LOCATOR.
Definition at line 64 of file SoundPlay.h. |
|
array of subject IDs, used to identify outgoing data
Definition at line 44 of file SoundPlay.h. |
Tekkotsu v1.4 |
Generated Sat Jul 19 00:09:11 2003 by Doxygen 1.3.2 |