mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
sys_spu_thread_bind_queue, sys_spu_thread_connect_event and SPU-side sys_spu_thread_receive_event, sys_spu_thread_send_event Fixed event system Fixed SleepQueue priority alg Audio: cellAudioGetPortTimestamp and cellAudioGetPortBlockTag
82 lines
1.3 KiB
C++
82 lines
1.3 KiB
C++
#include "stdafx.h"
|
|
#include "event.h"
|
|
|
|
void EventManager::Init()
|
|
{
|
|
|
|
}
|
|
|
|
void EventManager::Clear()
|
|
{
|
|
key_map.clear();
|
|
}
|
|
|
|
bool EventManager::CheckKey(u64 key)
|
|
{
|
|
if (!key) return true;
|
|
SMutexLocker lock(m_lock);
|
|
|
|
return key_map.find(key) != key_map.end();
|
|
}
|
|
|
|
bool EventManager::RegisterKey(EventQueue* data, u64 key)
|
|
{
|
|
if (!key) return true;
|
|
SMutexLocker lock(m_lock);
|
|
|
|
if (key_map.find(key) != key_map.end()) return false;
|
|
|
|
for (auto& v = key_map.begin(); v != key_map.end(); ++v)
|
|
{
|
|
if (v->second == data) return false;
|
|
}
|
|
|
|
key_map[key] = data;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool EventManager::GetEventQueue(u64 key, EventQueue*& data)
|
|
{
|
|
data = nullptr;
|
|
if (!key) return false;
|
|
SMutexLocker lock(m_lock);
|
|
|
|
auto f = key_map.find(key);
|
|
if (f != key_map.end())
|
|
{
|
|
data = f->second;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool EventManager::UnregisterKey(u64 key)
|
|
{
|
|
if (!key) return false;
|
|
SMutexLocker lock(m_lock);
|
|
|
|
auto f = key_map.find(key);
|
|
if (f != key_map.end())
|
|
{
|
|
key_map.erase(f);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool EventManager::SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3)
|
|
{
|
|
if (!key) return false;
|
|
SMutexLocker lock(m_lock);
|
|
|
|
auto f = key_map.find(key);
|
|
if (f == key_map.end())
|
|
{
|
|
return false;
|
|
}
|
|
EventQueue* eq = f->second;
|
|
|
|
eq->events.push(source, d1, d2, d3);
|
|
return true;
|
|
} |