mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
a NEED DEBUG version of openal sound system, nakee, try to FIX it! :)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3409 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
b8d3cae6e3
commit
ff0ec2b3f8
@ -25,18 +25,18 @@
|
||||
#include "FixedSizeQueue.h"
|
||||
#include "AudioCommon.h"
|
||||
|
||||
void CMixer::Mix(short *samples, int numSamples)
|
||||
int CMixer::Mix(short *samples, int numSamples)
|
||||
{
|
||||
if (! samples) {
|
||||
Premix(NULL, 0);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
// silence
|
||||
memset(samples, 0, numSamples * 2 * sizeof(short));
|
||||
|
||||
if (g_dspInitialize.pEmulatorState) {
|
||||
if (*g_dspInitialize.pEmulatorState != 0)
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// first get the DTK Music
|
||||
@ -46,9 +46,11 @@ void CMixer::Mix(short *samples, int numSamples)
|
||||
|
||||
Premix(samples, numSamples);
|
||||
|
||||
push_sync.Enter();
|
||||
int count = 0;
|
||||
while (m_queueSize > queue_minlength && count < numSamples * 2) {
|
||||
|
||||
push_sync.Enter();
|
||||
while (m_queueSize > queue_minlength && count < numSamples * 2)
|
||||
{
|
||||
int x = samples[count];
|
||||
x += sample_queue.front();
|
||||
if (x > 32767) x = 32767;
|
||||
@ -64,6 +66,8 @@ void CMixer::Mix(short *samples, int numSamples)
|
||||
m_queueSize-=2;
|
||||
}
|
||||
push_sync.Leave();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
CMixer() : m_sampleRate(48000),m_bits(16),m_channels(2), m_mode(2), m_HLEready(false),m_queueSize(0) {}
|
||||
|
||||
// Called from audio threads
|
||||
virtual void Mix(short *sample, int numSamples);
|
||||
virtual int Mix(short *sample, int numSamples);
|
||||
|
||||
// Called from main thread
|
||||
virtual void PushSamples(short* samples, int num_stereo_samples, int core_sample_rate);
|
||||
@ -39,7 +39,9 @@ public:
|
||||
virtual void Premix(short *samples, int numSamples) {}
|
||||
|
||||
int GetSampleRate() {return m_sampleRate;}
|
||||
|
||||
|
||||
int GetDataSize() {return m_queueSize;}
|
||||
|
||||
void SetThrottle(bool use) { m_throttle = use;}
|
||||
void SetDTKMusic(bool use) { m_EnableDTKMusic = use;}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
class NullMixer : public CMixer {
|
||||
public:
|
||||
virtual void Mix(short *sample, int numSamples) {}
|
||||
virtual int Mix(short *sample, int numSamples) {return 0;}
|
||||
virtual void PushSamples(short* samples, int num_stereo_samples,
|
||||
int core_sample_rate) {}
|
||||
};
|
||||
|
@ -86,7 +86,10 @@ void OpenALStream::Stop()
|
||||
|
||||
void OpenALStream::Update()
|
||||
{
|
||||
soundSyncEvent.Set();
|
||||
//if (m_mixer->GetDataSize()) //here need debug
|
||||
{
|
||||
soundSyncEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
THREAD_RETURN OpenALStream::ThreadFunc(void* args)
|
||||
@ -120,28 +123,37 @@ void OpenALStream::SoundLoop()
|
||||
|
||||
while (!threadData)
|
||||
{
|
||||
ALint iBuffersProcessed = 0;
|
||||
alGetSourcei(uiSource, AL_BUFFERS_PROCESSED, &iBuffersProcessed);
|
||||
soundCriticalSection.Enter();
|
||||
int numBytesToRender = 32768; //ya, this is a hack, we need real data count
|
||||
int numBytesRender = m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
if (iBuffersProcessed)
|
||||
//if (numBytesRender) //here need debug
|
||||
{
|
||||
// Remove the Buffer from the Queue. (uiBuffer contains the Buffer ID for the unqueued Buffer)
|
||||
ALuint uiTempBuffer = 0;
|
||||
alSourceUnqueueBuffers(uiSource, 1, &uiTempBuffer);
|
||||
ALint iBuffersProcessed = 0;
|
||||
alGetSourcei(uiSource, AL_BUFFERS_PROCESSED, &iBuffersProcessed);
|
||||
|
||||
soundCriticalSection.Enter();
|
||||
int numBytesToRender = 32768; //ya, this is a hack, we need real data count
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
unsigned long ulBytesWritten = 0;
|
||||
//if (ulBytesWritten)
|
||||
if (iBuffersProcessed)
|
||||
{
|
||||
//alBufferData(uiTempBuffer, ulFormat, pDecodeBuffer, ulBytesWritten, ulFrequency);
|
||||
alBufferData(uiTempBuffer, AL_FORMAT_STEREO16, realtimeBuffer, numBytesToRender, ulFrequency);
|
||||
// Remove the Buffer from the Queue. (uiBuffer contains the Buffer ID for the unqueued Buffer)
|
||||
ALuint uiTempBuffer = 0;
|
||||
alSourceUnqueueBuffers(uiSource, 1, &uiTempBuffer);
|
||||
/*
|
||||
soundCriticalSection.Enter();
|
||||
int numBytesToRender = 32768; //ya, this is a hack, we need real data count
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
unsigned long ulBytesWritten = 0;
|
||||
*/
|
||||
//if (numBytesRender)
|
||||
{
|
||||
alBufferData(uiTempBuffer, AL_FORMAT_STEREO16, realtimeBuffer, numBytesToRender, ulFrequency);
|
||||
}
|
||||
alSourceQueueBuffers(uiSource, 1, &uiTempBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (!threadData)
|
||||
soundSyncEvent.Wait();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user