diff options
author | Joerg Mueller <nexyon@gmail.com> | 2013-11-08 03:40:06 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2013-11-08 03:40:06 +0400 |
commit | 1457924a21cb0339b10866c4461f87a6f8c25ff8 (patch) | |
tree | b7a2cfc80e432f870fa59c9889cbc8f527064624 /intern/audaspace | |
parent | 106cff1b93b812e54eb375e24b1765e2a4f65eb4 (diff) |
Fix for [#37293] Audio does not Scrub, plays fully instead
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index 676a86e88fe..c3877c2c9f2 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -119,6 +119,14 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A { length = m_device->m_buffersize; reader->read(length, eos, m_device->m_buffer.getBuffer()); + + if(length == 0) + { + // AUD_XXX: TODO: don't fill all buffers and enqueue them later + length = 1; + memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs)); + } + alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(), length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate); @@ -132,8 +140,7 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A try { - alSourceQueueBuffers(m_source, CYCLE_BUFFERS, - m_buffers); + alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers); if(alGetError() != AL_NO_ERROR) AUD_THROW(AUD_ERROR_OPENAL, queue_error); } @@ -289,6 +296,14 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position) { length = m_device->m_buffersize; m_reader->read(length, m_eos, m_device->m_buffer.getBuffer()); + + if(length == 0) + { + // AUD_XXX: TODO: don't fill all buffers and enqueue them later + length = 1; + memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs)); + } + alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(), length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate); @@ -933,9 +948,8 @@ void AUD_OpenALDevice::updateStreams() break; } - // unqueue buffer - alSourceUnqueueBuffers(sound->m_source, 1, - &sound->m_buffers[sound->m_current]); + // unqueue buffer (warning: this might fail for slow early returning sources (none exist so far) if the buffer was not queued due to recent changes - has to be tested) + alSourceUnqueueBuffers(sound->m_source, 1, &sound->m_buffers[sound->m_current]); ALenum err; if((err = alGetError()) != AL_NO_ERROR) { |