From 13249b925eda7752b65a36d8270a3af3bdc02981 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 9 Aug 2011 08:38:14 +0000 Subject: 3D Audio GSoC: Speaker objects fully functional! Minor changes: * Fixed three memory bugs found via valgrind. * Fixed bug with jack transport crashing after file loading. * Sound NLA Strips now start at CFRA instead of 0. --- intern/audaspace/FX/AUD_DoubleReader.cpp | 2 +- intern/audaspace/FX/AUD_SuperposeReader.cpp | 2 +- intern/audaspace/intern/AUD_AnimateableProperty.cpp | 20 +++++++------------- intern/audaspace/intern/AUD_LinearResampleReader.cpp | 2 +- intern/audaspace/intern/AUD_ReadDevice.cpp | 2 +- intern/audaspace/intern/AUD_Space.h | 2 ++ 6 files changed, 13 insertions(+), 17 deletions(-) (limited to 'intern') diff --git a/intern/audaspace/FX/AUD_DoubleReader.cpp b/intern/audaspace/FX/AUD_DoubleReader.cpp index e9882743d28..178240fa23b 100644 --- a/intern/audaspace/FX/AUD_DoubleReader.cpp +++ b/intern/audaspace/FX/AUD_DoubleReader.cpp @@ -97,7 +97,7 @@ void AUD_DoubleReader::read(int& length, bool& eos, sample_t* buffer) AUD_Specs specs1, specs2; specs1 = m_reader1->getSpecs(); specs2 = m_reader2->getSpecs(); - if(memcmp(&specs1, &specs2, sizeof(AUD_Specs))) + if(AUD_COMPARE_SPECS(specs1, specs2)) length = len; else { diff --git a/intern/audaspace/FX/AUD_SuperposeReader.cpp b/intern/audaspace/FX/AUD_SuperposeReader.cpp index a0dc12fea96..b332a854a5d 100644 --- a/intern/audaspace/FX/AUD_SuperposeReader.cpp +++ b/intern/audaspace/FX/AUD_SuperposeReader.cpp @@ -81,7 +81,7 @@ void AUD_SuperposeReader::read(int& length, bool& eos, sample_t* buffer) { AUD_Specs specs = m_reader1->getSpecs(); AUD_Specs s2 = m_reader2->getSpecs(); - if(memcmp(&specs, &s2, sizeof(AUD_Specs))) + if(AUD_COMPARE_SPECS(specs, s2)) AUD_THROW(AUD_ERROR_SPECS, specs_error); int samplesize = AUD_SAMPLE_SIZE(specs); diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp index 03d2d3a5ea1..adc71928efd 100644 --- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp +++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp @@ -105,10 +105,10 @@ void AUD_AnimateableProperty::read(float position, float* out) return; } - float last = (getSize() / (sizeof(float) * m_count) - 1); + int last = getSize() / (sizeof(float) * m_count) - 1; float t = position - floor(position); - if(position > last) + if(position >= last) { position = last; t = 0; @@ -128,24 +128,18 @@ void AUD_AnimateableProperty::read(float position, float* out) float* p1 = getBuffer() + pos; float* p2; float* p3; + last *= m_count; if(pos == 0) p0 = p1; else p0 = p1 - m_count; - if(pos > last) - { - p3 = p2 = p1; - } + p2 = p1 + m_count; + if(pos + m_count == last) + p3 = p2; else - { - p2 = p1 + m_count; - if(pos + m_count > last) - p3 = p2; - else - p3 = p2 + m_count; - } + p3 = p2 + m_count; for(int i = 0; i < m_count; i++) { diff --git a/intern/audaspace/intern/AUD_LinearResampleReader.cpp b/intern/audaspace/intern/AUD_LinearResampleReader.cpp index 96add9bca4d..599be29f1d7 100644 --- a/intern/audaspace/intern/AUD_LinearResampleReader.cpp +++ b/intern/audaspace/intern/AUD_LinearResampleReader.cpp @@ -82,7 +82,7 @@ void AUD_LinearResampleReader::read(int& length, bool& eos, sample_t* buffer) int samplesize = AUD_SAMPLE_SIZE(specs); int size = length; - float factor = float(m_rate) / float(m_reader->getSpecs().rate); + float factor = m_rate / m_reader->getSpecs().rate; float spos; sample_t low, high; eos = false; diff --git a/intern/audaspace/intern/AUD_ReadDevice.cpp b/intern/audaspace/intern/AUD_ReadDevice.cpp index 24e92d22038..a1495b31ed0 100644 --- a/intern/audaspace/intern/AUD_ReadDevice.cpp +++ b/intern/audaspace/intern/AUD_ReadDevice.cpp @@ -70,7 +70,7 @@ bool AUD_ReadDevice::read(data_t* buffer, int length) void AUD_ReadDevice::changeSpecs(AUD_Specs specs) { - if(memcmp(&specs, &m_specs.specs, sizeof(specs))) + if(AUD_COMPARE_SPECS(specs, m_specs.specs)) setSpecs(specs); } diff --git a/intern/audaspace/intern/AUD_Space.h b/intern/audaspace/intern/AUD_Space.h index 4d0a06e37b2..9232864995b 100644 --- a/intern/audaspace/intern/AUD_Space.h +++ b/intern/audaspace/intern/AUD_Space.h @@ -41,6 +41,8 @@ /// Throws a AUD_Exception with the provided error code. #define AUD_THROW(exception, errorstr) { AUD_Exception e; e.error = exception; e.str = errorstr; throw e; } +#define AUD_COMPARE_SPECS(s1, s2) ((s1.rate == s2.rate) && (s1.channels == s2.channels)) + /// Returns the bit for a channel mask. #define AUD_CHANNEL_BIT(channel) (0x01 << channel) -- cgit v1.2.3