mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-22 04:25:19 +00:00
IdManager fix
This commit is contained in:
parent
0724a9efa2
commit
a70d305806
9 changed files with 20 additions and 27 deletions
|
@ -23,15 +23,8 @@ public:
|
|||
const std::type_info& info;
|
||||
const u32 type;
|
||||
|
||||
template<typename T, typename... Args> ID_data_t(u32 type, Args&&... args) // doesn't work
|
||||
: data(std::make_shared<T>(args...))
|
||||
, info(typeid(T))
|
||||
, type(type)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T> ID_data_t(const std::shared_ptr<T>& data, u32 type)
|
||||
: data(data)
|
||||
template<typename T> force_inline ID_data_t(std::shared_ptr<T> data, u32 type)
|
||||
: data(std::move(data))
|
||||
, info(typeid(T))
|
||||
, type(type)
|
||||
{
|
||||
|
@ -42,7 +35,7 @@ public:
|
|||
ID_data_t& operator =(const ID_data_t& right) = delete;
|
||||
|
||||
ID_data_t(ID_data_t&& right)
|
||||
: data(right.data)
|
||||
: data(std::move(const_cast<std::shared_ptr<void>&>(right.data)))
|
||||
, info(right.info)
|
||||
, type(right.type)
|
||||
{
|
||||
|
@ -95,11 +88,11 @@ public:
|
|||
}
|
||||
|
||||
// add new ID using existing std::shared_ptr (not recommended, use make() instead)
|
||||
template<typename T> u32 add(const std::shared_ptr<T>& data, u32 type = ID_type<T>::type)
|
||||
template<typename T> u32 add(std::shared_ptr<T> data, u32 type = ID_type<T>::type)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
m_id_map.emplace(m_cur_id, ID_data_t(data, type));
|
||||
m_id_map.emplace(m_cur_id, ID_data_t(std::move(data), type));
|
||||
|
||||
return m_cur_id++;
|
||||
}
|
||||
|
|
|
@ -763,12 +763,12 @@ s32 cellAudioCreateNotifyEventQueue(vm::ptr<u32> id, vm::ptr<u64> key)
|
|||
{
|
||||
const u64 key_value = 0x80004d494f323221ull + k;
|
||||
|
||||
const auto queue = std::make_shared<lv2_event_queue_t>(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0, key_value, 32);
|
||||
auto queue = std::make_shared<lv2_event_queue_t>(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0, key_value, 32);
|
||||
|
||||
// register key if not used yet
|
||||
if (Emu.GetEventManager().RegisterKey(queue))
|
||||
{
|
||||
*id = Emu.GetIdManager().add(queue);
|
||||
*id = Emu.GetIdManager().add(std::move(queue));
|
||||
*key = key_value;
|
||||
|
||||
return CELL_OK;
|
||||
|
|
|
@ -998,9 +998,9 @@ s32 cellDmuxEnableEs(u32 handle, vm::ptr<const CellCodecEsFilterId> esFilterId,
|
|||
|
||||
// TODO: check esFilterId, esResourceInfo, esCb and esSpecificInfo correctly
|
||||
|
||||
std::shared_ptr<ElementaryStream> es(new ElementaryStream(dmux.get(), esResourceInfo->memAddr, esResourceInfo->memSize,
|
||||
auto es = std::make_shared<ElementaryStream>(dmux.get(), esResourceInfo->memAddr, esResourceInfo->memSize,
|
||||
esFilterId->filterIdMajor, esFilterId->filterIdMinor, esFilterId->supplementalInfo1, esFilterId->supplementalInfo2,
|
||||
esCb->cbEsMsgFunc, esCb->cbArg, esSpecificInfo));
|
||||
esCb->cbEsMsgFunc, esCb->cbArg, esSpecificInfo);
|
||||
|
||||
u32 id = Emu.GetIdManager().add(es);
|
||||
es->id = id;
|
||||
|
|
|
@ -34,7 +34,7 @@ s32 cellGifDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellGifDecSrc
|
|||
{
|
||||
cellGifDec.Warning("cellGifDecOpen(mainHandle=0x%x, subHandle=*0x%x, src=*0x%x, openInfo=*0x%x)", mainHandle, subHandle, src, openInfo);
|
||||
|
||||
std::shared_ptr<CellGifDecSubHandle> current_subHandle(new CellGifDecSubHandle);
|
||||
auto current_subHandle = std::make_shared<CellGifDecSubHandle>();
|
||||
current_subHandle->fd = 0;
|
||||
current_subHandle->src = *src;
|
||||
|
||||
|
@ -57,7 +57,7 @@ s32 cellGifDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellGifDecSrc
|
|||
}
|
||||
|
||||
// From now, every u32 subHandle argument is a pointer to a CellGifDecSubHandle struct.
|
||||
*subHandle = Emu.GetIdManager().add(current_subHandle);
|
||||
*subHandle = Emu.GetIdManager().add(std::move(current_subHandle));
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ s32 cellJpgDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellJpgDecSrc
|
|||
{
|
||||
cellJpgDec.Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle=*0x%x, src=*0x%x, openInfo=*0x%x)", mainHandle, subHandle, src, openInfo);
|
||||
|
||||
std::shared_ptr<CellJpgDecSubHandle> current_subHandle(new CellJpgDecSubHandle);
|
||||
auto current_subHandle = std::make_shared<CellJpgDecSubHandle>();
|
||||
|
||||
current_subHandle->fd = 0;
|
||||
current_subHandle->src = *src;
|
||||
|
@ -63,7 +63,7 @@ s32 cellJpgDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellJpgDecSrc
|
|||
}
|
||||
|
||||
// From now, every u32 subHandle argument is a pointer to a CellJpgDecSubHandle struct.
|
||||
*subHandle = Emu.GetIdManager().add(current_subHandle);
|
||||
*subHandle = Emu.GetIdManager().add(std::move(current_subHandle));
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -29,14 +29,14 @@ s32 _cellSpursSendSignal(vm::ptr<CellSpursTaskset> taskset, u32 taskID);
|
|||
|
||||
s32 spursCreateLv2EventQueue(vm::ptr<CellSpurs> spurs, u32& queue_id, vm::ptr<u8> port, s32 size, u64 name_u64)
|
||||
{
|
||||
const auto queue = Emu.GetEventManager().MakeEventQueue(SYS_SYNC_FIFO, SYS_PPU_QUEUE, name_u64, 0, size);
|
||||
auto queue = Emu.GetEventManager().MakeEventQueue(SYS_SYNC_FIFO, SYS_PPU_QUEUE, name_u64, 0, size);
|
||||
|
||||
if (!queue) // rough
|
||||
{
|
||||
return CELL_EAGAIN;
|
||||
}
|
||||
|
||||
queue_id = Emu.GetIdManager().add(queue);
|
||||
queue_id = Emu.GetIdManager().add(std::move(queue));
|
||||
|
||||
if (s32 res = spursAttachLv2EventQueue(spurs, queue_id, port, 1, true))
|
||||
{
|
||||
|
|
|
@ -40,14 +40,14 @@ s32 sys_event_queue_create(vm::ptr<u32> equeue_id, vm::ptr<sys_event_queue_attr>
|
|||
default: sys_event.Error("sys_event_queue_create(): unknown type (0x%x)", type); return CELL_EINVAL;
|
||||
}
|
||||
|
||||
const auto queue = Emu.GetEventManager().MakeEventQueue(protocol, type, attr->name_u64, event_queue_key, size);
|
||||
auto queue = Emu.GetEventManager().MakeEventQueue(protocol, type, attr->name_u64, event_queue_key, size);
|
||||
|
||||
if (!queue)
|
||||
{
|
||||
return CELL_EEXIST;
|
||||
}
|
||||
|
||||
*equeue_id = Emu.GetIdManager().add(queue);
|
||||
*equeue_id = Emu.GetIdManager().add(std::move(queue));
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ s32 sys_fs_opendir(vm::ptr<const char> path, vm::ptr<u32> fd)
|
|||
return CELL_FS_ENOENT;
|
||||
}
|
||||
|
||||
*fd = Emu.GetIdManager().add(directory);
|
||||
*fd = Emu.GetIdManager().add(std::move(directory));
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_loa
|
|||
}
|
||||
|
||||
// Create the PRX object and return its id
|
||||
std::shared_ptr<lv2_prx_t> prx(new lv2_prx_t());
|
||||
std::shared_ptr<lv2_prx_t> prx = std::make_shared<lv2_prx_t>();
|
||||
prx->size = (u32)f.GetSize();
|
||||
prx->address = (u32)Memory.Alloc(prx->size, 4);
|
||||
prx->path = (const char*)path;
|
||||
|
@ -40,7 +40,7 @@ s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_loa
|
|||
// Load the PRX into memory
|
||||
f.Read(vm::get_ptr(prx->address), prx->size);
|
||||
|
||||
return Emu.GetIdManager().add(prx);
|
||||
return Emu.GetIdManager().add(std::move(prx));
|
||||
}
|
||||
|
||||
s32 sys_prx_load_module_on_memcontainer()
|
||||
|
|
Loading…
Add table
Reference in a new issue