3D Audio GSoC:

* Fixed a warning in AUD_DoubleReader.cpp
* Removed some unneeded includes
* Fixed a bug resulting in a crash when stopping a sound
* Fixed a bug where a NaN resulted in a horrible memory error
* Fixed a typo bug which caused crackling in audio playback and export
* Added memory debugging code (ifdefed)
This commit is contained in:
Joerg Mueller 2011-07-13 12:16:45 +00:00
parent fa78d3271f
commit f12614234a
7 changed files with 48 additions and 16 deletions

@ -33,9 +33,6 @@
#include <cstring>
static const char* specs_error = "AUD_DoubleReader: Both readers have to have "
"the same specs.";
AUD_DoubleReader::AUD_DoubleReader(AUD_Reference<AUD_IReader> reader1,
AUD_Reference<AUD_IReader> reader2) :
m_reader1(reader1), m_reader2(reader2), m_finished1(false)

@ -32,8 +32,6 @@
#include "AUD_LimiterReader.h"
#include "AUD_Buffer.h"
#include <iostream>
AUD_LimiterReader::AUD_LimiterReader(AUD_Reference<AUD_IReader> reader,
float start, float end) :
AUD_EffectReader(reader),

@ -178,10 +178,14 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::stop()
m_device->lock();
// AUD_XXX Create a reference of our own object so that it doesn't get
// deleted before the end of this function
AUD_Reference<AUD_OpenALHandle> This = this;
if(m_status == AUD_STATUS_PLAYING)
m_device->m_playingSounds.remove(this);
m_device->m_playingSounds.remove(This);
else
m_device->m_pausedSounds.remove(this);
m_device->m_pausedSounds.remove(This);
m_device->unlock();

@ -60,6 +60,8 @@ void AUD_ChannelMapperReader::setChannels(AUD_Channels channels)
void AUD_ChannelMapperReader::setMonoAngle(float angle)
{
if(std::isnan(angle))
angle = 0;
m_mono_angle = angle;
if(m_source_channels == AUD_CHANNELS_MONO)
calculateMapping();
@ -75,8 +77,6 @@ float AUD_ChannelMapperReader::angleDistance(float alpha, float beta)
return alpha;
}
#include <iostream>
void AUD_ChannelMapperReader::calculateMapping()
{
if(m_map_size < m_source_channels * m_target_channels)
@ -127,6 +127,8 @@ void AUD_ChannelMapperReader::calculateMapping()
for(int j = 0; j < m_target_channels; j++)
{
if(j == lfe)
continue;
angle = angleDistance(source_angles[i], target_angles[j]);
if(angle < angle_min1)
{

@ -92,7 +92,7 @@ void AUD_Mixer::mix(sample_t* buffer, int start, int length, float volume)
sample_t* out = m_buffer.getBuffer();
length = (AUD_MIN(m_length, length + start) - start) * m_specs.channels;
start += m_specs.channels;
start *= m_specs.channels;
for(int i = 0; i < length; i++)
out[i + start] += buffer[i] * volume;

@ -33,6 +33,11 @@
#include <map>
#ifdef MEM_DEBUG
#include <iostream>
#include <typeinfo>
#endif
class AUD_ReferenceHandler
{
private:
@ -88,6 +93,10 @@ public:
{
m_original = m_reference = reference;
AUD_ReferenceHandler::incref(reference);
#ifdef MEM_DEBUG
if(m_reference != 0)
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
}
/**
@ -98,6 +107,10 @@ public:
{
m_original = m_reference = ref.m_reference;
AUD_ReferenceHandler::incref(m_reference);
#ifdef MEM_DEBUG
if(m_reference != 0)
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
}
template <class U>
@ -106,6 +119,10 @@ public:
m_original = ref.get();
m_reference = dynamic_cast<T*>(ref.get());
AUD_ReferenceHandler::incref(m_original);
#ifdef MEM_DEBUG
if(m_reference != 0)
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
}
/**
@ -114,6 +131,10 @@ public:
*/
~AUD_Reference()
{
#ifdef MEM_DEBUG
if(m_reference != 0)
std::cerr << "-" << typeid(*m_reference).name() << std::endl;
#endif
if(AUD_ReferenceHandler::decref(m_original))
delete m_reference;
}
@ -127,12 +148,20 @@ public:
if(&ref == this)
return *this;
#ifdef MEM_DEBUG
if(m_reference != 0)
std::cerr << "-" << typeid(*m_reference).name() << std::endl;
#endif
if(AUD_ReferenceHandler::decref(m_original))
delete m_reference;
m_original = ref.m_original;
m_reference = ref.m_reference;
AUD_ReferenceHandler::incref(m_original);
#ifdef MEM_DEBUG
if(m_reference != 0)
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
return *this;
}

@ -65,8 +65,6 @@ AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* d
{
}
#include <iostream>
void AUD_SoftwareDevice::AUD_SoftwareHandle::update()
{
int flags = 0;
@ -170,7 +168,7 @@ void AUD_SoftwareDevice::AUD_SoftwareHandle::update()
{
AUD_Vector3 SZ = m_orientation.getLookAt();
float phi = acos(SZ * SL / (SZ.length() * SL.length()));
float phi = acos(float(SZ * SL / (SZ.length() * SL.length())));
float t = (phi - m_cone_angle_inner)/(m_cone_angle_outer - m_cone_angle_inner);
if(t > 0)
@ -202,7 +200,7 @@ void AUD_SoftwareDevice::AUD_SoftwareHandle::update()
if(Asquare > 0)
{
float phi = acos(Z * A/ (Z.length() * sqrt(Asquare)));
float phi = acos(float(Z * A / (Z.length() * sqrt(Asquare))));
if(N.cross(Z) * A > 0)
phi = -phi;
@ -268,15 +266,19 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::stop()
m_device->lock();
// AUD_XXX Create a reference of our own object so that it doesn't get
// deleted before the end of this function
AUD_Reference<AUD_SoftwareHandle> This = this;
if(m_status == AUD_STATUS_PLAYING)
{
m_device->m_playingSounds.remove(this);
m_device->m_playingSounds.remove(This);
if(m_device->m_playingSounds.empty())
m_device->playing(m_device->m_playback = false);
}
else
m_device->m_pausedSounds.remove(this);
m_device->m_pausedSounds.remove(This);
m_device->unlock();
m_status = AUD_STATUS_INVALID;