From 1b055fd07ecf4f4d46c690fb3c77cf66bc1cb0c0 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 11 Jan 2015 14:18:40 +0100 Subject: [PATCH] Make the sample rate queryable as a sysprop --- Windows/DSoundStream.cpp | 11 ++++++++--- Windows/DSoundStream.h | 2 +- Windows/main.cpp | 8 +++++++- native | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index 473cd66977..585573f2b2 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -50,13 +50,16 @@ private: // TODO: Get rid of this static DSoundState *g_dsound; - inline int RoundDown128(int x) { return x & (~127); } int DSound_GetSampleRate() { - return g_dsound->GetSampleRate(); + if (g_dsound) { + return g_dsound->GetSampleRate(); + } else { + return 0; + } } bool DSoundState::createBuffer() { @@ -246,7 +249,9 @@ int DSoundState::GetCurSample() { } void DSound_UpdateSound() { - g_dsound->UpdateSound(); + if (g_dsound) { + g_dsound->UpdateSound(); + } } bool DSound_StartSound(HWND window, StreamCallback _callback, int sampleRate) { diff --git a/Windows/DSoundStream.h b/Windows/DSoundStream.h index 2b888463b2..7e30b2e371 100644 --- a/Windows/DSoundStream.h +++ b/Windows/DSoundStream.h @@ -5,7 +5,7 @@ typedef int (*StreamCallback)(short *buffer, int numSamples, int bits, int rate, int channels); -bool DSound_StartSound(HWND window, StreamCallback _callback, int sampleRate = 44100); +bool DSound_StartSound(HWND window, StreamCallback _callback, int sampleRate); void DSound_UpdateSound(); void DSound_StopSound(); diff --git a/Windows/main.cpp b/Windows/main.cpp index 01325bf316..6aebf0c2a5 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -30,6 +30,7 @@ #include "Core/Config.h" #include "Core/SaveState.h" #include "Windows/EmuThread.h" +#include "Windows/DSoundStream.h" #include "ext/disarm.h" #include "Common/LogManager.h" @@ -256,7 +257,12 @@ std::string System_GetProperty(SystemProperty prop) { } int System_GetPropertyInt(SystemProperty prop) { - return -1; + switch (prop) { + case SYSPROP_AUDIO_SAMPLE_RATE: + return DSound_GetSampleRate(); + default: + return -1; + } } void System_SendMessage(const char *command, const char *parameter) { diff --git a/native b/native index 9201103abe..1b5bf730ca 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 9201103abe872dcdc50e0d8331f96d9044b8f0b4 +Subproject commit 1b5bf730caffa702de34a6db9f0ae93fbbd88eed