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:
arcum42 2010-01-17 03:21:23 +00:00
parent f878a438ff
commit 78aa3de579
6 changed files with 390 additions and 268 deletions

View File

@ -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;

View File

@ -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();

View File

@ -16,16 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <windows.h>
#include <windowsx.h>
#include "../zerospu2.h"
/////////////////////////////////////
// use DirectSound for the sound
#include <dsound.h>
//4*48*73
#define SOUNDSIZE 76800
#include "dsound51.h"
HWND hWMain = NULL;
LPDIRECTSOUND lpDS;
@ -41,7 +32,7 @@ unsigned long LastWrite = 0xffffffff;
unsigned long LastWriteS = 0xffffffff;
unsigned long LastPlay = 0;
int SetupSound()
int DSSetupSound()
{
HRESULT dsval;
WAVEFORMATEX pcmwf;
@ -138,7 +129,7 @@ int SetupSound()
return 0;
}
void RemoveSound()
void DSRemoveSound()
{
int iRes;
@ -176,7 +167,7 @@ void RemoveSound()
}
int SoundGetBytesBuffered()
int DSSoundGetBytesBuffered()
{
unsigned long cplay,cwrite;
@ -190,7 +181,7 @@ int SoundGetBytesBuffered()
return (SOUNDSIZE - cplay) + LastWrite;
}
void SoundFeedVoiceData(unsigned char* pSound,long lBytes)
void DSSoundFeedVoiceData(unsigned char* pSound,long lBytes)
{
LPVOID lpvPtr1, lpvPtr2;
unsigned long dwBytes1,dwBytes2;

View File

@ -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

View File

@ -234,7 +234,35 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<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
@ -259,10 +287,38 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
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
RelativePath="..\misc.h"
>
</File>
<File
RelativePath="..\Targets\OSS.h"
>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\reg.h"
>
@ -271,6 +327,10 @@
RelativePath=".\resource.h"
>
</File>
<File
RelativePath="..\Targets\SoundTargets.h"
>
</File>
<File
RelativePath="..\zerospu2.h"
>

View File

@ -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 <assert.h>
#include <stdlib.h>
@ -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