openal: Always use release_sound_data

This simplifies cleanup() a little bit.
This commit is contained in:
Sam Edwards 2018-03-02 00:53:10 -07:00
parent 9a5d7d8254
commit a10cd7d8bb
3 changed files with 13 additions and 7 deletions

View File

@ -55,10 +55,17 @@ require_sound_data() {
/**
* Checks if the sound data record is present and releasable, and if so,
* releases it.
*
* The sound data is "releasable" if it's from an ordinary, local file. Remote
* streams cannot necessarily be reopened if lost, so we'll hold onto them if
* so. The `force` argument overrides this, indicating we don't intend to
* reacquire the sound data.
*/
void OpenALAudioSound::
release_sound_data() {
if ((_sd!=0) && (!_movie->get_filename().empty())) {
release_sound_data(bool force) {
if (!has_sound_data()) return;
if (force || !_movie->get_filename().empty()) {
_manager->decrement_client_count(_sd);
_sd = 0;
}

View File

@ -80,7 +80,7 @@ OpenALAudioSound(OpenALAudioManager* manager,
audio_warning("stereo sound " << movie->get_filename() << " will not be spatialized");
}
}
release_sound_data();
release_sound_data(false);
}
@ -106,8 +106,7 @@ cleanup() {
stop();
}
if (has_sound_data()) {
_manager->decrement_client_count(_sd);
_sd = 0;
release_sound_data(true);
}
_manager->release_sound(this);
_manager = 0;
@ -219,7 +218,7 @@ stop() {
}
_manager->stopping_sound(this);
release_sound_data();
release_sound_data(false);
}
/**

View File

@ -117,7 +117,7 @@ private:
void pull_used_buffers();
void push_fresh_buffers();
INLINE bool require_sound_data();
INLINE void release_sound_data();
INLINE void release_sound_data(bool force);
INLINE bool is_valid() const;
INLINE bool is_playing() const;