psphawk: sound, except it doesn't work. i will figure it out later
This commit is contained in:
parent
c8577fc361
commit
1de395ca2a
|
@ -25,5 +25,8 @@ namespace BizHawk.Emulation.Consoles.Sony.PSP
|
||||||
|
|
||||||
[DllImport(dd, CallingConvention = cc)]
|
[DllImport(dd, CallingConvention = cc)]
|
||||||
public static extern void advance();
|
public static extern void advance();
|
||||||
|
|
||||||
|
[DllImport(dd, CallingConvention = cc)]
|
||||||
|
public static extern int mixsound(short[] buff, int nsamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,12 @@ namespace BizHawk.Emulation.Consoles.Sony.PSP
|
||||||
public void FrameAdvance(bool render, bool rendersound = true)
|
public void FrameAdvance(bool render, bool rendersound = true)
|
||||||
{
|
{
|
||||||
PPSSPPDll.advance();
|
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();
|
LogFlush();
|
||||||
|
//Console.WriteLine("Audio Service: {0}", nsampavail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Frame
|
public int Frame
|
||||||
|
@ -184,11 +189,12 @@ namespace BizHawk.Emulation.Consoles.Sony.PSP
|
||||||
public int BufferHeight { get { return screenheight; } }
|
public int BufferHeight { get { return screenheight; } }
|
||||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
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)
|
public void GetSamples(out short[] samples, out int nsamp)
|
||||||
{
|
{
|
||||||
samples = audiobuffer;
|
samples = audiobuffer;
|
||||||
nsamp = 735;
|
nsamp = nsampavail;
|
||||||
}
|
}
|
||||||
public void DiscardSamples()
|
public void DiscardSamples()
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -27,7 +27,7 @@
|
||||||
int PSPMixer::Mix(short *stereoout, int numSamples)
|
int PSPMixer::Mix(short *stereoout, int numSamples)
|
||||||
{
|
{
|
||||||
int numFrames = __AudioMix(stereoout, numSamples);
|
int numFrames = __AudioMix(stereoout, numSamples);
|
||||||
#ifdef _WIN32
|
#if 0 //def _WIN32
|
||||||
if (numFrames < numSamples) {
|
if (numFrames < numSamples) {
|
||||||
// Our dsound backend will not stop playing, let's just feed it zeroes if we miss data.
|
// 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));
|
memset(stereoout + 2 * 2 * numFrames, 0, 2 * 2 * (numSamples - numFrames));
|
||||||
|
|
|
@ -167,7 +167,7 @@ BZEXPORT int BZAPI init(const char *fn, void (BZAPI* logcallback)(char, const ch
|
||||||
CoreParameter coreParameter;
|
CoreParameter coreParameter;
|
||||||
coreParameter.cpuCore = CPU_JIT;
|
coreParameter.cpuCore = CPU_JIT;
|
||||||
coreParameter.gpuCore = GPU_GLES;
|
coreParameter.gpuCore = GPU_GLES;
|
||||||
coreParameter.enableSound = false;
|
coreParameter.enableSound = true;
|
||||||
coreParameter.fileToStart = fn;
|
coreParameter.fileToStart = fn;
|
||||||
coreParameter.mountIso = "";
|
coreParameter.mountIso = "";
|
||||||
coreParameter.startPaused = true;
|
coreParameter.startPaused = true;
|
||||||
|
@ -182,7 +182,7 @@ BZEXPORT int BZAPI init(const char *fn, void (BZAPI* logcallback)(char, const ch
|
||||||
coreParameter.pixelHeight = 272;
|
coreParameter.pixelHeight = 272;
|
||||||
coreParameter.unthrottle = true;
|
coreParameter.unthrottle = true;
|
||||||
|
|
||||||
g_Config.bEnableSound = false;
|
g_Config.bEnableSound = true;
|
||||||
g_Config.bFirstRun = false;
|
g_Config.bFirstRun = false;
|
||||||
g_Config.bIgnoreBadMemAccess = true;
|
g_Config.bIgnoreBadMemAccess = true;
|
||||||
// Never report from tests.
|
// Never report from tests.
|
||||||
|
@ -240,6 +240,11 @@ BZEXPORT void BZAPI die()
|
||||||
logger = NULL;
|
logger = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BZEXPORT int BZAPI mixsound(short *buff, int nsamp)
|
||||||
|
{
|
||||||
|
return headlessHost->SendSound(buff, nsamp);
|
||||||
|
}
|
||||||
|
|
||||||
BZEXPORT void BZAPI advance()
|
BZEXPORT void BZAPI advance()
|
||||||
{
|
{
|
||||||
coreState = CORE_RUNNING;
|
coreState = CORE_RUNNING;
|
||||||
|
|
|
@ -69,6 +69,25 @@ void SetVSync(int value)
|
||||||
wglSwapIntervalEXT(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
|
// TODO: also fix up GetSysDirectories
|
||||||
void WindowsHeadlessHost::LoadNativeAssets()
|
void WindowsHeadlessHost::LoadNativeAssets()
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,10 +38,18 @@ public:
|
||||||
virtual void SetComparisonScreenshot(const std::string &filename);
|
virtual void SetComparisonScreenshot(const std::string &filename);
|
||||||
virtual void SendBackBuffer(void *dest);
|
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:
|
private:
|
||||||
bool ResizeGL();
|
bool ResizeGL();
|
||||||
void LoadNativeAssets();
|
void LoadNativeAssets();
|
||||||
|
|
||||||
|
PMixer *gmixer;
|
||||||
|
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
HDC hDC;
|
HDC hDC;
|
||||||
HGLRC hRC;
|
HGLRC hRC;
|
||||||
|
|
Loading…
Reference in New Issue