diff --git a/BizHawk.Emulation/Consoles/Sony/PSP/PPSSPPDll.cs b/BizHawk.Emulation/Consoles/Sony/PSP/PPSSPPDll.cs index 40c1634fb8..9a7778079c 100644 --- a/BizHawk.Emulation/Consoles/Sony/PSP/PPSSPPDll.cs +++ b/BizHawk.Emulation/Consoles/Sony/PSP/PPSSPPDll.cs @@ -25,5 +25,8 @@ namespace BizHawk.Emulation.Consoles.Sony.PSP [DllImport(dd, CallingConvention = cc)] public static extern void advance(); + + [DllImport(dd, CallingConvention = cc)] + public static extern int mixsound(short[] buff, int nsamp); } } diff --git a/BizHawk.Emulation/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation/Consoles/Sony/PSP/PSP.cs index 6b72486e9b..111e117632 100644 --- a/BizHawk.Emulation/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation/Consoles/Sony/PSP/PSP.cs @@ -90,7 +90,12 @@ namespace BizHawk.Emulation.Consoles.Sony.PSP public void FrameAdvance(bool render, bool rendersound = true) { PPSSPPDll.advance(); + // problem 1: audio can be 48khz, if a particular core parameter is set. we're not accounting for that. + // problem 2: we seem to be getting approximately the right amount of output, but with + // a lot of jitter on the per-frame buffer size + nsampavail = PPSSPPDll.mixsound(audiobuffer, audiobuffer.Length / 2); LogFlush(); + //Console.WriteLine("Audio Service: {0}", nsampavail); } public int Frame @@ -184,11 +189,12 @@ namespace BizHawk.Emulation.Consoles.Sony.PSP public int BufferHeight { get { return screenheight; } } public int BackgroundColor { get { return unchecked((int)0xff000000); } } - readonly short[] audiobuffer = new short[735 * 2]; + readonly short[] audiobuffer = new short[2048 * 2]; + int nsampavail = 0; public void GetSamples(out short[] samples, out int nsamp) { - samples = audiobuffer; - nsamp = 735; + samples = audiobuffer; + nsamp = nsampavail; } public void DiscardSamples() { diff --git a/BizHawk.MultiClient/output/dll/PPSSPPBizhawk.dll b/BizHawk.MultiClient/output/dll/PPSSPPBizhawk.dll index 5cee165b7e..6c31108b0e 100644 Binary files a/BizHawk.MultiClient/output/dll/PPSSPPBizhawk.dll and b/BizHawk.MultiClient/output/dll/PPSSPPBizhawk.dll differ diff --git a/BizHawk.MultiClient/output/dll/at3plusdecoder.dll b/BizHawk.MultiClient/output/dll/at3plusdecoder.dll new file mode 100644 index 0000000000..7361ee2a3a Binary files /dev/null and b/BizHawk.MultiClient/output/dll/at3plusdecoder.dll differ diff --git a/ppsspp/Core/PSPMixer.cpp b/ppsspp/Core/PSPMixer.cpp index 69cec9f4c9..6ea7879c63 100644 --- a/ppsspp/Core/PSPMixer.cpp +++ b/ppsspp/Core/PSPMixer.cpp @@ -27,7 +27,7 @@ int PSPMixer::Mix(short *stereoout, int numSamples) { int numFrames = __AudioMix(stereoout, numSamples); -#ifdef _WIN32 +#if 0 //def _WIN32 if (numFrames < numSamples) { // Our dsound backend will not stop playing, let's just feed it zeroes if we miss data. memset(stereoout + 2 * 2 * numFrames, 0, 2 * 2 * (numSamples - numFrames)); diff --git a/ppsspp/bizhawk/Headless.cpp b/ppsspp/bizhawk/Headless.cpp index 01d57aa8b7..3905fc3407 100644 --- a/ppsspp/bizhawk/Headless.cpp +++ b/ppsspp/bizhawk/Headless.cpp @@ -167,7 +167,7 @@ BZEXPORT int BZAPI init(const char *fn, void (BZAPI* logcallback)(char, const ch CoreParameter coreParameter; coreParameter.cpuCore = CPU_JIT; coreParameter.gpuCore = GPU_GLES; - coreParameter.enableSound = false; + coreParameter.enableSound = true; coreParameter.fileToStart = fn; coreParameter.mountIso = ""; coreParameter.startPaused = true; @@ -182,7 +182,7 @@ BZEXPORT int BZAPI init(const char *fn, void (BZAPI* logcallback)(char, const ch coreParameter.pixelHeight = 272; coreParameter.unthrottle = true; - g_Config.bEnableSound = false; + g_Config.bEnableSound = true; g_Config.bFirstRun = false; g_Config.bIgnoreBadMemAccess = true; // Never report from tests. @@ -240,6 +240,11 @@ BZEXPORT void BZAPI die() logger = NULL; } +BZEXPORT int BZAPI mixsound(short *buff, int nsamp) +{ + return headlessHost->SendSound(buff, nsamp); +} + BZEXPORT void BZAPI advance() { coreState = CORE_RUNNING; diff --git a/ppsspp/bizhawk/WindowsHeadlessHost.cpp b/ppsspp/bizhawk/WindowsHeadlessHost.cpp index 8308bdb342..298ef397b1 100644 --- a/ppsspp/bizhawk/WindowsHeadlessHost.cpp +++ b/ppsspp/bizhawk/WindowsHeadlessHost.cpp @@ -69,6 +69,25 @@ void SetVSync(int value) wglSwapIntervalEXT(value); } +void WindowsHeadlessHost::InitSound(PMixer *mixer) +{ + gmixer = mixer; +} +void WindowsHeadlessHost::UpdateSound() +{ +} +void WindowsHeadlessHost::ShutdownSound() +{ + gmixer = NULL; +} + +int WindowsHeadlessHost::SendSound(short *buff, int n) +{ + if (!gmixer) + return 0; + return gmixer->Mix(buff, n); +} + // TODO: also fix up GetSysDirectories void WindowsHeadlessHost::LoadNativeAssets() { diff --git a/ppsspp/bizhawk/WindowsHeadlessHost.h b/ppsspp/bizhawk/WindowsHeadlessHost.h index b028aa2fc9..c593e78566 100644 --- a/ppsspp/bizhawk/WindowsHeadlessHost.h +++ b/ppsspp/bizhawk/WindowsHeadlessHost.h @@ -38,10 +38,18 @@ public: virtual void SetComparisonScreenshot(const std::string &filename); virtual void SendBackBuffer(void *dest); + virtual void WindowsHeadlessHost::InitSound(PMixer *mixer); + virtual void WindowsHeadlessHost::UpdateSound(); + virtual void WindowsHeadlessHost::ShutdownSound(); + + virtual int SendSound(short *buff, int n); + private: bool ResizeGL(); void LoadNativeAssets(); + PMixer *gmixer; + HWND hWnd; HDC hDC; HGLRC hRC;