From 5e28df26b2e170554b062dc47b55df50923e3660 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 4 Jun 2013 23:54:37 +0200 Subject: [PATCH] Fixes and cleanup --- Core/HLE/__sceAudio.cpp | 21 +++++++++------------ UI/NativeApp.cpp | 8 +++++--- UI/PluginScreen.cpp | 6 +++--- native | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 8f9df38bf2..fe4619ade1 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -19,7 +19,7 @@ #include "sceAudio.h" #include "sceKernel.h" #include "sceKernelThread.h" -#include "StdMutex.h" +#include "base/mutex.h" #include "CommonTypes.h" #include "../CoreTiming.h" #include "../MemMap.h" @@ -30,7 +30,7 @@ #include "Common/Thread.h" // Should be used to lock anything related to the outAudioQueue. -std::recursive_mutex section; +recursive_mutex section; int eventAudioUpdate = -1; int eventHostAudioUpdate = -1; @@ -84,9 +84,10 @@ void __AudioDoState(PointerWrap &p) p.Do(mixFrequency); - section.lock(); - outAudioQueue.DoState(p); - section.unlock(); + { + lock_guard guard(section); + outAudioQueue.DoState(p); + } int chanCount = ARRAY_SIZE(chans); p.Do(chanCount); @@ -250,7 +251,7 @@ void __AudioUpdate() } if (g_Config.bEnableSound) { - section.lock(); + lock_guard guard(section); if (outAudioQueue.room() >= hwBlockSize * 2) { // Push the mixed samples onto the output audio queue. for (int i = 0; i < hwBlockSize; i++) { @@ -265,7 +266,6 @@ void __AudioUpdate() // about the amount of audio we produce. DEBUG_LOG(HLE, "Audio outbuffer overrun! room = %i / %i", outAudioQueue.room(), (u32)outAudioQueue.capacity()); } - section.unlock(); } } @@ -281,15 +281,13 @@ void __AudioSetOutputFrequency(int freq) int __AudioMix(short *outstereo, int numFrames) { // TODO: if mixFrequency != the actual output frequency, resample! - - section.lock(); + lock_guard guard(section); int underrun = -1; s16 sampleL = 0; s16 sampleR = 0; bool anythingToPlay = false; for (int i = 0; i < numFrames; i++) { - if (outAudioQueue.size() >= 2) - { + if (outAudioQueue.size() >= 2) { sampleL = outAudioQueue.pop_front(); sampleR = outAudioQueue.pop_front(); outstereo[i * 2 + 0] = sampleL; @@ -306,6 +304,5 @@ int __AudioMix(short *outstereo, int numFrames) } else { // DEBUG_LOG(HLE, "No underrun, mixed %i samples fine", numFrames); } - section.unlock(); return underrun >= 0 ? underrun : numFrames; } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 765f39eae3..31b11c4544 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -174,12 +174,14 @@ void NativeHost::ShutdownSound() { } int NativeMix(short *audio, int num_samples) { + // ILOG("Entering mixer"); if (g_mixer) { - return g_mixer->Mix(audio, num_samples); + num_samples = g_mixer->Mix(audio, num_samples); } else { - //memset(audio, 0, numSamples * 2); - return 0; + memset(audio, 0, num_samples * 2 * sizeof(short)); } + // ILOG("Leaving mixer"); + return num_samples; } void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, bool *landscape) { diff --git a/UI/PluginScreen.cpp b/UI/PluginScreen.cpp index e19792b818..19d435e639 100644 --- a/UI/PluginScreen.cpp +++ b/UI/PluginScreen.cpp @@ -71,11 +71,11 @@ void PluginScreen::CreateViews() { root_->Add(buttonBar); buttonBack_ = new Button(c->T("Back"), new LinearLayoutParams(1.0)); - buttonBar->Add(buttonBack_)->OnClick.Add(std::bind(&UIScreen::OnBack, this, placeholder::_1)); + buttonBar->Add(buttonBack_)->OnClick.Handle(this, &UIScreen::OnBack); buttonDownload_ = new Button(c->T("Download"), new LinearLayoutParams(1.0)); buttonDownload_->SetEnabled(false); - buttonBar->Add(buttonDownload_)->OnClick.Add(std::bind(&PluginScreen::OnDownload, this, placeholder::_1)); - buttonBar->Add(new Button(c->T("More Information"), new LinearLayoutParams(1.0)))->OnClick.Add(std::bind(&PluginScreen::OnInformation, this, placeholder::_1)); + buttonBar->Add(buttonDownload_)->OnClick.Handle(this, &PluginScreen::OnDownload); + buttonBar->Add(new Button(c->T("More Information"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &PluginScreen::OnInformation); } void PluginScreen::update(InputState &input) { diff --git a/native b/native index a509d38357..04f6a35031 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit a509d38357c8ccff9efb4208957965c1aaf46e92 +Subproject commit 04f6a3503110d29aa41577a9e443a0ffd029067a