mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-04 21:39:54 +00:00
SMutex partially replaced with std::mutex
SPURecompiler.h: SETcc bug fixed
This commit is contained in:
parent
237e7989b4
commit
90b9861043
@ -8,7 +8,14 @@
|
||||
|
||||
__forceinline void SM_Sleep()
|
||||
{
|
||||
Sleep(1);
|
||||
if (NamedThreadBase* t = GetCurrentNamedThread())
|
||||
{
|
||||
t->WaitForAnySignal();
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
thread_local size_t g_this_thread_id = 0;
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
default: return res;
|
||||
}
|
||||
|
||||
wait();
|
||||
if (wait) wait();
|
||||
|
||||
if (timeout && counter++ > timeout)
|
||||
{
|
||||
@ -133,14 +133,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, T (get_tid)()>
|
||||
template<typename T, typename Tid, Tid (get_tid)()>
|
||||
class SMutexLockerBase
|
||||
{
|
||||
SMutexBase<T>& sm;
|
||||
T& sm;
|
||||
public:
|
||||
const T tid;
|
||||
const Tid tid;
|
||||
|
||||
__forceinline SMutexLockerBase(SMutexBase<T>& _sm)
|
||||
__forceinline SMutexLockerBase(T& _sm)
|
||||
: sm(_sm)
|
||||
, tid(get_tid())
|
||||
{
|
||||
@ -169,9 +169,9 @@ typedef SMutexBase<u32>
|
||||
typedef SMutexBase<be_t<u32>>
|
||||
SMutexBE;
|
||||
|
||||
typedef SMutexLockerBase<size_t, SM_GetCurrentThreadId>
|
||||
typedef SMutexLockerBase<SMutexGeneral, size_t, SM_GetCurrentThreadId>
|
||||
SMutexGeneralLocker;
|
||||
typedef SMutexLockerBase<u32, SM_GetCurrentCPUThreadId>
|
||||
typedef SMutexLockerBase<SMutex, u32, SM_GetCurrentCPUThreadId>
|
||||
SMutexLocker;
|
||||
typedef SMutexLockerBase<be_t<u32>, SM_GetCurrentCPUThreadIdBE>
|
||||
typedef SMutexLockerBase<SMutexBE, be_t<u32>, SM_GetCurrentCPUThreadIdBE>
|
||||
SMutexBELocker;
|
||||
|
@ -3,7 +3,7 @@
|
||||
template<typename T, u32 SQSize = 666>
|
||||
class SQueue
|
||||
{
|
||||
SMutexGeneral m_mutex;
|
||||
std::mutex m_mutex;
|
||||
u32 m_pos;
|
||||
u32 m_count;
|
||||
T m_data[SQSize];
|
||||
@ -24,11 +24,6 @@ public:
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (m_mutex.GetOwner() == m_mutex.GetDeadValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_count >= SQSize)
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
@ -40,7 +35,7 @@ public:
|
||||
}
|
||||
|
||||
{
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_count >= SQSize) continue;
|
||||
|
||||
@ -55,11 +50,6 @@ public:
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (m_mutex.GetOwner() == m_mutex.GetDeadValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_count)
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
@ -71,7 +61,7 @@ public:
|
||||
}
|
||||
|
||||
{
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (!m_count) continue;
|
||||
|
||||
@ -96,7 +86,7 @@ public:
|
||||
|
||||
void Clear()
|
||||
{
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
@ -104,11 +94,6 @@ public:
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (m_mutex.GetOwner() == m_mutex.GetDeadValue())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!m_count)
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
@ -120,7 +105,7 @@ public:
|
||||
}
|
||||
|
||||
{
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_count) break;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "Thread.h"
|
||||
|
||||
thread_local NamedThreadBase* g_tls_this_thread = nullptr;
|
||||
std::atomic<u32> g_thread_count = 0;
|
||||
std::atomic<u32> g_thread_count(0);
|
||||
|
||||
NamedThreadBase* GetCurrentNamedThread()
|
||||
{
|
||||
|
@ -13,6 +13,9 @@ class NamedThreadBase
|
||||
{
|
||||
std::string m_name;
|
||||
|
||||
std::condition_variable m_signal_cv;
|
||||
std::mutex m_signal_mtx;
|
||||
|
||||
public:
|
||||
NamedThreadBase(const std::string& name) : m_name(name)
|
||||
{
|
||||
@ -24,6 +27,17 @@ public:
|
||||
|
||||
virtual std::string GetThreadName() const;
|
||||
virtual void SetThreadName(const std::string& name);
|
||||
|
||||
void WaitForAnySignal() // wait 1 ms for something
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_signal_mtx);
|
||||
m_signal_cv.wait_for(lock, std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
void Notify() // wake up waiting thread or nothing
|
||||
{
|
||||
m_signal_cv.notify_one();
|
||||
}
|
||||
};
|
||||
|
||||
NamedThreadBase* GetCurrentNamedThread();
|
||||
|
@ -3,9 +3,14 @@
|
||||
#include "Emu/CPU/CPUDecoder.h"
|
||||
#include "Utilities/SMutex.h"
|
||||
|
||||
typedef SMutexBase<u32, 0, 0xffffffff, /* busy wait: specify nullptr */ SM_Sleep> SMutexR;
|
||||
typedef SMutexLockerBase<SMutexR, u32, SM_GetCurrentCPUThreadId> SMutexLockerR;
|
||||
|
||||
struct reservation_struct
|
||||
{
|
||||
SMutex mutex; // mutex for updating reservation_owner and data
|
||||
SMutexR mutex; // mutex for updating reservation_owner and data
|
||||
// std::mutex doesn't work because it probably wakes up waiting threads in the most unwanted order
|
||||
// and doesn't give a chance to finish some work before losing the reservation
|
||||
u32 owner; // id of thread that got reservation
|
||||
u32 addr;
|
||||
u32 size;
|
||||
|
@ -2367,7 +2367,7 @@ private:
|
||||
{
|
||||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
|
||||
SMutexLocker lock(reservation.mutex);
|
||||
SMutexLockerR lock(reservation.mutex);
|
||||
reservation.owner = lock.tid;
|
||||
reservation.addr = addr;
|
||||
reservation.size = 4;
|
||||
@ -2522,7 +2522,7 @@ private:
|
||||
{
|
||||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
|
||||
SMutexLocker lock(reservation.mutex);
|
||||
SMutexLockerR lock(reservation.mutex);
|
||||
reservation.owner = lock.tid;
|
||||
reservation.addr = addr;
|
||||
reservation.size = 8;
|
||||
@ -2641,7 +2641,7 @@ private:
|
||||
{
|
||||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
|
||||
SMutexLocker lock(reservation.mutex);
|
||||
SMutexLockerR lock(reservation.mutex);
|
||||
if (lock.tid == reservation.owner && reservation.addr == addr && reservation.size == 4)
|
||||
{
|
||||
// Memory.Write32(addr, CPU.GPR[rs]);
|
||||
@ -2702,7 +2702,7 @@ private:
|
||||
{
|
||||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
|
||||
SMutexLocker lock(reservation.mutex);
|
||||
SMutexLockerR lock(reservation.mutex);
|
||||
if (lock.tid == reservation.owner && reservation.addr == addr && reservation.size == 8)
|
||||
{
|
||||
// Memory.Write64(addr, CPU.GPR[rs]);
|
||||
|
@ -1931,7 +1931,7 @@ private:
|
||||
c.mov(*addr, cpu_dword(GPR[ra]._i32[3]));
|
||||
c.cmp(*addr, cpu_dword(GPR[rb]._i32[3]));
|
||||
c.mov(*addr, 0);
|
||||
c.setg(*addr);
|
||||
c.setg(addr->r8());
|
||||
c.neg(*addr);
|
||||
c.mov(*pos_var, (CPU.PC >> 2) + 1);
|
||||
c.xor_(*pos_var, *addr);
|
||||
@ -2311,7 +2311,7 @@ private:
|
||||
c.mov(*addr, cpu_dword(GPR[ra]._u32[3]));
|
||||
c.cmp(*addr, cpu_dword(GPR[rb]._u32[3]));
|
||||
c.mov(*addr, 0);
|
||||
c.seta(*addr);
|
||||
c.seta(addr->r8());
|
||||
c.neg(*addr);
|
||||
c.mov(*pos_var, (CPU.PC >> 2) + 1);
|
||||
c.xor_(*pos_var, *addr);
|
||||
@ -2729,7 +2729,7 @@ private:
|
||||
c.mov(*addr, cpu_dword(GPR[ra]._i32[3]));
|
||||
c.cmp(*addr, cpu_dword(GPR[rb]._i32[3]));
|
||||
c.mov(*addr, 0);
|
||||
c.sete(*addr);
|
||||
c.sete(addr->r8());
|
||||
c.neg(*addr);
|
||||
c.mov(*pos_var, (CPU.PC >> 2) + 1);
|
||||
c.xor_(*pos_var, *addr);
|
||||
@ -3391,7 +3391,7 @@ private:
|
||||
c.mov(*addr, cpu_dword(GPR[ra]._i32[3]));
|
||||
c.cmp(*addr, i10);
|
||||
c.mov(*addr, 0);
|
||||
c.setg(*addr);
|
||||
c.setg(addr->r8());
|
||||
c.neg(*addr);
|
||||
c.mov(*pos_var, (CPU.PC >> 2) + 1);
|
||||
c.xor_(*pos_var, *addr);
|
||||
@ -3457,7 +3457,7 @@ private:
|
||||
c.mov(*addr, cpu_dword(GPR[ra]._u32[3]));
|
||||
c.cmp(*addr, i10);
|
||||
c.mov(*addr, 0);
|
||||
c.seta(*addr);
|
||||
c.seta(addr->r8());
|
||||
c.neg(*addr);
|
||||
c.mov(*pos_var, (CPU.PC >> 2) + 1);
|
||||
c.xor_(*pos_var, *addr);
|
||||
@ -3508,7 +3508,7 @@ private:
|
||||
c.mov(*addr, cpu_dword(GPR[ra]._u32[3]));
|
||||
c.cmp(*addr, i10);
|
||||
c.mov(*addr, 0);
|
||||
c.sete(*addr);
|
||||
c.sete(addr->r8());
|
||||
c.neg(*addr);
|
||||
c.mov(*pos_var, (CPU.PC >> 2) + 1);
|
||||
c.xor_(*pos_var, *addr);
|
||||
|
@ -115,7 +115,7 @@ void SPUThread::DoClose()
|
||||
for (u32 i = 0; i < 64; i++)
|
||||
{
|
||||
EventPort& port = SPUPs[i];
|
||||
SMutexLocker lock(port.mutex);
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
if (port.eq)
|
||||
{
|
||||
port.eq->ports.remove(&port);
|
||||
|
@ -733,7 +733,7 @@ public:
|
||||
|
||||
if (op == MFC_GETLLAR_CMD) // get reservation
|
||||
{
|
||||
SMutexLocker lock(reservation.mutex);
|
||||
SMutexLockerR lock(reservation.mutex);
|
||||
reservation.owner = lock.tid;
|
||||
reservation.addr = ea;
|
||||
reservation.size = 128;
|
||||
@ -746,7 +746,7 @@ public:
|
||||
}
|
||||
else if (op == MFC_PUTLLC_CMD) // store conditional
|
||||
{
|
||||
SMutexLocker lock(reservation.mutex);
|
||||
SMutexLockerR lock(reservation.mutex);
|
||||
if (reservation.owner == lock.tid) // succeeded
|
||||
{
|
||||
if (reservation.addr == ea && reservation.size == 128)
|
||||
@ -827,7 +827,7 @@ public:
|
||||
}
|
||||
else // store unconditional
|
||||
{
|
||||
SMutexLocker lock(reservation.mutex);
|
||||
SMutexLockerR lock(reservation.mutex);
|
||||
ProcessCmd(MFC_PUT_CMD, tag, lsa, ea, 128);
|
||||
if (op == MFC_PUTLLUC_CMD)
|
||||
{
|
||||
@ -929,7 +929,7 @@ public:
|
||||
|
||||
EventPort& port = SPUPs[spup];
|
||||
|
||||
SMutexLocker lock(port.mutex);
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
|
||||
if (!port.eq)
|
||||
{
|
||||
@ -937,7 +937,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!port.eq->events.push(SYS_SPU_THREAD_EVENT_USER_KEY, lock.tid, ((u64)code << 32) | (v & 0x00ffffff), data))
|
||||
if (!port.eq->events.push(SYS_SPU_THREAD_EVENT_USER_KEY, GetCurrentCPUThread()->GetId(), ((u64)code << 32) | (v & 0x00ffffff), data))
|
||||
{
|
||||
SPU.In_MBox.PushUncond(CELL_EBUSY);
|
||||
return;
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
void EventManager::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void EventManager::Clear()
|
||||
@ -17,7 +16,7 @@ void EventManager::Clear()
|
||||
bool EventManager::CheckKey(u64 key)
|
||||
{
|
||||
if (!key) return true;
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
return key_map.find(key) != key_map.end();
|
||||
}
|
||||
@ -25,7 +24,7 @@ bool EventManager::CheckKey(u64 key)
|
||||
bool EventManager::RegisterKey(EventQueue* data, u64 key)
|
||||
{
|
||||
if (!key) return true;
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
if (key_map.find(key) != key_map.end()) return false;
|
||||
|
||||
@ -43,7 +42,7 @@ bool EventManager::GetEventQueue(u64 key, EventQueue*& data)
|
||||
{
|
||||
data = nullptr;
|
||||
if (!key) return false;
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
auto f = key_map.find(key);
|
||||
if (f != key_map.end())
|
||||
@ -57,7 +56,7 @@ bool EventManager::GetEventQueue(u64 key, EventQueue*& data)
|
||||
bool EventManager::UnregisterKey(u64 key)
|
||||
{
|
||||
if (!key) return false;
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
auto f = key_map.find(key);
|
||||
if (f != key_map.end())
|
||||
@ -71,7 +70,7 @@ bool EventManager::UnregisterKey(u64 key)
|
||||
bool EventManager::SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3)
|
||||
{
|
||||
if (!key) return false;
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
auto f = key_map.find(key);
|
||||
if (f == key_map.end())
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "Emu/SysCalls/SysCalls.h"
|
||||
#include "cellPamf.h"
|
||||
|
||||
extern SMutexGeneral g_mutex_avcodec_open2;
|
||||
extern std::mutex g_mutex_avcodec_open2;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -352,7 +352,7 @@ u32 adecOpen(AudioDecoder* data)
|
||||
AVDictionary* opts = nullptr;
|
||||
av_dict_set(&opts, "refcounted_frames", "1", 0);
|
||||
{
|
||||
SMutexGeneralLocker lock(g_mutex_avcodec_open2);
|
||||
std::lock_guard<std::mutex> lock(g_mutex_avcodec_open2);
|
||||
// not multithread-safe
|
||||
err = avcodec_open2(adec.ctx, codec, &opts);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
//Module cellAudio(0x0011, cellAudio_init);
|
||||
extern Module *cellAudio = nullptr;
|
||||
|
||||
static SMutexGeneral audioMutex;
|
||||
static std::mutex audioMutex;
|
||||
|
||||
AudioConfig m_config;
|
||||
|
||||
@ -394,7 +394,7 @@ int cellAudioInit()
|
||||
|
||||
// send aftermix event (normal audio event)
|
||||
{
|
||||
SMutexGeneralLocker lock(audioMutex);
|
||||
std::lock_guard<std::mutex> lock(audioMutex);
|
||||
// update indexes:
|
||||
for (u32 i = 0; i < m_config.AUDIO_PORT_COUNT; i++)
|
||||
{
|
||||
@ -694,7 +694,7 @@ int cellAudioGetPortTimestamp(u32 portNum, u64 tag, mem64_t stamp)
|
||||
|
||||
AudioPortConfig& port = m_config.m_ports[portNum];
|
||||
|
||||
SMutexGeneralLocker lock(audioMutex);
|
||||
std::lock_guard<std::mutex> lock(audioMutex);
|
||||
|
||||
stamp = m_config.start_time + (port.counter + (tag - port.tag)) * 256000000 / 48000;
|
||||
|
||||
@ -728,7 +728,7 @@ int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, mem64_t tag)
|
||||
return CELL_AUDIO_ERROR_PARAM;
|
||||
}
|
||||
|
||||
SMutexGeneralLocker lock(audioMutex);
|
||||
std::lock_guard<std::mutex> lock(audioMutex);
|
||||
|
||||
u64 tag_base = port.tag;
|
||||
if (tag_base % port.block > blockNo)
|
||||
@ -756,7 +756,7 @@ int cellAudioCreateNotifyEventQueue(mem32_t id, mem64_t key)
|
||||
{
|
||||
cellAudio->Warning("cellAudioCreateNotifyEventQueue(id_addr=0x%x, key_addr=0x%x)", id.GetAddr(), key.GetAddr());
|
||||
|
||||
SMutexGeneralLocker lock(audioMutex);
|
||||
std::lock_guard<std::mutex> lock(audioMutex);
|
||||
|
||||
u64 event_key = 0;
|
||||
while (Emu.GetEventManager().CheckKey((event_key << 48) | 0x80004d494f323221))
|
||||
@ -790,7 +790,7 @@ int cellAudioSetNotifyEventQueue(u64 key)
|
||||
{
|
||||
cellAudio->Warning("cellAudioSetNotifyEventQueue(key=0x%llx)", key);
|
||||
|
||||
SMutexGeneralLocker lock(audioMutex);
|
||||
std::lock_guard<std::mutex> lock(audioMutex);
|
||||
|
||||
for (u32 i = 0; i < m_config.m_keys.size(); i++) // check for duplicates
|
||||
{
|
||||
@ -822,7 +822,7 @@ int cellAudioRemoveNotifyEventQueue(u64 key)
|
||||
{
|
||||
cellAudio->Warning("cellAudioRemoveNotifyEventQueue(key=0x%llx)", key);
|
||||
|
||||
SMutexGeneralLocker lock(audioMutex);
|
||||
std::lock_guard<std::mutex> lock(audioMutex);
|
||||
|
||||
bool found = false;
|
||||
for (u32 i = 0; i < m_config.m_keys.size(); i++)
|
||||
|
@ -481,7 +481,7 @@ public:
|
||||
|
||||
class ElementaryStream
|
||||
{
|
||||
SMutex mutex;
|
||||
std::mutex m_mutex;
|
||||
|
||||
SQueue<u32> entries; // AU starting addresses
|
||||
u32 put_count; // number of AU written
|
||||
@ -566,19 +566,19 @@ public:
|
||||
|
||||
bool hasunseen()
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return peek_count < put_count;
|
||||
}
|
||||
|
||||
bool hasdata()
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return size;
|
||||
}
|
||||
|
||||
bool isfull()
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return is_full();
|
||||
}
|
||||
|
||||
@ -586,7 +586,7 @@ public:
|
||||
{
|
||||
u32 addr;
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
//if (fidMajor != 0xbd) ConLog.Write(">>> es::finish(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
|
||||
|
||||
addr = put;
|
||||
@ -621,7 +621,7 @@ public:
|
||||
|
||||
void push(DemuxerStream& stream, u32 sz, PesHeader& pes)
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (is_full())
|
||||
{
|
||||
@ -673,7 +673,7 @@ public:
|
||||
|
||||
bool release()
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
//if (fidMajor != 0xbd) ConLog.Write(">>> es::release(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
|
||||
if (released >= put_count)
|
||||
{
|
||||
@ -720,7 +720,7 @@ public:
|
||||
|
||||
bool peek(u32& out_data, bool no_ex, u32& out_spec, bool update_index)
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
//if (fidMajor != 0xbd) ConLog.Write(">>> es::peek(%sAu%s): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", wxString(update_index ? "Get" : "Peek").wx_str(),
|
||||
//wxString(no_ex ? "" : "Ex").wx_str(), peek, first, put, size);
|
||||
if (peek_count >= put_count) return false;
|
||||
@ -767,7 +767,7 @@ public:
|
||||
|
||||
void reset()
|
||||
{
|
||||
SMutexLocker lock(mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
//first = 0;
|
||||
//peek = 0;
|
||||
put = memAddr;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "Emu/SysCalls/Modules.h"
|
||||
#include "cellPamf.h"
|
||||
|
||||
SMutexGeneral g_mutex_avcodec_open2;
|
||||
std::mutex g_mutex_avcodec_open2;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -284,7 +284,7 @@ u32 vdecOpen(VideoDecoder* data)
|
||||
AVDictionary* opts = nullptr;
|
||||
av_dict_set(&opts, "refcounted_frames", "1", 0);
|
||||
{
|
||||
SMutexGeneralLocker lock(g_mutex_avcodec_open2);
|
||||
std::lock_guard<std::mutex> lock(g_mutex_avcodec_open2);
|
||||
// not multithread-safe
|
||||
err = avcodec_open2(vdec.ctx, codec, &opts);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ CellSurMixerConfig surMixer;
|
||||
#define SUR_PORT (7)
|
||||
u32 surMixerCb = 0;
|
||||
u32 surMixerCbArg = 0;
|
||||
SMutex mixer_mutex;
|
||||
std::mutex mixer_mutex;
|
||||
float mixdata[8*256];
|
||||
u64 mixcount = 0;
|
||||
|
||||
@ -53,7 +53,7 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
SMutexLocker lock(mixer_mutex);
|
||||
std::lock_guard<std::mutex> lock(mixer_mutex);
|
||||
|
||||
if (type == CELL_SURMIXER_CHSTRIP_TYPE1A)
|
||||
{
|
||||
@ -316,7 +316,7 @@ int cellSurMixerSurBusAddData(u32 busNo, u32 offset, u32 addr, u32 samples)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
SMutexLocker lock(mixer_mutex);
|
||||
std::lock_guard<std::mutex> lock(mixer_mutex);
|
||||
|
||||
for (u32 i = 0; i < samples; i++)
|
||||
{
|
||||
|
@ -280,20 +280,18 @@ int sys_event_port_destroy(u32 eport_id)
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
u32 tid = GetCurrentPPUThread().GetId();
|
||||
|
||||
if (eport->mutex.trylock(tid) != SMR_OK)
|
||||
if (!eport->m_mutex.try_lock())
|
||||
{
|
||||
return CELL_EISCONN;
|
||||
}
|
||||
|
||||
if (eport->eq)
|
||||
{
|
||||
eport->mutex.unlock(tid);
|
||||
eport->m_mutex.unlock();
|
||||
return CELL_EISCONN;
|
||||
}
|
||||
|
||||
eport->mutex.unlock(tid, ~0);
|
||||
eport->m_mutex.unlock();
|
||||
Emu.GetIdManager().RemoveID(eport_id);
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -308,16 +306,14 @@ int sys_event_port_connect_local(u32 eport_id, u32 equeue_id)
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
u32 tid = GetCurrentPPUThread().GetId();
|
||||
|
||||
if (eport->mutex.trylock(tid) != SMR_OK)
|
||||
if (!eport->m_mutex.try_lock())
|
||||
{
|
||||
return CELL_EISCONN;
|
||||
}
|
||||
|
||||
if (eport->eq)
|
||||
{
|
||||
eport->mutex.unlock(tid);
|
||||
eport->m_mutex.unlock();
|
||||
return CELL_EISCONN;
|
||||
}
|
||||
|
||||
@ -325,7 +321,7 @@ int sys_event_port_connect_local(u32 eport_id, u32 equeue_id)
|
||||
if (!Emu.GetIdManager().GetIDData(equeue_id, equeue))
|
||||
{
|
||||
sys_event.Error("sys_event_port_connect_local: event_queue(%d) not found!", equeue_id);
|
||||
eport->mutex.unlock(tid);
|
||||
eport->m_mutex.unlock();
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
else
|
||||
@ -334,7 +330,7 @@ int sys_event_port_connect_local(u32 eport_id, u32 equeue_id)
|
||||
}
|
||||
|
||||
eport->eq = equeue;
|
||||
eport->mutex.unlock(tid);
|
||||
eport->m_mutex.unlock();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
@ -353,16 +349,14 @@ int sys_event_port_disconnect(u32 eport_id)
|
||||
return CELL_ENOTCONN;
|
||||
}
|
||||
|
||||
u32 tid = GetCurrentPPUThread().GetId();
|
||||
|
||||
if (eport->mutex.trylock(tid) != SMR_OK)
|
||||
if (!eport->m_mutex.try_lock())
|
||||
{
|
||||
return CELL_EBUSY;
|
||||
}
|
||||
|
||||
eport->eq->ports.remove(eport);
|
||||
eport->eq = nullptr;
|
||||
eport->mutex.unlock(tid);
|
||||
eport->m_mutex.unlock();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
@ -377,7 +371,7 @@ int sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
SMutexLocker lock(eport->mutex);
|
||||
std::lock_guard<std::mutex> lock(eport->m_mutex);
|
||||
|
||||
EventQueue* eq = eport->eq;
|
||||
if (!eq)
|
||||
|
@ -604,7 +604,7 @@ int sys_spu_thread_connect_event(u32 id, u32 eq_id, u32 et, u8 spup)
|
||||
|
||||
EventPort& port = spu.SPUPs[spup];
|
||||
|
||||
SMutexLocker lock(port.mutex);
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
|
||||
if (port.eq)
|
||||
{
|
||||
@ -645,7 +645,7 @@ int sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup)
|
||||
|
||||
EventPort& port = spu.SPUPs[spup];
|
||||
|
||||
SMutexLocker lock(port.mutex);
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
|
||||
if (!port.eq)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ struct EventPort
|
||||
{
|
||||
u64 name; // generated or user-specified code that is passed to sys_event_data struct
|
||||
EventQueue* eq; // event queue this port has been connected to
|
||||
SMutex mutex; // may be locked until the event sending is finished
|
||||
std::mutex m_mutex; // may be locked until the event sending is finished
|
||||
|
||||
EventPort(u64 name = 0)
|
||||
: eq(nullptr)
|
||||
@ -70,7 +70,7 @@ struct EventPort
|
||||
class EventRingBuffer
|
||||
{
|
||||
std::vector<sys_event_data> data;
|
||||
SMutex m_lock;
|
||||
std::mutex m_mutex;
|
||||
u32 buf_pos;
|
||||
u32 buf_count;
|
||||
|
||||
@ -87,14 +87,14 @@ public:
|
||||
|
||||
void clear()
|
||||
{
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
buf_count = 0;
|
||||
buf_pos = 0;
|
||||
}
|
||||
|
||||
bool push(u64 name, u64 d1, u64 d2, u64 d3)
|
||||
{
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (buf_count >= size) return false;
|
||||
|
||||
sys_event_data& ref = data[(buf_pos + buf_count++) % size];
|
||||
@ -108,7 +108,7 @@ public:
|
||||
|
||||
bool pop(sys_event_data& ref)
|
||||
{
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (!buf_count) return false;
|
||||
|
||||
sys_event_data& from = data[buf_pos];
|
||||
@ -124,7 +124,7 @@ public:
|
||||
|
||||
u32 pop_all(sys_event_data* ptr, u32 max)
|
||||
{
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
u32 res = 0;
|
||||
while (buf_count && max)
|
||||
@ -152,16 +152,16 @@ public:
|
||||
class EventPortList
|
||||
{
|
||||
std::vector<EventPort*> data;
|
||||
SMutex m_lock;
|
||||
std::mutex m_mutex;
|
||||
|
||||
public:
|
||||
|
||||
void clear()
|
||||
{
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
for (u32 i = 0; i < data.size(); i++)
|
||||
{
|
||||
SMutexLocker lock2(data[i]->mutex);
|
||||
std::lock_guard<std::mutex> lock2(data[i]->m_mutex);
|
||||
data[i]->eq = nullptr; // force all ports to disconnect
|
||||
}
|
||||
data.clear();
|
||||
@ -169,13 +169,13 @@ public:
|
||||
|
||||
void add(EventPort* port)
|
||||
{
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
data.push_back(port);
|
||||
}
|
||||
|
||||
void remove(EventPort* port)
|
||||
{
|
||||
SMutexLocker lock(m_lock);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
for (u32 i = 0; i < data.size(); i++)
|
||||
{
|
||||
if (data[i] == port)
|
||||
@ -215,7 +215,7 @@ struct EventQueue
|
||||
|
||||
class EventManager
|
||||
{
|
||||
SMutex m_lock;
|
||||
std::mutex m_lock;
|
||||
std::unordered_map<u64, EventQueue*> key_map;
|
||||
|
||||
public:
|
||||
|
@ -267,6 +267,7 @@
|
||||
<ClInclude Include="Emu\CPU\CPUThread.h" />
|
||||
<ClInclude Include="Emu\CPU\CPUThreadManager.h" />
|
||||
<ClInclude Include="Emu\DbgCommand.h" />
|
||||
<ClInclude Include="Emu\event.h" />
|
||||
<ClInclude Include="Emu\FS\VFS.h" />
|
||||
<ClInclude Include="Emu\FS\vfsDevice.h" />
|
||||
<ClInclude Include="Emu\FS\vfsDeviceLocalFile.h" />
|
||||
|
@ -1039,5 +1039,8 @@
|
||||
<ClInclude Include="Emu\Io\XInput\XInputPadHandler.h">
|
||||
<Filter>Emu\Io\XInput</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\event.h">
|
||||
<Filter>Emu\SysCalls</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user