Game Development Reference
In-Depth Information
command &= 7FFFFFFF;
sleepUntilGameTimeMatchesLoggedTime(game_time);
switch ( command )
{
case ( CMD_SND_PLAY ):
{
// Process play command.
LogDataForPlayingASound * log =
(LogDataForPlayingASound*)data;
SoundEvent * event = EventDatabase::getEvent(
data->m_event_name );
unsigned int old_inst = log->m_instance_id;
SoundInstance * new_inst =
SoundSystem::playSound( event,
log->m_params,
log->m_owner_id,
true );
createNewInstanceMapping( new_inst, old_inst );
break;
}
case ( CMD_SND_STOP ):
{
// Process stop command.
SoundInstance * inst = findMappedSoundInstance(
(LogDataForStop*)data );
SoundSystem::StopSound( inst, true );
break;
}
....
// Handle other commands.
}
}
Listing 11.11. Pseudocode sample of reading and executing the command.
11.2.4 Streaming Monitor
An increasing problem faced by audio designers is that there are several game
systems, aside from audio, which need to stream data from the same storage me-
dia. On a device such as a DVD, which has limited streaming bandwidth and
long file access times, we can experience delays before an audio sample starts play-
ing. Worse problems occur if a file cannot be serviced frequently enough by the
storage device. This leads to choppy audio playback due to the audio buffer not
storing a sucient amount of data to play while the next part of the file is being
read.
A solution to this problem is to develop a streaming monitor. The purpose
of the streaming monitor is to help organize data so that we can optimally use
our storage media. This tool will also help us to debug in-game situations where
Search WWH ::




Custom Search