mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Minor refactor
This commit is contained in:
@@ -164,16 +164,17 @@ LogManager::LogManager() {
|
||||
stdioUseColor_ = isatty(fileno(stdout));
|
||||
#endif
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
if (IsDebuggerPresent()) {
|
||||
outputs_ |= LogOutput::DebugString;
|
||||
}
|
||||
|
||||
#if !PPSSPP_PLATFORM(UWP)
|
||||
if (!consoleLog_) {
|
||||
consoleLog_ = new ConsoleListener();
|
||||
}
|
||||
outputs_ |= LogOutput::WinConsole;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
LogManager::~LogManager() {
|
||||
|
||||
+1
-1
@@ -344,7 +344,7 @@ static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loo
|
||||
|
||||
u32 prevVagAddr = v.vagAddr;
|
||||
bool reset = false;
|
||||
if (v.type != VOICETYPE_VAG || v.vagAddr != vagAddr || v.vagSize != size || v.loop != loop) {
|
||||
if (v.type != VOICETYPE_VAG || v.vagAddr != vagAddr || v.vagSize != size || v.loop != (loop != 0)) {
|
||||
v.type = VOICETYPE_VAG;
|
||||
reset = true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -842,9 +842,9 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
#ifdef _WIN32
|
||||
winAudioBackend = CreateAudioBackend((AudioBackendType)g_Config.iAudioBackend);
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
winAudioBackend->Init(0, &NativeMix, 44100);
|
||||
winAudioBackend->Init(&NativeMix);
|
||||
#else
|
||||
winAudioBackend->Init(MainWindow::GetHWND(), &NativeMix, 44100);
|
||||
winAudioBackend->Init(&NativeMix);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@ public:
|
||||
XAudioBackend();
|
||||
~XAudioBackend() override;
|
||||
|
||||
bool Init(HWND window, StreamCallback callback, int sampleRate) override; // If fails, can safely delete the object
|
||||
bool Init(StreamCallback callback, void *userdata = nullptr) override; // If fails, can safely delete the object
|
||||
int GetSampleRate() const override { return sampleRate_; }
|
||||
int PeriodFrames() const override { return 0; }
|
||||
|
||||
private:
|
||||
bool RunSound();
|
||||
@@ -32,7 +33,10 @@ private:
|
||||
IXAudio2MasteringVoice *xaudioMaster = nullptr;
|
||||
IXAudio2SourceVoice *xaudioVoice = nullptr;
|
||||
|
||||
int sampleRate_ = 0;
|
||||
void *userdata_ = nullptr;
|
||||
|
||||
int sampleRate_ = 44100;
|
||||
int periodFrames_ = 0;
|
||||
|
||||
char realtimeBuffer_[BUFSIZE]{};
|
||||
uint32_t cursor_ = 0;
|
||||
@@ -126,9 +130,9 @@ XAudioBackend::~XAudioBackend() {
|
||||
xaudioDevice->Release();
|
||||
}
|
||||
|
||||
bool XAudioBackend::Init(HWND window, StreamCallback _callback, int sampleRate) {
|
||||
bool XAudioBackend::Init(StreamCallback _callback, void *userdata) {
|
||||
callback_ = _callback;
|
||||
sampleRate_ = sampleRate;
|
||||
userdata_ = userdata;
|
||||
return RunSound();
|
||||
}
|
||||
|
||||
@@ -170,6 +174,7 @@ void XAudioBackend::PollLoop() {
|
||||
cursor_ = 0;
|
||||
bytesLeftInBuffer = BUFSIZE;
|
||||
}
|
||||
periodFrames_ = stereoSamplesRendered;
|
||||
}
|
||||
|
||||
SetEvent(exitEvent_);
|
||||
|
||||
@@ -186,8 +186,7 @@ private:
|
||||
#define REFTIMES_PER_SEC (10000000/200)
|
||||
#define REFTIMES_PER_MILLISEC (REFTIMES_PER_SEC / 1000)
|
||||
|
||||
WASAPIAudioBackend::WASAPIAudioBackend() : threadData_(0) {
|
||||
}
|
||||
WASAPIAudioBackend::WASAPIAudioBackend() : threadData_(0) { }
|
||||
|
||||
WASAPIAudioBackend::~WASAPIAudioBackend() {
|
||||
if (threadData_ == 0) {
|
||||
@@ -210,10 +209,10 @@ unsigned int WINAPI WASAPIAudioBackend::soundThread(void *param) {
|
||||
return backend->RunThread();
|
||||
}
|
||||
|
||||
bool WASAPIAudioBackend::Init(HWND window, StreamCallback callback, int sampleRate) {
|
||||
bool WASAPIAudioBackend::Init(StreamCallback callback, void *userdata) {
|
||||
threadData_ = 0;
|
||||
userdata_ = userdata;
|
||||
callback_ = callback;
|
||||
sampleRate_ = sampleRate;
|
||||
hThread_ = (HANDLE)_beginthreadex(0, 0, soundThread, (void *)this, 0, 0);
|
||||
if (!hThread_)
|
||||
return false;
|
||||
|
||||
@@ -10,8 +10,9 @@ public:
|
||||
WASAPIAudioBackend();
|
||||
~WASAPIAudioBackend();
|
||||
|
||||
bool Init(HWND window, StreamCallback callback, int sampleRate) override; // If fails, can safely delete the object
|
||||
bool Init(StreamCallback callback, void *userdata) override; // If fails, can safely delete the object
|
||||
int GetSampleRate() const override { return sampleRate_; }
|
||||
int PeriodFrames() const override { return periodFrames_; } // amount of frames normally requested
|
||||
|
||||
private:
|
||||
int RunThread();
|
||||
@@ -20,5 +21,7 @@ private:
|
||||
HANDLE hThread_ = nullptr;
|
||||
StreamCallback callback_ = nullptr;
|
||||
int sampleRate_ = 0;
|
||||
std::atomic<int> threadData_;
|
||||
int periodFrames_ = 0;
|
||||
void *userdata_ = 0;
|
||||
std::atomic<int> threadData_{};
|
||||
};
|
||||
|
||||
@@ -11,8 +11,9 @@ typedef int (*StreamCallback)(short *buffer, int numSamples, int rate);
|
||||
class WindowsAudioBackend {
|
||||
public:
|
||||
virtual ~WindowsAudioBackend() {}
|
||||
virtual bool Init(HWND window, StreamCallback _callback, int sampleRate) = 0;
|
||||
virtual bool Init(StreamCallback _callback, void *userdata = nullptr) = 0;
|
||||
virtual int GetSampleRate() const = 0;
|
||||
virtual int PeriodFrames() const = 0;
|
||||
};
|
||||
|
||||
// Factory
|
||||
|
||||
@@ -325,6 +325,8 @@ int64_t System_GetPropertyInt(SystemProperty prop) {
|
||||
return (int64_t)MainWindow::GetHWND();
|
||||
case SYSPROP_AUDIO_SAMPLE_RATE:
|
||||
return winAudioBackend ? winAudioBackend->GetSampleRate() : -1;
|
||||
case SYSPROP_AUDIO_FRAMES_PER_BUFFER:
|
||||
return winAudioBackend ? winAudioBackend->PeriodFrames() : -1;
|
||||
case SYSPROP_DEVICE_TYPE:
|
||||
return DEVICE_TYPE_DESKTOP;
|
||||
case SYSPROP_DISPLAY_COUNT:
|
||||
|
||||
Reference in New Issue
Block a user