add get_null_sound()

This commit is contained in:
David Rose 2003-02-28 19:45:54 +00:00
parent 86ac9e99e0
commit f32b59b92d
3 changed files with 20 additions and 4 deletions

View File

@ -83,9 +83,23 @@ create_AudioManager() {
return am;
}
////////////////////////////////////////////////////////////////////
// Function: AudioManager::get_null_sound
// Access: Public
// Description: Returns a special NullAudioSound object that has all
// the interface of a normal sound object, but plays no
// sound. This same object may also be returned by
// get_sound() if it fails.
////////////////////////////////////////////////////////////////////
PT(AudioSound) AudioManager::
get_null_sound() {
if (_null_sound == (AudioSound *)NULL) {
_null_sound = new NullAudioSound;
}
return _null_sound;
}
void AudioManager::
set_mutually_exclusive(bool bExclusive) {
_bExclusive = bExclusive;
}

View File

@ -42,6 +42,7 @@ PUBLISHED:
// Get a sound:
virtual PT(AudioSound) get_sound(const string& file_name) = 0;
PT(AudioSound) get_null_sound();
// Tell the AudioManager there is no need to keep this one cached.
// This doesn't break any connection between AudioSounds that have
@ -83,6 +84,7 @@ public:
protected:
static Create_AudioManager_proc* _create_AudioManager;
bool _bExclusive;
PT(AudioSound) _null_sound;
AudioManager() {
// intentionally blank.

View File

@ -265,7 +265,7 @@ get_sound(const string& file_name) {
if(!is_valid()) {
audio_debug("invalid MilesAudioManager returning NullSound");
return new NullAudioSound();
return get_null_sound();
}
assert(is_valid());
@ -303,7 +303,7 @@ get_sound(const string& file_name) {
// The insert failed.
audio_debug(" failed map insert of "<<path);
assert(is_valid());
return 0;
return get_null_sound();
}
// Set si, so that we can get a reference to the path
// for the MilesAudioSound.