X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Faudio%2Fstream_sound_source.cpp;h=5a0172362c4669fbc300482e55c5dd9796ed0b4c;hb=6b0c80bde84af0bf9323320d99f2fccd7c9eeedd;hp=0cf75b234cab87b5dab71b73255155f7a1fc6577;hpb=c62711567861587107d124642db29e2674ee6533;p=supertux.git diff --git a/src/audio/stream_sound_source.cpp b/src/audio/stream_sound_source.cpp index 0cf75b234..5a0172362 100644 --- a/src/audio/stream_sound_source.cpp +++ b/src/audio/stream_sound_source.cpp @@ -33,10 +33,14 @@ StreamSoundSource::StreamSoundSource() { alGenBuffers(STREAMFRAGMENTS, buffers); SoundManager::check_al_error("Couldn't allocate audio buffers: "); + //add me to update list + sound_manager->register_for_update( this ); } StreamSoundSource::~StreamSoundSource() { + //don't update me any longer + sound_manager->remove_from_update( this ); delete file; stop(); alDeleteBuffers(STREAMFRAGMENTS, buffers); @@ -74,8 +78,8 @@ StreamSoundSource::update() if(!playing()) { if(processed == 0 || !looping) return; - - // we might have to restart the source if we had a buffer underrun + + // we might have to restart the source if we had a buffer underrun log_info << "Restarting audio source because of buffer underrun" << std::endl; play(); } @@ -128,14 +132,13 @@ StreamSoundSource::fillBufferAndQueue(ALuint buffer) if(bytesread > 0) { ALenum format = SoundManager::get_sample_format(file); alBufferData(buffer, format, bufferdata, bytesread, file->rate); - delete[] bufferdata; SoundManager::check_al_error("Couldn't refill audio buffer: "); alSourceQueueBuffers(source, 1, &buffer); SoundManager::check_al_error("Couldn't queue audio buffer: "); } + delete[] bufferdata; // return false if there aren't more buffers to fill return bytesread >= STREAMFRAGMENTSIZE; } -