openal: Add cleanup guards to buffer functions

Without this, the audio might encounter an error, call cleanup()
on itself, and (if in the middle of update()) try to dereference
its recently cleaned-up _sd pointer.

Fixes #230
This commit is contained in:
Sam Edwards 2018-03-01 20:37:39 -07:00
parent 6ca0a68042
commit fd5ce687b3

View File

@ -434,6 +434,7 @@ correct_calibrated_clock(double rtc, double t) {
void OpenALAudioSound::
pull_used_buffers() {
ReMutexHolder holder(OpenALAudioManager::_lock);
if (_manager == 0) return;
while (_stream_queued.size()) {
ALuint buffer = 0;
ALint num_buffers = 0;
@ -489,6 +490,8 @@ push_fresh_buffers() {
ReMutexHolder holder(OpenALAudioManager::_lock);
static unsigned char data[65536];
if (_manager == 0) return;
if (_sd->_sample) {
while ((_loops_completed < _playing_loops) &&
(_stream_queued.size() < 100)) {