mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Attempt to move mixer to audio common, it's a bit more complicated than I expected
so please check I didn't break anything in hle git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2756 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -433,6 +433,14 @@
|
||||
RelativePath=".\Src\SoundStream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Mixer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Mixer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WaveFile.cpp"
|
||||
>
|
||||
|
||||
@@ -18,16 +18,18 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "AOSoundStream.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
#if defined(HAVE_AO) && HAVE_AO
|
||||
|
||||
void AOSound::SoundLoop()
|
||||
{
|
||||
uint_32 numBytesToRender = 256;
|
||||
ao_initialize();
|
||||
default_driver = ao_default_driver_id();
|
||||
format.bits = 16;
|
||||
format.channels = 2;
|
||||
format.rate = sampleRate;
|
||||
format.rate = m_mixer->GetSampleRate();
|
||||
format.byte_format = AO_FMT_LITTLE;
|
||||
|
||||
device = ao_open_live(default_driver, &format, NULL /* no options */);
|
||||
@@ -43,14 +45,21 @@ void AOSound::SoundLoop()
|
||||
|
||||
while (!threadData)
|
||||
{
|
||||
soundCriticalSection->Enter();
|
||||
soundCriticalSection.Enter();
|
||||
|
||||
uint_32 numBytesToRender = 256;
|
||||
(*callback)(realtimeBuffer, numBytesToRender >> 2, 16, sampleRate, 2);
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
soundCriticalSection->Leave();
|
||||
soundSyncEvent->Wait();
|
||||
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
if (! threadData)
|
||||
soundSyncEvent.Wait();
|
||||
}
|
||||
|
||||
ao_close(device);
|
||||
device = NULL;
|
||||
ao_shutdown();
|
||||
|
||||
}
|
||||
|
||||
void *soundThread(void *args)
|
||||
@@ -63,34 +72,28 @@ bool AOSound::Start()
|
||||
{
|
||||
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
|
||||
|
||||
soundSyncEvent = new Common::Event();
|
||||
soundSyncEvent->Init();
|
||||
|
||||
soundCriticalSection = new Common::CriticalSection(1);
|
||||
|
||||
soundSyncEvent.Init();
|
||||
|
||||
thread = new Common::Thread(soundThread, (void *)this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AOSound::Update()
|
||||
{
|
||||
soundSyncEvent->Set();
|
||||
soundSyncEvent.Set();
|
||||
}
|
||||
|
||||
void AOSound::Stop()
|
||||
{
|
||||
soundCriticalSection->Enter();
|
||||
soundCriticalSection.Enter();
|
||||
threadData = 1;
|
||||
soundSyncEvent->Set();
|
||||
soundCriticalSection->Leave();
|
||||
soundSyncEvent->Shutdown();
|
||||
delete soundCriticalSection;
|
||||
soundSyncEvent.Set();
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
delete thread;
|
||||
delete soundSyncEvent;
|
||||
thread = NULL;
|
||||
soundSyncEvent.Shutdown();
|
||||
|
||||
ao_close(device);
|
||||
device = NULL;
|
||||
ao_shutdown();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,8 +30,8 @@ class AOSound : public SoundStream
|
||||
{
|
||||
#if defined(HAVE_AO) && HAVE_AO
|
||||
Common::Thread *thread;
|
||||
Common::CriticalSection *soundCriticalSection;
|
||||
Common::Event *soundSyncEvent;
|
||||
Common::CriticalSection soundCriticalSection;
|
||||
Common::Event soundSyncEvent;
|
||||
|
||||
int buf_size;
|
||||
|
||||
@@ -42,9 +42,8 @@ class AOSound : public SoundStream
|
||||
short realtimeBuffer[1024 * 1024];
|
||||
|
||||
public:
|
||||
AOSound(int _sampleRate, StreamCallback _callback) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
|
||||
AOSound(CMixer *mixer) : SoundStream(mixer) {}
|
||||
|
||||
virtual ~AOSound() {}
|
||||
|
||||
virtual bool Start();
|
||||
@@ -63,14 +62,10 @@ public:
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual int GetSampleRate() {
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
#else
|
||||
public:
|
||||
AOSound(int _sampleRate, StreamCallback _callback) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
AOSound(CMixer *mixer) :
|
||||
SoundStream(mixer) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "AudioCommon.h"
|
||||
#include "Mixer.h"
|
||||
#include "AOSoundStream.h"
|
||||
#include "DSoundStream.h"
|
||||
#include "NullSoundStream.h"
|
||||
|
||||
|
||||
namespace AudioCommon {
|
||||
|
||||
SoundStream *InitSoundStream(std::string backend, CMixer *mixer) {
|
||||
|
||||
if (!mixer) {
|
||||
mixer = new CMixer();
|
||||
}
|
||||
|
||||
if (backend == "DSound") {
|
||||
if (DSound::isValid())
|
||||
soundStream = new DSound(mixer, g_dspInitialize.hWnd);
|
||||
}
|
||||
else if (backend == "AOSound") {
|
||||
if (AOSound::isValid())
|
||||
soundStream = new AOSound(mixer);
|
||||
}
|
||||
else if (backend == "NullSound") {
|
||||
soundStream = new NullSound(mixer);
|
||||
}
|
||||
else {
|
||||
PanicAlert("Cannot recognize backend %s", backend.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (soundStream) {
|
||||
if (!soundStream->Start()) {
|
||||
PanicAlert("Could not initialize backend %s, falling back to NULL",
|
||||
backend.c_str());
|
||||
delete soundStream;
|
||||
soundStream = new NullSound(mixer);
|
||||
soundStream->Start();
|
||||
}
|
||||
}
|
||||
else {
|
||||
PanicAlert("Sound backend %s is not valid, falling back to NULL",
|
||||
backend.c_str());
|
||||
delete soundStream;
|
||||
soundStream = new NullSound(mixer);
|
||||
soundStream->Start();
|
||||
}
|
||||
return soundStream;
|
||||
}
|
||||
|
||||
} // Namespace
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef _AUDIO_COMMON_H
|
||||
#define _AUDIO_COMMON_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "pluginspecs_dsp.h"
|
||||
#include "SoundStream.h"
|
||||
|
||||
class CMixer;
|
||||
|
||||
extern DSPInitialize g_dspInitialize;
|
||||
extern SoundStream *soundStream;
|
||||
|
||||
namespace AudioCommon {
|
||||
|
||||
SoundStream *InitSoundStream(std::string backend, CMixer *mixer = NULL);
|
||||
} // Namespace
|
||||
|
||||
#endif // AUDIO_COMMON
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <dxerr.h>
|
||||
#include "DSoundStream.h"
|
||||
|
||||
extern bool log_ai;
|
||||
//extern bool log_ai;
|
||||
|
||||
bool DSound::CreateBuffer()
|
||||
{
|
||||
@@ -114,7 +114,7 @@ void DSound::SoundLoop()
|
||||
{
|
||||
if (numBytesToRender > sizeof(realtimeBuffer))
|
||||
PanicAlert("soundThread: too big render call");
|
||||
(*callback)(realtimeBuffer, numBytesToRender >> 2, 16, sampleRate, 2);
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
WriteDataToBuffer(lastPos, (char*)realtimeBuffer, numBytesToRender);
|
||||
currentPos = ModBufferSize(lastPos + numBytesToRender);
|
||||
totalRenderedBytes += numBytesToRender;
|
||||
|
||||
@@ -64,12 +64,10 @@ class DSound : public SoundStream
|
||||
DWORD dwSoundBytes);
|
||||
|
||||
public:
|
||||
DSound(int _sampleRate, StreamCallback _callback) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
|
||||
DSound(int _sampleRate, StreamCallback _callback, void *_hWnd) :
|
||||
SoundStream(_sampleRate, _callback), hWnd(_hWnd) {}
|
||||
|
||||
DSound(CMixer *mixer, void *hWnd = NULL) : SoundStream(mixer) {}
|
||||
|
||||
DSound(CMixer *mixer) : SoundStream(mixer) {}
|
||||
|
||||
virtual ~DSound() {}
|
||||
|
||||
virtual bool Start();
|
||||
@@ -81,8 +79,8 @@ public:
|
||||
|
||||
#else
|
||||
public:
|
||||
DSound(int _sampleRate, StreamCallback _callback, void *hWnd = NULL) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
DSound(CMixer *mixer, void *hWnd = NULL) :
|
||||
SoundStream(mixer) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
+23
-63
@@ -21,87 +21,51 @@
|
||||
|
||||
#include "Thread.h" // Common
|
||||
|
||||
#include "../Config.h" // Local
|
||||
#include "../Globals.h"
|
||||
#include "../DSPHandler.h"
|
||||
#include "../Debugger/File.h"
|
||||
#include "../main.h"
|
||||
|
||||
#include "Mixer.h"
|
||||
#include "FixedSizeQueue.h"
|
||||
#include "AudioCommon.h"
|
||||
|
||||
namespace {
|
||||
|
||||
Common::CriticalSection push_sync;
|
||||
|
||||
// On real hardware, this fifo is much, much smaller. But timing is also tighter than under Windows, so...
|
||||
const int queue_minlength = 1024 * 4;
|
||||
const int queue_maxlength = 1024 * 28;
|
||||
|
||||
FixedSizeQueue<s16, queue_maxlength> sample_queue;
|
||||
|
||||
} // namespace
|
||||
|
||||
volatile bool mixer_HLEready = false;
|
||||
volatile int queue_size = 0;
|
||||
|
||||
void Mixer(short *buffer, int numSamples, int bits, int rate, int channels)
|
||||
void CMixer::Mix(short *samples, int numSamples)
|
||||
{
|
||||
// silence
|
||||
memset(buffer, 0, numSamples * 2 * sizeof(short));
|
||||
memset(samples, 0, numSamples * 2 * sizeof(short));
|
||||
|
||||
if (g_dspInitialize.pEmulatorState) {
|
||||
if (*g_dspInitialize.pEmulatorState != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
// first get the DTK Music
|
||||
if (g_Config.m_EnableDTKMusic)
|
||||
{
|
||||
g_dspInitialize.pGetAudioStreaming(buffer, numSamples);
|
||||
}
|
||||
|
||||
Mixer_MixUCode(buffer, numSamples, bits, rate, channels);
|
||||
|
||||
Premix(samples, numSamples);
|
||||
|
||||
push_sync.Enter();
|
||||
int count = 0;
|
||||
while (queue_size > queue_minlength && count < numSamples * 2) {
|
||||
int x = buffer[count];
|
||||
while (m_queueSize > queue_minlength && count < numSamples * 2) {
|
||||
int x = samples[count];
|
||||
x += sample_queue.front();
|
||||
if (x > 32767) x = 32767;
|
||||
if (x < -32767) x = -32767;
|
||||
buffer[count++] = x;
|
||||
samples[count++] = x;
|
||||
sample_queue.pop();
|
||||
x = buffer[count];
|
||||
x = samples[count];
|
||||
x += sample_queue.front();
|
||||
if (x > 32767) x = 32767;
|
||||
if (x < -32767) x = -32767;
|
||||
buffer[count++] = x;
|
||||
samples[count++] = x;
|
||||
sample_queue.pop();
|
||||
queue_size-=2;
|
||||
m_queueSize-=2;
|
||||
}
|
||||
push_sync.Leave();
|
||||
}
|
||||
|
||||
void Mixer_MixUCode(short *buffer, int numSamples, int bits, int rate,
|
||||
int channels) {
|
||||
//if this was called directly from the HLE, and not by timeout
|
||||
if (g_Config.m_EnableHLEAudio && mixer_HLEready)
|
||||
{
|
||||
IUCode* pUCode = CDSPHandler::GetInstance().GetUCode();
|
||||
if (pUCode != NULL)
|
||||
pUCode->MixAdd(buffer, numSamples);
|
||||
}
|
||||
}
|
||||
|
||||
void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
void CMixer::PushSamples(short *samples, int num_stereo_samples)
|
||||
{
|
||||
if (!soundStream)
|
||||
return;
|
||||
|
||||
if (queue_size == 0)
|
||||
if (m_queueSize == 0)
|
||||
{
|
||||
queue_size = queue_minlength;
|
||||
m_queueSize = queue_minlength;
|
||||
for (int i = 0; i < queue_minlength; i++)
|
||||
sample_queue.push((s16)0);
|
||||
}
|
||||
@@ -116,12 +80,11 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
#endif
|
||||
|
||||
// Write Other Audio
|
||||
if (g_Config.m_EnableThrottle)
|
||||
{
|
||||
if (m_throttle) {
|
||||
/* This is only needed for non-AX sound, currently directly
|
||||
streamed and DTK sound. For AX we call SoundStream::Update in
|
||||
AXTask() for example. */
|
||||
while (queue_size > queue_maxlength / 2) {
|
||||
while (m_queueSize > queue_maxlength / 2) {
|
||||
// Urgh.
|
||||
if (g_dspInitialize.pEmulatorState) {
|
||||
if (*g_dspInitialize.pEmulatorState != 0)
|
||||
@@ -129,25 +92,22 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
}
|
||||
soundStream->Update();
|
||||
Common::SleepCurrentThread(0);
|
||||
}
|
||||
|
||||
//convert into config option?
|
||||
const int mode = 2;
|
||||
}
|
||||
|
||||
push_sync.Enter();
|
||||
while (num_stereo_samples)
|
||||
{
|
||||
acc += sample_rate;
|
||||
acc += m_sampleRate;
|
||||
while (num_stereo_samples && (acc >= 48000))
|
||||
{
|
||||
PV4l=PV3l;
|
||||
PV3l=PV2l;
|
||||
PV2l=PV1l;
|
||||
PV1l=*(buffer++); //32bit processing
|
||||
PV1l=*(samples++); //32bit processing
|
||||
PV4r=PV3r;
|
||||
PV3r=PV2r;
|
||||
PV2r=PV1r;
|
||||
PV1r=*(buffer++); //32bit processing
|
||||
PV1r=*(samples++); //32bit processing
|
||||
num_stereo_samples--;
|
||||
acc-=48000;
|
||||
}
|
||||
@@ -156,12 +116,12 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
s32 DataL = PV1l;
|
||||
s32 DataR = PV1r;
|
||||
|
||||
if (mode == 1) //linear
|
||||
if (m_mode == 1) //linear
|
||||
{
|
||||
DataL = PV1l + ((PV2l - PV1l)*acc)/48000;
|
||||
DataR = PV1r + ((PV2r - PV1r)*acc)/48000;
|
||||
}
|
||||
else if (mode == 2) //cubic
|
||||
else if (m_mode == 2) //cubic
|
||||
{
|
||||
s32 a0l = PV1l - PV2l - PV4l + PV3l;
|
||||
s32 a0r = PV1r - PV2r - PV4r + PV3r;
|
||||
@@ -192,7 +152,7 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
if (r > 32767) r = 32767;
|
||||
sample_queue.push(l);
|
||||
sample_queue.push(r);
|
||||
queue_size += 2;
|
||||
m_queueSize += 2;
|
||||
}
|
||||
push_sync.Leave();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _MIXER_H
|
||||
#define _MIXER_H
|
||||
|
||||
#include "FixedSizeQueue.h"
|
||||
|
||||
// On real hardware, this fifo is much, much smaller. But timing is also
|
||||
// tighter than under Windows, so...
|
||||
#define queue_minlength 1024 * 4
|
||||
#define queue_maxlength 1024 * 28
|
||||
|
||||
class CMixer {
|
||||
|
||||
public:
|
||||
CMixer() : m_sampleRate(48000),m_bits(16),m_channels(2), m_mode(2), m_HLEready(false) {}
|
||||
|
||||
// Called from audio threads
|
||||
void Mix(short *sample, int numSamples);
|
||||
|
||||
// Called from main thread
|
||||
void PushSamples(short* samples, int num_stereo_samples);
|
||||
|
||||
virtual void Premix(short *samples, int numSamples) {}
|
||||
|
||||
int GetSampleRate() {return m_sampleRate;}
|
||||
|
||||
void SetThrottle(bool use) { m_throttle = use;}
|
||||
|
||||
// FIXME do we need this
|
||||
bool IsHLEReady() { return m_HLEready;}
|
||||
void SetHLEReady(bool ready) { m_HLEready = ready;}
|
||||
//////
|
||||
|
||||
protected:
|
||||
int m_sampleRate;
|
||||
int m_bits;
|
||||
int m_channels;
|
||||
|
||||
int m_mode;
|
||||
bool m_HLEready;
|
||||
int m_queueSize;
|
||||
|
||||
bool m_throttle;
|
||||
private:
|
||||
Common::CriticalSection push_sync;
|
||||
FixedSizeQueue<s16, queue_maxlength> sample_queue;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
class NullSound : public SoundStream
|
||||
{
|
||||
public:
|
||||
NullSound(int _sampleRate, StreamCallback _callback) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
NullSound(CMixer *mixer) : SoundStream(mixer) {}
|
||||
|
||||
virtual ~NullSound() {}
|
||||
|
||||
@@ -35,7 +34,8 @@ public:
|
||||
virtual bool Start() { return true; }
|
||||
|
||||
virtual void Update() {
|
||||
(*callback)(NULL, 256 >> 2, 16, sampleRate, 2);
|
||||
m_mixer->Mix(NULL, 256 >> 2);
|
||||
//(*callback)(NULL, 256 >> 2, 16, sampleRate, 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ Import('env')
|
||||
files = [
|
||||
'AOSoundStream.cpp',
|
||||
'WaveFile.cpp',
|
||||
'Mixer.cpp',
|
||||
'AudioCommon.cpp',
|
||||
]
|
||||
|
||||
env_audiocommon = env.Clone()
|
||||
|
||||
@@ -19,32 +19,27 @@
|
||||
#define __SOUNDSTREAM_H__
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
typedef void (*StreamCallback)(short* buffer, int numSamples, int bits, int rate, int channels);
|
||||
#include "Mixer.h"
|
||||
|
||||
class SoundStream
|
||||
{
|
||||
protected:
|
||||
int sampleRate;
|
||||
StreamCallback callback;
|
||||
|
||||
CMixer *m_mixer;
|
||||
// We set this to shut down the sound thread.
|
||||
// 0=keep playing, 1=stop playing NOW.
|
||||
volatile int threadData;
|
||||
|
||||
public:
|
||||
SoundStream(int _sampleRate, StreamCallback _callback) :
|
||||
sampleRate(_sampleRate), callback(_callback), threadData(0) {}
|
||||
virtual ~SoundStream() {}
|
||||
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0) {}
|
||||
virtual ~SoundStream() { delete m_mixer;}
|
||||
|
||||
static bool isValid() { return false; }
|
||||
virtual bool usesMixer() const { return false; }
|
||||
virtual bool Start() { return false; }
|
||||
virtual void SoundLoop() {}
|
||||
virtual void Stop() {}
|
||||
virtual void Update() {}
|
||||
|
||||
virtual int GetSampleRate() const { return sampleRate; }
|
||||
static bool isValid() { return false; }
|
||||
virtual CMixer *GetMixer() const { return m_mixer; }
|
||||
virtual bool Start() { return false; }
|
||||
virtual void SoundLoop() {}
|
||||
virtual void Stop() {}
|
||||
virtual void Update() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -548,18 +548,6 @@
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="PCHW"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Src\Pchw\Mixer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Pchw\Mixer.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="UCodes"
|
||||
>
|
||||
@@ -748,6 +736,14 @@
|
||||
RelativePath=".\Src\DSPHandler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\HLEMixer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\HLEMixer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Globals.cpp"
|
||||
>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "Config.h" // Local
|
||||
#include "Globals.h"
|
||||
#include "DSPHandler.h"
|
||||
#include "HLEMixer.h"
|
||||
|
||||
void HLEMixer::MixUCode(short *samples, int numSamples) {
|
||||
//if this was called directly from the HLE, and not by timeout
|
||||
if (g_Config.m_EnableHLEAudio && IsHLEReady()) {
|
||||
IUCode* pUCode = CDSPHandler::GetInstance().GetUCode();
|
||||
if (pUCode != NULL)
|
||||
pUCode->MixAdd(samples, numSamples);
|
||||
}
|
||||
}
|
||||
|
||||
void HLEMixer::Premix(short *samples, int numSamples) {
|
||||
|
||||
// first get the DTK Music
|
||||
if (g_Config.m_EnableDTKMusic) {
|
||||
g_dspInitialize.pGetAudioStreaming(samples, numSamples);
|
||||
}
|
||||
|
||||
MixUCode(samples, numSamples);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef HLEMIXER_H
|
||||
#define HLEMIXER_H
|
||||
#include "AudioCommon.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
class HLEMixer : public CMixer
|
||||
{
|
||||
public:
|
||||
void MixUCode(short *samples, int numSamples);
|
||||
|
||||
virtual void Premix(short *samples, int numSamples);
|
||||
};
|
||||
|
||||
#endif // HLEMIXER_H
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _MIXER_H
|
||||
#define _MIXER_H
|
||||
|
||||
extern volatile bool mixer_HLEready;
|
||||
|
||||
// Called from audio threads
|
||||
void Mixer(short* buffer, int numSamples, int bits, int rate, int channels);
|
||||
|
||||
void Mixer_MixUCode(short *buffer, int numSamples, int bits, int rate, int channels);
|
||||
|
||||
// Called from main thread
|
||||
void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,11 +8,10 @@ name = "Plugin_DSP_HLE"
|
||||
files = [
|
||||
'DSPHandler.cpp',
|
||||
'MailHandler.cpp',
|
||||
'HLEMixer.cpp',
|
||||
'main.cpp',
|
||||
'Config.cpp',
|
||||
'Globals.cpp',
|
||||
# 'PCHW/AOSoundStream.cpp',
|
||||
'PCHW/Mixer.cpp',
|
||||
'Debugger/File.cpp',
|
||||
'UCodes/UCode_AX.cpp',
|
||||
'UCodes/UCode_AXWii.cpp',
|
||||
|
||||
@@ -25,7 +25,7 @@ extern CDebugger* m_frame;
|
||||
#include <sstream>
|
||||
|
||||
#include "../Globals.h"
|
||||
#include "../PCHW/Mixer.h"
|
||||
#include "Mixer.h"
|
||||
#include "../MailHandler.h"
|
||||
|
||||
#include "UCodes.h"
|
||||
@@ -513,7 +513,7 @@ bool CUCode_AX::AXTask(u32& _uMail)
|
||||
m_addressPBs = Memory_Read_U32(uAddress);
|
||||
uAddress += 4;
|
||||
|
||||
mixer_HLEready = true;
|
||||
soundStream->GetMixer()->SetHLEReady(true);
|
||||
SaveLog("%08x : AXLIST PB address: %08x", uAddress, m_addressPBs);
|
||||
|
||||
SaveLog("Update the SoundThread to be in sync");
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
extern CDebugger * m_frame;
|
||||
#endif
|
||||
|
||||
#include "../PCHW/Mixer.h"
|
||||
#include "../MailHandler.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
#include "UCodes.h"
|
||||
#include "UCode_AXStructs.h"
|
||||
@@ -324,7 +324,7 @@ bool CUCode_AXWii::AXTask(u32& _uMail)
|
||||
case 0x0004: // PBs are here now
|
||||
m_addressPBs = Memory_Read_U32(uAddress);
|
||||
lCUCode_AX->m_addressPBs = m_addressPBs; // for the sake of logging
|
||||
mixer_HLEready = true;
|
||||
soundStream->GetMixer()->SetHLEReady(true);
|
||||
SaveLog("%08x : AXLIST PB address: %08x", uAddress, m_addressPBs);
|
||||
soundStream->Update();
|
||||
uAddress += 4;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "UCode_AX_ADPCM.h"
|
||||
#include "UCode_AX.h"
|
||||
#include "../main.h"
|
||||
|
||||
#include "Mixer.h"
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Externals
|
||||
@@ -107,7 +107,7 @@ inline void WriteBackPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
|
||||
template<class ParamBlockType>
|
||||
inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize, bool Wii)
|
||||
{
|
||||
ratioFactor = 32000.0f / (float)soundStream->GetSampleRate();
|
||||
ratioFactor = 32000.0f / (float)soundStream->GetMixer()->GetSampleRate();
|
||||
|
||||
DoVoiceHacks(pb, Wii);
|
||||
|
||||
@@ -115,7 +115,6 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
|
||||
if (pb.running)
|
||||
{
|
||||
|
||||
// =======================================================================================
|
||||
// Read initial parameters
|
||||
// ------------
|
||||
//constants
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user