diff options
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/CMakeLists.txt | 2 | ||||
-rw-r--r-- | intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 83 | ||||
-rw-r--r-- | intern/audaspace/OpenAL/AUD_OpenALDevice.h | 2 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_AnimateableProperty.cpp | 10 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 4 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_Sequencer.cpp | 3 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_Sequencer.h | 2 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_SequencerReader.cpp | 5 |
8 files changed, 57 insertions, 54 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 434928c5a2b..c0c77b6f917 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -97,7 +97,7 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::pause(bool keep) return false;} AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, boost::shared_ptr<AUD_IReader> reader, bool keep) : - m_isBuffered(false), m_reader(reader), m_keep(keep), m_format(format), m_current(0), m_bytepos(0), + m_isBuffered(false), m_reader(reader), m_keep(keep), m_format(format), m_current(0), m_eos(false), m_loopcount(0), m_stop(NULL), m_stop_data(NULL), m_status(AUD_STATUS_PLAYING), m_device(device) { @@ -208,8 +208,6 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::stop() if(!m_isBuffered) alDeleteBuffers(CYCLE_BUFFERS, m_buffers); - m_bytepos = 0; - for(AUD_HandleIterator it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++) { if(it->get() == this) @@ -271,61 +269,55 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position) alSourcef(m_source, AL_SEC_OFFSET, position); else { - int offset = (int)(position * m_reader->getSpecs().rate); - m_reader->seek(offset); + m_reader->seek((int)(position * m_reader->getSpecs().rate)); m_eos = false; ALint info; 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) + 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)); + + 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); - m_bytepos = offset; + if(alGetError() != AL_NO_ERROR) + break; } - alSourceRewind(m_source); - } - else { - m_bytepos = offset; + if(m_loopcount != 0) + m_eos = false; + + alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers); } + + alSourceRewind(m_source); } if(m_status == AUD_STATUS_STOPPED) @@ -350,8 +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_bytepos) / specs.rate; + position += (m_reader->getPosition() - m_device->m_buffersize * + queued) / (float)specs.rate; } return position; @@ -956,7 +954,6 @@ void AUD_OpenALDevice::updateStreams() // 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]); - sound->m_bytepos += length; ALenum err; if((err = alGetError()) != AL_NO_ERROR) { diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h index 142d482b7b0..f0e47824967 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h @@ -75,8 +75,6 @@ private: /// The first buffer to be read next. int m_current; - /// Amount of buffers already passed to OpenAL for processing. Used for proper timing - unsigned int m_bytepos; /// Whether the stream doesn't return any more data. bool m_eos; diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp index 9f399a0b99f..e0bc18ea520 100644 --- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp +++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp @@ -119,13 +119,11 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count) { m_unknown.push_back(Unknown(pos, position - 1)); + // if the buffer was not animated before, we copy the previous static value if(pos == 0) - { - for(int i = 0; i < position; i++) - memcpy(buf + i * m_count, data, m_count * sizeof(float)); - } - else - updateUnknownCache(pos, position - 1); + pos = 1; + + updateUnknownCache(pos, position - 1); } // otherwise it's not at the end, let's check if some unknown part got filled else 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_Sequencer.cpp b/intern/audaspace/intern/AUD_Sequencer.cpp index ddcf97e2ea1..a5b70232068 100644 --- a/intern/audaspace/intern/AUD_Sequencer.cpp +++ b/intern/audaspace/intern/AUD_Sequencer.cpp @@ -44,7 +44,8 @@ AUD_Sequencer::AUD_Sequencer(AUD_Specs specs, float fps, bool muted) : m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED), m_volume(1, 1.0f), m_location(3), - m_orientation(4) + m_orientation(4), + m_recursive(false) { AUD_Quaternion q; m_orientation.write(q.get()); diff --git a/intern/audaspace/intern/AUD_Sequencer.h b/intern/audaspace/intern/AUD_Sequencer.h index 1066eeae8e3..ef68efbbafc 100644 --- a/intern/audaspace/intern/AUD_Sequencer.h +++ b/intern/audaspace/intern/AUD_Sequencer.h @@ -201,6 +201,8 @@ public: * \param entry The entry to remove. */ void remove(boost::shared_ptr<AUD_SequencerEntry> entry); + + bool m_recursive; }; #endif //__AUD_SEQUENCER_H__ diff --git a/intern/audaspace/intern/AUD_SequencerReader.cpp b/intern/audaspace/intern/AUD_SequencerReader.cpp index aef93cd3896..b893b132fa3 100644 --- a/intern/audaspace/intern/AUD_SequencerReader.cpp +++ b/intern/audaspace/intern/AUD_SequencerReader.cpp @@ -78,6 +78,9 @@ AUD_Specs AUD_SequencerReader::getSpecs() const void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer) { + if (m_sequence->m_recursive) + return; + AUD_MutexLock lock(*m_sequence); if(m_sequence->m_status != m_status) @@ -192,7 +195,9 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer) v2 -= v; m_device.setListenerVelocity(v2 * m_sequence->m_fps); + m_sequence->m_recursive = true; m_device.read(reinterpret_cast<data_t*>(buffer + specs.channels * pos), len); + m_sequence->m_recursive = false; pos += len; time += float(len) / float(specs.rate); |