diff --git a/Utilities/cond.cpp b/Utilities/cond.cpp index 0e5951ce55..39c240775f 100644 --- a/Utilities/cond.cpp +++ b/Utilities/cond.cpp @@ -148,7 +148,7 @@ bool notifier::wait(u64 usec_timeout) return res; } -bool cond_one::imp_wait(u64 _timeout) noexcept +bool unique_cond::imp_wait(u64 _timeout) noexcept { // State transition: c_sig -> c_lock \ c_lock -> c_wait const u32 _old = m_value.fetch_sub(1); @@ -173,7 +173,7 @@ bool cond_one::imp_wait(u64 _timeout) noexcept }); } -void cond_one::imp_notify() noexcept +void unique_cond::imp_notify() noexcept { auto [old, ok] = m_value.fetch_op([](u32& v) { diff --git a/Utilities/cond.h b/Utilities/cond.h index 6e43a95922..0cadedac12 100644 --- a/Utilities/cond.h +++ b/Utilities/cond.h @@ -64,7 +64,7 @@ public: static constexpr u64 max_timeout = u64{UINT32_MAX} / 1000 * 1000000; }; -// Pair of a fake shared mutex (only limited shared locking) and a condition variable +// Pair of a fake shared mutex (only limited shared locking) and a condition variable. Obsolete. class notifier { atomic_t m_counter{0}; @@ -129,7 +129,8 @@ public: static constexpr u32 max_readers = 0x7f; }; -class cond_one +// Condition variable fused with a pseudo-mutex which is never supposed to be locked concurrently. +class unique_cond { enum : u32 { @@ -144,7 +145,7 @@ class cond_one void imp_notify() noexcept; public: - constexpr cond_one() = default; + constexpr unique_cond() = default; void lock() noexcept { @@ -158,7 +159,7 @@ public: m_value = 0; } - bool wait(std::unique_lock& lock, u64 usec_timeout = -1) noexcept + bool wait(std::unique_lock& lock, u64 usec_timeout = -1) noexcept { AUDIT(lock.owns_lock()); AUDIT(lock.mutex() == this); diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.cpp b/rpcs3/Emu/Cell/Modules/cellVdec.cpp index a9a3df603a..46fd63bba6 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVdec.cpp @@ -90,7 +90,6 @@ struct vdec_context final atomic_t au_count{0}; - cond_one in_cv; lf_queue> in_cmd; vdec_context(s32 type, u32 profile, u32 addr, u32 size, vm::ptr func, u32 arg) @@ -161,13 +160,11 @@ struct vdec_context final { ppu_tid = ppu.id; - std::unique_lock cv_lock(in_cv); - for (auto cmds = in_cmd.pop_all(); !Emu.IsStopped(); cmds ? cmds.pop_front() : cmds = in_cmd.pop_all()) { if (!cmds) { - in_cv.wait(cv_lock, 1000); + in_cmd.wait(1000); continue; } @@ -498,7 +495,6 @@ s32 cellVdecClose(ppu_thread& ppu, u32 handle) lv2_obj::sleep(ppu); vdec->out_max = 0; vdec->in_cmd.push(vdec_close); - vdec->in_cv.notify(); while (!atomic_storage::load(vdec->ppu_tid)) { @@ -522,7 +518,6 @@ s32 cellVdecStartSeq(u32 handle) } vdec->in_cmd.push(vdec_start_seq); - vdec->in_cv.notify(); return CELL_OK; } @@ -538,7 +533,6 @@ s32 cellVdecEndSeq(u32 handle) } vdec->in_cmd.push(vdec_cmd{-1}); - vdec->in_cv.notify(); return CELL_OK; } @@ -560,7 +554,6 @@ s32 cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::cptrin_cmd.push(vdec_cmd{mode, *auInfo}); - vdec->in_cv.notify(); return CELL_OK; } @@ -911,7 +904,6 @@ s32 cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc) // TODO: check frc value vdec->in_cmd.push(frc); - vdec->in_cv.notify(); return CELL_OK; }