From 78aa3de57915381fe8e9cd29c36f34a2a2792d72 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 17 Jan 2010 03:21:23 +0000 Subject: [PATCH] Bring Windows in sync with the earlier changes I made to ZeroSPU2. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2442 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zerospu2/Targets/SoundTargets.cpp | 10 +- plugins/zerospu2/Targets/SoundTargets.h | 23 +- .../{Windows => Targets}/dsound51.cpp | 485 +++++++++--------- plugins/zerospu2/Targets/dsound51.h | 46 ++ plugins/zerospu2/Windows/ZeroSPU2_2008.vcproj | 62 ++- plugins/zerospu2/zerospu2.cpp | 32 +- 6 files changed, 390 insertions(+), 268 deletions(-) rename plugins/zerospu2/{Windows => Targets}/dsound51.cpp (93%) create mode 100644 plugins/zerospu2/Targets/dsound51.h diff --git a/plugins/zerospu2/Targets/SoundTargets.cpp b/plugins/zerospu2/Targets/SoundTargets.cpp index fdce657384..56a5acee32 100644 --- a/plugins/zerospu2/Targets/SoundTargets.cpp +++ b/plugins/zerospu2/Targets/SoundTargets.cpp @@ -20,7 +20,7 @@ SoundCallbacks *SoundCmds; u32 SOUNDSIZE; -u32 MaxBuffer; +s32 MaxBuffer; #ifdef __LINUX__ @@ -47,19 +47,19 @@ void InitOSS() MaxBuffer = 80000; } #else -/*#include "dsound51.h" +#include "dsound51.h" void InitDSound() { SoundCmds = &DSCmds; SOUNDSIZE = 76800; MaxBuffer = 80000; -}*/ +} #endif -/*#include "PulseAudio.h" +/*#include "PortAudio.h" -void InitPulseAudio() +void InitPortAudio() { SoundCmds = &PACmds; SOUNDSIZE = 4096; diff --git a/plugins/zerospu2/Targets/SoundTargets.h b/plugins/zerospu2/Targets/SoundTargets.h index 6a71d5aee8..9345e3a3a8 100644 --- a/plugins/zerospu2/Targets/SoundTargets.h +++ b/plugins/zerospu2/Targets/SoundTargets.h @@ -36,24 +36,41 @@ struct SoundCallbacks extern SoundCallbacks *SoundCmds; extern u32 SOUNDSIZE; -extern u32 MaxBuffer; +extern s32 MaxBuffer; // Target List +#ifdef __LINUX__ #define ZEROSPU2_ALSA // Comment if Alsa isn't on the system. #define ZEROSPU2_OSS // Comment if OSS isn't on the system. +#else +#define ZEROSPU2_DS +#endif +//#define ZEROSPU2_PORTAUDIO #ifdef ZEROSPU2_OSS -#include "Targets/OSS.h" +#include "OSS.h" extern void InitOSS(); #endif #ifdef ZEROSPU2_ALSA -#include "Targets/Alsa.h" +#include "Alsa.h" extern void InitAlsa(); #endif +#ifdef ZEROSPU2_DS +#include "dsound51.h" + +extern void InitDSound(); +#endif + +#ifdef ZEROSPU2_PORTAUDIO +#include "PortAudio.h" + +extern void InitPortAudio(); +#endif + extern int SetupSound(); extern void RemoveSound(); extern int SoundGetBytesBuffered(); diff --git a/plugins/zerospu2/Windows/dsound51.cpp b/plugins/zerospu2/Targets/dsound51.cpp similarity index 93% rename from plugins/zerospu2/Windows/dsound51.cpp rename to plugins/zerospu2/Targets/dsound51.cpp index 2abb826ac5..12fd9149d3 100644 --- a/plugins/zerospu2/Windows/dsound51.cpp +++ b/plugins/zerospu2/Targets/dsound51.cpp @@ -1,248 +1,239 @@ -/* ZeroSPU2 - * Copyright (C) 2006-2007 zerofrog - * - * 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; either version 2 of the License, or - * (at your option) any later version. - * - * 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include "../zerospu2.h" -///////////////////////////////////// -// use DirectSound for the sound -#include - -//4*48*73 -#define SOUNDSIZE 76800 -HWND hWMain = NULL; - -LPDIRECTSOUND lpDS; -LPDIRECTSOUNDBUFFER lpDSBPRIMARY = NULL; -LPDIRECTSOUNDBUFFER lpDSBSECONDARY1 = NULL; -LPDIRECTSOUNDBUFFER lpDSBSECONDARY2 = NULL; -DSBUFFERDESC dsbd; -DSBUFFERDESC dsbdesc; -DSCAPS dscaps; -DSBCAPS dsbcaps; - -unsigned long LastWrite = 0xffffffff; -unsigned long LastWriteS = 0xffffffff; -unsigned long LastPlay = 0; - -int SetupSound() -{ - HRESULT dsval; - WAVEFORMATEX pcmwf; - - dsval = DirectSoundCreate(NULL,&lpDS,NULL); - if(dsval != DS_OK) - { - MessageBox(hWMain,"DirectSoundCreate!","Error",MB_OK); - return -1; - } - - if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_PRIORITY)) - { - if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_NORMAL)) - { - MessageBox(hWMain,"SetCooperativeLevel!","Error",MB_OK); - return -1; - } - } - - memset(&dsbd,0,sizeof(DSBUFFERDESC)); - dsbd.dwSize = sizeof(DSBUFFERDESC); // NT4 hack! sizeof(dsbd); - dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER; - dsbd.dwBufferBytes = 0; - dsbd.lpwfxFormat = NULL; - - dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbd,&lpDSBPRIMARY,NULL); - if(dsval != DS_OK) - { - MessageBox(hWMain, "CreateSoundBuffer (Primary)", "Error",MB_OK); - return -1; - } - - memset(&pcmwf, 0, sizeof(WAVEFORMATEX)); - pcmwf.wFormatTag = WAVE_FORMAT_PCM; - - pcmwf.nChannels = 2; - pcmwf.nBlockAlign = 4; - - pcmwf.nSamplesPerSec = SAMPLE_RATE; - - pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign; - pcmwf.wBitsPerSample = 16; - - dsval = IDirectSoundBuffer_SetFormat(lpDSBPRIMARY,&pcmwf); - if(dsval != DS_OK) - { - MessageBox(hWMain, "SetFormat!", "Error",MB_OK); - return -1; - } - - dscaps.dwSize = sizeof(DSCAPS); - dsbcaps.dwSize = sizeof(DSBCAPS); - IDirectSound_GetCaps(lpDS,&dscaps); - IDirectSoundBuffer_GetCaps(lpDSBPRIMARY,&dsbcaps); - - memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); - // NT4 hack! sizeof(DSBUFFERDESC); - dsbdesc.dwSize = sizeof(DSBUFFERDESC); - dsbdesc.dwFlags = DSBCAPS_LOCHARDWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; - dsbdesc.dwBufferBytes = SOUNDSIZE; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; - - dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL); - if(dsval != DS_OK) - { - dsbdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; - dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL); - if(dsval != DS_OK) - { - MessageBox(hWMain,"CreateSoundBuffer (Secondary1)", "Error",MB_OK); - return -1; - } - } - - dsval = IDirectSoundBuffer_Play(lpDSBPRIMARY,0,0,DSBPLAY_LOOPING); - if(dsval != DS_OK) - { - MessageBox(hWMain,"Play (Primary)","Error",MB_OK); - return -1; - } - - dsval = IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING); - if(dsval != DS_OK) - { - MessageBox(hWMain,"Play (Secondary1)","Error",MB_OK); - return -1; - } - - // init some play vars - LastWrite = 0x00000000; - LastPlay = 0; - - return 0; -} - -void RemoveSound() -{ - int iRes; - - if (lpDSBSECONDARY1 != NULL) - { - IDirectSoundBuffer_Stop(lpDSBSECONDARY1); - iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1); - - // FF says such a loop is bad... Demo says it's good... Pete doesn't care - while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1); - - lpDSBSECONDARY1 = NULL; - } - - if (lpDSBPRIMARY != NULL) - { - IDirectSoundBuffer_Stop(lpDSBPRIMARY); - iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY); - - // FF says such a loop is bad... Demo says it's good... Pete doesn't care - while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY); - - lpDSBPRIMARY = NULL; - } - - if (lpDS!=NULL) - { - iRes = IDirectSound_Release(lpDS); - - // FF says such a loop is bad... Demo says it's good... Pete doesn't care - while(iRes!=0) iRes = IDirectSound_Release(lpDS); - - lpDS = NULL; - } - -} - -int SoundGetBytesBuffered() -{ - unsigned long cplay,cwrite; - - if (LastWrite == 0xffffffff) return 0; - - IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite); - - if(cplay > SOUNDSIZE) return SOUNDSIZE; - if(cplay < LastWrite) return LastWrite - cplay; - - return (SOUNDSIZE - cplay) + LastWrite; -} - -void SoundFeedVoiceData(unsigned char* pSound,long lBytes) -{ - LPVOID lpvPtr1, lpvPtr2; - unsigned long dwBytes1,dwBytes2; - unsigned long *lpSS, *lpSD; - unsigned long dw,cplay,cwrite; - HRESULT hr; - unsigned long status; - - IDirectSoundBuffer_GetStatus(lpDSBSECONDARY1,&status); - if (status & DSBSTATUS_BUFFERLOST) - { - if (IDirectSoundBuffer_Restore(lpDSBSECONDARY1) != DS_OK) return; - IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING); - } - - IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite); - - if(LastWrite == 0xffffffff) LastWrite=cwrite; - - hr = IDirectSoundBuffer_Lock(lpDSBSECONDARY1,LastWrite,lBytes, - &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); - - if (hr != DS_OK) - { - LastWrite=0xffffffff; - return; - } - - lpSS = (unsigned long *)pSound; - lpSD = (unsigned long *)lpvPtr1; - dw = dwBytes1 >> 2; - - while(dw) - { - *lpSD++=*lpSS++; - dw--; - } - - if (lpvPtr2) - { - lpSD = (unsigned long *)lpvPtr2; - dw = dwBytes2 >> 2; - - while(dw) - { - *lpSD++ = *lpSS++; - dw--; - } - } - - IDirectSoundBuffer_Unlock(lpDSBSECONDARY1,lpvPtr1,dwBytes1,lpvPtr2,dwBytes2); - LastWrite += lBytes; - if(LastWrite >= SOUNDSIZE) LastWrite -= SOUNDSIZE; - LastPlay = cplay; +/* ZeroSPU2 + * Copyright (C) 2006-2007 zerofrog + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "dsound51.h" +HWND hWMain = NULL; + +LPDIRECTSOUND lpDS; +LPDIRECTSOUNDBUFFER lpDSBPRIMARY = NULL; +LPDIRECTSOUNDBUFFER lpDSBSECONDARY1 = NULL; +LPDIRECTSOUNDBUFFER lpDSBSECONDARY2 = NULL; +DSBUFFERDESC dsbd; +DSBUFFERDESC dsbdesc; +DSCAPS dscaps; +DSBCAPS dsbcaps; + +unsigned long LastWrite = 0xffffffff; +unsigned long LastWriteS = 0xffffffff; +unsigned long LastPlay = 0; + +int DSSetupSound() +{ + HRESULT dsval; + WAVEFORMATEX pcmwf; + + dsval = DirectSoundCreate(NULL,&lpDS,NULL); + if(dsval != DS_OK) + { + MessageBox(hWMain,"DirectSoundCreate!","Error",MB_OK); + return -1; + } + + if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_PRIORITY)) + { + if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_NORMAL)) + { + MessageBox(hWMain,"SetCooperativeLevel!","Error",MB_OK); + return -1; + } + } + + memset(&dsbd,0,sizeof(DSBUFFERDESC)); + dsbd.dwSize = sizeof(DSBUFFERDESC); // NT4 hack! sizeof(dsbd); + dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER; + dsbd.dwBufferBytes = 0; + dsbd.lpwfxFormat = NULL; + + dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbd,&lpDSBPRIMARY,NULL); + if(dsval != DS_OK) + { + MessageBox(hWMain, "CreateSoundBuffer (Primary)", "Error",MB_OK); + return -1; + } + + memset(&pcmwf, 0, sizeof(WAVEFORMATEX)); + pcmwf.wFormatTag = WAVE_FORMAT_PCM; + + pcmwf.nChannels = 2; + pcmwf.nBlockAlign = 4; + + pcmwf.nSamplesPerSec = SAMPLE_RATE; + + pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign; + pcmwf.wBitsPerSample = 16; + + dsval = IDirectSoundBuffer_SetFormat(lpDSBPRIMARY,&pcmwf); + if(dsval != DS_OK) + { + MessageBox(hWMain, "SetFormat!", "Error",MB_OK); + return -1; + } + + dscaps.dwSize = sizeof(DSCAPS); + dsbcaps.dwSize = sizeof(DSBCAPS); + IDirectSound_GetCaps(lpDS,&dscaps); + IDirectSoundBuffer_GetCaps(lpDSBPRIMARY,&dsbcaps); + + memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); + // NT4 hack! sizeof(DSBUFFERDESC); + dsbdesc.dwSize = sizeof(DSBUFFERDESC); + dsbdesc.dwFlags = DSBCAPS_LOCHARDWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; + dsbdesc.dwBufferBytes = SOUNDSIZE; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; + + dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL); + if(dsval != DS_OK) + { + dsbdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; + dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL); + if(dsval != DS_OK) + { + MessageBox(hWMain,"CreateSoundBuffer (Secondary1)", "Error",MB_OK); + return -1; + } + } + + dsval = IDirectSoundBuffer_Play(lpDSBPRIMARY,0,0,DSBPLAY_LOOPING); + if(dsval != DS_OK) + { + MessageBox(hWMain,"Play (Primary)","Error",MB_OK); + return -1; + } + + dsval = IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING); + if(dsval != DS_OK) + { + MessageBox(hWMain,"Play (Secondary1)","Error",MB_OK); + return -1; + } + + // init some play vars + LastWrite = 0x00000000; + LastPlay = 0; + + return 0; +} + +void DSRemoveSound() +{ + int iRes; + + if (lpDSBSECONDARY1 != NULL) + { + IDirectSoundBuffer_Stop(lpDSBSECONDARY1); + iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1); + + // FF says such a loop is bad... Demo says it's good... Pete doesn't care + while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1); + + lpDSBSECONDARY1 = NULL; + } + + if (lpDSBPRIMARY != NULL) + { + IDirectSoundBuffer_Stop(lpDSBPRIMARY); + iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY); + + // FF says such a loop is bad... Demo says it's good... Pete doesn't care + while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY); + + lpDSBPRIMARY = NULL; + } + + if (lpDS!=NULL) + { + iRes = IDirectSound_Release(lpDS); + + // FF says such a loop is bad... Demo says it's good... Pete doesn't care + while(iRes!=0) iRes = IDirectSound_Release(lpDS); + + lpDS = NULL; + } + +} + +int DSSoundGetBytesBuffered() +{ + unsigned long cplay,cwrite; + + if (LastWrite == 0xffffffff) return 0; + + IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite); + + if(cplay > SOUNDSIZE) return SOUNDSIZE; + if(cplay < LastWrite) return LastWrite - cplay; + + return (SOUNDSIZE - cplay) + LastWrite; +} + +void DSSoundFeedVoiceData(unsigned char* pSound,long lBytes) +{ + LPVOID lpvPtr1, lpvPtr2; + unsigned long dwBytes1,dwBytes2; + unsigned long *lpSS, *lpSD; + unsigned long dw,cplay,cwrite; + HRESULT hr; + unsigned long status; + + IDirectSoundBuffer_GetStatus(lpDSBSECONDARY1,&status); + if (status & DSBSTATUS_BUFFERLOST) + { + if (IDirectSoundBuffer_Restore(lpDSBSECONDARY1) != DS_OK) return; + IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING); + } + + IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite); + + if(LastWrite == 0xffffffff) LastWrite=cwrite; + + hr = IDirectSoundBuffer_Lock(lpDSBSECONDARY1,LastWrite,lBytes, + &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); + + if (hr != DS_OK) + { + LastWrite=0xffffffff; + return; + } + + lpSS = (unsigned long *)pSound; + lpSD = (unsigned long *)lpvPtr1; + dw = dwBytes1 >> 2; + + while(dw) + { + *lpSD++=*lpSS++; + dw--; + } + + if (lpvPtr2) + { + lpSD = (unsigned long *)lpvPtr2; + dw = dwBytes2 >> 2; + + while(dw) + { + *lpSD++ = *lpSS++; + dw--; + } + } + + IDirectSoundBuffer_Unlock(lpDSBSECONDARY1,lpvPtr1,dwBytes1,lpvPtr2,dwBytes2); + LastWrite += lBytes; + if(LastWrite >= SOUNDSIZE) LastWrite -= SOUNDSIZE; + LastPlay = cplay; } \ No newline at end of file diff --git a/plugins/zerospu2/Targets/dsound51.h b/plugins/zerospu2/Targets/dsound51.h new file mode 100644 index 0000000000..f402c92a85 --- /dev/null +++ b/plugins/zerospu2/Targets/dsound51.h @@ -0,0 +1,46 @@ +/* ZeroSPU2 + * Copyright (C) 2006-2010 zerofrog + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef DSOUND51_H_INCLUDED +#define DSOUND51_H_INCLUDED + +#include +#include +#include + +#include "SoundTargets.h" +#include "../zerospu2.h" + +///////////////////////////////////// +// use DirectSound for the sound +#include + +extern int DSSetupSound(); +extern void DSRemoveSound(); +extern int DSSoundGetBytesBuffered(); +extern void DSSoundFeedVoiceData(unsigned char* pSound,long lBytes); + +static SoundCallbacks DSCmds = +{ + (intFunction)DSSetupSound, + (voidFunction)DSRemoveSound, + (intFunction)DSSoundGetBytesBuffered, + (soundFeedFunction)DSSoundFeedVoiceData +}; + +#endif \ No newline at end of file diff --git a/plugins/zerospu2/Windows/ZeroSPU2_2008.vcproj b/plugins/zerospu2/Windows/ZeroSPU2_2008.vcproj index 2639c1afc3..5a9ed08454 100644 --- a/plugins/zerospu2/Windows/ZeroSPU2_2008.vcproj +++ b/plugins/zerospu2/Windows/ZeroSPU2_2008.vcproj @@ -234,7 +234,35 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + + + + + + + + + + + + + + + + + + + + + + + @@ -271,6 +327,10 @@ RelativePath=".\resource.h" > + + diff --git a/plugins/zerospu2/zerospu2.cpp b/plugins/zerospu2/zerospu2.cpp index 061b9bd4e6..5637889fdb 100644 --- a/plugins/zerospu2/zerospu2.cpp +++ b/plugins/zerospu2/zerospu2.cpp @@ -16,14 +16,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "zerospu2.h" + #ifdef _WIN32 #include "svnrev.h" - u32 MaxBuffer = 80000; // Until I put this in properly, avoid breaking Windows. -#else -#include "Targets/SoundTargets.h" #endif -#include "zerospu2.h" +#include "Targets/SoundTargets.h" #include #include @@ -210,6 +209,21 @@ void CALLBACK SPU2setSettingsDir(const char* dir) s_strIniPath = (dir==NULL) ? "inis/" : dir; } +void InitApi() +{ + // This is a placeholder till there is actually some way to choose Apis. For the moment, just + // Modify this so it does whichever one you want to use. +#ifdef _WIN32 + InitDSound(); +#else +#if defined(ZEROSPU2_ALSA) + InitAlsa(); +#elif defined(ZEROSPU2_OSS) + InitOSS(); +#endif +#endif +} + s32 CALLBACK SPU2init() { LOG_CALLBACK("SPU2init()\n"); @@ -221,15 +235,9 @@ s32 CALLBACK SPU2init() #ifdef _WIN32 QueryPerformanceFrequency(&g_counterfreq); -#else - -#if defined(ZEROSPU2_ALSA) - InitAlsa(); -#elif defined(ZEROSPU2_OSS) - InitOSS(); -#endif - #endif + + InitApi(); spu2regs = (s8*)malloc(0x10000); spu2mem = (u16*)malloc(0x200000); // 2Mb