3D Audio GSoC:
* Pepper depends on ffmpeg 0.7.1 or higher now, windows and mac build systems set to ffmpeg-0.8 * Fixed orientation retrieval in OpenAL device code. * Added stopAll() method to AUD_IDevice (also for Python) and call it on BGE exit * Changed BGE to use audaspace via native C++ instead over the C API. * Made AUD_SequencerFactory and AUD_SequencerEntry thread safe. * Changed sound caching into a flag which fixes problems on file loading, especially with undo. * Removed unused parameter from sound_mute_scene_sound * Fixed bug: changing FPS didn't update the sequencer sound positions. * Fixed bug: Properties of sequencer strips weren't set correctly. * Minor warning fixes.
This commit is contained in:
@@ -687,15 +687,15 @@ elseif(WIN32)
|
||||
|
||||
if(WITH_CODEC_FFMPEG)
|
||||
set(FFMPEG_INCLUDE_DIRS
|
||||
${LIBDIR}/ffmpeg/include
|
||||
${LIBDIR}/ffmpeg/include/msvc
|
||||
${LIBDIR}/ffmpeg-0.8/include
|
||||
${LIBDIR}/ffmpeg-0.8/include/msvc
|
||||
)
|
||||
set(FFMPEG_LIBRARIES
|
||||
${LIBDIR}/ffmpeg/lib/avcodec-52.lib
|
||||
${LIBDIR}/ffmpeg/lib/avformat-52.lib
|
||||
${LIBDIR}/ffmpeg/lib/avdevice-52.lib
|
||||
${LIBDIR}/ffmpeg/lib/avutil-50.lib
|
||||
${LIBDIR}/ffmpeg/lib/swscale-0.lib
|
||||
${LIBDIR}/ffmpeg-0.8/lib/avcodec-53.lib
|
||||
${LIBDIR}/ffmpeg-0.8/lib/avformat-53.lib
|
||||
${LIBDIR}/ffmpeg-0.8/lib/avdevice-53.lib
|
||||
${LIBDIR}/ffmpeg-0.8/lib/avutil-51.lib
|
||||
${LIBDIR}/ffmpeg-0.8/lib/swscale-2.lib
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -820,9 +820,9 @@ elseif(WIN32)
|
||||
endif()
|
||||
|
||||
if(WITH_CODEC_FFMPEG)
|
||||
set(FFMPEG ${LIBDIR}/ffmpeg)
|
||||
set(FFMPEG ${LIBDIR}/ffmpeg-0.8)
|
||||
set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include)
|
||||
set(FFMPEG_LIBRARIES avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
|
||||
set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
|
||||
set(FFMPEG_LIBPATH ${FFMPEG}/lib)
|
||||
endif()
|
||||
|
||||
@@ -959,7 +959,7 @@ elseif(APPLE)
|
||||
endif()
|
||||
|
||||
if(WITH_CODEC_FFMPEG)
|
||||
set(FFMPEG ${LIBDIR}/ffmpeg)
|
||||
set(FFMPEG ${LIBDIR}/ffmpeg-0.8)
|
||||
set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
|
||||
set(FFMPEG_LIBRARIES avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
|
||||
set(FFMPEG_LIBPATH ${FFMPEG}/lib)
|
||||
|
||||
@@ -79,7 +79,7 @@ else:
|
||||
|
||||
# enable ffmpeg support
|
||||
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
|
||||
BF_FFMPEG = LIBDIR + '/ffmpeg'
|
||||
BF_FFMPEG = LIBDIR + '/ffmpeg-0.8'
|
||||
BF_FFMPEG_INC = "${BF_FFMPEG}/include"
|
||||
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
|
||||
BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2'
|
||||
|
||||
@@ -18,9 +18,9 @@ BF_OPENAL_LIB = 'wrap_oal'
|
||||
BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
|
||||
|
||||
WITH_BF_FFMPEG = False
|
||||
BF_FFMPEG_LIB = 'avformat-52 avcodec-52 avdevice-52 avutil-50 swscale-0'
|
||||
BF_FFMPEG_LIBPATH = LIBDIR + '/ffmpeg/lib'
|
||||
BF_FFMPEG_INC = LIBDIR + '/ffmpeg/include'
|
||||
BF_FFMPEG_LIB = 'avformat-53 avcodec-53 avdevice-53 avutil-51 swscale-2'
|
||||
BF_FFMPEG_LIBPATH = LIBDIR + '/ffmpeg-0.8/lib'
|
||||
BF_FFMPEG_INC = LIBDIR + '/ffmpeg-0.8/include'
|
||||
|
||||
BF_LIBSAMPLERATE = LIBDIR + '/samplerate'
|
||||
BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include'
|
||||
|
||||
@@ -3,11 +3,11 @@ LIBDIR = '${LCGDIR}'
|
||||
|
||||
# enable ffmpeg support
|
||||
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
|
||||
BF_FFMPEG = LIBDIR +'/ffmpeg'
|
||||
BF_FFMPEG = LIBDIR +'/ffmpeg-0.8'
|
||||
BF_FFMPEG_INC = '${BF_FFMPEG}/include ${BF_FFMPEG}/include/msvc'
|
||||
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
|
||||
BF_FFMPEG_LIB = 'avformat-52.lib avcodec-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib'
|
||||
BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-52.dll ${BF_FFMPEG_LIBPATH}/avcodec-52.dll ${BF_FFMPEG_LIBPATH}/avdevice-52.dll ${BF_FFMPEG_LIBPATH}/avutil-50.dll ${BF_FFMPEG_LIBPATH}/swscale-0.dll'
|
||||
BF_FFMPEG_LIB = 'avformat-53.lib avcodec-53.lib avdevice-53.lib avutil-51.lib swscale-2.lib'
|
||||
BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
|
||||
|
||||
BF_PYTHON = LIBDIR + '/python'
|
||||
BF_PYTHON_VERSION = '3.2'
|
||||
|
||||
@@ -3,11 +3,11 @@ LIBDIR = '${LCGDIR}'
|
||||
|
||||
# enable ffmpeg support
|
||||
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
|
||||
BF_FFMPEG = LIBDIR +'/ffmpeg'
|
||||
BF_FFMPEG = LIBDIR +'/ffmpeg-0.8'
|
||||
BF_FFMPEG_INC = '${BF_FFMPEG}/include ${BF_FFMPEG}/include/msvc '
|
||||
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
|
||||
BF_FFMPEG_LIB = 'avformat-52.lib avcodec-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib'
|
||||
BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-52.dll ${BF_FFMPEG_LIBPATH}/avcodec-52.dll ${BF_FFMPEG_LIBPATH}/avdevice-52.dll ${BF_FFMPEG_LIBPATH}/avutil-50.dll ${BF_FFMPEG_LIBPATH}/swscale-0.dll'
|
||||
BF_FFMPEG_LIB = 'avformat-53.lib avcodec-53.lib avdevice-53.lib avutil-51.lib swscale-2.lib'
|
||||
BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
|
||||
|
||||
BF_PYTHON = LIBDIR + '/python'
|
||||
BF_PYTHON_VERSION = '3.2'
|
||||
|
||||
@@ -469,8 +469,7 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceVelocity(const AUD_Vector3& ve
|
||||
|
||||
AUD_Quaternion AUD_OpenALDevice::AUD_OpenALHandle::getSourceOrientation()
|
||||
{
|
||||
// AUD_XXX not implemented yet
|
||||
return AUD_Quaternion(0, 0, 0, 0);
|
||||
return m_orientation;
|
||||
}
|
||||
|
||||
bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceOrientation(const AUD_Quaternion& orientation)
|
||||
@@ -491,6 +490,8 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceOrientation(const AUD_Quaterni
|
||||
|
||||
m_device->unlock();
|
||||
|
||||
m_orientation = orientation;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1284,6 +1285,21 @@ AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IFactory> fa
|
||||
return play(factory->createReader(), keep);
|
||||
}
|
||||
|
||||
void AUD_OpenALDevice::stopAll()
|
||||
{
|
||||
lock();
|
||||
alcSuspendContext(m_context);
|
||||
|
||||
while(!m_playingSounds.empty())
|
||||
m_playingSounds.front()->stop();
|
||||
|
||||
while(!m_pausedSounds.empty())
|
||||
m_pausedSounds.front()->stop();
|
||||
|
||||
alcProcessContext(m_context);
|
||||
unlock();
|
||||
}
|
||||
|
||||
void AUD_OpenALDevice::lock()
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
@@ -1454,8 +1470,7 @@ void AUD_OpenALDevice::setListenerVelocity(const AUD_Vector3& velocity)
|
||||
|
||||
AUD_Quaternion AUD_OpenALDevice::getListenerOrientation() const
|
||||
{
|
||||
// AUD_XXX not implemented yet
|
||||
return AUD_Quaternion(0, 0, 0, 0);
|
||||
return m_orientation;
|
||||
}
|
||||
|
||||
void AUD_OpenALDevice::setListenerOrientation(const AUD_Quaternion& orientation)
|
||||
@@ -1474,6 +1489,7 @@ void AUD_OpenALDevice::setListenerOrientation(const AUD_Quaternion& orientation)
|
||||
direction[5] = 2 * (orientation.w() * orientation.x() +
|
||||
orientation.y() * orientation.z());
|
||||
alListenerfv(AL_ORIENTATION, direction);
|
||||
m_orientation = orientation;
|
||||
}
|
||||
|
||||
float AUD_OpenALDevice::getSpeedOfSound() const
|
||||
|
||||
@@ -89,6 +89,9 @@ private:
|
||||
/// Stop callback data.
|
||||
void* m_stop_data;
|
||||
|
||||
/// Orientation.
|
||||
AUD_Quaternion m_orientation;
|
||||
|
||||
/// Current status of the handle
|
||||
AUD_Status m_status;
|
||||
|
||||
@@ -204,6 +207,11 @@ private:
|
||||
*/
|
||||
AUD_Buffer m_buffer;
|
||||
|
||||
/**
|
||||
* Orientation.
|
||||
*/
|
||||
AUD_Quaternion m_orientation;
|
||||
|
||||
/**
|
||||
* Starts the streaming thread.
|
||||
*/
|
||||
@@ -243,6 +251,7 @@ public:
|
||||
virtual AUD_DeviceSpecs getSpecs() const;
|
||||
virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
|
||||
virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
|
||||
virtual void stopAll();
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual float getVolume() const;
|
||||
|
||||
@@ -2245,6 +2245,25 @@ Device_play(Device *self, PyObject *args, PyObject *kwds)
|
||||
return (PyObject *)handle;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Device_stopAll_doc,
|
||||
"stopAll()\n\n"
|
||||
"Stops all playing and paused sounds.");
|
||||
|
||||
static PyObject *
|
||||
Device_stopAll(Device *self)
|
||||
{
|
||||
try
|
||||
{
|
||||
(*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->stopAll();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
catch(AUD_Exception& e)
|
||||
{
|
||||
PyErr_SetString(AUDError, e.str);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(M_aud_Device_lock_doc,
|
||||
"lock()\n\n"
|
||||
"Locks the device so that it's guaranteed, that no samples are "
|
||||
@@ -2295,6 +2314,9 @@ static PyMethodDef Device_methods[] = {
|
||||
{"play", (PyCFunction)Device_play, METH_VARARGS | METH_KEYWORDS,
|
||||
M_aud_Device_play_doc
|
||||
},
|
||||
{"stopAll", (PyCFunction)Device_stopAll, METH_NOARGS,
|
||||
M_aud_Device_stopAll_doc
|
||||
},
|
||||
{"lock", (PyCFunction)Device_lock, METH_NOARGS,
|
||||
M_aud_Device_lock_doc
|
||||
},
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavformat/avio.h>
|
||||
#include "ffmpeg_compat.h"
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavformat/avio.h>
|
||||
#include "ffmpeg_compat.h"
|
||||
}
|
||||
|
||||
static const char* context_error = "AUD_FFMPEGWriter: Couldn't allocate context.";
|
||||
@@ -127,7 +128,8 @@ AUD_FFMPEGWriter::AUD_FFMPEGWriter(std::string filename, AUD_DeviceSpecs specs,
|
||||
m_codecCtx->bit_rate = bitrate;
|
||||
m_codecCtx->sample_rate = int(m_specs.rate);
|
||||
m_codecCtx->channels = m_specs.channels;
|
||||
m_codecCtx->time_base = (AVRational){1, m_codecCtx->sample_rate};
|
||||
m_codecCtx->time_base.num = 1;
|
||||
m_codecCtx->time_base.den = m_codecCtx->sample_rate;
|
||||
|
||||
switch(m_specs.format)
|
||||
{
|
||||
@@ -180,7 +182,7 @@ AUD_FFMPEGWriter::AUD_FFMPEGWriter(std::string filename, AUD_DeviceSpecs specs,
|
||||
|
||||
try
|
||||
{
|
||||
if(avio_open(&m_formatCtx->pb, filename.c_str(), AVIO_WRONLY))
|
||||
if(avio_open(&m_formatCtx->pb, filename.c_str(), AVIO_FLAG_WRITE))
|
||||
AUD_THROW(AUD_ERROR_FILE, file_error);
|
||||
|
||||
avformat_write_header(m_formatCtx, NULL);
|
||||
|
||||
@@ -1174,3 +1174,13 @@ const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int lengt
|
||||
return e.str;
|
||||
}
|
||||
}
|
||||
|
||||
AUD_Reference<AUD_IDevice> AUD_getDevice()
|
||||
{
|
||||
return AUD_device;
|
||||
}
|
||||
|
||||
AUD_I3DDevice* AUD_get3DDevice()
|
||||
{
|
||||
return AUD_3ddevice;
|
||||
}
|
||||
|
||||
@@ -528,6 +528,14 @@ extern AUD_Sound* AUD_getPythonSound(PyObject* sound);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#include "AUD_Reference.h"
|
||||
class AUD_IDevice;
|
||||
class AUD_I3DDevice;
|
||||
|
||||
AUD_Reference<AUD_IDevice> AUD_getDevice();
|
||||
|
||||
AUD_I3DDevice* AUD_get3DDevice();
|
||||
#endif
|
||||
|
||||
#endif //AUD_CAPI
|
||||
|
||||
@@ -83,6 +83,11 @@ public:
|
||||
*/
|
||||
virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false)=0;
|
||||
|
||||
/**
|
||||
* Stops all playing sounds.
|
||||
*/
|
||||
virtual void stopAll()=0;
|
||||
|
||||
/**
|
||||
* Locks the device.
|
||||
* Used to make sure that between lock and unlock, no buffers are read, so
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include "AUD_Space.h"
|
||||
#include "AUD_Reference.h"
|
||||
class AUD_IReader;
|
||||
#include "AUD_IReader.h"
|
||||
|
||||
/**
|
||||
* This class represents a type of sound source and saves the necessary values
|
||||
|
||||
@@ -139,6 +139,10 @@ AUD_Reference<AUD_IHandle> AUD_NULLDevice::play(AUD_Reference<AUD_IFactory> fact
|
||||
return new AUD_NULLHandle();
|
||||
}
|
||||
|
||||
void AUD_NULLDevice::stopAll()
|
||||
{
|
||||
}
|
||||
|
||||
void AUD_NULLDevice::lock()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
virtual AUD_DeviceSpecs getSpecs() const;
|
||||
virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
|
||||
virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
|
||||
virtual void stopAll();
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual float getVolume() const;
|
||||
|
||||
@@ -62,19 +62,48 @@ AUD_SequencerEntry::AUD_SequencerEntry(AUD_Reference<AUD_IFactory> sound, float
|
||||
float f = 1;
|
||||
m_volume.write(&f);
|
||||
m_pitch.write(&f);
|
||||
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
|
||||
pthread_mutex_init(&m_mutex, &attr);
|
||||
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
}
|
||||
|
||||
AUD_SequencerEntry::~AUD_SequencerEntry()
|
||||
{
|
||||
pthread_mutex_destroy(&m_mutex);
|
||||
}
|
||||
|
||||
void AUD_SequencerEntry::lock()
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
}
|
||||
|
||||
void AUD_SequencerEntry::unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
void AUD_SequencerEntry::setSound(AUD_Reference<AUD_IFactory> sound)
|
||||
{
|
||||
lock();
|
||||
|
||||
if(m_sound.get() != sound.get())
|
||||
{
|
||||
m_sound = sound;
|
||||
m_sound_status++;
|
||||
}
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
void AUD_SequencerEntry::move(float begin, float end, float skip)
|
||||
{
|
||||
lock();
|
||||
|
||||
if(m_begin != begin || m_skip != skip || m_end != end)
|
||||
{
|
||||
m_begin = begin;
|
||||
@@ -82,11 +111,17 @@ void AUD_SequencerEntry::move(float begin, float end, float skip)
|
||||
m_end = end;
|
||||
m_pos_status++;
|
||||
}
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
void AUD_SequencerEntry::mute(bool mute)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_muted = mute;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
int AUD_SequencerEntry::getID() const
|
||||
@@ -117,6 +152,8 @@ void AUD_SequencerEntry::updateAll(float volume_max, float volume_min, float dis
|
||||
float distance_reference, float attenuation, float cone_angle_outer,
|
||||
float cone_angle_inner, float cone_volume_outer)
|
||||
{
|
||||
lock();
|
||||
|
||||
if(volume_max != m_volume_max)
|
||||
{
|
||||
m_volume_max = volume_max;
|
||||
@@ -164,6 +201,8 @@ void AUD_SequencerEntry::updateAll(float volume_max, float volume_min, float dis
|
||||
m_cone_volume_outer = cone_volume_outer;
|
||||
m_status++;
|
||||
}
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
bool AUD_SequencerEntry::isRelative()
|
||||
@@ -173,11 +212,15 @@ bool AUD_SequencerEntry::isRelative()
|
||||
|
||||
void AUD_SequencerEntry::setRelative(bool relative)
|
||||
{
|
||||
lock();
|
||||
|
||||
if(m_relative != relative)
|
||||
{
|
||||
m_relative = relative;
|
||||
m_status++;
|
||||
}
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getVolumeMaximum()
|
||||
@@ -187,8 +230,12 @@ float AUD_SequencerEntry::getVolumeMaximum()
|
||||
|
||||
void AUD_SequencerEntry::setVolumeMaximum(float volume)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_volume_max = volume;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getVolumeMinimum()
|
||||
@@ -198,8 +245,12 @@ float AUD_SequencerEntry::getVolumeMinimum()
|
||||
|
||||
void AUD_SequencerEntry::setVolumeMinimum(float volume)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_volume_min = volume;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getDistanceMaximum()
|
||||
@@ -209,8 +260,12 @@ float AUD_SequencerEntry::getDistanceMaximum()
|
||||
|
||||
void AUD_SequencerEntry::setDistanceMaximum(float distance)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_distance_max = distance;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getDistanceReference()
|
||||
@@ -220,8 +275,12 @@ float AUD_SequencerEntry::getDistanceReference()
|
||||
|
||||
void AUD_SequencerEntry::setDistanceReference(float distance)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_distance_reference = distance;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getAttenuation()
|
||||
@@ -231,8 +290,12 @@ float AUD_SequencerEntry::getAttenuation()
|
||||
|
||||
void AUD_SequencerEntry::setAttenuation(float factor)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_attenuation = factor;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getConeAngleOuter()
|
||||
@@ -242,8 +305,12 @@ float AUD_SequencerEntry::getConeAngleOuter()
|
||||
|
||||
void AUD_SequencerEntry::setConeAngleOuter(float angle)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_cone_angle_outer = angle;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getConeAngleInner()
|
||||
@@ -253,8 +320,12 @@ float AUD_SequencerEntry::getConeAngleInner()
|
||||
|
||||
void AUD_SequencerEntry::setConeAngleInner(float angle)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_cone_angle_inner = angle;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerEntry::getConeVolumeOuter()
|
||||
@@ -264,6 +335,10 @@ float AUD_SequencerEntry::getConeVolumeOuter()
|
||||
|
||||
void AUD_SequencerEntry::setConeVolumeOuter(float volume)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_cone_volume_outer = volume;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "AUD_AnimateableProperty.h"
|
||||
#include "AUD_IFactory.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
class AUD_SequencerEntry
|
||||
{
|
||||
friend class AUD_SequencerHandle;
|
||||
@@ -60,6 +62,9 @@ private:
|
||||
float m_cone_angle_inner;
|
||||
float m_cone_volume_outer;
|
||||
|
||||
/// The mutex for locking.
|
||||
pthread_mutex_t m_mutex;
|
||||
|
||||
AUD_AnimateableProperty m_volume;
|
||||
AUD_AnimateableProperty m_panning;
|
||||
AUD_AnimateableProperty m_pitch;
|
||||
@@ -68,6 +73,17 @@ private:
|
||||
|
||||
public:
|
||||
AUD_SequencerEntry(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip, int id);
|
||||
virtual ~AUD_SequencerEntry();
|
||||
|
||||
/**
|
||||
* Locks the entry.
|
||||
*/
|
||||
void lock();
|
||||
|
||||
/**
|
||||
* Unlocks the previously locked entry.
|
||||
*/
|
||||
void unlock();
|
||||
|
||||
void setSound(AUD_Reference<AUD_IFactory> sound);
|
||||
|
||||
|
||||
@@ -50,26 +50,57 @@ AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool mute
|
||||
m_orientation.write(q.get());
|
||||
float f = 1;
|
||||
m_volume.write(&f);
|
||||
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
|
||||
pthread_mutex_init(&m_mutex, &attr);
|
||||
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
}
|
||||
|
||||
AUD_SequencerFactory::~AUD_SequencerFactory()
|
||||
{
|
||||
pthread_mutex_destroy(&m_mutex);
|
||||
}
|
||||
|
||||
void AUD_SequencerFactory::lock()
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
}
|
||||
|
||||
void AUD_SequencerFactory::unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
void AUD_SequencerFactory::setSpecs(AUD_Specs specs)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_specs = specs;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
void AUD_SequencerFactory::setFPS(float fps)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_fps = fps;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
void AUD_SequencerFactory::mute(bool muted)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_muted = muted;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
bool AUD_SequencerFactory::getMute() const
|
||||
@@ -84,8 +115,12 @@ float AUD_SequencerFactory::getSpeedOfSound() const
|
||||
|
||||
void AUD_SequencerFactory::setSpeedOfSound(float speed)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_speed_of_sound = speed;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
float AUD_SequencerFactory::getDopplerFactor() const
|
||||
@@ -95,8 +130,12 @@ float AUD_SequencerFactory::getDopplerFactor() const
|
||||
|
||||
void AUD_SequencerFactory::setDopplerFactor(float factor)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_doppler_factor = factor;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
|
||||
@@ -106,8 +145,12 @@ AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
|
||||
|
||||
void AUD_SequencerFactory::setDistanceModel(AUD_DistanceModel model)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_distance_model = model;
|
||||
m_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePropertyType type)
|
||||
@@ -127,18 +170,26 @@ 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)
|
||||
{
|
||||
lock();
|
||||
|
||||
AUD_Reference<AUD_SequencerEntry> entry = new AUD_SequencerEntry(sound, begin, end, skip, m_id++);
|
||||
|
||||
m_entries.push_front(entry);
|
||||
m_entry_status++;
|
||||
|
||||
unlock();
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void AUD_SequencerFactory::remove(AUD_Reference<AUD_SequencerEntry> entry)
|
||||
{
|
||||
lock();
|
||||
|
||||
m_entries.remove(entry);
|
||||
m_entry_status++;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
AUD_Reference<AUD_IReader> AUD_SequencerFactory::createReader()
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
#include "AUD_AnimateableProperty.h"
|
||||
|
||||
#include <list>
|
||||
#include <pthread.h>
|
||||
|
||||
class AUD_SequencerEntry;
|
||||
|
||||
// AUD_XXX TODO: This class is not thread safe yet!
|
||||
/**
|
||||
* This factory creates a resampling reader that does simple linear resampling.
|
||||
*/
|
||||
@@ -68,6 +68,9 @@ private:
|
||||
AUD_AnimateableProperty m_location;
|
||||
AUD_AnimateableProperty m_orientation;
|
||||
|
||||
/// The mutex for locking.
|
||||
pthread_mutex_t m_mutex;
|
||||
|
||||
// hide copy constructor and operator=
|
||||
AUD_SequencerFactory(const AUD_SequencerFactory&);
|
||||
AUD_SequencerFactory& operator=(const AUD_SequencerFactory&);
|
||||
@@ -76,6 +79,16 @@ public:
|
||||
AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted);
|
||||
~AUD_SequencerFactory();
|
||||
|
||||
/**
|
||||
* Locks the factory.
|
||||
*/
|
||||
void lock();
|
||||
|
||||
/**
|
||||
* Unlocks the previously locked factory.
|
||||
*/
|
||||
void unlock();
|
||||
|
||||
void setSpecs(AUD_Specs specs);
|
||||
void setFPS(float fps);
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ void AUD_SequencerHandle::update(float position, float frame)
|
||||
{
|
||||
if(!m_handle.isNull())
|
||||
{
|
||||
m_entry->lock();
|
||||
if(position >= m_entry->m_end && m_entry->m_end >= 0)
|
||||
m_handle->pause();
|
||||
else if(position >= m_entry->m_begin)
|
||||
@@ -133,6 +134,7 @@ void AUD_SequencerHandle::update(float position, float frame)
|
||||
|
||||
if(m_entry->m_muted)
|
||||
m_handle->setVolume(0);
|
||||
m_entry->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,9 +142,11 @@ void AUD_SequencerHandle::seek(float position)
|
||||
{
|
||||
if(!m_handle.isNull())
|
||||
{
|
||||
m_entry->lock();
|
||||
if(position >= m_entry->m_end && m_entry->m_end >= 0)
|
||||
{
|
||||
m_handle->pause();
|
||||
m_entry->unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,5 +159,6 @@ void AUD_SequencerHandle::seek(float position)
|
||||
m_handle->pause();
|
||||
else
|
||||
m_handle->resume();
|
||||
m_entry->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ AUD_Specs AUD_SequencerReader::getSpecs() const
|
||||
|
||||
void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
|
||||
{
|
||||
m_factory->lock();
|
||||
|
||||
if(m_factory->m_status != m_status)
|
||||
{
|
||||
m_device.changeSpecs(m_factory->m_specs);
|
||||
@@ -179,6 +181,8 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
|
||||
time += float(len) / float(specs.rate);
|
||||
}
|
||||
|
||||
m_factory->unlock();
|
||||
|
||||
m_position += length;
|
||||
|
||||
eos = false;
|
||||
|
||||
@@ -838,6 +838,19 @@ AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IFactory>
|
||||
return play(factory->createReader(), keep);
|
||||
}
|
||||
|
||||
void AUD_SoftwareDevice::stopAll()
|
||||
{
|
||||
lock();
|
||||
|
||||
while(!m_playingSounds.empty())
|
||||
m_playingSounds.front()->stop();
|
||||
|
||||
while(!m_pausedSounds.empty())
|
||||
m_pausedSounds.front()->stop();
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
void AUD_SoftwareDevice::lock()
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
|
||||
@@ -287,6 +287,7 @@ public:
|
||||
virtual AUD_DeviceSpecs getSpecs() const;
|
||||
virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
|
||||
virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
|
||||
virtual void stopAll();
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual float getVolume() const;
|
||||
|
||||
@@ -282,8 +282,9 @@ void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_m
|
||||
struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence * seq, int dupe_flag);
|
||||
int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str);
|
||||
|
||||
void seq_update_sound_bounds_all(struct Scene *scene);
|
||||
void seq_update_sound_bounds(struct Scene* scene, struct Sequence *seq);
|
||||
void seq_update_muting(struct Scene* scene, struct Editing *ed);
|
||||
void seq_update_muting(struct Editing *ed);
|
||||
void seq_update_sound(struct Scene *scene, struct bSound *sound);
|
||||
void seqbase_sound_reload(struct Scene *scene, ListBase *seqbase);
|
||||
void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
|
||||
|
||||
@@ -62,9 +62,9 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa
|
||||
|
||||
void sound_delete(struct bContext *C, struct bSound* sound);
|
||||
|
||||
void sound_cache(struct bSound* sound, int ignore);
|
||||
void sound_cache(struct bSound* sound);
|
||||
|
||||
void sound_cache_notifying(struct Main* main, struct bSound* sound, int ignore);
|
||||
void sound_cache_notifying(struct Main* main, struct bSound* sound);
|
||||
|
||||
void sound_delete_cache(struct bSound* sound);
|
||||
|
||||
@@ -92,7 +92,7 @@ void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int
|
||||
|
||||
void sound_remove_scene_sound(struct Scene *scene, void* handle);
|
||||
|
||||
void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute);
|
||||
void sound_mute_scene_sound(void* handle, char mute);
|
||||
|
||||
void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip);
|
||||
|
||||
|
||||
@@ -3145,6 +3145,28 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene)
|
||||
return offset? 0:1;
|
||||
}
|
||||
|
||||
void seq_update_sound_bounds_all(Scene *scene)
|
||||
{
|
||||
Editing *ed = scene->ed;
|
||||
|
||||
if(ed)
|
||||
{
|
||||
Sequence *seq;
|
||||
|
||||
for(seq = ed->seqbase.first; seq; seq = seq->next)
|
||||
{
|
||||
if(seq->type == SEQ_META)
|
||||
{
|
||||
seq_update_sound_bounds_recursive(scene, seq);
|
||||
}
|
||||
else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE))
|
||||
{
|
||||
seq_update_sound_bounds(scene, seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void seq_update_sound_bounds(Scene* scene, Sequence *seq)
|
||||
{
|
||||
if(seq->scene_sound)
|
||||
@@ -3154,7 +3176,7 @@ void seq_update_sound_bounds(Scene* scene, Sequence *seq)
|
||||
}
|
||||
}
|
||||
|
||||
static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequence *metaseq, int mute)
|
||||
static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute)
|
||||
{
|
||||
Sequence *seq;
|
||||
int seqmute;
|
||||
@@ -3170,26 +3192,26 @@ static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequen
|
||||
if(seq == metaseq)
|
||||
seqmute= 0;
|
||||
|
||||
seq_update_muting_recursive(scene, &seq->seqbase, metaseq, seqmute);
|
||||
seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute);
|
||||
}
|
||||
else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
|
||||
if(seq->scene_sound) {
|
||||
sound_mute_scene_sound(scene, seq->scene_sound, seqmute);
|
||||
sound_mute_scene_sound(seq->scene_sound, seqmute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void seq_update_muting(Scene *scene, Editing *ed)
|
||||
void seq_update_muting(Editing *ed)
|
||||
{
|
||||
if(ed) {
|
||||
/* mute all sounds up to current metastack list */
|
||||
MetaStack *ms= ed->metastack.last;
|
||||
|
||||
if(ms)
|
||||
seq_update_muting_recursive(scene, &ed->seqbase, ms->parseq, 1);
|
||||
seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1);
|
||||
else
|
||||
seq_update_muting_recursive(scene, &ed->seqbase, NULL, 0);
|
||||
seq_update_muting_recursive(&ed->seqbase, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3469,7 +3491,7 @@ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
|
||||
|
||||
if(seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
|
||||
if(seq->sound)
|
||||
sound_cache(seq->sound, 0);
|
||||
sound_cache(seq->sound);
|
||||
}
|
||||
|
||||
seq_load->tot_success++;
|
||||
|
||||
@@ -91,6 +91,7 @@ void sound_free(struct bSound* sound)
|
||||
if(sound->cache)
|
||||
{
|
||||
AUD_unload(sound->cache);
|
||||
sound->cache = NULL;
|
||||
}
|
||||
#endif // WITH_AUDASPACE
|
||||
}
|
||||
@@ -250,23 +251,25 @@ void sound_delete(struct bContext *C, struct bSound* sound)
|
||||
}
|
||||
}
|
||||
|
||||
void sound_cache(struct bSound* sound, int ignore)
|
||||
void sound_cache(struct bSound* sound)
|
||||
{
|
||||
if(sound->cache && !ignore)
|
||||
sound->flags |= SOUND_FLAGS_CACHING;
|
||||
if(sound->cache)
|
||||
AUD_unload(sound->cache);
|
||||
|
||||
sound->cache = AUD_bufferSound(sound->handle);
|
||||
sound->playback_handle = sound->cache;
|
||||
}
|
||||
|
||||
void sound_cache_notifying(struct Main* main, struct bSound* sound, int ignore)
|
||||
void sound_cache_notifying(struct Main* main, struct bSound* sound)
|
||||
{
|
||||
sound_cache(sound, ignore);
|
||||
sound_cache(sound);
|
||||
sound_update_sequencer(main, sound);
|
||||
}
|
||||
|
||||
void sound_delete_cache(struct bSound* sound)
|
||||
{
|
||||
sound->flags &= ~SOUND_FLAGS_CACHING;
|
||||
if(sound->cache)
|
||||
{
|
||||
AUD_unload(sound->cache);
|
||||
@@ -279,6 +282,12 @@ void sound_load(struct Main *bmain, struct bSound* sound)
|
||||
{
|
||||
if(sound)
|
||||
{
|
||||
if(sound->cache)
|
||||
{
|
||||
AUD_unload(sound->cache);
|
||||
sound->cache = NULL;
|
||||
}
|
||||
|
||||
if(sound->handle)
|
||||
{
|
||||
AUD_unload(sound->handle);
|
||||
@@ -330,6 +339,11 @@ void sound_load(struct Main *bmain, struct bSound* sound)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if(sound->flags & SOUND_FLAGS_CACHING)
|
||||
{
|
||||
sound->cache = AUD_bufferSound(sound->handle);
|
||||
}
|
||||
|
||||
if(sound->cache)
|
||||
sound->playback_handle = sound->cache;
|
||||
else
|
||||
@@ -400,7 +414,12 @@ void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence
|
||||
|
||||
void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
|
||||
{
|
||||
return AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
|
||||
void* handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
|
||||
AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0);
|
||||
AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0);
|
||||
AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0);
|
||||
AUD_setSequenceAnimData(handle, AUD_AP_PANNING, CFRA, &sequence->pan, 0);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sound_remove_scene_sound(struct Scene *scene, void* handle)
|
||||
@@ -408,7 +427,7 @@ void sound_remove_scene_sound(struct Scene *scene, void* handle)
|
||||
AUD_removeSequence(scene->sound_scene, handle);
|
||||
}
|
||||
|
||||
void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute)
|
||||
void sound_mute_scene_sound(void* handle, char mute)
|
||||
{
|
||||
AUD_muteSequence(handle, mute);
|
||||
}
|
||||
@@ -612,7 +631,7 @@ void sound_force_device(int UNUSED(device)) {}
|
||||
void sound_init_once(void) {}
|
||||
void sound_init(struct Main *UNUSED(bmain)) {}
|
||||
void sound_exit(void) {}
|
||||
void sound_cache(struct bSound* UNUSED(sound), int UNUSED(ignore)) { }
|
||||
void sound_cache(struct bSound* UNUSED(sound)) { }
|
||||
void sound_delete_cache(struct bSound* UNUSED(sound)) {}
|
||||
void sound_load(struct Main *UNUSED(bmain), struct bSound* UNUSED(sound)) {}
|
||||
void sound_create_scene(struct Scene *UNUSED(scene)) {}
|
||||
@@ -621,7 +640,7 @@ void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
|
||||
void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
|
||||
void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
|
||||
void sound_remove_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle)) {}
|
||||
void sound_mute_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), char UNUSED(mute)) {}
|
||||
void sound_mute_scene_sound(void* UNUSED(handle), char UNUSED(mute)) {}
|
||||
void sound_move_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {}
|
||||
static void sound_start_play_scene(struct Scene *UNUSED(scene)) {}
|
||||
void sound_play_scene(struct Scene *UNUSED(scene)) {}
|
||||
|
||||
@@ -4473,7 +4473,7 @@ static void lib_link_scene(FileData *fd, Main *main)
|
||||
#endif
|
||||
|
||||
if(sce->ed)
|
||||
seq_update_muting(sce, sce->ed);
|
||||
seq_update_muting(sce->ed);
|
||||
|
||||
if(sce->nodetree) {
|
||||
lib_link_ntree(fd, &sce->id, sce->nodetree);
|
||||
@@ -5608,6 +5608,13 @@ static void direct_link_sound(FileData *fd, bSound *sound)
|
||||
sound->handle = NULL;
|
||||
sound->playback_handle = NULL;
|
||||
|
||||
// versioning stuff, if there was a cache, then we enable caching:
|
||||
if(sound->cache)
|
||||
{
|
||||
sound->flags |= SOUND_FLAGS_CACHING;
|
||||
sound->cache = NULL;
|
||||
}
|
||||
|
||||
sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
|
||||
sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
|
||||
}
|
||||
@@ -5623,9 +5630,6 @@ static void lib_link_sound(FileData *fd, Main *main)
|
||||
sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system
|
||||
|
||||
sound_load(main, sound);
|
||||
|
||||
if(sound->cache)
|
||||
sound_cache_notifying(main, sound, 1);
|
||||
}
|
||||
sound= sound->id.next;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ static int open_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "cache")) {
|
||||
sound_cache(sound, 0);
|
||||
sound_cache(sound);
|
||||
}
|
||||
|
||||
/* hook into UI */
|
||||
@@ -356,6 +356,8 @@ static void mixdown_draw(bContext *C, wmOperator *op)
|
||||
case AUD_CODEC_VORBIS:
|
||||
RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -382,6 +384,8 @@ static void mixdown_draw(bContext *C, wmOperator *op)
|
||||
RNA_def_property_enum_items(prop_codec, all_codec_items);
|
||||
RNA_enum_set(op->ptr, "codec", AUD_CODEC_PCM);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
|
||||
@@ -354,7 +354,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
|
||||
}
|
||||
|
||||
sort_seq(scene);
|
||||
seq_update_muting(scene, ed);
|
||||
seq_update_muting(ed);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
|
||||
|
||||
|
||||
@@ -1228,7 +1228,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
seq_update_muting(scene, ed);
|
||||
seq_update_muting(ed);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1275,7 +1275,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
seq_update_muting(scene, ed);
|
||||
seq_update_muting(ed);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1901,7 +1901,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
}
|
||||
|
||||
seq_update_muting(scene, ed);
|
||||
seq_update_muting(ed);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1965,7 +1965,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene);
|
||||
|
||||
seq_update_muting(scene, ed);
|
||||
seq_update_muting(ed);
|
||||
|
||||
seqbase_unique_name_recursive(&scene->ed->seqbase, seqm);
|
||||
|
||||
@@ -2038,7 +2038,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
|
||||
sort_seq(scene);
|
||||
seq_update_muting(scene, ed);
|
||||
seq_update_muting(ed);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
|
||||
|
||||
|
||||
@@ -106,7 +106,8 @@ typedef enum eSound_Type {
|
||||
#define SND_DRAWFRAMES 1
|
||||
#define SND_CFRA_NUM 2
|
||||
|
||||
#define SOUND_FLAGS_3D (1 << 3)
|
||||
#define SOUND_FLAGS_3D (1 << 3) /* deprecated! used for sound actuator loading */
|
||||
#define SOUND_FLAGS_CACHING (1 << 4)
|
||||
|
||||
/* to DNA_sound_types.h*/
|
||||
|
||||
|
||||
@@ -182,6 +182,7 @@ EnumPropertyItem image_type_items[] = {
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_sound.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_sequencer.h"
|
||||
#include "BKE_animsys.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
@@ -335,6 +336,7 @@ static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
static void rna_Scene_fps_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
sound_update_fps(scene);
|
||||
seq_update_sound_bounds_all(scene);
|
||||
}
|
||||
|
||||
static void rna_Scene_listener_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
|
||||
|
||||
@@ -602,7 +602,7 @@ static void rna_Sequence_mute_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
Editing *ed= seq_give_editing(scene, FALSE);
|
||||
|
||||
seq_update_muting(scene, ed);
|
||||
seq_update_muting(ed);
|
||||
rna_Sequence_update(bmain, scene, ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ static void rna_Sound_filepath_update(Main *bmain, Scene *UNUSED(scene), Pointer
|
||||
static int rna_Sound_caching_get(PointerRNA *ptr)
|
||||
{
|
||||
bSound *sound = (bSound*)(ptr->data);
|
||||
return sound->cache != NULL;
|
||||
return (sound->flags & SOUND_FLAGS_CACHING) != 0;
|
||||
}
|
||||
|
||||
static void rna_Sound_caching_set(PointerRNA *ptr, const int value)
|
||||
{
|
||||
bSound *sound = (bSound*)(ptr->data);
|
||||
if(value)
|
||||
sound_cache(sound, 0);
|
||||
sound_cache(sound);
|
||||
else
|
||||
sound_delete_cache(sound);
|
||||
}
|
||||
|
||||
@@ -95,10 +95,6 @@ extern float BKE_screen_view3d_zoom_to_fac(float camzoom);
|
||||
#include "BKE_ipo.h"
|
||||
/***/
|
||||
|
||||
#ifdef WITH_AUDASPACE
|
||||
# include "AUD_C-API.h"
|
||||
#endif
|
||||
|
||||
//XXX #include "BSE_headerbuttons.h"
|
||||
#include "BKE_context.h"
|
||||
#include "../../blender/windowmanager/WM_types.h"
|
||||
@@ -108,6 +104,11 @@ extern float BKE_screen_view3d_zoom_to_fac(float camzoom);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_AUDASPACE
|
||||
# include "AUD_C-API.h"
|
||||
# include "AUD_I3DDevice.h"
|
||||
# include "AUD_IDevice.h"
|
||||
#endif
|
||||
|
||||
static BlendFileData *load_game_data(char *filename)
|
||||
{
|
||||
@@ -394,9 +395,13 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
||||
ketsjiengine->InitDome(scene->gm.dome.res, scene->gm.dome.mode, scene->gm.dome.angle, scene->gm.dome.resbuf, scene->gm.dome.tilt, scene->gm.dome.warptext);
|
||||
|
||||
// initialize 3D Audio Settings
|
||||
AUD_setSpeedOfSound(scene->audio.speed_of_sound);
|
||||
AUD_setDopplerFactor(scene->audio.doppler_factor);
|
||||
AUD_setDistanceModel(AUD_DistanceModel(scene->audio.distance_model));
|
||||
AUD_I3DDevice* dev = AUD_get3DDevice();
|
||||
if(dev)
|
||||
{
|
||||
dev->setSpeedOfSound(scene->audio.speed_of_sound);
|
||||
dev->setDopplerFactor(scene->audio.doppler_factor);
|
||||
dev->setDistanceModel(AUD_DistanceModel(scene->audio.distance_model));
|
||||
}
|
||||
|
||||
// from see blender.c:
|
||||
// FIXME: this version patching should really be part of the file-reading code,
|
||||
@@ -581,7 +586,10 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
||||
{
|
||||
delete canvas;
|
||||
canvas = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// stop all remaining playing sounds
|
||||
AUD_getDevice()->stopAll();
|
||||
|
||||
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ void BL_ConvertActuators(char* maggiename,
|
||||
{
|
||||
bSound* sound = soundact->sound;
|
||||
bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
|
||||
AUD_Sound* snd_sound = NULL;
|
||||
AUD_Reference<AUD_IFactory> snd_sound;
|
||||
KX_3DSoundSettings settings;
|
||||
settings.cone_inner_angle = soundact->sound3D.cone_inner_angle;
|
||||
settings.cone_outer_angle = soundact->sound3D.cone_outer_angle;
|
||||
@@ -406,7 +406,7 @@ void BL_ConvertActuators(char* maggiename,
|
||||
"\" has no sound datablock." << std::endl;
|
||||
}
|
||||
else
|
||||
snd_sound = sound->playback_handle;
|
||||
snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle);
|
||||
KX_SoundActuator* tmpsoundact =
|
||||
new KX_SoundActuator(gameobj,
|
||||
snd_sound,
|
||||
|
||||
@@ -251,6 +251,7 @@ endif()
|
||||
if(WITH_AUDASPACE)
|
||||
list(APPEND INC
|
||||
../../../intern/audaspace/intern
|
||||
../../../intern/audaspace/FX
|
||||
)
|
||||
add_definitions(-DWITH_AUDASPACE)
|
||||
endif()
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
|
||||
#ifdef WITH_AUDASPACE
|
||||
# include "AUD_C-API.h"
|
||||
# include "AUD_I3DDevice.h"
|
||||
#endif
|
||||
|
||||
#include "NG_NetworkScene.h"
|
||||
@@ -995,16 +996,20 @@ void KX_KetsjiEngine::DoSound(KX_Scene* scene)
|
||||
if (!cam)
|
||||
return;
|
||||
|
||||
float f[4];
|
||||
AUD_I3DDevice* dev = AUD_get3DDevice();
|
||||
if(dev)
|
||||
{
|
||||
AUD_Vector3 v;
|
||||
AUD_Quaternion q;
|
||||
cam->NodeGetWorldPosition().getValue(v.get());
|
||||
dev->setListenerLocation(v);
|
||||
|
||||
cam->NodeGetWorldPosition().getValue(f);
|
||||
AUD_setListenerLocation(f);
|
||||
cam->GetLinearVelocity().getValue(v.get());
|
||||
dev->setListenerVelocity(v);
|
||||
|
||||
cam->GetLinearVelocity().getValue(f);
|
||||
AUD_setListenerVelocity(f);
|
||||
|
||||
cam->NodeGetWorldOrientation().getRotation().getValue(f);
|
||||
AUD_setListenerOrientation(f);
|
||||
cam->NodeGetWorldOrientation().getRotation().getValue(q.get());
|
||||
dev->setListenerOrientation(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
|
||||
#ifdef WITH_AUDASPACE
|
||||
# include "AUD_C-API.h"
|
||||
# include "AUD_PingPongFactory.h"
|
||||
# include "AUD_IDevice.h"
|
||||
# include "AUD_I3DHandle.h"
|
||||
#endif
|
||||
|
||||
#include "KX_GameObject.h"
|
||||
@@ -49,7 +52,7 @@
|
||||
/* Native functions */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
|
||||
AUD_Sound* sound,
|
||||
AUD_Reference<AUD_IFactory> sound,
|
||||
float volume,
|
||||
float pitch,
|
||||
bool is3d,
|
||||
@@ -57,15 +60,11 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
|
||||
KX_SOUNDACT_TYPE type)//,
|
||||
: SCA_IActuator(gameobj, KX_ACT_SOUND)
|
||||
{
|
||||
if(sound)
|
||||
m_sound = AUD_copy(sound);
|
||||
else
|
||||
m_sound = NULL;
|
||||
m_sound = sound;
|
||||
m_volume = volume;
|
||||
m_pitch = pitch;
|
||||
m_is3d = is3d;
|
||||
m_3d = settings;
|
||||
m_handle = NULL;
|
||||
m_type = type;
|
||||
m_isplaying = false;
|
||||
}
|
||||
@@ -74,27 +73,20 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
|
||||
|
||||
KX_SoundActuator::~KX_SoundActuator()
|
||||
{
|
||||
if(m_handle)
|
||||
AUD_stop(m_handle);
|
||||
if(m_sound)
|
||||
AUD_unload(m_sound);
|
||||
if(!m_handle.isNull())
|
||||
m_handle->stop();
|
||||
}
|
||||
|
||||
void KX_SoundActuator::play()
|
||||
{
|
||||
if(m_handle)
|
||||
{
|
||||
AUD_stop(m_handle);
|
||||
m_handle = NULL;
|
||||
}
|
||||
if(!m_handle.isNull())
|
||||
m_handle->stop();
|
||||
|
||||
if(!m_sound)
|
||||
if(m_sound.isNull())
|
||||
return;
|
||||
|
||||
// this is the sound that will be played and not deleted afterwards
|
||||
AUD_Sound* sound = m_sound;
|
||||
// this sound is for temporary stacked sounds, will be deleted if not NULL
|
||||
AUD_Sound* sound2 = NULL;
|
||||
AUD_Reference<AUD_IFactory> sound = m_sound;
|
||||
|
||||
bool loop = false;
|
||||
|
||||
@@ -102,7 +94,7 @@ void KX_SoundActuator::play()
|
||||
{
|
||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
|
||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
|
||||
sound = sound2 = AUD_pingpongSound(sound);
|
||||
sound = new AUD_PingPongFactory(sound);
|
||||
// fall through
|
||||
case KX_SOUNDACT_LOOPEND:
|
||||
case KX_SOUNDACT_LOOPSTOP:
|
||||
@@ -114,31 +106,27 @@ void KX_SoundActuator::play()
|
||||
break;
|
||||
}
|
||||
|
||||
m_handle = AUD_play(sound, 0);
|
||||
m_handle = AUD_getDevice()->play(sound, 0);
|
||||
|
||||
if(sound2)
|
||||
AUD_unload(sound2);
|
||||
AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(m_handle);
|
||||
|
||||
if(!m_handle)
|
||||
return;
|
||||
|
||||
if(m_is3d)
|
||||
if(m_is3d && !handle3d.isNull())
|
||||
{
|
||||
AUD_setRelative(m_handle, false);
|
||||
AUD_setVolumeMaximum(m_handle, m_3d.max_gain);
|
||||
AUD_setVolumeMinimum(m_handle, m_3d.min_gain);
|
||||
AUD_setDistanceReference(m_handle, m_3d.reference_distance);
|
||||
AUD_setDistanceMaximum(m_handle, m_3d.max_distance);
|
||||
AUD_setAttenuation(m_handle, m_3d.rolloff_factor);
|
||||
AUD_setConeAngleInner(m_handle, m_3d.cone_inner_angle);
|
||||
AUD_setConeAngleOuter(m_handle, m_3d.cone_outer_angle);
|
||||
AUD_setConeVolumeOuter(m_handle, m_3d.cone_outer_gain);
|
||||
handle3d->setRelative(false);
|
||||
handle3d->setVolumeMaximum(m_3d.max_gain);
|
||||
handle3d->setVolumeMinimum(m_3d.min_gain);
|
||||
handle3d->setDistanceReference(m_3d.reference_distance);
|
||||
handle3d->setDistanceMaximum(m_3d.max_distance);
|
||||
handle3d->setAttenuation(m_3d.rolloff_factor);
|
||||
handle3d->setConeAngleInner(m_3d.cone_inner_angle);
|
||||
handle3d->setConeAngleOuter(m_3d.cone_outer_angle);
|
||||
handle3d->setConeVolumeOuter(m_3d.cone_outer_gain);
|
||||
}
|
||||
|
||||
if(loop)
|
||||
AUD_setLoop(m_handle, -1);
|
||||
AUD_setSoundPitch(m_handle, m_pitch);
|
||||
AUD_setSoundVolume(m_handle, m_volume);
|
||||
m_handle->setLoopCount(-1);
|
||||
m_handle->setPitch(m_pitch);
|
||||
m_handle->setVolume(m_volume);
|
||||
m_isplaying = true;
|
||||
}
|
||||
|
||||
@@ -152,7 +140,7 @@ CValue* KX_SoundActuator::GetReplica()
|
||||
void KX_SoundActuator::ProcessReplica()
|
||||
{
|
||||
SCA_IActuator::ProcessReplica();
|
||||
m_handle = 0;
|
||||
m_handle = AUD_Reference<AUD_IHandle>();
|
||||
}
|
||||
|
||||
bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||
@@ -167,11 +155,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||
|
||||
RemoveAllEvents();
|
||||
|
||||
if(!m_sound)
|
||||
if(m_sound.isNull())
|
||||
return false;
|
||||
|
||||
// actual audio device playing state
|
||||
bool isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
|
||||
bool isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING);
|
||||
|
||||
if (bNegativeEvent)
|
||||
{
|
||||
@@ -185,9 +173,9 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
|
||||
{
|
||||
// stop immediately
|
||||
if(m_handle)
|
||||
AUD_stop(m_handle);
|
||||
m_handle = NULL;
|
||||
if(!m_handle.isNull())
|
||||
m_handle->stop();
|
||||
m_handle = AUD_Reference<AUD_IHandle>();
|
||||
break;
|
||||
}
|
||||
case KX_SOUNDACT_PLAYEND:
|
||||
@@ -199,8 +187,8 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
|
||||
{
|
||||
// stop the looping so that the sound stops when it finished
|
||||
if(m_handle)
|
||||
AUD_setLoop(m_handle, 0);
|
||||
if(!m_handle.isNull())
|
||||
m_handle->setLoopCount(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -226,21 +214,24 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||
play();
|
||||
}
|
||||
// verify that the sound is still playing
|
||||
isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
|
||||
isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING);
|
||||
|
||||
if (isplaying)
|
||||
{
|
||||
if(m_is3d)
|
||||
AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(m_handle);
|
||||
|
||||
if(m_is3d && !handle3d.isNull())
|
||||
{
|
||||
KX_GameObject* obj = (KX_GameObject*)this->GetParent();
|
||||
float f[4];
|
||||
AUD_Vector3 v;
|
||||
AUD_Quaternion q;
|
||||
|
||||
obj->NodeGetWorldPosition().getValue(f);
|
||||
AUD_setSourceLocation(m_handle, f);
|
||||
obj->GetLinearVelocity().getValue(f);
|
||||
AUD_setSourceVelocity(m_handle, f);
|
||||
obj->NodeGetWorldOrientation().getRotation().getValue(f);
|
||||
AUD_setSourceOrientation(m_handle, f);
|
||||
obj->NodeGetWorldPosition().getValue(v.get());
|
||||
handle3d->setSourceLocation(v);
|
||||
obj->GetLinearVelocity().getValue(v.get());
|
||||
handle3d->setSourceVelocity(v);
|
||||
obj->NodeGetWorldOrientation().getRotation().getValue(q.get());
|
||||
handle3d->setSourceOrientation(q);
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
@@ -252,7 +243,6 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -315,14 +305,14 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound,
|
||||
"startSound()\n"
|
||||
"\tStarts the sound.\n")
|
||||
{
|
||||
if(m_handle)
|
||||
if(!m_handle.isNull())
|
||||
{
|
||||
switch(AUD_getStatus(m_handle))
|
||||
switch(m_handle->getStatus())
|
||||
{
|
||||
case AUD_STATUS_PLAYING:
|
||||
break;
|
||||
case AUD_STATUS_PAUSED:
|
||||
AUD_resume(m_handle);
|
||||
m_handle->resume();
|
||||
break;
|
||||
default:
|
||||
play();
|
||||
@@ -335,8 +325,8 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound,
|
||||
"pauseSound()\n"
|
||||
"\tPauses the sound.\n")
|
||||
{
|
||||
if(m_handle)
|
||||
AUD_pause(m_handle);
|
||||
if(!m_handle.isNull())
|
||||
m_handle->pause();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -344,9 +334,9 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
|
||||
"stopSound()\n"
|
||||
"\tStops the sound.\n")
|
||||
{
|
||||
if(m_handle)
|
||||
AUD_stop(m_handle);
|
||||
m_handle = NULL;
|
||||
if(!m_handle.isNull())
|
||||
m_handle->stop();
|
||||
m_handle = AUD_Reference<AUD_IHandle>();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -394,8 +384,8 @@ PyObject* KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_P
|
||||
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
|
||||
float position = 0.0;
|
||||
|
||||
if(actuator->m_handle)
|
||||
position = AUD_getPosition(actuator->m_handle);
|
||||
if(!actuator->m_handle.isNull())
|
||||
position = actuator->m_handle->getPosition();
|
||||
|
||||
PyObject* result = PyFloat_FromDouble(position);
|
||||
|
||||
@@ -425,8 +415,8 @@ PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRI
|
||||
PyObject* KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
|
||||
if(actuator->m_sound)
|
||||
return AUD_getPythonFactory(actuator->m_sound);
|
||||
if(!actuator->m_sound.isNull())
|
||||
return AUD_getPythonFactory(&actuator->m_sound);
|
||||
else
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -440,49 +430,50 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI
|
||||
if (!PyArg_Parse(value, "f", &prop_value))
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(actuator->m_handle);
|
||||
// if sound is working and 3D, set the new setting
|
||||
if(!actuator->m_is3d)
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
if(!strcmp(prop, "volume_maximum")) {
|
||||
actuator->m_3d.max_gain = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setVolumeMaximum(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setVolumeMaximum(prop_value);
|
||||
|
||||
} else if (!strcmp(prop, "volume_minimum")) {
|
||||
actuator->m_3d.min_gain = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setVolumeMinimum(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setVolumeMinimum(prop_value);
|
||||
|
||||
} else if (!strcmp(prop, "distance_reference")) {
|
||||
actuator->m_3d.reference_distance = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setDistanceReference(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setDistanceReference(prop_value);
|
||||
|
||||
} else if (!strcmp(prop, "distance_maximum")) {
|
||||
actuator->m_3d.max_distance = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setDistanceMaximum(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setDistanceMaximum(prop_value);
|
||||
|
||||
} else if (!strcmp(prop, "attenuation")) {
|
||||
actuator->m_3d.rolloff_factor = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setAttenuation(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setAttenuation(prop_value);
|
||||
|
||||
} else if (!!strcmp(prop, "cone_angle_inner")) {
|
||||
actuator->m_3d.cone_inner_angle = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setConeAngleInner(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setConeAngleInner(prop_value);
|
||||
|
||||
} else if (!strcmp(prop, "cone_angle_outer")) {
|
||||
actuator->m_3d.cone_outer_angle = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setConeAngleOuter(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setConeAngleOuter(prop_value);
|
||||
|
||||
} else if (!strcmp(prop, "cone_volume_outer")) {
|
||||
actuator->m_3d.cone_outer_gain = prop_value;
|
||||
if(actuator->m_handle)
|
||||
AUD_setConeVolumeOuter(actuator->m_handle, prop_value);
|
||||
if(!handle3d.isNull())
|
||||
handle3d->setConeVolumeOuter(prop_value);
|
||||
|
||||
} else {
|
||||
return PY_SET_ATTR_FAIL;
|
||||
@@ -499,8 +490,8 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI
|
||||
if (!PyArg_Parse(value, "f", &position))
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
if(actuator->m_handle)
|
||||
AUD_seek(actuator->m_handle, position);
|
||||
if(!actuator->m_handle.isNull())
|
||||
actuator->m_handle->seek(position);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -512,8 +503,8 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
actuator->m_volume = gain;
|
||||
if(actuator->m_handle)
|
||||
AUD_setSoundVolume(actuator->m_handle, gain);
|
||||
if(!actuator->m_handle.isNull())
|
||||
actuator->m_handle->setVolume(gain);
|
||||
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
@@ -526,8 +517,8 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
actuator->m_pitch = pitch;
|
||||
if(actuator->m_handle)
|
||||
AUD_setSoundPitch(actuator->m_handle, pitch);
|
||||
if(!actuator->m_handle.isNull())
|
||||
actuator->m_handle->setPitch(pitch);
|
||||
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
@@ -539,12 +530,11 @@ int KX_SoundActuator::pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_D
|
||||
if (!PyArg_Parse(value, "O", &sound))
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
AUD_Sound* snd = AUD_getPythonSound(sound);
|
||||
AUD_Reference<AUD_IFactory>* snd = reinterpret_cast<AUD_Reference<AUD_IFactory>*>(AUD_getPythonSound(sound));
|
||||
if(snd)
|
||||
{
|
||||
if(actuator->m_sound)
|
||||
AUD_unload(actuator->m_sound);
|
||||
actuator->m_sound = snd;
|
||||
actuator->m_sound = *snd;
|
||||
delete snd;
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
|
||||
#ifdef WITH_AUDASPACE
|
||||
# include "AUD_C-API.h"
|
||||
# include "AUD_Reference.h"
|
||||
# include "AUD_IFactory.h"
|
||||
# include "AUD_IHandle.h"
|
||||
#endif
|
||||
|
||||
#include "BKE_sound.h"
|
||||
@@ -58,12 +61,12 @@ class KX_SoundActuator : public SCA_IActuator
|
||||
{
|
||||
Py_Header;
|
||||
bool m_isplaying;
|
||||
AUD_Sound* m_sound;
|
||||
AUD_Reference<AUD_IFactory> m_sound;
|
||||
float m_volume;
|
||||
float m_pitch;
|
||||
bool m_is3d;
|
||||
KX_3DSoundSettings m_3d;
|
||||
AUD_Handle* m_handle;
|
||||
AUD_Reference<AUD_IHandle> m_handle;
|
||||
|
||||
void play();
|
||||
|
||||
@@ -84,7 +87,7 @@ public:
|
||||
KX_SOUNDACT_TYPE m_type;
|
||||
|
||||
KX_SoundActuator(SCA_IObject* gameobj,
|
||||
AUD_Sound* sound,
|
||||
AUD_Reference<AUD_IFactory> sound,
|
||||
float volume,
|
||||
float pitch,
|
||||
bool is3d,
|
||||
|
||||
@@ -11,7 +11,7 @@ incs += ' #source/blender/python/mathutils' # Only for mathutils, be very carefu
|
||||
|
||||
incs += ' #intern/string #intern/guardedalloc #intern/container'
|
||||
incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer'
|
||||
incs += ' #intern/audaspace/intern #source/gameengine/Converter'
|
||||
incs += ' #intern/audaspace/intern #intern/audaspace/FX #source/gameengine/Converter'
|
||||
incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf #intern/moto/include'
|
||||
incs += ' #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork #source/blender/blenlib #source/blender/blenfont'
|
||||
incs += ' #source/blender/blenkernel #source/blender #source/blender/editors/include'
|
||||
|
||||
Reference in New Issue
Block a user