diff options
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/CMakeLists.txt | 2 | ||||
-rw-r--r-- | intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 70 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 4 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_ConverterFunctions.h | 9 |
4 files changed, 41 insertions, 44 deletions
diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index 21a42553935..5b810493663 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -19,6 +19,8 @@ # # ***** END LGPL LICENSE BLOCK ***** +remove_extra_strict_flags() + set(INC . FX diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index d055c131183..c0c77b6f917 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -276,49 +276,48 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position) alGetSourcei(m_source, AL_SOURCE_STATE, &info); - if(info != AL_PLAYING) - { - if(info == AL_PAUSED) - alSourceStop(m_source); + // we need to stop playing sounds as well to clear the buffers + // this might cause clicks, but fixes a bug regarding position determination + if(info == AL_PAUSED || info == AL_PLAYING) + alSourceStop(m_source); + + alSourcei(m_source, AL_BUFFER, 0); + m_current = 0; - alSourcei(m_source, AL_BUFFER, 0); - m_current = 0; + ALenum err; + if((err = alGetError()) == AL_NO_ERROR) + { + int length; + AUD_DeviceSpecs specs = m_device->m_specs; + specs.specs = m_reader->getSpecs(); + m_device->m_buffer.assureSize(m_device->m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs)); - ALenum err; - if((err = alGetError()) == AL_NO_ERROR) + for(int i = 0; i < CYCLE_BUFFERS; i++) { - int length; - AUD_DeviceSpecs specs = m_device->m_specs; - specs.specs = m_reader->getSpecs(); - m_device->m_buffer.assureSize(m_device->m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs)); + length = m_device->m_buffersize; + m_reader->read(length, m_eos, m_device->m_buffer.getBuffer()); - for(int i = 0; i < CYCLE_BUFFERS; i++) + if(length == 0) { - 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); - - if(alGetError() != AL_NO_ERROR) - break; + // 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)); } - if(m_loopcount != 0) - m_eos = false; + alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(), + length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate); - alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers); + if(alGetError() != AL_NO_ERROR) + break; } - alSourceRewind(m_source); + if(m_loopcount != 0) + m_eos = false; + + alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers); } + + alSourceRewind(m_source); } if(m_status == AUD_STATUS_STOPPED) @@ -343,9 +342,14 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getPosition() if(!m_isBuffered) { + int queued; + + // this usually always returns CYCLE_BUFFERS + alGetSourcei(m_source, AL_BUFFERS_QUEUED, &queued); + AUD_Specs specs = m_reader->getSpecs(); position += (m_reader->getPosition() - m_device->m_buffersize * - CYCLE_BUFFERS) / (float)specs.rate; + queued) / (float)specs.rate; } return position; diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index 45d72ccb50e..78b9279a54a 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -222,7 +222,7 @@ static PyMethodDef meth_getcdevice[] = { }; extern "C" { -extern void *sound_get_factory(void *sound); +extern void *BKE_sound_get_factory(void *sound); } static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args) @@ -231,7 +231,7 @@ static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args) if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) { if (lptr) { - boost::shared_ptr<AUD_IFactory>* factory = (boost::shared_ptr<AUD_IFactory>*) sound_get_factory((void *) lptr); + boost::shared_ptr<AUD_IFactory>* factory = (boost::shared_ptr<AUD_IFactory>*) BKE_sound_get_factory((void *) lptr); if (factory) { Factory *obj = (Factory *)Factory_empty(); diff --git a/intern/audaspace/intern/AUD_ConverterFunctions.h b/intern/audaspace/intern/AUD_ConverterFunctions.h index 7817ee88c07..eca2b327b8c 100644 --- a/intern/audaspace/intern/AUD_ConverterFunctions.h +++ b/intern/audaspace/intern/AUD_ConverterFunctions.h @@ -33,16 +33,7 @@ #include "AUD_Space.h" #include <cstring> -#ifdef _MSC_VER -#if (_MSC_VER <= 1500) - typedef short int16_t; - typedef int int32_t; -#else -# include <stdint.h> -#endif -#else #include <stdint.h> -#endif typedef void (*AUD_convert_f)(data_t* target, data_t* source, int length); |