Game Development Reference
In-Depth Information
Listing 7-9. Fatal Error Handler
public void OnFatalError(final String text) {
mHandler.post(new Runnable() {
public void run() {
MessageBox("Fatal Error",
text + " - Please report this error.");
}
});
// Wait for the user to read the box
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
}
// Must quit here or the LIB will crash
DoomTools.hardExit(-1);
}
Audio Request Handlers
The native Doom engine cannot access the sound device directly. This is due to the nonstandard audio
library used by Android (Enhanced Audio System, EAS, by SoniVOX). To overcome this very serious
limitation, audio requests are cascaded back to these handlers, which start sound events at a given
volume, start and stop background music events, and set the background music.
Listing 7-10 shows the audio handlers for Doom. Note that all requests are delegated to the
doom.audio.AudioManager class, which deals with the Android audio system.
Listing 7-10. Sound and Music Handlers
public void OnStartSound(String name, int vol)
{
if ( mSound && mAudioMgr == null)
Log.e(TAG, "Bug: Audio Mgr is NULL but sound is enabled!");
try {
if ( mSound && mAudioMgr != null)
mAudioMgr.startSound( name, vol);
} catch (Exception e) {
Log.e(TAG, "OnStartSound: " + e.toString());
}
}
/**
* Fires on background music
*/
public void OnStartMusic(String name, int loop) {
if ( mSound && mAudioMgr != null)
Search WWH ::




Custom Search