From bf6854d121c44b3c89c71828651857403cd72fc6 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 5 Feb 2017 16:35:10 +0300 Subject: [PATCH] LV2_LOCK removed --- rpcs3/Emu/Cell/Modules/cellAudio.cpp | 6 ++--- rpcs3/Emu/Cell/Modules/cellAudio.h | 2 ++ rpcs3/Emu/Cell/lv2/lv2.cpp | 2 -- rpcs3/Emu/Cell/lv2/sys_sync.h | 24 ----------------- rpcs3/Emu/System.cpp | 40 +++++++++++----------------- 5 files changed, 21 insertions(+), 53 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index 89c5720528..81e9bb4152 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -274,7 +274,7 @@ void audio_config::on_task() // send aftermix event (normal audio event) - LV2_LOCK; + semaphore_lock lock(mutex); for (u64 key : keys) { @@ -702,7 +702,7 @@ s32 cellAudioSetNotifyEventQueue(u64 key) return CELL_AUDIO_ERROR_NOT_INIT; } - LV2_LOCK; + semaphore_lock lock(g_audio->mutex); for (auto k : g_audio->keys) // check for duplicates { @@ -737,7 +737,7 @@ s32 cellAudioRemoveNotifyEventQueue(u64 key) return CELL_AUDIO_ERROR_NOT_INIT; } - LV2_LOCK; + semaphore_lock lock(g_audio->mutex); for (auto i = g_audio->keys.begin(); i != g_audio->keys.end(); i++) { diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.h b/rpcs3/Emu/Cell/Modules/cellAudio.h index c916e70c63..9aa41299c5 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.h +++ b/rpcs3/Emu/Cell/Modules/cellAudio.h @@ -137,6 +137,8 @@ public: std::vector keys; + semaphore<> mutex; + audio_config() { for (u32 i = 0; i < AUDIO_PORT_COUNT; i++) diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index f017dc69fa..f5c826faa9 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -1015,5 +1015,3 @@ extern ppu_function_t ppu_get_syscall(u64 code) return nullptr; } - -DECLARE(lv2_lock_guard::g_sema); diff --git a/rpcs3/Emu/Cell/lv2/sys_sync.h b/rpcs3/Emu/Cell/lv2/sys_sync.h index 1fe1f602db..80915194e0 100644 --- a/rpcs3/Emu/Cell/lv2/sys_sync.h +++ b/rpcs3/Emu/Cell/lv2/sys_sync.h @@ -106,27 +106,3 @@ struct lv2_obj return res; } }; - -// Temporary implementation for LV2_UNLOCK (TODO: remove it) -struct lv2_lock_guard -{ - static semaphore<> g_sema; - - lv2_lock_guard(const lv2_lock_guard&) = delete; - - lv2_lock_guard() - { - g_sema.post(); - } - - ~lv2_lock_guard() - { - g_sema.wait(); - } -}; - -using lv2_lock_t = semaphore_lock&; - -#define LV2_LOCK semaphore_lock lv2_lock(lv2_lock_guard::g_sema) - -#define LV2_UNLOCK lv2_lock_guard{} diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index d7e388b1a9..727e621b6b 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -418,20 +418,16 @@ void Emulator::Resume() SendDbgCommand(DID_RESUME_EMU); + auto on_select = [](u32, cpu_thread& cpu) { - LV2_LOCK; + cpu.state -= cpu_flag::dbg_global_pause; + cpu.notify(); + }; - auto on_select = [](u32, cpu_thread& cpu) - { - cpu.state -= cpu_flag::dbg_global_pause; - cpu.notify(); - }; - - idm::select(on_select); - idm::select(on_select); - idm::select(on_select); - idm::select(on_select); - } + idm::select(on_select); + idm::select(on_select); + idm::select(on_select); + idm::select(on_select); rpcs3::on_resume()(); @@ -450,20 +446,16 @@ void Emulator::Stop() rpcs3::on_stop()(); SendDbgCommand(DID_STOP_EMU); + auto on_select = [](u32, cpu_thread& cpu) { - LV2_LOCK; + cpu.state += cpu_flag::dbg_global_stop; + cpu.get()->set_exception(std::make_exception_ptr(EmulationStopped())); + }; - auto on_select = [](u32, cpu_thread& cpu) - { - cpu.state += cpu_flag::dbg_global_stop; - cpu.get()->set_exception(std::make_exception_ptr(EmulationStopped())); - }; - - idm::select(on_select); - idm::select(on_select); - idm::select(on_select); - idm::select(on_select); - } + idm::select(on_select); + idm::select(on_select); + idm::select(on_select); + idm::select(on_select); LOG_NOTICE(GENERAL, "All threads signaled...");