Audaspace:
RAII locking implementation. This should fix bug [#32096] Background music stops when playing 3D sounds.
This commit is contained in:
@@ -94,6 +94,7 @@ set(SRC
|
|||||||
intern/AUD_IDevice.h
|
intern/AUD_IDevice.h
|
||||||
intern/AUD_IFactory.h
|
intern/AUD_IFactory.h
|
||||||
intern/AUD_IHandle.h
|
intern/AUD_IHandle.h
|
||||||
|
intern/AUD_ILockable.h
|
||||||
intern/AUD_IReader.h
|
intern/AUD_IReader.h
|
||||||
intern/AUD_IWriter.h
|
intern/AUD_IWriter.h
|
||||||
intern/AUD_JOSResampleFactory.cpp
|
intern/AUD_JOSResampleFactory.cpp
|
||||||
@@ -108,6 +109,7 @@ set(SRC
|
|||||||
intern/AUD_Mixer.h
|
intern/AUD_Mixer.h
|
||||||
intern/AUD_MixerFactory.cpp
|
intern/AUD_MixerFactory.cpp
|
||||||
intern/AUD_MixerFactory.h
|
intern/AUD_MixerFactory.h
|
||||||
|
intern/AUD_MutexLock.h
|
||||||
intern/AUD_NULLDevice.cpp
|
intern/AUD_NULLDevice.cpp
|
||||||
intern/AUD_NULLDevice.h
|
intern/AUD_NULLDevice.h
|
||||||
intern/AUD_PyInit.h
|
intern/AUD_PyInit.h
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "AUD_IFactory.h"
|
#include "AUD_IFactory.h"
|
||||||
#include "AUD_IReader.h"
|
#include "AUD_IReader.h"
|
||||||
#include "AUD_ConverterReader.h"
|
#include "AUD_ConverterReader.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -125,7 +126,7 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::pause()
|
|||||||
{
|
{
|
||||||
if(m_status)
|
if(m_status)
|
||||||
{
|
{
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(m_status == AUD_STATUS_PLAYING)
|
if(m_status == AUD_STATUS_PLAYING)
|
||||||
{
|
{
|
||||||
@@ -135,12 +136,9 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::pause()
|
|||||||
alSourcePause(m_source);
|
alSourcePause(m_source);
|
||||||
|
|
||||||
m_status = AUD_STATUS_PAUSED;
|
m_status = AUD_STATUS_PAUSED;
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -150,7 +148,7 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::resume()
|
|||||||
{
|
{
|
||||||
if(m_status)
|
if(m_status)
|
||||||
{
|
{
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(m_status == AUD_STATUS_PAUSED)
|
if(m_status == AUD_STATUS_PAUSED)
|
||||||
{
|
{
|
||||||
@@ -159,11 +157,8 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::resume()
|
|||||||
|
|
||||||
m_device->start();
|
m_device->start();
|
||||||
m_status = AUD_STATUS_PLAYING;
|
m_status = AUD_STATUS_PLAYING;
|
||||||
m_device->unlock();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -174,7 +169,10 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::stop()
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
// AUD_XXX Create a reference of our own object so that it doesn't get
|
// AUD_XXX Create a reference of our own object so that it doesn't get
|
||||||
// deleted before the end of this function
|
// deleted before the end of this function
|
||||||
@@ -185,8 +183,6 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::stop()
|
|||||||
else
|
else
|
||||||
m_device->m_pausedSounds.remove(This);
|
m_device->m_pausedSounds.remove(This);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
alDeleteSources(1, &m_source);
|
alDeleteSources(1, &m_source);
|
||||||
if(!m_isBuffered)
|
if(!m_isBuffered)
|
||||||
alDeleteBuffers(CYCLE_BUFFERS, m_buffers);
|
alDeleteBuffers(CYCLE_BUFFERS, m_buffers);
|
||||||
@@ -208,12 +204,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setKeep(bool keep)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_keep = keep;
|
m_keep = keep;
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +219,10 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(m_isBuffered)
|
if(m_isBuffered)
|
||||||
alSourcef(m_source, AL_SEC_OFFSET, position);
|
alSourcef(m_source, AL_SEC_OFFSET, position);
|
||||||
@@ -272,17 +272,18 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_OpenALDevice::AUD_OpenALHandle::getPosition()
|
float AUD_OpenALDevice::AUD_OpenALHandle::getPosition()
|
||||||
{
|
{
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return 0.0f;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
float position = 0.0f;
|
float position = 0.0f;
|
||||||
|
|
||||||
@@ -295,8 +296,6 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getPosition()
|
|||||||
CYCLE_BUFFERS) / (float)specs.rate;
|
CYCLE_BUFFERS) / (float)specs.rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,15 +308,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getVolume()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_GAIN, &result);
|
alGetSourcef(m_source, AL_GAIN, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,12 +326,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setVolume(float volume)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_GAIN, volume);
|
alSourcef(m_source, AL_GAIN, volume);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,15 +340,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getPitch()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_PITCH, &result);
|
alGetSourcef(m_source, AL_PITCH, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,12 +358,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setPitch(float pitch)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_PITCH, pitch);
|
alSourcef(m_source, AL_PITCH, pitch);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,13 +388,14 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setStopCallback(stopCallback callback,
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_stop = callback;
|
m_stop = callback;
|
||||||
m_stop_data = data;
|
m_stop_data = data;
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,15 +408,16 @@ AUD_Vector3 AUD_OpenALDevice::AUD_OpenALHandle::getSourceLocation()
|
|||||||
AUD_Vector3 result = AUD_Vector3(0, 0, 0);
|
AUD_Vector3 result = AUD_Vector3(0, 0, 0);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return result;
|
||||||
|
|
||||||
ALfloat p[3];
|
ALfloat p[3];
|
||||||
alGetSourcefv(m_source, AL_POSITION, p);
|
alGetSourcefv(m_source, AL_POSITION, p);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
result = AUD_Vector3(p[0], p[1], p[2]);
|
result = AUD_Vector3(p[0], p[1], p[2]);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -423,12 +428,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceLocation(const AUD_Vector3& lo
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcefv(m_source, AL_POSITION, (ALfloat*)location.get());
|
alSourcefv(m_source, AL_POSITION, (ALfloat*)location.get());
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,15 +443,16 @@ AUD_Vector3 AUD_OpenALDevice::AUD_OpenALHandle::getSourceVelocity()
|
|||||||
AUD_Vector3 result = AUD_Vector3(0, 0, 0);
|
AUD_Vector3 result = AUD_Vector3(0, 0, 0);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return result;
|
||||||
|
|
||||||
ALfloat v[3];
|
ALfloat v[3];
|
||||||
alGetSourcefv(m_source, AL_VELOCITY, v);
|
alGetSourcefv(m_source, AL_VELOCITY, v);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
result = AUD_Vector3(v[0], v[1], v[2]);
|
result = AUD_Vector3(v[0], v[1], v[2]);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -456,12 +463,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceVelocity(const AUD_Vector3& ve
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcefv(m_source, AL_VELOCITY, (ALfloat*)velocity.get());
|
alSourcefv(m_source, AL_VELOCITY, (ALfloat*)velocity.get());
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,9 +480,6 @@ AUD_Quaternion AUD_OpenALDevice::AUD_OpenALHandle::getSourceOrientation()
|
|||||||
|
|
||||||
bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceOrientation(const AUD_Quaternion& orientation)
|
bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceOrientation(const AUD_Quaternion& orientation)
|
||||||
{
|
{
|
||||||
if(!m_status)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ALfloat direction[3];
|
ALfloat direction[3];
|
||||||
direction[0] = -2 * (orientation.w() * orientation.y() +
|
direction[0] = -2 * (orientation.w() * orientation.y() +
|
||||||
orientation.x() * orientation.z());
|
orientation.x() * orientation.z());
|
||||||
@@ -482,12 +487,17 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceOrientation(const AUD_Quaterni
|
|||||||
orientation.z() * orientation.y());
|
orientation.z() * orientation.y());
|
||||||
direction[2] = 2 * (orientation.x() * orientation.x() +
|
direction[2] = 2 * (orientation.x() * orientation.x() +
|
||||||
orientation.y() * orientation.y()) - 1;
|
orientation.y() * orientation.y()) - 1;
|
||||||
m_device->lock();
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcefv(m_source, AL_DIRECTION, direction);
|
alSourcefv(m_source, AL_DIRECTION, direction);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
m_orientation = orientation;
|
m_orientation = orientation;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -500,12 +510,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::isRelative()
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alGetSourcei(m_source, AL_SOURCE_RELATIVE, &result);
|
alGetSourcei(m_source, AL_SOURCE_RELATIVE, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,12 +525,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setRelative(bool relative)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcei(m_source, AL_SOURCE_RELATIVE, relative);
|
alSourcei(m_source, AL_SOURCE_RELATIVE, relative);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,15 +539,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getVolumeMaximum()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_MAX_GAIN, &result);
|
alGetSourcef(m_source, AL_MAX_GAIN, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,12 +557,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setVolumeMaximum(float volume)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_MAX_GAIN, volume);
|
alSourcef(m_source, AL_MAX_GAIN, volume);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,15 +571,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getVolumeMinimum()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_MIN_GAIN, &result);
|
alGetSourcef(m_source, AL_MIN_GAIN, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,12 +589,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setVolumeMinimum(float volume)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_MIN_GAIN, volume);
|
alSourcef(m_source, AL_MIN_GAIN, volume);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,15 +603,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getDistanceMaximum()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_MAX_DISTANCE, &result);
|
alGetSourcef(m_source, AL_MAX_DISTANCE, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,12 +621,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setDistanceMaximum(float distance)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_MAX_DISTANCE, distance);
|
alSourcef(m_source, AL_MAX_DISTANCE, distance);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,15 +635,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getDistanceReference()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_REFERENCE_DISTANCE, &result);
|
alGetSourcef(m_source, AL_REFERENCE_DISTANCE, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,12 +653,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setDistanceReference(float distance)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_REFERENCE_DISTANCE, distance);
|
alSourcef(m_source, AL_REFERENCE_DISTANCE, distance);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,15 +667,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getAttenuation()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_ROLLOFF_FACTOR, &result);
|
alGetSourcef(m_source, AL_ROLLOFF_FACTOR, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,12 +685,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setAttenuation(float factor)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_ROLLOFF_FACTOR, factor);
|
alSourcef(m_source, AL_ROLLOFF_FACTOR, factor);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,15 +699,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getConeAngleOuter()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_CONE_OUTER_ANGLE, &result);
|
alGetSourcef(m_source, AL_CONE_OUTER_ANGLE, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,12 +717,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setConeAngleOuter(float angle)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_CONE_OUTER_ANGLE, angle);
|
alSourcef(m_source, AL_CONE_OUTER_ANGLE, angle);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,15 +731,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getConeAngleInner()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_CONE_INNER_ANGLE, &result);
|
alGetSourcef(m_source, AL_CONE_INNER_ANGLE, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,12 +749,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setConeAngleInner(float angle)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_CONE_INNER_ANGLE, angle);
|
alSourcef(m_source, AL_CONE_INNER_ANGLE, angle);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,15 +763,16 @@ float AUD_OpenALDevice::AUD_OpenALHandle::getConeVolumeOuter()
|
|||||||
{
|
{
|
||||||
float result = std::numeric_limits<float>::quiet_NaN();
|
float result = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
alGetSourcef(m_source, AL_CONE_OUTER_GAIN, &result);
|
alGetSourcef(m_source, AL_CONE_OUTER_GAIN, &result);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,12 +781,13 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setConeVolumeOuter(float volume)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourcef(m_source, AL_CONE_OUTER_GAIN, volume);
|
alSourcef(m_source, AL_CONE_OUTER_GAIN, volume);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -776,7 +804,7 @@ static void *AUD_openalRunThread(void *device)
|
|||||||
|
|
||||||
void AUD_OpenALDevice::start(bool join)
|
void AUD_OpenALDevice::start(bool join)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
if(!m_playing)
|
if(!m_playing)
|
||||||
{
|
{
|
||||||
@@ -793,8 +821,6 @@ void AUD_OpenALDevice::start(bool join)
|
|||||||
|
|
||||||
m_playing = true;
|
m_playing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_OpenALDevice::updateStreams()
|
void AUD_OpenALDevice::updateStreams()
|
||||||
@@ -1177,7 +1203,8 @@ AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IReader> rea
|
|||||||
if(!getFormat(format, specs))
|
if(!getFormat(format, specs))
|
||||||
return AUD_Reference<AUD_IHandle>();
|
return AUD_Reference<AUD_IHandle>();
|
||||||
|
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
alcSuspendContext(m_context);
|
alcSuspendContext(m_context);
|
||||||
|
|
||||||
AUD_Reference<AUD_OpenALDevice::AUD_OpenALHandle> sound;
|
AUD_Reference<AUD_OpenALDevice::AUD_OpenALHandle> sound;
|
||||||
@@ -1190,7 +1217,6 @@ AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IReader> rea
|
|||||||
catch(AUD_Exception&)
|
catch(AUD_Exception&)
|
||||||
{
|
{
|
||||||
alcProcessContext(m_context);
|
alcProcessContext(m_context);
|
||||||
unlock();
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,8 +1227,6 @@ AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IReader> rea
|
|||||||
|
|
||||||
start();
|
start();
|
||||||
|
|
||||||
unlock();
|
|
||||||
|
|
||||||
return AUD_Reference<AUD_IHandle>(sound);
|
return AUD_Reference<AUD_IHandle>(sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1285,7 +1309,8 @@ AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IFactory> fa
|
|||||||
|
|
||||||
void AUD_OpenALDevice::stopAll()
|
void AUD_OpenALDevice::stopAll()
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
alcSuspendContext(m_context);
|
alcSuspendContext(m_context);
|
||||||
|
|
||||||
while(!m_playingSounds.empty())
|
while(!m_playingSounds.empty())
|
||||||
@@ -1295,7 +1320,6 @@ void AUD_OpenALDevice::stopAll()
|
|||||||
m_pausedSounds.front()->stop();
|
m_pausedSounds.front()->stop();
|
||||||
|
|
||||||
alcProcessContext(m_context);
|
alcProcessContext(m_context);
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_OpenALDevice::lock()
|
void AUD_OpenALDevice::lock()
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "AUD_AnimateableProperty.h"
|
#include "AUD_AnimateableProperty.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@@ -63,17 +64,15 @@ void AUD_AnimateableProperty::unlock()
|
|||||||
|
|
||||||
void AUD_AnimateableProperty::write(const float* data)
|
void AUD_AnimateableProperty::write(const float* data)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_isAnimated = false;
|
m_isAnimated = false;
|
||||||
memcpy(getBuffer(), data, m_count * sizeof(float));
|
memcpy(getBuffer(), data, m_count * sizeof(float));
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_AnimateableProperty::write(const float* data, int position, int count)
|
void AUD_AnimateableProperty::write(const float* data, int position, int count)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_isAnimated = true;
|
m_isAnimated = true;
|
||||||
|
|
||||||
@@ -87,18 +86,15 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count)
|
|||||||
|
|
||||||
for(int i = pos; i < position; i++)
|
for(int i = pos; i < position; i++)
|
||||||
memcpy(buf + i * m_count, buf + (pos - 1) * m_count, m_count * sizeof(float));
|
memcpy(buf + i * m_count, buf + (pos - 1) * m_count, m_count * sizeof(float));
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_AnimateableProperty::read(float position, float* out)
|
void AUD_AnimateableProperty::read(float position, float* out)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
if(!m_isAnimated)
|
if(!m_isAnimated)
|
||||||
{
|
{
|
||||||
memcpy(out, getBuffer(), m_count * sizeof(float));
|
memcpy(out, getBuffer(), m_count * sizeof(float));
|
||||||
unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,8 +143,6 @@ void AUD_AnimateableProperty::read(float position, float* out)
|
|||||||
(t3 - 2 * t2 + t) * m0 + (t3 - t2) * m1;
|
(t3 - 2 * t2 + t) * m0 + (t3 - t2) * m1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AUD_AnimateableProperty::isAnimated() const
|
bool AUD_AnimateableProperty::isAnimated() const
|
||||||
|
@@ -31,13 +31,14 @@
|
|||||||
#define __AUD_ANIMATEABLEPROPERTY_H__
|
#define __AUD_ANIMATEABLEPROPERTY_H__
|
||||||
|
|
||||||
#include "AUD_Buffer.h"
|
#include "AUD_Buffer.h"
|
||||||
|
#include "AUD_ILockable.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class saves animation data for float properties.
|
* This class saves animation data for float properties.
|
||||||
*/
|
*/
|
||||||
class AUD_AnimateableProperty : private AUD_Buffer
|
class AUD_AnimateableProperty : private AUD_Buffer, public AUD_ILockable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/// The count of floats for a single property.
|
/// The count of floats for a single property.
|
||||||
@@ -68,12 +69,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Locks the property.
|
* Locks the property.
|
||||||
*/
|
*/
|
||||||
void lock();
|
virtual void lock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks the previously locked property.
|
* Unlocks the previously locked property.
|
||||||
*/
|
*/
|
||||||
void unlock();
|
virtual void unlock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the properties value and marks it non-animated.
|
* Writes the properties value and marks it non-animated.
|
||||||
|
@@ -68,6 +68,7 @@
|
|||||||
#include "AUD_SequencerFactory.h"
|
#include "AUD_SequencerFactory.h"
|
||||||
#include "AUD_SequencerEntry.h"
|
#include "AUD_SequencerEntry.h"
|
||||||
#include "AUD_SilenceFactory.h"
|
#include "AUD_SilenceFactory.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
#ifdef WITH_SDL
|
#ifdef WITH_SDL
|
||||||
#include "AUD_SDLDevice.h"
|
#include "AUD_SDLDevice.h"
|
||||||
@@ -858,13 +859,12 @@ AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds)
|
|||||||
AUD_Reference<AUD_IFactory> silence = new AUD_SilenceFactory;
|
AUD_Reference<AUD_IFactory> silence = new AUD_SilenceFactory;
|
||||||
AUD_Reference<AUD_IFactory> limiter = new AUD_LimiterFactory(silence, 0, seconds);
|
AUD_Reference<AUD_IFactory> limiter = new AUD_LimiterFactory(silence, 0, seconds);
|
||||||
|
|
||||||
AUD_device->lock();
|
AUD_MutexLock lock(*AUD_device);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AUD_Handle handle2 = AUD_device->play(limiter);
|
AUD_Handle handle2 = AUD_device->play(limiter);
|
||||||
if (!handle2.isNull()) {
|
if (!handle2.isNull()) {
|
||||||
handle2->setStopCallback((stopCallback)pauseSound, handle);
|
handle2->setStopCallback((stopCallback)pauseSound, handle);
|
||||||
AUD_device->unlock();
|
|
||||||
return new AUD_Handle(handle2);
|
return new AUD_Handle(handle2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -872,8 +872,6 @@ AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AUD_device->unlock();
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "AUD_IFactory.h"
|
#include "AUD_IFactory.h"
|
||||||
#include "AUD_IReader.h"
|
#include "AUD_IReader.h"
|
||||||
#include "AUD_IHandle.h"
|
#include "AUD_IHandle.h"
|
||||||
|
#include "AUD_ILockable.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents an output device for sound sources.
|
* This class represents an output device for sound sources.
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
* \warning Thread safety must be insured so that no reader is beeing called
|
* \warning Thread safety must be insured so that no reader is beeing called
|
||||||
* twice at the same time.
|
* twice at the same time.
|
||||||
*/
|
*/
|
||||||
class AUD_IDevice
|
class AUD_IDevice : public AUD_ILockable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
21
intern/audaspace/intern/AUD_ILockable.h
Normal file
21
intern/audaspace/intern/AUD_ILockable.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef AUD_ILOCKABLE_H
|
||||||
|
#define AUD_ILOCKABLE_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides an interface for lockable objects.
|
||||||
|
* The main reason for this interface is to be used with AUD_MutexLock.
|
||||||
|
*/
|
||||||
|
class AUD_ILockable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Locks the object.
|
||||||
|
*/
|
||||||
|
virtual void lock()=0;
|
||||||
|
/**
|
||||||
|
* Unlocks the previously locked object.
|
||||||
|
*/
|
||||||
|
virtual void unlock()=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AUD_ILOCKABLE_H
|
24
intern/audaspace/intern/AUD_MutexLock.h
Normal file
24
intern/audaspace/intern/AUD_MutexLock.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef AUD_MUTEXLOCK_H
|
||||||
|
#define AUD_MUTEXLOCK_H
|
||||||
|
|
||||||
|
#include "AUD_ILockable.h"
|
||||||
|
|
||||||
|
class AUD_MutexLock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline AUD_MutexLock(AUD_ILockable& lockable) :
|
||||||
|
lockable(lockable)
|
||||||
|
{
|
||||||
|
lockable.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ~AUD_MutexLock()
|
||||||
|
{
|
||||||
|
lockable.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
AUD_ILockable& lockable;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AUD_MUTEXLOCK_H
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "AUD_SequencerEntry.h"
|
#include "AUD_SequencerEntry.h"
|
||||||
#include "AUD_SequencerReader.h"
|
#include "AUD_SequencerReader.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -87,20 +88,18 @@ void AUD_SequencerEntry::unlock()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setSound(AUD_Reference<AUD_IFactory> sound)
|
void AUD_SequencerEntry::setSound(AUD_Reference<AUD_IFactory> sound)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
if(m_sound.get() != sound.get())
|
if(m_sound.get() != sound.get())
|
||||||
{
|
{
|
||||||
m_sound = sound;
|
m_sound = sound;
|
||||||
m_sound_status++;
|
m_sound_status++;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_SequencerEntry::move(float begin, float end, float skip)
|
void AUD_SequencerEntry::move(float begin, float end, float skip)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
if(m_begin != begin || m_skip != skip || m_end != end)
|
if(m_begin != begin || m_skip != skip || m_end != end)
|
||||||
{
|
{
|
||||||
@@ -109,17 +108,13 @@ void AUD_SequencerEntry::move(float begin, float end, float skip)
|
|||||||
m_end = end;
|
m_end = end;
|
||||||
m_pos_status++;
|
m_pos_status++;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_SequencerEntry::mute(bool mute)
|
void AUD_SequencerEntry::mute(bool mute)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_muted = mute;
|
m_muted = mute;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AUD_SequencerEntry::getID() const
|
int AUD_SequencerEntry::getID() const
|
||||||
@@ -150,7 +145,7 @@ void AUD_SequencerEntry::updateAll(float volume_max, float volume_min, float dis
|
|||||||
float distance_reference, float attenuation, float cone_angle_outer,
|
float distance_reference, float attenuation, float cone_angle_outer,
|
||||||
float cone_angle_inner, float cone_volume_outer)
|
float cone_angle_inner, float cone_volume_outer)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
if(volume_max != m_volume_max)
|
if(volume_max != m_volume_max)
|
||||||
{
|
{
|
||||||
@@ -199,8 +194,6 @@ void AUD_SequencerEntry::updateAll(float volume_max, float volume_min, float dis
|
|||||||
m_cone_volume_outer = cone_volume_outer;
|
m_cone_volume_outer = cone_volume_outer;
|
||||||
m_status++;
|
m_status++;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AUD_SequencerEntry::isRelative()
|
bool AUD_SequencerEntry::isRelative()
|
||||||
@@ -210,15 +203,13 @@ bool AUD_SequencerEntry::isRelative()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setRelative(bool relative)
|
void AUD_SequencerEntry::setRelative(bool relative)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
if(m_relative != relative)
|
if(m_relative != relative)
|
||||||
{
|
{
|
||||||
m_relative = relative;
|
m_relative = relative;
|
||||||
m_status++;
|
m_status++;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getVolumeMaximum()
|
float AUD_SequencerEntry::getVolumeMaximum()
|
||||||
@@ -228,12 +219,10 @@ float AUD_SequencerEntry::getVolumeMaximum()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setVolumeMaximum(float volume)
|
void AUD_SequencerEntry::setVolumeMaximum(float volume)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_volume_max = volume;
|
m_volume_max = volume;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getVolumeMinimum()
|
float AUD_SequencerEntry::getVolumeMinimum()
|
||||||
@@ -243,12 +232,10 @@ float AUD_SequencerEntry::getVolumeMinimum()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setVolumeMinimum(float volume)
|
void AUD_SequencerEntry::setVolumeMinimum(float volume)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_volume_min = volume;
|
m_volume_min = volume;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getDistanceMaximum()
|
float AUD_SequencerEntry::getDistanceMaximum()
|
||||||
@@ -258,12 +245,10 @@ float AUD_SequencerEntry::getDistanceMaximum()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setDistanceMaximum(float distance)
|
void AUD_SequencerEntry::setDistanceMaximum(float distance)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_distance_max = distance;
|
m_distance_max = distance;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getDistanceReference()
|
float AUD_SequencerEntry::getDistanceReference()
|
||||||
@@ -273,12 +258,10 @@ float AUD_SequencerEntry::getDistanceReference()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setDistanceReference(float distance)
|
void AUD_SequencerEntry::setDistanceReference(float distance)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_distance_reference = distance;
|
m_distance_reference = distance;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getAttenuation()
|
float AUD_SequencerEntry::getAttenuation()
|
||||||
@@ -288,12 +271,10 @@ float AUD_SequencerEntry::getAttenuation()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setAttenuation(float factor)
|
void AUD_SequencerEntry::setAttenuation(float factor)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_attenuation = factor;
|
m_attenuation = factor;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getConeAngleOuter()
|
float AUD_SequencerEntry::getConeAngleOuter()
|
||||||
@@ -303,12 +284,10 @@ float AUD_SequencerEntry::getConeAngleOuter()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setConeAngleOuter(float angle)
|
void AUD_SequencerEntry::setConeAngleOuter(float angle)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_cone_angle_outer = angle;
|
m_cone_angle_outer = angle;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getConeAngleInner()
|
float AUD_SequencerEntry::getConeAngleInner()
|
||||||
@@ -318,12 +297,10 @@ float AUD_SequencerEntry::getConeAngleInner()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setConeAngleInner(float angle)
|
void AUD_SequencerEntry::setConeAngleInner(float angle)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_cone_angle_inner = angle;
|
m_cone_angle_inner = angle;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerEntry::getConeVolumeOuter()
|
float AUD_SequencerEntry::getConeVolumeOuter()
|
||||||
@@ -333,10 +310,8 @@ float AUD_SequencerEntry::getConeVolumeOuter()
|
|||||||
|
|
||||||
void AUD_SequencerEntry::setConeVolumeOuter(float volume)
|
void AUD_SequencerEntry::setConeVolumeOuter(float volume)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_cone_volume_outer = volume;
|
m_cone_volume_outer = volume;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
@@ -33,13 +33,14 @@
|
|||||||
#include "AUD_Reference.h"
|
#include "AUD_Reference.h"
|
||||||
#include "AUD_AnimateableProperty.h"
|
#include "AUD_AnimateableProperty.h"
|
||||||
#include "AUD_IFactory.h"
|
#include "AUD_IFactory.h"
|
||||||
|
#include "AUD_ILockable.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a sequenced entry in a sequencer factory.
|
* This class represents a sequenced entry in a sequencer factory.
|
||||||
*/
|
*/
|
||||||
class AUD_SequencerEntry
|
class AUD_SequencerEntry : public AUD_ILockable
|
||||||
{
|
{
|
||||||
friend class AUD_SequencerHandle;
|
friend class AUD_SequencerHandle;
|
||||||
private:
|
private:
|
||||||
@@ -130,12 +131,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Locks the entry.
|
* Locks the entry.
|
||||||
*/
|
*/
|
||||||
void lock();
|
virtual void lock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks the previously locked entry.
|
* Unlocks the previously locked entry.
|
||||||
*/
|
*/
|
||||||
void unlock();
|
virtual void unlock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the sound of the entry.
|
* Sets the sound of the entry.
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "AUD_SequencerFactory.h"
|
#include "AUD_SequencerFactory.h"
|
||||||
#include "AUD_SequencerReader.h"
|
#include "AUD_SequencerReader.h"
|
||||||
#include "AUD_3DMath.h"
|
#include "AUD_3DMath.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted) :
|
AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted) :
|
||||||
m_specs(specs),
|
m_specs(specs),
|
||||||
@@ -75,30 +76,24 @@ void AUD_SequencerFactory::unlock()
|
|||||||
|
|
||||||
void AUD_SequencerFactory::setSpecs(AUD_Specs specs)
|
void AUD_SequencerFactory::setSpecs(AUD_Specs specs)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_specs = specs;
|
m_specs = specs;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_SequencerFactory::setFPS(float fps)
|
void AUD_SequencerFactory::setFPS(float fps)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_fps = fps;
|
m_fps = fps;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_SequencerFactory::mute(bool muted)
|
void AUD_SequencerFactory::mute(bool muted)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_muted = muted;
|
m_muted = muted;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AUD_SequencerFactory::getMute() const
|
bool AUD_SequencerFactory::getMute() const
|
||||||
@@ -113,12 +108,10 @@ float AUD_SequencerFactory::getSpeedOfSound() const
|
|||||||
|
|
||||||
void AUD_SequencerFactory::setSpeedOfSound(float speed)
|
void AUD_SequencerFactory::setSpeedOfSound(float speed)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_speed_of_sound = speed;
|
m_speed_of_sound = speed;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SequencerFactory::getDopplerFactor() const
|
float AUD_SequencerFactory::getDopplerFactor() const
|
||||||
@@ -128,12 +121,10 @@ float AUD_SequencerFactory::getDopplerFactor() const
|
|||||||
|
|
||||||
void AUD_SequencerFactory::setDopplerFactor(float factor)
|
void AUD_SequencerFactory::setDopplerFactor(float factor)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_doppler_factor = factor;
|
m_doppler_factor = factor;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
|
AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
|
||||||
@@ -143,12 +134,10 @@ AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
|
|||||||
|
|
||||||
void AUD_SequencerFactory::setDistanceModel(AUD_DistanceModel model)
|
void AUD_SequencerFactory::setDistanceModel(AUD_DistanceModel model)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_distance_model = model;
|
m_distance_model = model;
|
||||||
m_status++;
|
m_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePropertyType type)
|
AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePropertyType type)
|
||||||
@@ -168,26 +157,22 @@ AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePr
|
|||||||
|
|
||||||
AUD_Reference<AUD_SequencerEntry> AUD_SequencerFactory::add(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip)
|
AUD_Reference<AUD_SequencerEntry> AUD_SequencerFactory::add(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
AUD_Reference<AUD_SequencerEntry> entry = new AUD_SequencerEntry(sound, begin, end, skip, m_id++);
|
AUD_Reference<AUD_SequencerEntry> entry = new AUD_SequencerEntry(sound, begin, end, skip, m_id++);
|
||||||
|
|
||||||
m_entries.push_front(entry);
|
m_entries.push_front(entry);
|
||||||
m_entry_status++;
|
m_entry_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_SequencerFactory::remove(AUD_Reference<AUD_SequencerEntry> entry)
|
void AUD_SequencerFactory::remove(AUD_Reference<AUD_SequencerEntry> entry)
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_entries.remove(entry);
|
m_entries.remove(entry);
|
||||||
m_entry_status++;
|
m_entry_status++;
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AUD_Reference<AUD_IReader> AUD_SequencerFactory::createQualityReader()
|
AUD_Reference<AUD_IReader> AUD_SequencerFactory::createQualityReader()
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "AUD_IFactory.h"
|
#include "AUD_IFactory.h"
|
||||||
#include "AUD_AnimateableProperty.h"
|
#include "AUD_AnimateableProperty.h"
|
||||||
|
#include "AUD_ILockable.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@@ -41,7 +42,7 @@ class AUD_SequencerEntry;
|
|||||||
/**
|
/**
|
||||||
* This factory represents sequenced entries to play a sound scene.
|
* This factory represents sequenced entries to play a sound scene.
|
||||||
*/
|
*/
|
||||||
class AUD_SequencerFactory : public AUD_IFactory
|
class AUD_SequencerFactory : public AUD_IFactory, public AUD_ILockable
|
||||||
{
|
{
|
||||||
friend class AUD_SequencerReader;
|
friend class AUD_SequencerReader;
|
||||||
private:
|
private:
|
||||||
@@ -104,12 +105,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Locks the factory.
|
* Locks the factory.
|
||||||
*/
|
*/
|
||||||
void lock();
|
virtual void lock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks the previously locked factory.
|
* Unlocks the previously locked factory.
|
||||||
*/
|
*/
|
||||||
void unlock();
|
virtual void unlock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the audio output specification.
|
* Sets the audio output specification.
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "AUD_SequencerHandle.h"
|
#include "AUD_SequencerHandle.h"
|
||||||
#include "AUD_ReadDevice.h"
|
#include "AUD_ReadDevice.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
AUD_SequencerHandle::AUD_SequencerHandle(AUD_Reference<AUD_SequencerEntry> entry, AUD_ReadDevice& device) :
|
AUD_SequencerHandle::AUD_SequencerHandle(AUD_Reference<AUD_SequencerEntry> entry, AUD_ReadDevice& device) :
|
||||||
m_entry(entry),
|
m_entry(entry),
|
||||||
@@ -68,7 +69,7 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
|
|||||||
{
|
{
|
||||||
if(!m_handle.isNull())
|
if(!m_handle.isNull())
|
||||||
{
|
{
|
||||||
m_entry->lock();
|
AUD_MutexLock lock(*m_entry);
|
||||||
if(position >= m_entry->m_end && m_entry->m_end >= 0)
|
if(position >= m_entry->m_end && m_entry->m_end >= 0)
|
||||||
m_handle->pause();
|
m_handle->pause();
|
||||||
else if(position >= m_entry->m_begin)
|
else if(position >= m_entry->m_begin)
|
||||||
@@ -134,7 +135,6 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
|
|||||||
|
|
||||||
if(m_entry->m_muted)
|
if(m_entry->m_muted)
|
||||||
m_handle->setVolume(0);
|
m_handle->setVolume(0);
|
||||||
m_entry->unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,11 +142,10 @@ void AUD_SequencerHandle::seek(float position)
|
|||||||
{
|
{
|
||||||
if(!m_handle.isNull())
|
if(!m_handle.isNull())
|
||||||
{
|
{
|
||||||
m_entry->lock();
|
AUD_MutexLock lock(*m_entry);
|
||||||
if(position >= m_entry->m_end && m_entry->m_end >= 0)
|
if(position >= m_entry->m_end && m_entry->m_end >= 0)
|
||||||
{
|
{
|
||||||
m_handle->pause();
|
m_handle->pause();
|
||||||
m_entry->unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +159,5 @@ void AUD_SequencerHandle::seek(float position)
|
|||||||
m_handle->pause();
|
m_handle->pause();
|
||||||
else
|
else
|
||||||
m_handle->resume();
|
m_handle->resume();
|
||||||
m_entry->unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "AUD_SequencerReader.h"
|
#include "AUD_SequencerReader.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
typedef std::list<AUD_Reference<AUD_SequencerHandle> >::iterator AUD_HandleIterator;
|
typedef std::list<AUD_Reference<AUD_SequencerHandle> >::iterator AUD_HandleIterator;
|
||||||
typedef std::list<AUD_Reference<AUD_SequencerEntry> >::iterator AUD_EntryIterator;
|
typedef std::list<AUD_Reference<AUD_SequencerEntry> >::iterator AUD_EntryIterator;
|
||||||
@@ -77,7 +78,7 @@ AUD_Specs AUD_SequencerReader::getSpecs() const
|
|||||||
|
|
||||||
void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
|
void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
|
||||||
{
|
{
|
||||||
m_factory->lock();
|
AUD_MutexLock lock(*m_factory);
|
||||||
|
|
||||||
if(m_factory->m_status != m_status)
|
if(m_factory->m_status != m_status)
|
||||||
{
|
{
|
||||||
@@ -197,8 +198,6 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
|
|||||||
time += float(len) / float(specs.rate);
|
time += float(len) / float(specs.rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_factory->unlock();
|
|
||||||
|
|
||||||
m_position += length;
|
m_position += length;
|
||||||
|
|
||||||
eos = false;
|
eos = false;
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "AUD_IFactory.h"
|
#include "AUD_IFactory.h"
|
||||||
#include "AUD_JOSResampleReader.h"
|
#include "AUD_JOSResampleReader.h"
|
||||||
#include "AUD_LinearResampleReader.h"
|
#include "AUD_LinearResampleReader.h"
|
||||||
|
#include "AUD_MutexLock.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@@ -226,7 +227,7 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::pause()
|
|||||||
{
|
{
|
||||||
if(m_status)
|
if(m_status)
|
||||||
{
|
{
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(m_status == AUD_STATUS_PLAYING)
|
if(m_status == AUD_STATUS_PLAYING)
|
||||||
{
|
{
|
||||||
@@ -236,12 +237,9 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::pause()
|
|||||||
if(m_device->m_playingSounds.empty())
|
if(m_device->m_playingSounds.empty())
|
||||||
m_device->playing(m_device->m_playback = false);
|
m_device->playing(m_device->m_playback = false);
|
||||||
m_status = AUD_STATUS_PAUSED;
|
m_status = AUD_STATUS_PAUSED;
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -251,7 +249,7 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::resume()
|
|||||||
{
|
{
|
||||||
if(m_status)
|
if(m_status)
|
||||||
{
|
{
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(m_status == AUD_STATUS_PAUSED)
|
if(m_status == AUD_STATUS_PAUSED)
|
||||||
{
|
{
|
||||||
@@ -261,11 +259,9 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::resume()
|
|||||||
if(!m_device->m_playback)
|
if(!m_device->m_playback)
|
||||||
m_device->playing(m_device->m_playback = true);
|
m_device->playing(m_device->m_playback = true);
|
||||||
m_status = AUD_STATUS_PLAYING;
|
m_status = AUD_STATUS_PLAYING;
|
||||||
m_device->unlock();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -276,7 +272,10 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::stop()
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
// AUD_XXX Create a reference of our own object so that it doesn't get
|
// AUD_XXX Create a reference of our own object so that it doesn't get
|
||||||
// deleted before the end of this function
|
// deleted before the end of this function
|
||||||
@@ -292,7 +291,6 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::stop()
|
|||||||
else
|
else
|
||||||
m_device->m_pausedSounds.remove(This);
|
m_device->m_pausedSounds.remove(This);
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
m_status = AUD_STATUS_INVALID;
|
m_status = AUD_STATUS_INVALID;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -310,12 +308,13 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::setKeep(bool keep)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_keep = keep;
|
m_keep = keep;
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,26 +323,28 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::seek(float position)
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_reader->seek((int)(position * m_reader->getSpecs().rate));
|
m_reader->seek((int)(position * m_reader->getSpecs().rate));
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AUD_SoftwareDevice::AUD_SoftwareHandle::getPosition()
|
float AUD_SoftwareDevice::AUD_SoftwareHandle::getPosition()
|
||||||
{
|
{
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
if(!m_status)
|
if(!m_status)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
m_device->lock();
|
|
||||||
|
|
||||||
float position = m_reader->getPosition() / (float)m_device->m_specs.rate;
|
float position = m_reader->getPosition() / (float)m_device->m_specs.rate;
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,13 +408,14 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::setStopCallback(stopCallback callba
|
|||||||
if(!m_status)
|
if(!m_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_device->lock();
|
AUD_MutexLock lock(*m_device);
|
||||||
|
|
||||||
|
if(!m_status)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_stop = callback;
|
m_stop = callback;
|
||||||
m_stop_data = data;
|
m_stop_data = data;
|
||||||
|
|
||||||
m_device->unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +693,7 @@ void AUD_SoftwareDevice::mix(data_t* buffer, int length)
|
|||||||
{
|
{
|
||||||
m_buffer.assureSize(length * AUD_SAMPLE_SIZE(m_specs));
|
m_buffer.assureSize(length * AUD_SAMPLE_SIZE(m_specs));
|
||||||
|
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
{
|
{
|
||||||
AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound;
|
AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound;
|
||||||
@@ -775,8 +777,6 @@ void AUD_SoftwareDevice::mix(data_t* buffer, int length)
|
|||||||
sound->pause();
|
sound->pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_SoftwareDevice::setPanning(AUD_IHandle* handle, float pan)
|
void AUD_SoftwareDevice::setPanning(AUD_IHandle* handle, float pan)
|
||||||
@@ -833,12 +833,12 @@ AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IReader> r
|
|||||||
// play sound
|
// play sound
|
||||||
AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, resampler, mapper, keep);
|
AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, resampler, mapper, keep);
|
||||||
|
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
m_playingSounds.push_back(sound);
|
m_playingSounds.push_back(sound);
|
||||||
|
|
||||||
if(!m_playback)
|
if(!m_playback)
|
||||||
playing(m_playback = true);
|
playing(m_playback = true);
|
||||||
unlock();
|
|
||||||
|
|
||||||
return AUD_Reference<AUD_IHandle>(sound);
|
return AUD_Reference<AUD_IHandle>(sound);
|
||||||
}
|
}
|
||||||
@@ -850,15 +850,13 @@ AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IFactory>
|
|||||||
|
|
||||||
void AUD_SoftwareDevice::stopAll()
|
void AUD_SoftwareDevice::stopAll()
|
||||||
{
|
{
|
||||||
lock();
|
AUD_MutexLock lock(*this);
|
||||||
|
|
||||||
while(!m_playingSounds.empty())
|
while(!m_playingSounds.empty())
|
||||||
m_playingSounds.front()->stop();
|
m_playingSounds.front()->stop();
|
||||||
|
|
||||||
while(!m_pausedSounds.empty())
|
while(!m_pausedSounds.empty())
|
||||||
m_pausedSounds.front()->stop();
|
m_pausedSounds.front()->stop();
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUD_SoftwareDevice::lock()
|
void AUD_SoftwareDevice::lock()
|
||||||
|
Reference in New Issue
Block a user