mirror of https://github.com/PCSX2/pcsx2.git
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
This commit is contained in:
parent
f878a438ff
commit
78aa3de579
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
SoundCallbacks *SoundCmds;
|
SoundCallbacks *SoundCmds;
|
||||||
u32 SOUNDSIZE;
|
u32 SOUNDSIZE;
|
||||||
u32 MaxBuffer;
|
s32 MaxBuffer;
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
|
|
||||||
|
@ -47,19 +47,19 @@ void InitOSS()
|
||||||
MaxBuffer = 80000;
|
MaxBuffer = 80000;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/*#include "dsound51.h"
|
#include "dsound51.h"
|
||||||
|
|
||||||
void InitDSound()
|
void InitDSound()
|
||||||
{
|
{
|
||||||
SoundCmds = &DSCmds;
|
SoundCmds = &DSCmds;
|
||||||
SOUNDSIZE = 76800;
|
SOUNDSIZE = 76800;
|
||||||
MaxBuffer = 80000;
|
MaxBuffer = 80000;
|
||||||
}*/
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*#include "PulseAudio.h"
|
/*#include "PortAudio.h"
|
||||||
|
|
||||||
void InitPulseAudio()
|
void InitPortAudio()
|
||||||
{
|
{
|
||||||
SoundCmds = &PACmds;
|
SoundCmds = &PACmds;
|
||||||
SOUNDSIZE = 4096;
|
SOUNDSIZE = 4096;
|
||||||
|
|
|
@ -36,24 +36,41 @@ struct SoundCallbacks
|
||||||
|
|
||||||
extern SoundCallbacks *SoundCmds;
|
extern SoundCallbacks *SoundCmds;
|
||||||
extern u32 SOUNDSIZE;
|
extern u32 SOUNDSIZE;
|
||||||
extern u32 MaxBuffer;
|
extern s32 MaxBuffer;
|
||||||
|
|
||||||
// Target List
|
// Target List
|
||||||
|
#ifdef __LINUX__
|
||||||
#define ZEROSPU2_ALSA // Comment if Alsa isn't on the system.
|
#define ZEROSPU2_ALSA // Comment if Alsa isn't on the system.
|
||||||
#define ZEROSPU2_OSS // Comment if OSS 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
|
#ifdef ZEROSPU2_OSS
|
||||||
#include "Targets/OSS.h"
|
#include "OSS.h"
|
||||||
|
|
||||||
extern void InitOSS();
|
extern void InitOSS();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZEROSPU2_ALSA
|
#ifdef ZEROSPU2_ALSA
|
||||||
#include "Targets/Alsa.h"
|
#include "Alsa.h"
|
||||||
|
|
||||||
extern void InitAlsa();
|
extern void InitAlsa();
|
||||||
#endif
|
#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 int SetupSound();
|
||||||
extern void RemoveSound();
|
extern void RemoveSound();
|
||||||
extern int SoundGetBytesBuffered();
|
extern int SoundGetBytesBuffered();
|
||||||
|
|
|
@ -1,248 +1,239 @@
|
||||||
/* ZeroSPU2
|
/* ZeroSPU2
|
||||||
* Copyright (C) 2006-2007 zerofrog
|
* Copyright (C) 2006-2007 zerofrog
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "dsound51.h"
|
||||||
#include <windows.h>
|
HWND hWMain = NULL;
|
||||||
#include <windowsx.h>
|
|
||||||
#include "../zerospu2.h"
|
LPDIRECTSOUND lpDS;
|
||||||
/////////////////////////////////////
|
LPDIRECTSOUNDBUFFER lpDSBPRIMARY = NULL;
|
||||||
// use DirectSound for the sound
|
LPDIRECTSOUNDBUFFER lpDSBSECONDARY1 = NULL;
|
||||||
#include <dsound.h>
|
LPDIRECTSOUNDBUFFER lpDSBSECONDARY2 = NULL;
|
||||||
|
DSBUFFERDESC dsbd;
|
||||||
//4*48*73
|
DSBUFFERDESC dsbdesc;
|
||||||
#define SOUNDSIZE 76800
|
DSCAPS dscaps;
|
||||||
HWND hWMain = NULL;
|
DSBCAPS dsbcaps;
|
||||||
|
|
||||||
LPDIRECTSOUND lpDS;
|
unsigned long LastWrite = 0xffffffff;
|
||||||
LPDIRECTSOUNDBUFFER lpDSBPRIMARY = NULL;
|
unsigned long LastWriteS = 0xffffffff;
|
||||||
LPDIRECTSOUNDBUFFER lpDSBSECONDARY1 = NULL;
|
unsigned long LastPlay = 0;
|
||||||
LPDIRECTSOUNDBUFFER lpDSBSECONDARY2 = NULL;
|
|
||||||
DSBUFFERDESC dsbd;
|
int DSSetupSound()
|
||||||
DSBUFFERDESC dsbdesc;
|
{
|
||||||
DSCAPS dscaps;
|
HRESULT dsval;
|
||||||
DSBCAPS dsbcaps;
|
WAVEFORMATEX pcmwf;
|
||||||
|
|
||||||
unsigned long LastWrite = 0xffffffff;
|
dsval = DirectSoundCreate(NULL,&lpDS,NULL);
|
||||||
unsigned long LastWriteS = 0xffffffff;
|
if(dsval != DS_OK)
|
||||||
unsigned long LastPlay = 0;
|
{
|
||||||
|
MessageBox(hWMain,"DirectSoundCreate!","Error",MB_OK);
|
||||||
int SetupSound()
|
return -1;
|
||||||
{
|
}
|
||||||
HRESULT dsval;
|
|
||||||
WAVEFORMATEX pcmwf;
|
if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_PRIORITY))
|
||||||
|
{
|
||||||
dsval = DirectSoundCreate(NULL,&lpDS,NULL);
|
if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_NORMAL))
|
||||||
if(dsval != DS_OK)
|
{
|
||||||
{
|
MessageBox(hWMain,"SetCooperativeLevel!","Error",MB_OK);
|
||||||
MessageBox(hWMain,"DirectSoundCreate!","Error",MB_OK);
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_PRIORITY))
|
memset(&dsbd,0,sizeof(DSBUFFERDESC));
|
||||||
{
|
dsbd.dwSize = sizeof(DSBUFFERDESC); // NT4 hack! sizeof(dsbd);
|
||||||
if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_NORMAL))
|
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||||
{
|
dsbd.dwBufferBytes = 0;
|
||||||
MessageBox(hWMain,"SetCooperativeLevel!","Error",MB_OK);
|
dsbd.lpwfxFormat = NULL;
|
||||||
return -1;
|
|
||||||
}
|
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbd,&lpDSBPRIMARY,NULL);
|
||||||
}
|
if(dsval != DS_OK)
|
||||||
|
{
|
||||||
memset(&dsbd,0,sizeof(DSBUFFERDESC));
|
MessageBox(hWMain, "CreateSoundBuffer (Primary)", "Error",MB_OK);
|
||||||
dsbd.dwSize = sizeof(DSBUFFERDESC); // NT4 hack! sizeof(dsbd);
|
return -1;
|
||||||
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
}
|
||||||
dsbd.dwBufferBytes = 0;
|
|
||||||
dsbd.lpwfxFormat = NULL;
|
memset(&pcmwf, 0, sizeof(WAVEFORMATEX));
|
||||||
|
pcmwf.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbd,&lpDSBPRIMARY,NULL);
|
|
||||||
if(dsval != DS_OK)
|
pcmwf.nChannels = 2;
|
||||||
{
|
pcmwf.nBlockAlign = 4;
|
||||||
MessageBox(hWMain, "CreateSoundBuffer (Primary)", "Error",MB_OK);
|
|
||||||
return -1;
|
pcmwf.nSamplesPerSec = SAMPLE_RATE;
|
||||||
}
|
|
||||||
|
pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
|
||||||
memset(&pcmwf, 0, sizeof(WAVEFORMATEX));
|
pcmwf.wBitsPerSample = 16;
|
||||||
pcmwf.wFormatTag = WAVE_FORMAT_PCM;
|
|
||||||
|
dsval = IDirectSoundBuffer_SetFormat(lpDSBPRIMARY,&pcmwf);
|
||||||
pcmwf.nChannels = 2;
|
if(dsval != DS_OK)
|
||||||
pcmwf.nBlockAlign = 4;
|
{
|
||||||
|
MessageBox(hWMain, "SetFormat!", "Error",MB_OK);
|
||||||
pcmwf.nSamplesPerSec = SAMPLE_RATE;
|
return -1;
|
||||||
|
}
|
||||||
pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
|
|
||||||
pcmwf.wBitsPerSample = 16;
|
dscaps.dwSize = sizeof(DSCAPS);
|
||||||
|
dsbcaps.dwSize = sizeof(DSBCAPS);
|
||||||
dsval = IDirectSoundBuffer_SetFormat(lpDSBPRIMARY,&pcmwf);
|
IDirectSound_GetCaps(lpDS,&dscaps);
|
||||||
if(dsval != DS_OK)
|
IDirectSoundBuffer_GetCaps(lpDSBPRIMARY,&dsbcaps);
|
||||||
{
|
|
||||||
MessageBox(hWMain, "SetFormat!", "Error",MB_OK);
|
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
|
||||||
return -1;
|
// NT4 hack! sizeof(DSBUFFERDESC);
|
||||||
}
|
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||||
|
dsbdesc.dwFlags = DSBCAPS_LOCHARDWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2;
|
||||||
dscaps.dwSize = sizeof(DSCAPS);
|
dsbdesc.dwBufferBytes = SOUNDSIZE;
|
||||||
dsbcaps.dwSize = sizeof(DSBCAPS);
|
dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf;
|
||||||
IDirectSound_GetCaps(lpDS,&dscaps);
|
|
||||||
IDirectSoundBuffer_GetCaps(lpDSBPRIMARY,&dsbcaps);
|
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL);
|
||||||
|
if(dsval != DS_OK)
|
||||||
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
|
{
|
||||||
// NT4 hack! sizeof(DSBUFFERDESC);
|
dsbdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2;
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL);
|
||||||
dsbdesc.dwFlags = DSBCAPS_LOCHARDWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2;
|
if(dsval != DS_OK)
|
||||||
dsbdesc.dwBufferBytes = SOUNDSIZE;
|
{
|
||||||
dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf;
|
MessageBox(hWMain,"CreateSoundBuffer (Secondary1)", "Error",MB_OK);
|
||||||
|
return -1;
|
||||||
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL);
|
}
|
||||||
if(dsval != DS_OK)
|
}
|
||||||
{
|
|
||||||
dsbdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2;
|
dsval = IDirectSoundBuffer_Play(lpDSBPRIMARY,0,0,DSBPLAY_LOOPING);
|
||||||
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL);
|
if(dsval != DS_OK)
|
||||||
if(dsval != DS_OK)
|
{
|
||||||
{
|
MessageBox(hWMain,"Play (Primary)","Error",MB_OK);
|
||||||
MessageBox(hWMain,"CreateSoundBuffer (Secondary1)", "Error",MB_OK);
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
|
||||||
}
|
dsval = IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING);
|
||||||
|
if(dsval != DS_OK)
|
||||||
dsval = IDirectSoundBuffer_Play(lpDSBPRIMARY,0,0,DSBPLAY_LOOPING);
|
{
|
||||||
if(dsval != DS_OK)
|
MessageBox(hWMain,"Play (Secondary1)","Error",MB_OK);
|
||||||
{
|
return -1;
|
||||||
MessageBox(hWMain,"Play (Primary)","Error",MB_OK);
|
}
|
||||||
return -1;
|
|
||||||
}
|
// init some play vars
|
||||||
|
LastWrite = 0x00000000;
|
||||||
dsval = IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING);
|
LastPlay = 0;
|
||||||
if(dsval != DS_OK)
|
|
||||||
{
|
return 0;
|
||||||
MessageBox(hWMain,"Play (Secondary1)","Error",MB_OK);
|
}
|
||||||
return -1;
|
|
||||||
}
|
void DSRemoveSound()
|
||||||
|
{
|
||||||
// init some play vars
|
int iRes;
|
||||||
LastWrite = 0x00000000;
|
|
||||||
LastPlay = 0;
|
if (lpDSBSECONDARY1 != NULL)
|
||||||
|
{
|
||||||
return 0;
|
IDirectSoundBuffer_Stop(lpDSBSECONDARY1);
|
||||||
}
|
iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1);
|
||||||
|
|
||||||
void RemoveSound()
|
// FF says such a loop is bad... Demo says it's good... Pete doesn't care
|
||||||
{
|
while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1);
|
||||||
int iRes;
|
|
||||||
|
lpDSBSECONDARY1 = NULL;
|
||||||
if (lpDSBSECONDARY1 != NULL)
|
}
|
||||||
{
|
|
||||||
IDirectSoundBuffer_Stop(lpDSBSECONDARY1);
|
if (lpDSBPRIMARY != NULL)
|
||||||
iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1);
|
{
|
||||||
|
IDirectSoundBuffer_Stop(lpDSBPRIMARY);
|
||||||
// FF says such a loop is bad... Demo says it's good... Pete doesn't care
|
iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY);
|
||||||
while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBSECONDARY1);
|
|
||||||
|
// FF says such a loop is bad... Demo says it's good... Pete doesn't care
|
||||||
lpDSBSECONDARY1 = NULL;
|
while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY);
|
||||||
}
|
|
||||||
|
lpDSBPRIMARY = NULL;
|
||||||
if (lpDSBPRIMARY != NULL)
|
}
|
||||||
{
|
|
||||||
IDirectSoundBuffer_Stop(lpDSBPRIMARY);
|
if (lpDS!=NULL)
|
||||||
iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY);
|
{
|
||||||
|
iRes = IDirectSound_Release(lpDS);
|
||||||
// FF says such a loop is bad... Demo says it's good... Pete doesn't care
|
|
||||||
while(iRes!=0) iRes = IDirectSoundBuffer_Release(lpDSBPRIMARY);
|
// FF says such a loop is bad... Demo says it's good... Pete doesn't care
|
||||||
|
while(iRes!=0) iRes = IDirectSound_Release(lpDS);
|
||||||
lpDSBPRIMARY = NULL;
|
|
||||||
}
|
lpDS = NULL;
|
||||||
|
}
|
||||||
if (lpDS!=NULL)
|
|
||||||
{
|
}
|
||||||
iRes = IDirectSound_Release(lpDS);
|
|
||||||
|
int DSSoundGetBytesBuffered()
|
||||||
// FF says such a loop is bad... Demo says it's good... Pete doesn't care
|
{
|
||||||
while(iRes!=0) iRes = IDirectSound_Release(lpDS);
|
unsigned long cplay,cwrite;
|
||||||
|
|
||||||
lpDS = NULL;
|
if (LastWrite == 0xffffffff) return 0;
|
||||||
}
|
|
||||||
|
IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite);
|
||||||
}
|
|
||||||
|
if(cplay > SOUNDSIZE) return SOUNDSIZE;
|
||||||
int SoundGetBytesBuffered()
|
if(cplay < LastWrite) return LastWrite - cplay;
|
||||||
{
|
|
||||||
unsigned long cplay,cwrite;
|
return (SOUNDSIZE - cplay) + LastWrite;
|
||||||
|
}
|
||||||
if (LastWrite == 0xffffffff) return 0;
|
|
||||||
|
void DSSoundFeedVoiceData(unsigned char* pSound,long lBytes)
|
||||||
IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite);
|
{
|
||||||
|
LPVOID lpvPtr1, lpvPtr2;
|
||||||
if(cplay > SOUNDSIZE) return SOUNDSIZE;
|
unsigned long dwBytes1,dwBytes2;
|
||||||
if(cplay < LastWrite) return LastWrite - cplay;
|
unsigned long *lpSS, *lpSD;
|
||||||
|
unsigned long dw,cplay,cwrite;
|
||||||
return (SOUNDSIZE - cplay) + LastWrite;
|
HRESULT hr;
|
||||||
}
|
unsigned long status;
|
||||||
|
|
||||||
void SoundFeedVoiceData(unsigned char* pSound,long lBytes)
|
IDirectSoundBuffer_GetStatus(lpDSBSECONDARY1,&status);
|
||||||
{
|
if (status & DSBSTATUS_BUFFERLOST)
|
||||||
LPVOID lpvPtr1, lpvPtr2;
|
{
|
||||||
unsigned long dwBytes1,dwBytes2;
|
if (IDirectSoundBuffer_Restore(lpDSBSECONDARY1) != DS_OK) return;
|
||||||
unsigned long *lpSS, *lpSD;
|
IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING);
|
||||||
unsigned long dw,cplay,cwrite;
|
}
|
||||||
HRESULT hr;
|
|
||||||
unsigned long status;
|
IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite);
|
||||||
|
|
||||||
IDirectSoundBuffer_GetStatus(lpDSBSECONDARY1,&status);
|
if(LastWrite == 0xffffffff) LastWrite=cwrite;
|
||||||
if (status & DSBSTATUS_BUFFERLOST)
|
|
||||||
{
|
hr = IDirectSoundBuffer_Lock(lpDSBSECONDARY1,LastWrite,lBytes,
|
||||||
if (IDirectSoundBuffer_Restore(lpDSBSECONDARY1) != DS_OK) return;
|
&lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0);
|
||||||
IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING);
|
|
||||||
}
|
if (hr != DS_OK)
|
||||||
|
{
|
||||||
IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite);
|
LastWrite=0xffffffff;
|
||||||
|
return;
|
||||||
if(LastWrite == 0xffffffff) LastWrite=cwrite;
|
}
|
||||||
|
|
||||||
hr = IDirectSoundBuffer_Lock(lpDSBSECONDARY1,LastWrite,lBytes,
|
lpSS = (unsigned long *)pSound;
|
||||||
&lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0);
|
lpSD = (unsigned long *)lpvPtr1;
|
||||||
|
dw = dwBytes1 >> 2;
|
||||||
if (hr != DS_OK)
|
|
||||||
{
|
while(dw)
|
||||||
LastWrite=0xffffffff;
|
{
|
||||||
return;
|
*lpSD++=*lpSS++;
|
||||||
}
|
dw--;
|
||||||
|
}
|
||||||
lpSS = (unsigned long *)pSound;
|
|
||||||
lpSD = (unsigned long *)lpvPtr1;
|
if (lpvPtr2)
|
||||||
dw = dwBytes1 >> 2;
|
{
|
||||||
|
lpSD = (unsigned long *)lpvPtr2;
|
||||||
while(dw)
|
dw = dwBytes2 >> 2;
|
||||||
{
|
|
||||||
*lpSD++=*lpSS++;
|
while(dw)
|
||||||
dw--;
|
{
|
||||||
}
|
*lpSD++ = *lpSS++;
|
||||||
|
dw--;
|
||||||
if (lpvPtr2)
|
}
|
||||||
{
|
}
|
||||||
lpSD = (unsigned long *)lpvPtr2;
|
|
||||||
dw = dwBytes2 >> 2;
|
IDirectSoundBuffer_Unlock(lpDSBSECONDARY1,lpvPtr1,dwBytes1,lpvPtr2,dwBytes2);
|
||||||
|
LastWrite += lBytes;
|
||||||
while(dw)
|
if(LastWrite >= SOUNDSIZE) LastWrite -= SOUNDSIZE;
|
||||||
{
|
LastPlay = cplay;
|
||||||
*lpSD++ = *lpSS++;
|
|
||||||
dw--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IDirectSoundBuffer_Unlock(lpDSBSECONDARY1,lpvPtr1,dwBytes1,lpvPtr2,dwBytes2);
|
|
||||||
LastWrite += lBytes;
|
|
||||||
if(LastWrite >= SOUNDSIZE) LastWrite -= SOUNDSIZE;
|
|
||||||
LastPlay = cplay;
|
|
||||||
}
|
}
|
|
@ -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 <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
|
|
||||||
|
#include "SoundTargets.h"
|
||||||
|
#include "../zerospu2.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// use DirectSound for the sound
|
||||||
|
#include <dsound.h>
|
||||||
|
|
||||||
|
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
|
|
@ -234,7 +234,35 @@
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dsound51.cpp"
|
RelativePath="..\Targets\Alsa.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Devel|Win32"
|
||||||
|
ExcludedFromBuild="true"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Targets\dsound51.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Targets\OSS.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Devel|Win32"
|
||||||
|
ExcludedFromBuild="true"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Targets\SoundTargets.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
@ -259,10 +287,38 @@
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Targets\Alsa.h"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Devel|Win32"
|
||||||
|
ExcludedFromBuild="true"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Targets\dsound51.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\misc.h"
|
RelativePath="..\misc.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Targets\OSS.h"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Devel|Win32"
|
||||||
|
ExcludedFromBuild="true"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\reg.h"
|
RelativePath="..\reg.h"
|
||||||
>
|
>
|
||||||
|
@ -271,6 +327,10 @@
|
||||||
RelativePath=".\resource.h"
|
RelativePath=".\resource.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Targets\SoundTargets.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\zerospu2.h"
|
RelativePath="..\zerospu2.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -16,14 +16,13 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "zerospu2.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "svnrev.h"
|
#include "svnrev.h"
|
||||||
u32 MaxBuffer = 80000; // Until I put this in properly, avoid breaking Windows.
|
|
||||||
#else
|
|
||||||
#include "Targets/SoundTargets.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "zerospu2.h"
|
#include "Targets/SoundTargets.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -210,6 +209,21 @@ void CALLBACK SPU2setSettingsDir(const char* dir)
|
||||||
s_strIniPath = (dir==NULL) ? "inis/" : 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()
|
s32 CALLBACK SPU2init()
|
||||||
{
|
{
|
||||||
LOG_CALLBACK("SPU2init()\n");
|
LOG_CALLBACK("SPU2init()\n");
|
||||||
|
@ -221,15 +235,9 @@ s32 CALLBACK SPU2init()
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
QueryPerformanceFrequency(&g_counterfreq);
|
QueryPerformanceFrequency(&g_counterfreq);
|
||||||
#else
|
|
||||||
|
|
||||||
#if defined(ZEROSPU2_ALSA)
|
|
||||||
InitAlsa();
|
|
||||||
#elif defined(ZEROSPU2_OSS)
|
|
||||||
InitOSS();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
InitApi();
|
||||||
|
|
||||||
spu2regs = (s8*)malloc(0x10000);
|
spu2regs = (s8*)malloc(0x10000);
|
||||||
spu2mem = (u16*)malloc(0x200000); // 2Mb
|
spu2mem = (u16*)malloc(0x200000); // 2Mb
|
||||||
|
|
Loading…
Reference in New Issue