mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
The Mega Change Of Doom - or, fixing Stop. Almost. At least it's better than before. However, the OpenGL plugin seems to lose textures a lot between game restarts :P I think the GL plugin needs to do a lot more cleanup.
This change also includes tons of minor code formatting cleanup. Yeah, should've separated it ... sorry :( Kills the old CPUCompare support. I'll resurrect it if I need it again, right now it mostly clutters the code. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2321 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -31,7 +31,8 @@ void AOSound::SoundLoop()
|
||||
format.byte_format = AO_FMT_LITTLE;
|
||||
|
||||
device = ao_open_live(default_driver, &format, NULL /* no options */);
|
||||
if (device == NULL) {
|
||||
if (!device)
|
||||
{
|
||||
PanicAlert("DSP_HLE: Error opening AO device.\n");
|
||||
ao_shutdown();
|
||||
Stop();
|
||||
@ -40,23 +41,26 @@ void AOSound::SoundLoop()
|
||||
|
||||
buf_size = format.bits/8 * format.channels * format.rate;
|
||||
|
||||
while (!threadData) {
|
||||
soundCriticalSection->Enter();
|
||||
|
||||
uint_32 numBytesToRender = 256;
|
||||
(*callback)(realtimeBuffer, numBytesToRender >> 2, 16, sampleRate, 2);
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
soundCriticalSection->Leave();
|
||||
soundSyncEvent->Wait();
|
||||
}
|
||||
while (!threadData)
|
||||
{
|
||||
soundCriticalSection->Enter();
|
||||
|
||||
uint_32 numBytesToRender = 256;
|
||||
(*callback)(realtimeBuffer, numBytesToRender >> 2, 16, sampleRate, 2);
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
soundCriticalSection->Leave();
|
||||
soundSyncEvent->Wait();
|
||||
}
|
||||
}
|
||||
|
||||
void *soundThread(void *args) {
|
||||
void *soundThread(void *args)
|
||||
{
|
||||
((AOSound *)args)->SoundLoop();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool AOSound::Start() {
|
||||
bool AOSound::Start()
|
||||
{
|
||||
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
|
||||
|
||||
soundSyncEvent = new Common::Event();
|
||||
@ -68,7 +72,8 @@ bool AOSound::Start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void AOSound::Update() {
|
||||
void AOSound::Update()
|
||||
{
|
||||
soundSyncEvent->Set();
|
||||
}
|
||||
|
||||
|
@ -26,61 +26,52 @@
|
||||
|
||||
#include "Thread.h"
|
||||
|
||||
|
||||
class AOSound : public SoundStream
|
||||
{
|
||||
|
||||
#if defined(HAVE_AO) && HAVE_AO
|
||||
|
||||
Common::Thread *thread;
|
||||
Common::Thread *thread;
|
||||
Common::CriticalSection *soundCriticalSection;
|
||||
Common::Event *soundSyncEvent;
|
||||
|
||||
Common::CriticalSection *soundCriticalSection;
|
||||
|
||||
Common::Event *soundSyncEvent;
|
||||
|
||||
int buf_size;
|
||||
|
||||
ao_device *device;
|
||||
ao_sample_format format;
|
||||
int default_driver;
|
||||
|
||||
short realtimeBuffer[1024 * 1024];
|
||||
int buf_size;
|
||||
|
||||
ao_device *device;
|
||||
ao_sample_format format;
|
||||
int default_driver;
|
||||
|
||||
short realtimeBuffer[1024 * 1024];
|
||||
|
||||
public:
|
||||
AOSound(int _sampleRate, StreamCallback _callback) :
|
||||
AOSound(int _sampleRate, StreamCallback _callback) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
|
||||
virtual ~AOSound() {}
|
||||
|
||||
virtual bool Start();
|
||||
|
||||
virtual void SoundLoop();
|
||||
|
||||
virtual void Stop();
|
||||
|
||||
static bool isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool usesMixer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual ~AOSound() {}
|
||||
|
||||
virtual bool Start();
|
||||
|
||||
virtual void SoundLoop();
|
||||
|
||||
virtual void Stop();
|
||||
|
||||
static bool isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool usesMixer() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual int GetSampleRate() {
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
virtual int GetSampleRate() {
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
public:
|
||||
AOSound(int _sampleRate, StreamCallback _callback) :
|
||||
AOSound(int _sampleRate, StreamCallback _callback) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif //__AOSOUNDSTREAM_H__
|
||||
|
@ -16,13 +16,9 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <dxerr.h>
|
||||
|
||||
#include "DSoundStream.h"
|
||||
#include "../main.h"
|
||||
#include "WaveFile.h"
|
||||
|
||||
extern bool log_ai;
|
||||
extern WaveFileWriter g_wave_writer;
|
||||
|
||||
bool DSound::CreateBuffer()
|
||||
{
|
||||
@ -39,9 +35,9 @@ bool DSound::CreateBuffer()
|
||||
pcmwf.wf.nAvgBytesPerSec = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign;
|
||||
pcmwf.wBitsPerSample = 16;
|
||||
|
||||
//buffer description
|
||||
// Fill out DSound buffer description.
|
||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STICKYFOCUS; //VIKTIGT //DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
|
||||
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STICKYFOCUS;
|
||||
dsbdesc.dwBufferBytes = bufferSize = BUFSIZE;
|
||||
dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&pcmwf;
|
||||
|
||||
@ -51,7 +47,8 @@ bool DSound::CreateBuffer()
|
||||
dsBuffer->SetCurrentPosition(0);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// Failed.
|
||||
PanicAlert("Sound buffer creation failed: %s", DXGetErrorString(res));
|
||||
dsBuffer = NULL;
|
||||
@ -64,11 +61,12 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write
|
||||
DWORD dwSoundBytes) // Size of block to copy.
|
||||
{
|
||||
// I want to record the regular audio to, how do I do that?
|
||||
// Well, it's gonna be a bit tricky. For future work :)
|
||||
//std::string Data = ArrayToString((const u8*)soundData, dwSoundBytes);
|
||||
//Console::Print("Data: %s\n\n", Data.c_str());
|
||||
//if (log_ai) g_wave_writer.AddStereoSamples((const short*)soundData, dwSoundBytes);
|
||||
|
||||
void* ptr1, * ptr2;
|
||||
void *ptr1, *ptr2;
|
||||
DWORD numBytes1, numBytes2;
|
||||
// Obtain memory address of write block. This will be in two parts if the block wraps around.
|
||||
HRESULT hr = dsBuffer->Lock(dwOffset, dwSoundBytes, &ptr1, &numBytes1, &ptr2, &numBytes2, 0);
|
||||
@ -79,15 +77,11 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write
|
||||
dsBuffer->Restore();
|
||||
hr = dsBuffer->Lock(dwOffset, dwSoundBytes, &ptr1, &numBytes1, &ptr2, &numBytes2, 0);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
memcpy(ptr1, soundData, numBytes1);
|
||||
|
||||
if (ptr2 != 0)
|
||||
{
|
||||
memcpy(ptr2, soundData + numBytes1, numBytes2);
|
||||
}
|
||||
|
||||
// Release the data back to DirectSound.
|
||||
dsBuffer->Unlock(ptr1, numBytes1, ptr2, numBytes2);
|
||||
@ -100,43 +94,33 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write
|
||||
// The audio thread.
|
||||
DWORD WINAPI soundThread(void* args)
|
||||
{
|
||||
((DSound *)args)->SoundLoop();
|
||||
|
||||
return 0; //huzzah! :D
|
||||
(reinterpret_cast<DSound *>(args))->SoundLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DSound::SoundLoop() {
|
||||
|
||||
void DSound::SoundLoop()
|
||||
{
|
||||
currentPos = 0;
|
||||
lastPos = 0;
|
||||
|
||||
// Prefill buffer?
|
||||
//writeDataToBuffer(0,realtimeBuffer,bufferSize);
|
||||
// dsBuffer->Lock(0, bufferSize, (void **)&p1, &num1, (void **)&p2, &num2, 0);
|
||||
dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
|
||||
|
||||
while (!threadData) {
|
||||
while (!threadData)
|
||||
{
|
||||
// No blocking inside the csection
|
||||
soundCriticalSection->Enter();
|
||||
dsBuffer->GetCurrentPosition((DWORD*)¤tPos, 0);
|
||||
int numBytesToRender = FIX128(ModBufferSize(currentPos - lastPos));
|
||||
|
||||
if (numBytesToRender >= 256)
|
||||
{
|
||||
if (numBytesToRender > sizeof(realtimeBuffer))
|
||||
PanicAlert("soundThread: too big render call");
|
||||
(*callback)(realtimeBuffer, numBytesToRender >> 2, 16,
|
||||
sampleRate, 2);
|
||||
|
||||
(*callback)(realtimeBuffer, numBytesToRender >> 2, 16, sampleRate, 2);
|
||||
WriteDataToBuffer(lastPos, (char*)realtimeBuffer, numBytesToRender);
|
||||
currentPos = ModBufferSize(lastPos + numBytesToRender);
|
||||
totalRenderedBytes += numBytesToRender;
|
||||
|
||||
lastPos = currentPos;
|
||||
}
|
||||
|
||||
soundCriticalSection->Leave();
|
||||
|
||||
soundSyncEvent->Wait();
|
||||
}
|
||||
|
||||
@ -145,20 +129,14 @@ void DSound::SoundLoop() {
|
||||
|
||||
bool DSound::Start()
|
||||
{
|
||||
//no security attributes, automatic resetting, init state nonset, untitled
|
||||
soundSyncEvent = new Common::Event();
|
||||
soundSyncEvent->Init();
|
||||
|
||||
//vi initierar den...........
|
||||
soundCriticalSection = new Common::CriticalSection();
|
||||
|
||||
//vi vill ha access till DSOUND s<>...
|
||||
if (FAILED(DirectSoundCreate8(0, &ds, 0)))
|
||||
return false;
|
||||
|
||||
return false;
|
||||
if(hWnd)
|
||||
ds->SetCooperativeLevel((HWND)hWnd, DSSCL_NORMAL);
|
||||
|
||||
if (!CreateBuffer())
|
||||
return false;
|
||||
|
||||
@ -168,7 +146,6 @@ bool DSound::Start()
|
||||
memset(p1, 0, num1);
|
||||
dsBuffer->Unlock(p1, num1, 0, 0);
|
||||
totalRenderedBytes = -bufferSize;
|
||||
|
||||
thread = new Common::Thread(soundThread, (void *)this);
|
||||
return true;
|
||||
}
|
||||
@ -196,15 +173,3 @@ void DSound::Stop()
|
||||
soundSyncEvent = NULL;
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
/* Unused, is it needed?
|
||||
int DSound::GetCurSample()
|
||||
{
|
||||
soundCriticalSection->Enter();
|
||||
int playCursor;
|
||||
dsBuffer->GetCurrentPosition((DWORD*)&playCursor, 0);
|
||||
playCursor = ModBufferSize(playCursor - lastPos) + totalRenderedBytes;
|
||||
soundCriticalSection->Leave();
|
||||
return playCursor;
|
||||
}
|
||||
*/
|
||||
|
@ -34,11 +34,8 @@
|
||||
|
||||
class DSound : public SoundStream
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
Common::Thread *thread;
|
||||
|
||||
Common::CriticalSection *soundCriticalSection;
|
||||
Common::Event *soundSyncEvent;
|
||||
void *hWnd;
|
||||
@ -55,20 +52,18 @@ class DSound : public SoundStream
|
||||
short realtimeBuffer[1024 * 1024];
|
||||
|
||||
inline int FIX128(int x) {
|
||||
return x & (~127);
|
||||
return x & (~127);
|
||||
}
|
||||
|
||||
inline int ModBufferSize(int x) {
|
||||
return (x + bufferSize) % bufferSize;
|
||||
return (x + bufferSize) % bufferSize;
|
||||
}
|
||||
|
||||
bool CreateBuffer();
|
||||
|
||||
bool WriteDataToBuffer(DWORD dwOffset, char* soundData,
|
||||
DWORD dwSoundBytes);
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
DSound(int _sampleRate, StreamCallback _callback) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
|
||||
@ -76,29 +71,19 @@ public:
|
||||
SoundStream(_sampleRate, _callback), hWnd(_hWnd) {}
|
||||
|
||||
virtual ~DSound() {}
|
||||
|
||||
virtual bool Start();
|
||||
|
||||
|
||||
virtual bool Start();
|
||||
virtual void SoundLoop();
|
||||
|
||||
virtual void Stop();
|
||||
|
||||
static bool isValid() { return true; }
|
||||
|
||||
virtual bool usesMixer() { return true; }
|
||||
|
||||
virtual bool usesMixer() const { return true; }
|
||||
virtual void Update();
|
||||
|
||||
#else
|
||||
public:
|
||||
|
||||
DSound(int _sampleRate, StreamCallback _callback, void *hWnd = NULL) :
|
||||
SoundStream(_sampleRate, _callback) {}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif //__DSOUNDSTREAM_H__
|
||||
|
@ -31,9 +31,8 @@
|
||||
#include "Mixer.h"
|
||||
#include "FixedSizeQueue.h"
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
Common::CriticalSection push_sync;
|
||||
|
||||
// On real hardware, this fifo is much, much smaller. But timing is also tighter than under Windows, so...
|
||||
@ -46,13 +45,6 @@ FixedSizeQueue<s16, queue_maxlength> sample_queue;
|
||||
|
||||
volatile bool mixer_HLEready = false;
|
||||
volatile int queue_size = 0;
|
||||
bool bThrottling = false;
|
||||
|
||||
/* What is this for?
|
||||
void UpdateThrottle(bool update)
|
||||
{
|
||||
bThrottling = update;
|
||||
}*/
|
||||
|
||||
void Mixer(short *buffer, int numSamples, int bits, int rate, int channels)
|
||||
{
|
||||
@ -105,11 +97,8 @@ void Mixer_MixUCode(short *buffer, int numSamples, int bits, int rate,
|
||||
|
||||
void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
{
|
||||
// We alredady do this with the WaveFileWriter right? So no need for this to?
|
||||
// static FILE *f;
|
||||
// if (!f)
|
||||
// f = fopen("d:\\hello.raw", "wb");
|
||||
// fwrite(buffer, num_stereo_samples * 4, 1, f);
|
||||
if (!soundStream)
|
||||
return;
|
||||
|
||||
if (queue_size == 0)
|
||||
{
|
||||
@ -128,14 +117,18 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
#endif
|
||||
|
||||
// Write Other Audio
|
||||
//bThrottling = g_Config.m_EnableThrottle;
|
||||
if (g_Config.m_EnableThrottle)
|
||||
{
|
||||
/* 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) {
|
||||
soundStream->Update();
|
||||
// Urgh.
|
||||
if (g_dspInitialize.pEmulatorState) {
|
||||
if (*g_dspInitialize.pEmulatorState != 0)
|
||||
return;
|
||||
}
|
||||
soundStream->Update();
|
||||
Common::SleepCurrentThread(0);
|
||||
}
|
||||
|
||||
@ -144,64 +137,64 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
|
||||
|
||||
push_sync.Enter();
|
||||
while (num_stereo_samples)
|
||||
{
|
||||
acc += sample_rate;
|
||||
while (num_stereo_samples && (acc >= 48000))
|
||||
{
|
||||
acc += sample_rate;
|
||||
while (num_stereo_samples && (acc >= 48000))
|
||||
{
|
||||
PV4l=PV3l;
|
||||
PV3l=PV2l;
|
||||
PV2l=PV1l;
|
||||
PV1l=*(buffer++); //32bit processing
|
||||
PV4r=PV3r;
|
||||
PV3r=PV2r;
|
||||
PV2r=PV1r;
|
||||
PV1r=*(buffer++); //32bit processing
|
||||
num_stereo_samples--;
|
||||
acc-=48000;
|
||||
}
|
||||
|
||||
// defaults to nearest
|
||||
s32 DataL = PV1l;
|
||||
s32 DataR = PV1r;
|
||||
|
||||
if (mode == 1) //linear
|
||||
{
|
||||
DataL = PV1l + ((PV2l - PV1l)*acc)/48000;
|
||||
DataR = PV1r + ((PV2r - PV1r)*acc)/48000;
|
||||
}
|
||||
else if (mode == 2) //cubic
|
||||
{
|
||||
s32 a0l = PV1l - PV2l - PV4l + PV3l;
|
||||
s32 a0r = PV1r - PV2r - PV4r + PV3r;
|
||||
s32 a1l = PV4l - PV3l - a0l;
|
||||
s32 a1r = PV4r - PV3r - a0r;
|
||||
s32 a2l = PV1l - PV4l;
|
||||
s32 a2r = PV1r - PV4r;
|
||||
s32 a3l = PV2l;
|
||||
s32 a3r = PV2r;
|
||||
|
||||
s32 t0l = ((a0l )*acc)/48000;
|
||||
s32 t0r = ((a0r )*acc)/48000;
|
||||
s32 t1l = ((t0l+a1l)*acc)/48000;
|
||||
s32 t1r = ((t0r+a1r)*acc)/48000;
|
||||
s32 t2l = ((t1l+a2l)*acc)/48000;
|
||||
s32 t2r = ((t1r+a2r)*acc)/48000;
|
||||
s32 t3l = ((t2l+a3l));
|
||||
s32 t3r = ((t2r+a3r));
|
||||
|
||||
DataL = t3l;
|
||||
DataR = t3r;
|
||||
}
|
||||
|
||||
int l = DataL, r = DataR;
|
||||
if (l < -32767) l = -32767;
|
||||
if (r < -32767) r = -32767;
|
||||
if (l > 32767) l = 32767;
|
||||
if (r > 32767) r = 32767;
|
||||
sample_queue.push(l);
|
||||
sample_queue.push(r);
|
||||
queue_size += 2;
|
||||
PV4l=PV3l;
|
||||
PV3l=PV2l;
|
||||
PV2l=PV1l;
|
||||
PV1l=*(buffer++); //32bit processing
|
||||
PV4r=PV3r;
|
||||
PV3r=PV2r;
|
||||
PV2r=PV1r;
|
||||
PV1r=*(buffer++); //32bit processing
|
||||
num_stereo_samples--;
|
||||
acc-=48000;
|
||||
}
|
||||
|
||||
// defaults to nearest
|
||||
s32 DataL = PV1l;
|
||||
s32 DataR = PV1r;
|
||||
|
||||
if (mode == 1) //linear
|
||||
{
|
||||
DataL = PV1l + ((PV2l - PV1l)*acc)/48000;
|
||||
DataR = PV1r + ((PV2r - PV1r)*acc)/48000;
|
||||
}
|
||||
else if (mode == 2) //cubic
|
||||
{
|
||||
s32 a0l = PV1l - PV2l - PV4l + PV3l;
|
||||
s32 a0r = PV1r - PV2r - PV4r + PV3r;
|
||||
s32 a1l = PV4l - PV3l - a0l;
|
||||
s32 a1r = PV4r - PV3r - a0r;
|
||||
s32 a2l = PV1l - PV4l;
|
||||
s32 a2r = PV1r - PV4r;
|
||||
s32 a3l = PV2l;
|
||||
s32 a3r = PV2r;
|
||||
|
||||
s32 t0l = ((a0l )*acc)/48000;
|
||||
s32 t0r = ((a0r )*acc)/48000;
|
||||
s32 t1l = ((t0l+a1l)*acc)/48000;
|
||||
s32 t1r = ((t0r+a1r)*acc)/48000;
|
||||
s32 t2l = ((t1l+a2l)*acc)/48000;
|
||||
s32 t2r = ((t1r+a2r)*acc)/48000;
|
||||
s32 t3l = ((t2l+a3l));
|
||||
s32 t3r = ((t2r+a3r));
|
||||
|
||||
DataL = t3l;
|
||||
DataR = t3r;
|
||||
}
|
||||
|
||||
int l = DataL, r = DataR;
|
||||
if (l < -32767) l = -32767;
|
||||
if (r < -32767) r = -32767;
|
||||
if (l > 32767) l = 32767;
|
||||
if (r > 32767) r = 32767;
|
||||
sample_queue.push(l);
|
||||
sample_queue.push(r);
|
||||
queue_size += 2;
|
||||
}
|
||||
push_sync.Leave();
|
||||
}
|
||||
}
|
||||
|
@ -22,37 +22,29 @@
|
||||
|
||||
typedef void (*StreamCallback)(short* buffer, int numSamples, int bits, int rate, int channels);
|
||||
|
||||
class SoundStream {
|
||||
|
||||
protected:
|
||||
class SoundStream
|
||||
{
|
||||
protected:
|
||||
int sampleRate;
|
||||
|
||||
StreamCallback callback;
|
||||
|
||||
// We set this to shut down the sound thread.
|
||||
// 0=keep playing, 1=stop playing NOW.
|
||||
volatile int threadData;
|
||||
|
||||
public:
|
||||
public:
|
||||
SoundStream(int _sampleRate, StreamCallback _callback) :
|
||||
sampleRate(_sampleRate), callback(_callback), threadData(0) {}
|
||||
|
||||
sampleRate(_sampleRate), callback(_callback), threadData(0) {}
|
||||
virtual ~SoundStream() {}
|
||||
|
||||
static bool isValid() { return false; }
|
||||
|
||||
virtual bool usesMixer() { return false; }
|
||||
|
||||
virtual bool usesMixer() const { return false; }
|
||||
virtual bool Start() { return false; }
|
||||
|
||||
virtual void SoundLoop() { }
|
||||
|
||||
virtual void SoundLoop() {}
|
||||
virtual void Stop() {}
|
||||
|
||||
virtual void Update() {}
|
||||
|
||||
virtual int GetSampleRate() { return sampleRate; }
|
||||
|
||||
virtual int GetSampleRate() const { return sampleRate; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -47,7 +47,6 @@ std::string gpName;
|
||||
|
||||
SoundStream *soundStream = NULL;
|
||||
|
||||
|
||||
// Set this if you want to log audio. search for log_ai in this file to see the filename.
|
||||
bool log_ai = false;
|
||||
WaveFileWriter g_wave_writer;
|
||||
@ -155,17 +154,16 @@ void CloseConsole()
|
||||
void DllDebugger(HWND _hParent, bool Show)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
|
||||
if(m_frame && Show) // if we have created it, let us show it again
|
||||
if (m_frame && Show) // if we have created it, let us show it again
|
||||
{
|
||||
m_frame->DoShow();
|
||||
}
|
||||
else if(!m_frame && Show)
|
||||
else if (!m_frame && Show)
|
||||
{
|
||||
m_frame = new CDebugger(NULL);
|
||||
m_frame->Show();
|
||||
}
|
||||
else if(m_frame && !Show)
|
||||
else if (m_frame && !Show)
|
||||
{
|
||||
m_frame->DoHide();
|
||||
}
|
||||
@ -213,10 +211,9 @@ void Initialize(void *init)
|
||||
{
|
||||
//Console::Open(80, 5000);
|
||||
|
||||
g_Config.Load();
|
||||
|
||||
g_dspInitialize = *(DSPInitialize*)init;
|
||||
|
||||
g_Config.Load();
|
||||
g_pMemory = g_dspInitialize.pGetMemoryPointer(0);
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
@ -237,12 +234,12 @@ void Initialize(void *init)
|
||||
if (DSound::isValid())
|
||||
soundStream = new DSound(48000, Mixer, g_dspInitialize.hWnd);
|
||||
}
|
||||
else if(g_Config.sBackend == "AOSound")
|
||||
else if (g_Config.sBackend == "AOSound")
|
||||
{
|
||||
if (AOSound::isValid())
|
||||
soundStream = new AOSound(48000, Mixer);
|
||||
}
|
||||
else if(g_Config.sBackend == "NullSound")
|
||||
else if (g_Config.sBackend == "NullSound")
|
||||
{
|
||||
soundStream = new NullSound(48000, Mixer_MixUCode);
|
||||
}
|
||||
@ -258,15 +255,19 @@ void Initialize(void *init)
|
||||
_CrtSetDbgFlag(tmpflag);
|
||||
#endif
|
||||
|
||||
if (soundStream) {
|
||||
if(!soundStream->Start()) {
|
||||
if (soundStream)
|
||||
{
|
||||
if (!soundStream->Start())
|
||||
{
|
||||
PanicAlert("Could not initialize backend %s, falling back to NULL",
|
||||
g_Config.sBackend);
|
||||
delete soundStream;
|
||||
soundStream = new NullSound(48000, Mixer);
|
||||
soundStream->Start();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PanicAlert("Sound backend %s is not valid, falling back to NULL",
|
||||
g_Config.sBackend);
|
||||
delete soundStream;
|
||||
@ -282,28 +283,38 @@ void Initialize(void *init)
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
void DSP_StopSoundStream()
|
||||
{
|
||||
// Stop the sound recording
|
||||
if (log_ai) g_wave_writer.Stop();
|
||||
|
||||
// Delete the UCodes
|
||||
if (!soundStream)
|
||||
PanicAlert("Can't stop non running SoundStream!");
|
||||
soundStream->Stop();
|
||||
delete soundStream;
|
||||
soundStream = NULL;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
// Check that soundstream already is stopped.
|
||||
if (soundStream)
|
||||
PanicAlert("SoundStream alive in DSP::Shutdown!");
|
||||
|
||||
// Stop the sound recording
|
||||
if (log_ai)
|
||||
g_wave_writer.Stop();
|
||||
|
||||
// Delete the UCodes
|
||||
CDSPHandler::Destroy();
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
// Reset mails
|
||||
if(m_frame)
|
||||
{
|
||||
sMailLog.clear();
|
||||
sMailTime.clear();
|
||||
m_frame->sMail.clear();
|
||||
m_frame->sMailEnd.clear();
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
// Reset mails
|
||||
if (m_frame)
|
||||
{
|
||||
sMailLog.clear();
|
||||
sMailTime.clear();
|
||||
m_frame->sMail.clear();
|
||||
m_frame->sMailEnd.clear();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DoState(unsigned char **ptr, int mode)
|
||||
@ -406,7 +417,12 @@ void DSP_Update(int cycles)
|
||||
game has started. */
|
||||
void DSP_SendAIBuffer(unsigned int address, int sample_rate)
|
||||
{
|
||||
if(soundStream->usesMixer())
|
||||
// TODO: This is not yet fully threadsafe.
|
||||
if (!soundStream) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (soundStream->usesMixer())
|
||||
{
|
||||
short samples[16] = {0}; // interleaved stereo
|
||||
if (address)
|
||||
@ -417,21 +433,19 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate)
|
||||
}
|
||||
|
||||
// Write the audio to a file
|
||||
if (log_ai) g_wave_writer.AddStereoSamples(samples, 8);
|
||||
if (log_ai)
|
||||
g_wave_writer.AddStereoSamples(samples, 8);
|
||||
}
|
||||
Mixer_PushSamples(samples, 32 / 4, sample_rate);
|
||||
}
|
||||
|
||||
/* If I don't use this in Wario Land Shake It I get bad sound, it's a lot of static and noise
|
||||
in the sound. It's the same both with an without Enable Other Audio. I can't really say why
|
||||
this occurs because I don't know what SoundSyncEvent->Set() does. */
|
||||
#ifdef SETUP_AVOID_SOUND_ARTIFACTS
|
||||
static int counter = 0;
|
||||
counter++;
|
||||
if ((counter & 255) == 0)
|
||||
#endif
|
||||
// SoundStream is updated only when necessary (there is no 70 ms limit
|
||||
// so each sample now triggers the sound stream)
|
||||
soundStream->Update();
|
||||
|
||||
// TODO: think about this.
|
||||
static int counter = 0;
|
||||
counter++;
|
||||
if ((counter & 31) == 0 && soundStream)
|
||||
soundStream->Update();
|
||||
}
|
||||
/////////////////////////////////////
|
||||
|
@ -291,20 +291,23 @@ void Initialize(void *init)
|
||||
#endif
|
||||
}
|
||||
|
||||
void DSP_StopSoundStream()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (g_hDSPThread != NULL)
|
||||
{
|
||||
TerminateThread(g_hDSPThread, 0);
|
||||
}
|
||||
#else
|
||||
// Isn't pthread_cancel kind of evil?
|
||||
pthread_cancel(g_hDSPThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Shutdown(void)
|
||||
{
|
||||
if (log_ai)
|
||||
g_wave_writer.Stop();
|
||||
#ifdef _WIN32
|
||||
if (g_hDSPThread != NULL)
|
||||
{
|
||||
TerminateThread(g_hDSPThread, 0);
|
||||
}
|
||||
#else
|
||||
pthread_cancel(g_hDSPThread);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
u16 DSP_WriteControlRegister(u16 _uFlag)
|
||||
|
@ -200,12 +200,17 @@ void DoState(unsigned char **ptr, int mode) {
|
||||
//PanicAlert("Saving/Loading state from DirectX9");
|
||||
}
|
||||
|
||||
|
||||
void Video_EnterLoop()
|
||||
{
|
||||
Fifo_EnterLoop(g_VideoInitialize);
|
||||
}
|
||||
|
||||
void Video_ExitLoop()
|
||||
{
|
||||
Fifo_ExitLoop();
|
||||
}
|
||||
|
||||
|
||||
void Video_Prepare(void)
|
||||
{
|
||||
Renderer::Init(g_VideoInitialize);
|
||||
@ -230,10 +235,6 @@ void Shutdown(void)
|
||||
DeInit();
|
||||
}
|
||||
|
||||
void Video_Stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Video_UpdateXFB(u8* /*_pXFB*/, u32 /*_dwWidth*/, u32 /*_dwHeight*/, s32 /*_dwYOffset*/, bool /*scheduling*/)
|
||||
{
|
||||
/*
|
||||
@ -251,6 +252,10 @@ void Video_UpdateXFB(u8* /*_pXFB*/, u32 /*_dwWidth*/, u32 /*_dwHeight*/, s32 /*_
|
||||
D3D::BeginFrame();*/
|
||||
}
|
||||
|
||||
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
||||
{
|
||||
Renderer::AddMessage(pstr,milliseconds);
|
||||
}
|
||||
|
||||
void DebugLog(const char* _fmt, ...)
|
||||
{
|
||||
@ -306,19 +311,10 @@ HRESULT ScreenShot(TCHAR *File)
|
||||
}
|
||||
|
||||
surf->Release();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
unsigned int Video_Screenshot(TCHAR* _szFilename)
|
||||
{
|
||||
if (ScreenShot(_szFilename) == S_OK)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
||||
{
|
||||
Renderer::AddMessage(pstr,milliseconds);
|
||||
return ScreenShot(_szFilename) == S_OK ? TRUE : FALSE;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\Cg64;..\..\..\Externals\GLew;..\..\..\Externals\libjpeg"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="false"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
|
||||
RandomizedBaseAddress="1"
|
||||
FixedBaseAddress="1"
|
||||
|
@ -121,11 +121,11 @@ void CDebugger::LoadSettings()
|
||||
m_Check[1]->SetValue(Console);
|
||||
|
||||
file.Get("VideoWindow", "ConfBits", &g_Config.iLog, 0);
|
||||
bInfoLog = g_Config.iLog & CONF_LOG;
|
||||
bPrimLog = g_Config.iLog & CONF_PRIMLOG;
|
||||
bSaveTextures = g_Config.iLog & CONF_SAVETEXTURES;
|
||||
bSaveTargets = g_Config.iLog & CONF_SAVETARGETS;
|
||||
bSaveShaders = g_Config.iLog & CONF_SAVESHADERS;
|
||||
bInfoLog = (g_Config.iLog & CONF_LOG) ? true : false;
|
||||
bPrimLog = (g_Config.iLog & CONF_PRIMLOG) ? true : false;
|
||||
bSaveTextures = (g_Config.iLog & CONF_SAVETEXTURES) ? true : false;
|
||||
bSaveTargets = (g_Config.iLog & CONF_SAVETARGETS) ? true : false;
|
||||
bSaveShaders = (g_Config.iLog & CONF_SAVESHADERS) ? true : false;
|
||||
m_Check[2]->SetValue(bInfoLog);
|
||||
m_Check[3]->SetValue(bPrimLog);
|
||||
m_Check[4]->SetValue(bSaveTextures);
|
||||
|
@ -91,20 +91,19 @@ extern bool gShowDebugger;
|
||||
//////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// The rendering window
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
namespace EmuWindow
|
||||
{
|
||||
HWND m_hWnd = NULL; // The new window that is created here
|
||||
HWND m_hParent = NULL, m_hMain = NULL; // The main CPanel
|
||||
HWND m_hParent = NULL;
|
||||
HWND m_hMain = NULL; // The main CPanel
|
||||
|
||||
HINSTANCE m_hInstance = NULL;
|
||||
WNDCLASSEX wndClass;
|
||||
const TCHAR m_szClassName[] = "DolphinEmuWnd";
|
||||
int g_winstyle;
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make
|
||||
@ -117,7 +116,7 @@ namespace EmuWindow
|
||||
BYTE XORmaskCursor[] = { 0x00 };
|
||||
hCursorBlank = CreateCursor(hInstance, 0,0, 1,1, ANDmaskCursor,XORmaskCursor);
|
||||
|
||||
hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
}
|
||||
|
||||
|
||||
@ -156,25 +155,27 @@ namespace EmuWindow
|
||||
/* The fullscreen option for Windows users is not very user friendly. With this the user
|
||||
can only get out of the fullscreen mode by pressing Esc or Alt + F4. Esc also stops
|
||||
the emulation. Todo: But currently it hangs, so I have disabled the shutdown. */
|
||||
//if(m_hParent == NULL) ExitProcess(0);
|
||||
if(m_hParent == NULL)
|
||||
//if (m_hParent == NULL) ExitProcess(0);
|
||||
if (m_hParent == NULL)
|
||||
{
|
||||
if (g_Config.bFullscreen)
|
||||
{
|
||||
//PostMessage(m_hMain, WM_USER, OPENGL_WM_USER_STOP, 0); // Stop
|
||||
}
|
||||
else
|
||||
{
|
||||
// Toggle maximize and restore
|
||||
if (IsZoomed(hWnd)) ShowWindow(hWnd, SW_RESTORE); else ShowWindow(hWnd, SW_MAXIMIZE);
|
||||
if (IsZoomed(hWnd))
|
||||
ShowWindow(hWnd, SW_RESTORE);
|
||||
else
|
||||
ShowWindow(hWnd, SW_MAXIMIZE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case MY_KEYS:
|
||||
hypotheticalScene->sendMessage(KEYDOWN...);
|
||||
*/
|
||||
|
||||
case 'E': // EFB hotkey
|
||||
if(g_Config.bEFBCopyDisableHotKey)
|
||||
if (g_Config.bEFBCopyDisableHotKey)
|
||||
{
|
||||
g_Config.bEFBCopyDisable = !g_Config.bEFBCopyDisable;
|
||||
Renderer::AddMessage(StringFromFormat("Copy EFB was turned %s",
|
||||
@ -206,9 +207,9 @@ namespace EmuWindow
|
||||
case WM_USER:
|
||||
/* I set wParam to 10 just in case there are other WM_USER events. If we want more
|
||||
WM_USER cases we would start making wParam or lParam cases */
|
||||
if(wParam == 10)
|
||||
if (wParam == 10)
|
||||
{
|
||||
if(lParam)
|
||||
if (lParam)
|
||||
SetCursor(hCursor);
|
||||
else
|
||||
SetCursor(hCursorBlank);
|
||||
@ -225,24 +226,13 @@ namespace EmuWindow
|
||||
|
||||
// This is called when we close the window when we render to a separate window
|
||||
case WM_CLOSE:
|
||||
if(m_hParent == NULL)
|
||||
if (m_hParent == NULL)
|
||||
{
|
||||
// Simple hack to easily exit without stopping. Hope to fix the stopping errors soon.
|
||||
ExitProcess(0);
|
||||
|
||||
/* Attempt to only Stop when we close the separate window. But it didn't work, it hanged.
|
||||
It may need some more coordination with the Stop code in the Core */
|
||||
//PostMessage(m_hMain, WM_USER, 5, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is called from the Core when we Stop, but currently we only use DefWindowProc(),
|
||||
whatever that does with it, if any */
|
||||
//case WM_QUIT:
|
||||
//Video_Shutdown();
|
||||
// ExitProcess(0);
|
||||
// return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
//Shutdown();
|
||||
//PostQuitMessage( 0 ); // Call WM_QUIT
|
||||
|
@ -318,13 +318,13 @@ void Video_Prepare(void)
|
||||
|
||||
void Shutdown(void)
|
||||
{
|
||||
Fifo_Shutdown();
|
||||
TextureConverter::Shutdown();
|
||||
VertexLoaderManager::Shutdown();
|
||||
VertexShaderCache::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
PixelShaderCache::Shutdown();
|
||||
Fifo_Shutdown();
|
||||
VertexManager::Shutdown();
|
||||
TextureMngr::Shutdown();
|
||||
OpcodeDecoder_Shutdown();
|
||||
@ -332,17 +332,16 @@ void Shutdown(void)
|
||||
OpenGL_Shutdown();
|
||||
}
|
||||
|
||||
|
||||
void Video_Stop(void)
|
||||
{
|
||||
Fifo_Stop();
|
||||
}
|
||||
|
||||
void Video_EnterLoop()
|
||||
{
|
||||
Fifo_EnterLoop(g_VideoInitialize);
|
||||
}
|
||||
|
||||
void Video_ExitLoop()
|
||||
{
|
||||
Fifo_ExitLoop();
|
||||
}
|
||||
|
||||
void DebugLog(const char* _fmt, ...)
|
||||
{
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
|
@ -42,10 +42,9 @@ void ConfigDialog::LoadFile()
|
||||
IniFile file;
|
||||
file.Load("WiimoteMovement.ini");
|
||||
|
||||
for(int i = 1; i < (RECORDING_ROWS + 1); i++)
|
||||
for (int i = 1; i < (RECORDING_ROWS + 1); i++)
|
||||
{
|
||||
// Temporary storage
|
||||
bool bTmp;
|
||||
int iTmp;
|
||||
std::string STmp;
|
||||
|
||||
|
@ -132,11 +132,11 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
|
||||
if (abs(cos(_Roll)) < abs(cos(_Pitch))) z = cos(_Roll); else z = cos(_Pitch);
|
||||
/* I got these from reversing the calculation in PitchAccelerometerToDegree() in a math program
|
||||
I don't know if we can derive these from some kind of matrix or something */
|
||||
float x_num = 2 * tan(0.5 * _Roll) * z;
|
||||
float x_den = pow(tan(0.5 * _Roll),2) - 1;
|
||||
float x_num = 2 * tanf(0.5f * _Roll) * z;
|
||||
float x_den = powf(tanf(0.5f * _Roll), 2) - 1;
|
||||
x = - (x_num / x_den);
|
||||
float y_num = 2 * tan(0.5 * _Pitch) * z;
|
||||
float y_den = pow(tan(0.5 * _Pitch), 2) - 1;
|
||||
float y_num = 2 * tanf(0.5f * _Pitch) * z;
|
||||
float y_den = powf(tanf(0.5f * _Pitch), 2) - 1;
|
||||
y = - (y_num / y_den);
|
||||
// =========================
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr)
|
||||
}
|
||||
|
||||
// Dead zone adjustment
|
||||
float DeadZoneLeft = (float)PadMapping[Page].DeadZoneL / 100.0;
|
||||
float DeadZoneRight = (float)PadMapping[Page].DeadZoneR / 100.0;
|
||||
float DeadZoneLeft = (float)PadMapping[Page].DeadZoneL / 100.0f;
|
||||
float DeadZoneRight = (float)PadMapping[Page].DeadZoneR / 100.0f;
|
||||
if (InputCommon::IsDeadZone(DeadZoneLeft, Lx, Ly))
|
||||
{
|
||||
Lx = 0;
|
||||
|
@ -393,7 +393,7 @@ int Initialize()
|
||||
// Initialized, even if we didn't find a Wiimote
|
||||
g_RealWiiMoteInitialized = true;
|
||||
|
||||
return g_NumberOfWiiMotes;
|
||||
return g_NumberOfWiiMotes;
|
||||
}
|
||||
|
||||
void DoState(void* ptr, int mode) {}
|
||||
@ -401,25 +401,25 @@ void DoState(void* ptr, int mode) {}
|
||||
void Shutdown(void)
|
||||
{
|
||||
// Stop the loop in the thread
|
||||
g_Shutdown = true;
|
||||
g_Shutdown = true;
|
||||
|
||||
// Stop the thread
|
||||
if (g_pReadThread != NULL)
|
||||
{
|
||||
g_pReadThread->WaitForDeath();
|
||||
delete g_pReadThread;
|
||||
g_pReadThread = NULL;
|
||||
}
|
||||
// Stop the thread
|
||||
if (g_pReadThread != NULL)
|
||||
{
|
||||
delete g_pReadThread;
|
||||
g_pReadThread = NULL;
|
||||
}
|
||||
|
||||
// Delete the wiimotes
|
||||
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||
{
|
||||
delete g_WiiMotes[i];
|
||||
g_WiiMotes[i] = NULL;
|
||||
}
|
||||
// Delete the wiimotes
|
||||
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||
{
|
||||
delete g_WiiMotes[i];
|
||||
g_WiiMotes[i] = NULL;
|
||||
}
|
||||
|
||||
// Flash flights
|
||||
if (!g_EmulatorRunning && g_RealWiiMotePresent) FlashLights(false);
|
||||
if (!g_EmulatorRunning && g_RealWiiMotePresent)
|
||||
FlashLights(false);
|
||||
|
||||
// Clean up wiiuse
|
||||
wiiuse_cleanup(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes);
|
||||
|
Reference in New Issue
Block a user