Fixed a bug that would cause a crash when ever a audio listener would be added and or removed.
This commit is contained in:
parent
12bed3d337
commit
0c9ae2fc36
|
@ -12,8 +12,8 @@
|
|||
namespace cAudio
|
||||
{
|
||||
#ifdef CAUDIO_EFX_ENABLED
|
||||
cAudioSource::cAudioSource(IAudioDecoder* decoder, ALCcontext* context, cEFXFunctions* oALFunctions)
|
||||
: Context(context), Source(0), Decoder(decoder), Loop(false), Valid(false),
|
||||
cAudioSource::cAudioSource(IAudioDecoder* decoder, ALCcontext* context, cEFXFunctions* oALFunctions)
|
||||
: Context(context), Source(0), Decoder(decoder), Loop(false), Valid(false),
|
||||
EFX(oALFunctions), Filter(NULL), EffectSlotsAvailable(0), LastFilterTimeStamp(0)
|
||||
#else
|
||||
cAudioSource::cAudioSource(IAudioDecoder* decoder, ALCcontext* context)
|
||||
|
@ -85,25 +85,25 @@ namespace cAudio
|
|||
bool cAudioSource::play()
|
||||
{
|
||||
cAudioMutexBasicLock lock(Mutex);
|
||||
if (!isPaused())
|
||||
{
|
||||
if (!isPaused())
|
||||
{
|
||||
int queueSize = 0;
|
||||
//Purges all buffers from the source
|
||||
alSourcei(Source, AL_BUFFER, 0);
|
||||
checkError();
|
||||
for(int u = 0; u < CAUDIO_SOURCE_NUM_BUFFERS; u++)
|
||||
{
|
||||
int val = stream(Buffers[u]);
|
||||
|
||||
if(val < 0)
|
||||
{
|
||||
for(int u = 0; u < CAUDIO_SOURCE_NUM_BUFFERS; u++)
|
||||
{
|
||||
int val = stream(Buffers[u]);
|
||||
|
||||
if(val < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(val > 0)
|
||||
++queueSize;
|
||||
}
|
||||
//Stores the sources 3 buffers to be used in the queue
|
||||
alSourceQueueBuffers(Source, queueSize, Buffers);
|
||||
}
|
||||
else if(val > 0)
|
||||
++queueSize;
|
||||
}
|
||||
//Stores the sources 3 buffers to be used in the queue
|
||||
alSourceQueueBuffers(Source, queueSize, Buffers);
|
||||
checkError();
|
||||
}
|
||||
#ifdef CAUDIO_EFX_ENABLED
|
||||
|
@ -116,7 +116,7 @@ namespace cAudio
|
|||
getLogger()->logDebug("Audio Source", "Source playing.");
|
||||
signalEvent(ON_PLAY);
|
||||
oldState = AL_PLAYING;
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cAudioSource::play2d(const bool& toLoop)
|
||||
|
@ -150,7 +150,7 @@ namespace cAudio
|
|||
signalEvent(ON_PAUSE);
|
||||
oldState = AL_PAUSED;
|
||||
}
|
||||
|
||||
|
||||
void cAudioSource::stop()
|
||||
{
|
||||
cAudioMutexBasicLock lock(Mutex);
|
||||
|
@ -305,7 +305,7 @@ namespace cAudio
|
|||
{
|
||||
return Loop;
|
||||
}
|
||||
|
||||
|
||||
void cAudioSource::setPosition(const cVector3& position)
|
||||
{
|
||||
cAudioMutexBasicLock lock(Mutex);
|
||||
|
@ -772,6 +772,7 @@ namespace cAudio
|
|||
{
|
||||
if(handler)
|
||||
{
|
||||
cAudioMutexbasicLock lock(Mutex);
|
||||
eventHandlerList.push_back(handler);
|
||||
}
|
||||
}
|
||||
|
@ -780,12 +781,14 @@ namespace cAudio
|
|||
{
|
||||
if(handler)
|
||||
{
|
||||
cAudioMutexLock lock(Mutex);
|
||||
eventHandlerList.remove(handler);
|
||||
}
|
||||
}
|
||||
|
||||
void cAudioSource::unRegisterAllEventHandlers()
|
||||
{
|
||||
cAudioMutexLock lock(Mutex);
|
||||
eventHandlerList.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// For conditions of distribution and use, see copyright notice in cAudio.h
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include "../Headers/cLogger.h"
|
||||
#include "../Headers/cConsoleLogReceiver.h"
|
||||
#include "../Headers/cFileLogReceiver.h"
|
||||
|
@ -12,7 +13,7 @@ namespace cAudio
|
|||
{
|
||||
static cLogger Logger;
|
||||
static bool FirstTimeLogInit(false);
|
||||
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER
|
||||
static cConsoleLogReceiver ConsoleLog;
|
||||
#endif
|
||||
|
@ -162,4 +163,4 @@ namespace cAudio
|
|||
}
|
||||
return &Logger;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_workspace_file>
|
||||
<Workspace title="Workspace">
|
||||
<Project filename="cAudio.cbp" active="1" />
|
||||
<Project filename="Examples\Tutorial1_2DSound\Tutorial1_2DSound.cbp" />
|
||||
<Project filename="Examples\Tutorial2_3DSound\Tutorial2_3DSound.cbp" />
|
||||
<Project filename="Examples\Tutorial3_MemoryPlayback\Tutorial3_MemoryPlayback.cbp" />
|
||||
<Project filename="Examples\Tutorial4_AudioCapture\Tutorial4_AudioCapture.cbp" />
|
||||
<Project filename="Examples\Tutorial5_AudioEffects\Tutorial5_AudioEffects.cbp" />
|
||||
<Project filename="Examples\Tutorial6_CustomEventHandler\Tutorial6_CustomEventHandler.cbp" />
|
||||
<Project filename="Examples\Tutorial7_CustomLogReceiver\Tutorial7_CustomLogReceiver.cbp" />
|
||||
<Project filename="plugins\mp3Decoder\mp3Decoder.cbp" />
|
||||
<Project filename="plugins\EAXLegacyPreset\EAXLegacyPreset.cbp" />
|
||||
<Project filename="tests\Stress_Test\Stress_Test.cbp" />
|
||||
<Project filename="cAudio.cbp" />
|
||||
<Project filename="Examples/Tutorial1_2DSound/Tutorial1_2DSound.cbp" active="1" />
|
||||
<Project filename="Examples/Tutorial2_3DSound/Tutorial2_3DSound.cbp" />
|
||||
<Project filename="Examples/Tutorial3_MemoryPlayback/Tutorial3_MemoryPlayback.cbp" />
|
||||
<Project filename="Examples/Tutorial4_AudioCapture/Tutorial4_AudioCapture.cbp" />
|
||||
<Project filename="Examples/Tutorial5_AudioEffects/Tutorial5_AudioEffects.cbp" />
|
||||
<Project filename="Examples/Tutorial6_CustomEventHandler/Tutorial6_CustomEventHandler.cbp" />
|
||||
<Project filename="Examples/Tutorial7_CustomLogReceiver/Tutorial7_CustomLogReceiver.cbp" />
|
||||
<Project filename="plugins/mp3Decoder/mp3Decoder.cbp" />
|
||||
<Project filename="plugins/EAXLegacyPreset/EAXLegacyPreset.cbp" />
|
||||
<Project filename="tests/Stress_Test/Stress_Test.cbp" />
|
||||
</Workspace>
|
||||
</CodeBlocks_workspace_file>
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#define CAUDIO_SOURCE_NUM_BUFFERS 3
|
||||
|
||||
//! Comment out to remove all EFX support from the library
|
||||
#define CAUDIO_EFX_ENABLED
|
||||
//#define CAUDIO_EFX_ENABLED
|
||||
|
||||
//! Max number of effects that can be attached to a single sound source
|
||||
#define CAUDIO_SOURCE_MAX_EFFECT_SLOTS 4
|
||||
|
|
Loading…
Reference in New Issue