1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-21 18:22:33 +01:00

fixed_typemap.hpp: return reference

This commit is contained in:
Nekotekina 2021-03-02 14:59:19 +03:00
parent bbf52f3cea
commit ea5e837bd6
87 changed files with 3028 additions and 2997 deletions

View File

@ -1423,13 +1423,13 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
vm::temporary_unlock(*cpu);
u32 pf_port_id = 0;
if (auto pf_entries = g_fxo->get<page_fault_notification_entries>(); true)
if (auto& pf_entries = g_fxo->get<page_fault_notification_entries>(); true)
{
if (auto mem = vm::get(vm::any, addr))
{
reader_lock lock(pf_entries->mutex);
reader_lock lock(pf_entries.mutex);
for (const auto& entry : pf_entries->entries)
for (const auto& entry : pf_entries.entries)
{
if (entry.start_addr == mem->addr)
{
@ -1489,10 +1489,10 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
// Now, place the page fault event onto table so that other functions [sys_mmapper_free_address and pagefault recovery funcs etc]
// know that this thread is page faulted and where.
auto pf_events = g_fxo->get<page_fault_event_entries>();
auto& pf_events = g_fxo->get<page_fault_event_entries>();
{
std::lock_guard pf_lock(pf_events->pf_mutex);
pf_events->events.emplace(cpu, addr);
std::lock_guard pf_lock(pf_events.pf_mutex);
pf_events.events.emplace(cpu, addr);
}
sig_log.warning("Page_fault %s location 0x%x because of %s memory", is_writing ? "writing" : "reading",

View File

@ -444,14 +444,14 @@ void cpu_thread::operator()()
{
case 1:
{
//g_fxo->get<cpu_profiler>()->registered.push(id);
//g_fxo->get<cpu_profiler>().registered.push(id);
break;
}
case 2:
{
if (g_cfg.core.spu_prof)
{
g_fxo->get<cpu_profiler>()->registered.push(id);
g_fxo->get<cpu_profiler>().registered.push(id);
}
break;
@ -763,7 +763,7 @@ bool cpu_thread::check_state() noexcept
{
if (state0 & cpu_flag::dbg_pause)
{
g_fxo->get<gdb_server>()->pause_from(this);
g_fxo->get<gdb_server>().pause_from(this);
}
cpu_wait(state1);
@ -1159,6 +1159,6 @@ void cpu_thread::flush_profilers() noexcept
if (g_cfg.core.spu_prof || false)
{
g_fxo->get<cpu_profiler>()->registered.push(0);
g_fxo->get<cpu_profiler>().registered.push(0);
}
}

View File

@ -561,12 +561,12 @@ namespace audio
void configure_audio()
{
if (const auto g_audio = g_fxo->get<cell_audio>())
if (auto& g_audio = g_fxo->get<cell_audio>(); g_fxo->is_init<cell_audio>())
{
// Only reboot the audio renderer if a relevant setting changed
const auto new_raw = get_raw_config();
if (const auto raw = g_audio->cfg.raw;
if (const auto raw = g_audio.cfg.raw;
raw.desired_buffer_duration != new_raw.desired_buffer_duration ||
raw.buffering_enabled != new_raw.buffering_enabled ||
raw.time_stretching_threshold != new_raw.time_stretching_threshold ||
@ -577,8 +577,8 @@ namespace audio
raw.downmix != new_raw.downmix ||
raw.renderer != new_raw.renderer)
{
g_audio->cfg.raw = new_raw;
g_audio->m_update_configuration = true;
g_audio.cfg.raw = new_raw;
g_audio.m_update_configuration = true;
}
}
}
@ -1100,11 +1100,11 @@ error_code cellAudioInit()
{
cellAudio.warning("cellAudioInit()");
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (g_audio->init)
if (g_audio.init)
{
return CELL_AUDIO_ERROR_ALREADY_INIT;
}
@ -1114,13 +1114,13 @@ error_code cellAudioInit()
for (u32 i = 0; i < AUDIO_PORT_COUNT; i++)
{
g_audio->ports[i].number = i;
g_audio->ports[i].addr = g_audio_buffer + AUDIO_PORT_OFFSET * i;
g_audio->ports[i].index = g_audio_indices + i;
g_audio->ports[i].state = audio_port_state::closed;
g_audio.ports[i].number = i;
g_audio.ports[i].addr = g_audio_buffer + AUDIO_PORT_OFFSET * i;
g_audio.ports[i].index = g_audio_indices + i;
g_audio.ports[i].state = audio_port_state::closed;
}
g_audio->init = 1;
g_audio.init = 1;
return CELL_OK;
}
@ -1129,20 +1129,20 @@ error_code cellAudioQuit(ppu_thread& ppu)
{
cellAudio.warning("cellAudioQuit()");
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
// TODO
g_audio->keys.clear();
g_audio->key_count = 0;
g_audio->event_period = 0;
g_audio->init = 0;
g_audio.keys.clear();
g_audio.key_count = 0;
g_audio.event_period = 0;
g_audio.init = 0;
return CELL_OK;
}
@ -1151,11 +1151,11 @@ error_code cellAudioPortOpen(vm::ptr<CellAudioPortParam> audioParam, vm::ptr<u32
{
cellAudio.warning("cellAudioPortOpen(audioParam=*0x%x, portNum=*0x%x)", audioParam, portNum);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1221,7 +1221,7 @@ error_code cellAudioPortOpen(vm::ptr<CellAudioPortParam> audioParam, vm::ptr<u32
}
// Open audio port
const auto port = g_audio->open_port();
const auto port = g_audio.open_port();
if (!port)
{
@ -1236,9 +1236,9 @@ error_code cellAudioPortOpen(vm::ptr<CellAudioPortParam> audioParam, vm::ptr<u32
port->attr = attr;
port->size = ::narrow<u32>(num_channels * num_blocks * port->block_size());
port->cur_pos = 0;
port->global_counter = g_audio->m_counter;
port->global_counter = g_audio.m_counter;
port->active_counter = 0;
port->timestamp = g_audio->m_last_period_end;
port->timestamp = g_audio.m_last_period_end;
if (attr & CELL_AUDIO_PORTATTR_INITLEVEL)
{
@ -1264,11 +1264,11 @@ error_code cellAudioGetPortConfig(u32 portNum, vm::ptr<CellAudioPortConfig> port
{
cellAudio.trace("cellAudioGetPortConfig(portNum=%d, portConfig=*0x%x)", portNum, portConfig);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1278,7 +1278,7 @@ error_code cellAudioGetPortConfig(u32 portNum, vm::ptr<CellAudioPortConfig> port
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
audio_port& port = g_audio.ports[portNum];
portConfig->readIndexAddr = port.index;
@ -1309,11 +1309,11 @@ error_code cellAudioPortStart(u32 portNum)
{
cellAudio.warning("cellAudioPortStart(portNum=%d)", portNum);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1323,7 +1323,7 @@ error_code cellAudioPortStart(u32 portNum)
return CELL_AUDIO_ERROR_PARAM;
}
switch (auto state = g_audio->ports[portNum].state.compare_and_swap(audio_port_state::opened, audio_port_state::started))
switch (auto state = g_audio.ports[portNum].state.compare_and_swap(audio_port_state::opened, audio_port_state::started))
{
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
case audio_port_state::started: return CELL_AUDIO_ERROR_PORT_ALREADY_RUN;
@ -1336,11 +1336,11 @@ error_code cellAudioPortClose(u32 portNum)
{
cellAudio.warning("cellAudioPortClose(portNum=%d)", portNum);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1350,7 +1350,7 @@ error_code cellAudioPortClose(u32 portNum)
return CELL_AUDIO_ERROR_PARAM;
}
switch (auto state = g_audio->ports[portNum].state.exchange(audio_port_state::closed))
switch (auto state = g_audio.ports[portNum].state.exchange(audio_port_state::closed))
{
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
case audio_port_state::started: return CELL_OK;
@ -1363,11 +1363,11 @@ error_code cellAudioPortStop(u32 portNum)
{
cellAudio.warning("cellAudioPortStop(portNum=%d)", portNum);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1377,7 +1377,7 @@ error_code cellAudioPortStop(u32 portNum)
return CELL_AUDIO_ERROR_PARAM;
}
switch (auto state = g_audio->ports[portNum].state.compare_and_swap(audio_port_state::started, audio_port_state::opened))
switch (auto state = g_audio.ports[portNum].state.compare_and_swap(audio_port_state::started, audio_port_state::opened))
{
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_RUN;
case audio_port_state::started: return CELL_OK;
@ -1390,11 +1390,11 @@ error_code cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr<u64> stamp)
{
cellAudio.trace("cellAudioGetPortTimestamp(portNum=%d, tag=0x%llx, stamp=*0x%x)", portNum, tag, stamp);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1404,7 +1404,7 @@ error_code cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr<u64> stamp)
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
audio_port& port = g_audio.ports[portNum];
if (port.state == audio_port_state::closed)
{
@ -1417,7 +1417,7 @@ error_code cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr<u64> stamp)
}
const u64 delta_tag = port.global_counter - tag;
const u64 delta_tag_stamp = delta_tag * g_audio->cfg.audio_block_period;
const u64 delta_tag_stamp = delta_tag * g_audio.cfg.audio_block_period;
// Apparently no error is returned if stamp is null
*stamp = port.timestamp - delta_tag_stamp;
@ -1429,11 +1429,11 @@ error_code cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, vm::ptr<u64> tag)
{
cellAudio.trace("cellAudioGetPortBlockTag(portNum=%d, blockNo=0x%llx, tag=*0x%x)", portNum, blockNo, tag);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1443,7 +1443,7 @@ error_code cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, vm::ptr<u64> tag)
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
audio_port& port = g_audio.ports[portNum];
if (port.state == audio_port_state::closed)
{
@ -1465,11 +1465,11 @@ error_code cellAudioSetPortLevel(u32 portNum, float level)
{
cellAudio.trace("cellAudioSetPortLevel(portNum=%d, level=%f)", portNum, level);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1479,7 +1479,7 @@ error_code cellAudioSetPortLevel(u32 portNum, float level)
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
audio_port& port = g_audio.ports[portNum];
if (port.state == audio_port_state::closed)
{
@ -1512,7 +1512,7 @@ static error_code AudioCreateNotifyEventQueue(ppu_thread& ppu, vm::ptr<u32> id,
// This originally reads from a global sdk value set by cellAudioInit
// So check initialization as well
const u32 queue_depth = g_fxo->get<cell_audio>()->init && g_ps3_process_info.sdk_ver <= 0x35FFFF ? 2 : 8;
const u32 queue_depth = g_fxo->get<cell_audio>().init && g_ps3_process_info.sdk_ver <= 0x35FFFF ? 2 : 8;
if (CellError res{sys_event_queue_create(ppu, id, attr, key_value, queue_depth) + 0u})
{
@ -1553,11 +1553,11 @@ error_code cellAudioCreateNotifyEventQueueEx(ppu_thread& ppu, vm::ptr<u32> id, v
error_code AudioSetNotifyEventQueue(u64 key, u32 iFlags)
{
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1569,7 +1569,7 @@ error_code AudioSetNotifyEventQueue(u64 key, u32 iFlags)
return CELL_AUDIO_ERROR_TRANS_EVENT;
}
for (auto i = g_audio->keys.cbegin(); i != g_audio->keys.cend();) // check for duplicates
for (auto i = g_audio.keys.cbegin(); i != g_audio.keys.cend();) // check for duplicates
{
auto port = i->port.lock();
@ -1581,7 +1581,7 @@ error_code AudioSetNotifyEventQueue(u64 key, u32 iFlags)
if (!lv2_event_queue::check(port))
{
// Cleanup, avoid cases where there are multiple ports with the same key
i = g_audio->keys.erase(i);
i = g_audio.keys.erase(i);
}
else
{
@ -1590,8 +1590,8 @@ error_code AudioSetNotifyEventQueue(u64 key, u32 iFlags)
}
// Set unique source associated with the key
g_audio->keys.push_back({g_audio->event_period, iFlags, ((process_getpid() + u64{}) << 32) + lv2_event_port::id_base + (g_audio->key_count++ * lv2_event_port::id_step), std::move(q)});
g_audio->key_count %= lv2_event_port::id_count;
g_audio.keys.push_back({g_audio.event_period, iFlags, ((process_getpid() + u64{}) << 32) + lv2_event_port::id_base + (g_audio.key_count++ * lv2_event_port::id_step), std::move(q)});
g_audio.key_count %= lv2_event_port::id_count;
return CELL_OK;
}
@ -1617,16 +1617,16 @@ error_code cellAudioSetNotifyEventQueueEx(u64 key, u32 iFlags)
error_code AudioRemoveNotifyEventQueue(u64 key, u32 iFlags)
{
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::lock_guard lock(g_audio->mutex);
std::lock_guard lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
for (auto i = g_audio->keys.cbegin(); i != g_audio->keys.cend(); i++)
for (auto i = g_audio.keys.cbegin(); i != g_audio.keys.cend(); i++)
{
if ([&](auto port){ return lv2_event_queue::check(port) && port->key == key; }(i->port.lock()))
{
@ -1635,7 +1635,7 @@ error_code AudioRemoveNotifyEventQueue(u64 key, u32 iFlags)
break;
}
g_audio->keys.erase(i);
g_audio.keys.erase(i);
return CELL_OK;
}
@ -1667,11 +1667,11 @@ error_code cellAudioAddData(u32 portNum, vm::ptr<float> src, u32 samples, float
{
cellAudio.trace("cellAudioAddData(portNum=%d, src=*0x%x, samples=%d, volume=%f)", portNum, src, samples, volume);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::unique_lock lock(g_audio->mutex);
std::unique_lock lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1681,7 +1681,7 @@ error_code cellAudioAddData(u32 portNum, vm::ptr<float> src, u32 samples, float
return CELL_AUDIO_ERROR_PARAM;
}
const audio_port& port = g_audio->ports[portNum];
const audio_port& port = g_audio.ports[portNum];
const auto dst = port.get_vm_ptr();
@ -1701,11 +1701,11 @@ error_code cellAudioAdd2chData(u32 portNum, vm::ptr<float> src, u32 samples, flo
{
cellAudio.trace("cellAudioAdd2chData(portNum=%d, src=*0x%x, samples=%d, volume=%f)", portNum, src, samples, volume);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::unique_lock lock(g_audio->mutex);
std::unique_lock lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1715,7 +1715,7 @@ error_code cellAudioAdd2chData(u32 portNum, vm::ptr<float> src, u32 samples, flo
return CELL_AUDIO_ERROR_PARAM;
}
const audio_port& port = g_audio->ports[portNum];
const audio_port& port = g_audio.ports[portNum];
const auto dst = port.get_vm_ptr();
@ -1769,11 +1769,11 @@ error_code cellAudioAdd6chData(u32 portNum, vm::ptr<float> src, float volume)
{
cellAudio.trace("cellAudioAdd6chData(portNum=%d, src=*0x%x, volume=%f)", portNum, src, volume);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::unique_lock lock(g_audio->mutex);
std::unique_lock lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1783,7 +1783,7 @@ error_code cellAudioAdd6chData(u32 portNum, vm::ptr<float> src, float volume)
return CELL_AUDIO_ERROR_PARAM;
}
const audio_port& port = g_audio->ports[portNum];
const audio_port& port = g_audio.ports[portNum];
const auto dst = port.get_vm_ptr();
@ -1829,11 +1829,11 @@ error_code cellAudioMiscSetAccessoryVolume(u32 devNum, float volume)
{
cellAudio.todo("cellAudioMiscSetAccessoryVolume(devNum=%d, volume=%f)", devNum, volume);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::unique_lock lock(g_audio->mutex);
std::unique_lock lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1853,11 +1853,11 @@ error_code cellAudioSetPersonalDevice(s32 iPersonalStream, s32 iDevice)
{
cellAudio.todo("cellAudioSetPersonalDevice(iPersonalStream=%d, iDevice=%d)", iPersonalStream, iDevice);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::unique_lock lock(g_audio->mutex);
std::unique_lock lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
@ -1877,11 +1877,11 @@ error_code cellAudioUnsetPersonalDevice(s32 iPersonalStream)
{
cellAudio.todo("cellAudioUnsetPersonalDevice(iPersonalStream=%d)", iPersonalStream);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
std::unique_lock lock(g_audio->mutex);
std::unique_lock lock(g_audio.mutex);
if (!g_audio->init)
if (!g_audio.init)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}

View File

@ -175,12 +175,12 @@ error_code cellAudioInGetDeviceInfo(u32 deviceNumber, u32 deviceIndex, vm::ptr<C
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER;
}
auto av_manager = g_fxo->get<avconf_manager>();
auto& av_manager = g_fxo->get<avconf_manager>();
if (deviceNumber >= av_manager->devices.size())
if (deviceNumber >= av_manager.devices.size())
return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND;
av_manager->copy_device_info(deviceNumber, info);
av_manager.copy_device_info(deviceNumber, info);
return CELL_OK;
}
@ -201,8 +201,9 @@ error_code cellVideoOutGetGamma(u32 videoOut, vm::ptr<f32> gamma)
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
auto conf = g_fxo->get<rsx::avconf>();
*gamma = conf->gamma;
auto& conf = g_fxo->get<rsx::avconf>();
*gamma = conf.gamma;
return CELL_OK;
}
@ -216,13 +217,13 @@ error_code cellAudioInGetAvailableDeviceInfo(u32 count, vm::ptr<CellAudioInDevic
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER;
}
auto av_manager = g_fxo->get<avconf_manager>();
auto& av_manager = g_fxo->get<avconf_manager>();
u32 num_devices_returned = std::min<u32>(count, ::size32(av_manager->devices));
u32 num_devices_returned = std::min<u32>(count, ::size32(av_manager.devices));
for (u32 index = 0; index < num_devices_returned; index++)
{
av_manager->copy_device_info(index, device_info + index);
av_manager.copy_device_info(index, device_info + index);
}
return not_an_error(num_devices_returned);
@ -248,8 +249,8 @@ error_code cellVideoOutSetGamma(u32 videoOut, f32 gamma)
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
auto conf = g_fxo->get<rsx::avconf>();
conf->gamma = gamma;
auto& conf = g_fxo->get<rsx::avconf>();
conf.gamma = gamma;
return CELL_OK;
}
@ -350,8 +351,8 @@ error_code cellVideoOutGetResolutionAvailability2()
return CELL_OK;
}
DECLARE(ppu_module_manager::cellAvconfExt)
("cellSysutilAvconfExt", []() {
DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []()
{
REG_FUNC(cellSysutilAvconfExt, cellAudioOutUnregisterDevice);
REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetDeviceInfo2);
REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetXVColor);

View File

@ -271,18 +271,18 @@ error_code cellCameraInit()
cellCamera.todo("cellCameraInit()");
// Start camera thread
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
if (g_camera->init)
if (g_camera.init)
{
return CELL_CAMERA_ERROR_ALREADY_INIT;
}
if (g_cfg.io.camera == camera_handler::null)
{
g_camera->init = 1;
g_camera.init = 1;
return CELL_OK;
}
@ -290,40 +290,40 @@ error_code cellCameraInit()
{
case fake_camera_type::eyetoy:
{
g_camera->attr[CELL_CAMERA_SATURATION] = { 164 };
g_camera->attr[CELL_CAMERA_BRIGHTNESS] = { 96 };
g_camera->attr[CELL_CAMERA_AEC] = { 1 };
g_camera->attr[CELL_CAMERA_AGC] = { 1 };
g_camera->attr[CELL_CAMERA_AWB] = { 1 };
g_camera->attr[CELL_CAMERA_ABC] = { 0 };
g_camera->attr[CELL_CAMERA_LED] = { 1 };
g_camera->attr[CELL_CAMERA_QS] = { 0 };
g_camera->attr[CELL_CAMERA_NONZEROCOEFFS] = { 32, 32 };
g_camera->attr[CELL_CAMERA_YUVFLAG] = { 0 };
g_camera->attr[CELL_CAMERA_BACKLIGHTCOMP] = { 0 };
g_camera->attr[CELL_CAMERA_MIRRORFLAG] = { 1 };
g_camera->attr[CELL_CAMERA_422FLAG] = { 1 };
g_camera->attr[CELL_CAMERA_USBLOAD] = { 4 };
g_camera.attr[CELL_CAMERA_SATURATION] = { 164 };
g_camera.attr[CELL_CAMERA_BRIGHTNESS] = { 96 };
g_camera.attr[CELL_CAMERA_AEC] = { 1 };
g_camera.attr[CELL_CAMERA_AGC] = { 1 };
g_camera.attr[CELL_CAMERA_AWB] = { 1 };
g_camera.attr[CELL_CAMERA_ABC] = { 0 };
g_camera.attr[CELL_CAMERA_LED] = { 1 };
g_camera.attr[CELL_CAMERA_QS] = { 0 };
g_camera.attr[CELL_CAMERA_NONZEROCOEFFS] = { 32, 32 };
g_camera.attr[CELL_CAMERA_YUVFLAG] = { 0 };
g_camera.attr[CELL_CAMERA_BACKLIGHTCOMP] = { 0 };
g_camera.attr[CELL_CAMERA_MIRRORFLAG] = { 1 };
g_camera.attr[CELL_CAMERA_422FLAG] = { 1 };
g_camera.attr[CELL_CAMERA_USBLOAD] = { 4 };
break;
}
case fake_camera_type::eyetoy2:
{
g_camera->attr[CELL_CAMERA_SATURATION] = { 64 };
g_camera->attr[CELL_CAMERA_BRIGHTNESS] = { 8 };
g_camera->attr[CELL_CAMERA_AEC] = { 1 };
g_camera->attr[CELL_CAMERA_AGC] = { 1 };
g_camera->attr[CELL_CAMERA_AWB] = { 1 };
g_camera->attr[CELL_CAMERA_LED] = { 1 };
g_camera->attr[CELL_CAMERA_BACKLIGHTCOMP] = { 0 };
g_camera->attr[CELL_CAMERA_MIRRORFLAG] = { 1 };
g_camera->attr[CELL_CAMERA_GAMMA] = { 1 };
g_camera->attr[CELL_CAMERA_AGCLIMIT] = { 4 };
g_camera->attr[CELL_CAMERA_DENOISE] = { 0 };
g_camera->attr[CELL_CAMERA_FRAMERATEADJUST] = { 0 };
g_camera->attr[CELL_CAMERA_PIXELOUTLIERFILTER] = { 1 };
g_camera->attr[CELL_CAMERA_AGCLOW] = { 48 };
g_camera->attr[CELL_CAMERA_AGCHIGH] = { 64 };
g_camera.attr[CELL_CAMERA_SATURATION] = { 64 };
g_camera.attr[CELL_CAMERA_BRIGHTNESS] = { 8 };
g_camera.attr[CELL_CAMERA_AEC] = { 1 };
g_camera.attr[CELL_CAMERA_AGC] = { 1 };
g_camera.attr[CELL_CAMERA_AWB] = { 1 };
g_camera.attr[CELL_CAMERA_LED] = { 1 };
g_camera.attr[CELL_CAMERA_BACKLIGHTCOMP] = { 0 };
g_camera.attr[CELL_CAMERA_MIRRORFLAG] = { 1 };
g_camera.attr[CELL_CAMERA_GAMMA] = { 1 };
g_camera.attr[CELL_CAMERA_AGCLIMIT] = { 4 };
g_camera.attr[CELL_CAMERA_DENOISE] = { 0 };
g_camera.attr[CELL_CAMERA_FRAMERATEADJUST] = { 0 };
g_camera.attr[CELL_CAMERA_PIXELOUTLIERFILTER] = { 1 };
g_camera.attr[CELL_CAMERA_AGCLOW] = { 48 };
g_camera.attr[CELL_CAMERA_AGCHIGH] = { 64 };
break;
}
default:
@ -334,10 +334,10 @@ error_code cellCameraInit()
if (g_cfg.io.camera == camera_handler::fake)
{
g_camera->is_attached = true;
g_camera.is_attached = true;
}
g_camera->init = 1;
g_camera.init = 1;
return CELL_OK;
}
@ -345,11 +345,11 @@ error_code cellCameraEnd()
{
cellCamera.todo("cellCameraEnd()");
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -361,8 +361,8 @@ error_code cellCameraEnd()
//}
// TODO
g_camera->init = 0;
g_camera->reset_state();
g_camera.init = 0;
g_camera.reset_state();
return CELL_OK;
}
@ -413,10 +413,10 @@ error_code cellCameraOpenEx(s32 dev_num, vm::ptr<CellCameraInfoEx> info)
return CELL_CAMERA_ERROR_PARAM;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
// we know g_camera is valid here (cellCameraSetAttribute above checks for it)
if (g_camera->is_open)
if (g_camera.is_open)
{
return CELL_CAMERA_ERROR_ALREADY_OPEN;
}
@ -430,7 +430,7 @@ error_code cellCameraOpenEx(s32 dev_num, vm::ptr<CellCameraInfoEx> info)
const auto vbuf_size = get_video_buffer_size(*info);
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
if (info->read_mode != CELL_CAMERA_READ_DIRECT && !info->buffer)
{
@ -440,8 +440,8 @@ error_code cellCameraOpenEx(s32 dev_num, vm::ptr<CellCameraInfoEx> info)
std::tie(info->width, info->height) = get_video_resolution(*info);
g_camera->is_open = true;
g_camera->info = *info;
g_camera.is_open = true;
g_camera.info = *info;
return CELL_OK;
}
@ -461,9 +461,9 @@ error_code cellCameraClose(s32 dev_num)
return CELL_CAMERA_ERROR_PARAM;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -473,15 +473,15 @@ error_code cellCameraClose(s32 dev_num)
return not_an_error(CELL_CAMERA_ERROR_NOT_OPEN);
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
if (!g_camera->is_open)
if (!g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
vm::dealloc(g_camera->info.buffer.addr(), vm::main);
g_camera->is_open = false;
vm::dealloc(g_camera.info.buffer.addr(), vm::main);
g_camera.is_open = false;
return CELL_OK;
}
@ -502,9 +502,9 @@ error_code cellCameraGetDeviceGUID(s32 dev_num, vm::ptr<u32> guid)
{
cellCamera.todo("cellCameraGetDeviceGUID(dev_num=%d, guid=*0x%x)", dev_num, guid);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -520,9 +520,9 @@ error_code cellCameraGetType(s32 dev_num, vm::ptr<s32> type)
{
cellCamera.todo("cellCameraGetType(dev_num=%d, type=*0x%x)", dev_num, type);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -537,7 +537,7 @@ error_code cellCameraGetType(s32 dev_num, vm::ptr<s32> type)
return CELL_CAMERA_ERROR_PARAM;
}
if (!g_camera->is_attached)
if (!g_camera.is_attached)
{
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
}
@ -562,9 +562,9 @@ s32 cellCameraIsAvailable(s32 dev_num)
return false;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return false;
}
@ -586,9 +586,9 @@ s32 cellCameraIsAttached(s32 dev_num)
return false;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return false;
}
@ -598,9 +598,9 @@ s32 cellCameraIsAttached(s32 dev_num)
return false;
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
bool is_attached = g_camera->is_attached;
bool is_attached = g_camera.is_attached;
if (g_cfg.io.camera == camera_handler::fake)
{
@ -608,8 +608,8 @@ s32 cellCameraIsAttached(s32 dev_num)
// normally should be attached immediately after event queue is registered, but just to be sure
if (!is_attached)
{
g_camera->send_attach_state(true);
is_attached = g_camera->is_attached;
g_camera.send_attach_state(true);
is_attached = g_camera.is_attached;
}
}
@ -625,9 +625,9 @@ s32 cellCameraIsOpen(s32 dev_num)
return false;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return false;
}
@ -637,9 +637,9 @@ s32 cellCameraIsOpen(s32 dev_num)
return false;
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
return g_camera->is_open.load();
return g_camera.is_open.load();
}
s32 cellCameraIsStarted(s32 dev_num)
@ -651,9 +651,9 @@ s32 cellCameraIsStarted(s32 dev_num)
return false;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return false;
}
@ -663,9 +663,9 @@ s32 cellCameraIsStarted(s32 dev_num)
return false;
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
return g_camera->is_streaming.load();
return g_camera.is_streaming.load();
}
error_code cellCameraGetAttribute(s32 dev_num, s32 attrib, vm::ptr<u32> arg1, vm::ptr<u32> arg2)
@ -673,9 +673,9 @@ error_code cellCameraGetAttribute(s32 dev_num, s32 attrib, vm::ptr<u32> arg1, vm
const auto attr_name = get_camera_attr_name(attrib);
cellCamera.todo("cellCameraGetAttribute(dev_num=%d, attrib=%d=%s, arg1=*0x%x, arg2=*0x%x)", dev_num, attrib, attr_name, arg1, arg2);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -691,25 +691,25 @@ error_code cellCameraGetAttribute(s32 dev_num, s32 attrib, vm::ptr<u32> arg1, vm
}
// actually compares <= 0x63 which is equivalent
if (attrib < CELL_CAMERA_FORMATCAP && !g_camera->is_open)
if (attrib < CELL_CAMERA_FORMATCAP && !g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
if (!g_camera->is_attached)
if (!g_camera.is_attached)
{
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
}
if (arg1)
{
*arg1 = g_camera->attr[attrib].v1;
*arg1 = g_camera.attr[attrib].v1;
}
if (arg2)
{
*arg2 = g_camera->attr[attrib].v2;
*arg2 = g_camera.attr[attrib].v2;
}
return CELL_OK;
@ -720,9 +720,9 @@ error_code cellCameraSetAttribute(s32 dev_num, s32 attrib, u32 arg1, u32 arg2)
const auto attr_name = get_camera_attr_name(attrib);
cellCamera.todo("cellCameraSetAttribute(dev_num=%d, attrib=%d=%s, arg1=%d, arg2=%d)", dev_num, attrib, attr_name, arg1, arg2);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -738,12 +738,12 @@ error_code cellCameraSetAttribute(s32 dev_num, s32 attrib, u32 arg1, u32 arg2)
}
// actually compares <= 0x63 which is equivalent
if (attrib < CELL_CAMERA_FORMATCAP && !g_camera->is_open)
if (attrib < CELL_CAMERA_FORMATCAP && !g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
g_camera->set_attr(attrib, arg1, arg2);
g_camera.set_attr(attrib, arg1, arg2);
return CELL_OK;
}
@ -758,9 +758,9 @@ error_code cellCameraGetBufferSize(s32 dev_num, vm::ptr<CellCameraInfoEx> info)
{
cellCamera.todo("cellCameraGetBufferSize(dev_num=%d, info=*0x%x)", dev_num, info);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -777,7 +777,7 @@ error_code cellCameraGetBufferSize(s32 dev_num, vm::ptr<CellCameraInfoEx> info)
return CELL_CAMERA_ERROR_PARAM;
}
if (g_camera->is_open)
if (g_camera.is_open)
{
return CELL_CAMERA_ERROR_ALREADY_OPEN;
}
@ -802,10 +802,10 @@ error_code cellCameraGetBufferSize(s32 dev_num, vm::ptr<CellCameraInfoEx> info)
return status;
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
info->bytesize = get_video_buffer_size(g_camera->info);
g_camera->info = *info;
info->bytesize = get_video_buffer_size(g_camera.info);
g_camera.info = *info;
return info->bytesize;
}
@ -825,9 +825,9 @@ error_code cellCameraGetBufferInfoEx(s32 dev_num, vm::ptr<CellCameraInfoEx> info
// the following should be moved to cellCameraGetBufferInfo
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -842,7 +842,7 @@ error_code cellCameraGetBufferInfoEx(s32 dev_num, vm::ptr<CellCameraInfoEx> info
return CELL_CAMERA_ERROR_PARAM;
}
if (!g_camera->is_open)
if (!g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
@ -852,8 +852,8 @@ error_code cellCameraGetBufferInfoEx(s32 dev_num, vm::ptr<CellCameraInfoEx> info
return CELL_CAMERA_ERROR_PARAM;
}
std::lock_guard lock(g_camera->mutex);
*info = g_camera->info;
std::lock_guard lock(g_camera.mutex);
*info = g_camera.info;
return CELL_OK;
}
@ -899,9 +899,9 @@ error_code cellCameraReset(s32 dev_num)
return CELL_CAMERA_ERROR_PARAM;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -911,12 +911,12 @@ error_code cellCameraReset(s32 dev_num)
return not_an_error(CELL_CAMERA_ERROR_NOT_OPEN);
}
if (!g_camera->is_open)
if (!g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
if (!g_camera->is_attached)
if (!g_camera.is_attached)
{
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
}
@ -947,9 +947,9 @@ error_code cellCameraStart(s32 dev_num)
return CELL_CAMERA_ERROR_PARAM;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -959,20 +959,20 @@ error_code cellCameraStart(s32 dev_num)
return not_an_error(CELL_CAMERA_ERROR_NOT_OPEN);
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
if (!g_camera->is_open)
if (!g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
if (!g_camera->is_attached)
if (!g_camera.is_attached)
{
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
}
g_camera->timer.Start();
g_camera->is_streaming = true;
g_camera.timer.Start();
g_camera.is_streaming = true;
return CELL_OK;
}
@ -1023,9 +1023,9 @@ error_code cellCameraReadEx(s32 dev_num, vm::ptr<CellCameraReadEx> read)
{
cellCamera.todo("cellCameraReadEx(dev_num=%d, read=0x%x)", dev_num, read);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -1040,19 +1040,19 @@ error_code cellCameraReadEx(s32 dev_num, vm::ptr<CellCameraReadEx> read)
return CELL_CAMERA_ERROR_PARAM;
}
std::lock_guard lock(g_camera->mutex);
std::lock_guard lock(g_camera.mutex);
if (!g_camera->is_open)
if (!g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
if (!g_camera->is_attached)
if (!g_camera.is_attached)
{
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
}
if (!g_camera->is_streaming)
if (!g_camera.is_streaming)
{
return CELL_CAMERA_ERROR_NOT_STARTED;
}
@ -1061,13 +1061,13 @@ error_code cellCameraReadEx(s32 dev_num, vm::ptr<CellCameraReadEx> read)
if (read) // NULL returns CELL_OK
{
read->timestamp = g_camera->timer.GetElapsedTimeInMicroSec();
read->frame = g_camera->frame_num;
read->bytesread = g_camera->is_streaming ? get_video_buffer_size(g_camera->info) : 0;
read->timestamp = g_camera.timer.GetElapsedTimeInMicroSec();
read->frame = g_camera.frame_num;
read->bytesread = g_camera.is_streaming ? get_video_buffer_size(g_camera.info) : 0;
auto shared_data = g_fxo->get<gem_camera_shared>();
auto& shared_data = g_fxo->get<gem_camera_shared>();
shared_data->frame_timestamp.exchange(read->timestamp);
shared_data.frame_timestamp.exchange(read->timestamp);
}
return CELL_OK;
@ -1089,9 +1089,9 @@ error_code cellCameraStop(s32 dev_num)
return CELL_CAMERA_ERROR_PARAM;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -1101,25 +1101,25 @@ error_code cellCameraStop(s32 dev_num)
return not_an_error(CELL_CAMERA_ERROR_NOT_OPEN);
}
if (!g_camera->is_open)
if (!g_camera.is_open)
{
return CELL_CAMERA_ERROR_NOT_OPEN;
}
if (!g_camera->is_attached)
if (!g_camera.is_attached)
{
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
}
if (!g_camera->is_streaming)
if (!g_camera.is_streaming)
{
return CELL_CAMERA_ERROR_NOT_STARTED;
}
g_camera->is_streaming = false;
g_camera.is_streaming = false;
std::lock_guard lock(g_camera->mutex);
g_camera->timer.Stop();
std::lock_guard lock(g_camera.mutex);
g_camera.timer.Stop();
return CELL_OK;
}
@ -1140,9 +1140,9 @@ error_code cellCameraSetNotifyEventQueue(u64 key)
{
cellCamera.todo("cellCameraSetNotifyEventQueue(key=0x%x)", key);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -1152,7 +1152,7 @@ error_code cellCameraSetNotifyEventQueue(u64 key)
return CELL_OK;
}
g_camera->add_queue(key, 0, 0);
g_camera.add_queue(key, 0, 0);
return CELL_OK;
}
@ -1161,9 +1161,9 @@ error_code cellCameraRemoveNotifyEventQueue(u64 key)
{
cellCamera.todo("cellCameraRemoveNotifyEventQueue(key=0x%x)", key);
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
@ -1173,7 +1173,7 @@ error_code cellCameraRemoveNotifyEventQueue(u64 key)
return CELL_OK;
}
g_camera->remove_queue(key);
g_camera.remove_queue(key);
return CELL_OK;
}
@ -1187,14 +1187,14 @@ error_code cellCameraSetNotifyEventQueue2(u64 key, u64 source, u64 flag)
return CELL_OK;
}
const auto g_camera = g_fxo->get<camera_thread>();
auto& g_camera = g_fxo->get<camera_thread>();
if (!g_camera->init)
if (!g_camera.init)
{
return CELL_CAMERA_ERROR_NOT_INIT;
}
g_camera->add_queue(key, source, flag);
g_camera.add_queue(key, source, flag);
return CELL_OK;
}

View File

@ -967,16 +967,16 @@ s32 cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
// TODO: detect mount point and send AIO request to the AIO thread of this mount point
const auto m = g_fxo->get<fs_aio_manager>();
auto& m = g_fxo->get<fs_aio_manager>();
if (!m)
if (!m.thread)
{
return CELL_ENXIO;
}
const s32 xid = (*id = ++g_fs_aio_id);
m->thread->cmd_list
m.thread->cmd_list
({
{ 1, xid },
{ aio, func },
@ -991,16 +991,16 @@ s32 cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
// TODO: detect mount point and send AIO request to the AIO thread of this mount point
const auto m = g_fxo->get<fs_aio_manager>();
auto& m = g_fxo->get<fs_aio_manager>();
if (!m)
if (!m.thread)
{
return CELL_ENXIO;
}
const s32 xid = (*id = ++g_fs_aio_id);
m->thread->cmd_list
m.thread->cmd_list
({
{ 2, xid },
{ aio, func },

View File

@ -459,9 +459,9 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
return CELL_GAME_ERROR_PARAM;
}
const auto perm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto init = perm->init.init();
const auto init = perm.init.init();
if (!init)
{
@ -510,10 +510,10 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
strcpy_trunc(*dirName, Emu.GetTitleID());
}
perm->dir = std::move(dir);
perm->sfo = std::move(sfo);
perm->restrict_sfo_params = *type == u32{CELL_GAME_GAMETYPE_HDD}; // Ratchet & Clank: All 4 One (PSN versions) rely on this error checking (TODO: Needs proper hw tests)
perm->exists = true;
perm.dir = std::move(dir);
perm.sfo = std::move(sfo);
perm.restrict_sfo_params = *type == u32{CELL_GAME_GAMETYPE_HDD}; // Ratchet & Clank: All 4 One (PSN versions) rely on this error checking (TODO: Needs proper hw tests)
perm.exists = true;
return CELL_OK;
}
@ -529,9 +529,9 @@ error_code cellGamePatchCheck(vm::ptr<CellGameContentSize> size, vm::ptr<void> r
psf::registry sfo = psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")));
const auto perm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto init = perm->init.init();
const auto init = perm.init.init();
if (!init)
{
@ -548,10 +548,10 @@ error_code cellGamePatchCheck(vm::ptr<CellGameContentSize> size, vm::ptr<void> r
size->sysSizeKB = 0; // TODO
}
perm->restrict_sfo_params = false;
perm->dir = Emu.GetTitleID();
perm->sfo = std::move(sfo);
perm->exists = true;
perm.restrict_sfo_params = false;
perm.dir = Emu.GetTitleID();
perm.sfo = std::move(sfo);
perm.exists = true;
return CELL_OK;
}
@ -576,9 +576,9 @@ error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameC
// TODO: not sure what should be checked there
const auto perm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
auto init = perm->init.init();
auto init = perm.init.init();
if (!init)
{
@ -615,14 +615,14 @@ error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameC
size->sysSizeKB = 0; // TODO
}
perm->dir = std::move(name);
perm.dir = std::move(name);
if (type == CELL_GAME_GAMETYPE_GAMEDATA)
{
perm->can_create = true;
perm.can_create = true;
}
perm->restrict_sfo_params = false;
perm.restrict_sfo_params = false;
if (sfo.empty())
{
@ -630,8 +630,8 @@ error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameC
return not_an_error(CELL_GAME_RET_NONE);
}
perm->exists = true;
perm->sfo = std::move(sfo);
perm.exists = true;
perm.sfo = std::move(sfo);
return CELL_OK;
}
@ -644,55 +644,55 @@ error_code cellGameContentPermit(vm::ptr<char[CELL_GAME_PATH_MAX]> contentInfoPa
return CELL_GAME_ERROR_PARAM;
}
const auto perm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto init = perm->init.reset();
const auto init = perm.init.reset();
if (!init)
{
return CELL_GAME_ERROR_FAILURE;
}
const std::string dir = perm->dir.empty() ? "/dev_bdvd/PS3_GAME"s : "/dev_hdd0/game/" + perm->dir;
const std::string dir = perm.dir.empty() ? "/dev_bdvd/PS3_GAME"s : "/dev_hdd0/game/" + perm.dir;
if (perm->temp.empty() && !perm->exists)
if (perm.temp.empty() && !perm.exists)
{
perm->reset();
perm.reset();
strcpy_trunc(*contentInfoPath, "");
strcpy_trunc(*usrdirPath, "");
return CELL_OK;
}
if (!perm->temp.empty())
if (!perm.temp.empty())
{
// Create PARAM.SFO
fs::pending_file temp(perm->temp + "/PARAM.SFO");
temp.file.write(psf::save_object(perm->sfo));
fs::pending_file temp(perm.temp + "/PARAM.SFO");
temp.file.write(psf::save_object(perm.sfo));
ensure(temp.commit());
// Make temporary directory persistent (atomically)
if (vfs::host::rename(perm->temp, vfs::get(dir), &g_mp_sys_dev_hdd0, false))
if (vfs::host::rename(perm.temp, vfs::get(dir), &g_mp_sys_dev_hdd0, false))
{
cellGame.success("cellGameContentPermit(): directory '%s' has been created", dir);
// Prevent cleanup
perm->temp.clear();
perm.temp.clear();
}
else
{
cellGame.error("cellGameContentPermit(): failed to initialize directory '%s' (%s)", dir, fs::g_tls_error);
}
}
else if (perm->can_create)
else if (perm.can_create)
{
// Update PARAM.SFO
fs::pending_file temp(vfs::get(dir + "/PARAM.SFO"));
temp.file.write(psf::save_object(perm->sfo));
temp.file.write(psf::save_object(perm.sfo));
ensure(temp.commit());
}
// Cleanup
perm->reset();
perm.reset();
strcpy_trunc(*contentInfoPath, dir);
strcpy_trunc(*usrdirPath, dir + "/USRDIR");
@ -883,21 +883,21 @@ error_code cellGameCreateGameData(vm::ptr<CellGameSetInitParams> init, vm::ptr<c
return CELL_GAME_ERROR_PARAM;
}
const auto prm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto _init = prm->init.access();
const auto _init = perm.init.access();
if (!_init || prm->dir.empty())
if (!_init || perm.dir.empty())
{
return CELL_GAME_ERROR_FAILURE;
}
if (!prm->can_create)
if (!perm.can_create)
{
return CELL_GAME_ERROR_NOTSUPPORTED;
}
if (prm->exists)
if (perm.exists)
{
return CELL_GAME_ERROR_EXIST;
}
@ -923,11 +923,11 @@ error_code cellGameCreateGameData(vm::ptr<CellGameSetInitParams> init, vm::ptr<c
if (tmp_usrdirPath) strcpy_trunc(*tmp_usrdirPath, tmp_usrdir);
prm->temp = vfs::get(tmp_contentInfo);
perm.temp = vfs::get(tmp_contentInfo);
cellGame.success("cellGameCreateGameData(): temporary directory '%s' has been created", tmp_contentInfo);
// Initial PARAM.SFO parameters (overwrite)
prm->sfo =
perm.sfo =
{
{ "CATEGORY", psf::string(3, "GD") },
{ "TITLE_ID", psf::string(CELL_GAME_SYSP_TITLEID_SIZE, init->titleId) },
@ -950,7 +950,7 @@ error_code cellGameDeleteGameData(vm::cptr<char> dirName)
const std::string name = dirName.get_ptr();
const std::string dir = vfs::get("/dev_hdd0/game/"s + name);
const auto prm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
auto remove_gd = [&]() -> error_code
{
@ -990,16 +990,16 @@ error_code cellGameDeleteGameData(vm::cptr<char> dirName)
while (true)
{
// Obtain exclusive lock and cancel init
auto _init = prm->init.init();
auto _init = perm.init.init();
if (!_init)
{
// Or access it
if (auto access = prm->init.access(); access)
if (auto access = perm.init.access(); access)
{
// Cannot remove it when it is accessed by cellGameDataCheck
// If it is HG data then resort to remove_gd for ERROR_BROKEN
if (prm->dir == name && prm->can_create)
if (perm.dir == name && perm.can_create)
{
return CELL_GAME_ERROR_NOTSUPPORTED;
}
@ -1028,9 +1028,9 @@ error_code cellGameGetParamInt(s32 id, vm::ptr<s32> value)
return CELL_GAME_ERROR_PARAM;
}
const auto prm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto init = prm->init.access();
const auto init = perm.init.access();
if (!init)
{
@ -1050,13 +1050,13 @@ error_code cellGameGetParamInt(s32 id, vm::ptr<s32> value)
}
}
if (!prm->sfo.count(key))
if (!perm.sfo.count(key))
{
// TODO: Check if special values need to be set here
cellGame.warning("cellGameGetParamInt(): id=%d was not found", id);
}
*value = psf::get_integer(prm->sfo, key, 0);
*value = psf::get_integer(perm.sfo, key, 0);
return CELL_OK;
}
@ -1122,9 +1122,9 @@ error_code cellGameGetParamString(s32 id, vm::ptr<char> buf, u32 bufsize)
return CELL_GAME_ERROR_PARAM;
}
const auto prm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto init = prm->init.access();
const auto init = perm.init.access();
if (!init)
{
@ -1138,14 +1138,14 @@ error_code cellGameGetParamString(s32 id, vm::ptr<char> buf, u32 bufsize)
return CELL_GAME_ERROR_INVALID_ID;
}
if (key.flags & strkey_flag::get && prm->restrict_sfo_params)
if (key.flags & strkey_flag::get && perm.restrict_sfo_params)
{
return CELL_GAME_ERROR_NOTSUPPORTED;
}
const auto value = psf::get_string(prm->sfo, std::string(key.name));
const auto value = psf::get_string(perm.sfo, std::string(key.name));
if (value.empty() && !prm->sfo.count(std::string(key.name)))
if (value.empty() && !perm.sfo.count(std::string(key.name)))
{
// TODO: Check if special values need to be set here
cellGame.warning("cellGameGetParamString(): id=%d was not found", id);
@ -1165,9 +1165,9 @@ error_code cellGameSetParamString(s32 id, vm::cptr<char> buf)
return CELL_GAME_ERROR_PARAM;
}
const auto prm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto init = prm->init.access();
const auto init = perm.init.access();
if (!init)
{
@ -1181,12 +1181,12 @@ error_code cellGameSetParamString(s32 id, vm::cptr<char> buf)
return CELL_GAME_ERROR_INVALID_ID;
}
if (!prm->can_create || key.flags & strkey_flag::read_only || (key.flags & strkey_flag::set && prm->restrict_sfo_params))
if (!perm.can_create || key.flags & strkey_flag::read_only || (key.flags & strkey_flag::set && perm.restrict_sfo_params))
{
return CELL_GAME_ERROR_NOTSUPPORTED;
}
psf::assign(prm->sfo, std::string(key.name), psf::string(key.max_size, buf.get_ptr()));
psf::assign(perm.sfo, std::string(key.name), psf::string(key.max_size, buf.get_ptr()));
return CELL_OK;
}
@ -1203,16 +1203,16 @@ error_code cellGameGetSizeKB(vm::ptr<s32> size)
// Always reset to 0 at start
*size = 0;
const auto prm = g_fxo->get<content_permission>();
auto& perm = g_fxo->get<content_permission>();
const auto init = prm->init.access();
const auto init = perm.init.access();
if (!init)
{
return CELL_GAME_ERROR_FAILURE;
}
const std::string local_dir = !prm->temp.empty() ? prm->temp : vfs::get("/dev_hdd0/game/" + prm->dir);
const std::string local_dir = !perm.temp.empty() ? perm.temp : vfs::get("/dev_hdd0/game/" + perm.dir);
const auto dirsz = fs::get_dir_size(local_dir, 1024);

View File

@ -100,7 +100,7 @@ error_code gcmMapEaIoAddress(ppu_thread& ppu, u32 ea, u32 io, u32 size, bool is_
u32 gcmIoOffsetToAddress(u32 ioOffset)
{
const u32 upper12Bits = g_fxo->get<gcm_config>()->offsetTable.eaAddress[ioOffset >> 20];
const u32 upper12Bits = g_fxo->get<gcm_config>().offsetTable.eaAddress[ioOffset >> 20];
if (upper12Bits > 0xBFF)
{
@ -112,12 +112,12 @@ u32 gcmIoOffsetToAddress(u32 ioOffset)
void InitOffsetTable()
{
const auto cfg = g_fxo->get<gcm_config>();
auto& cfg = g_fxo->get<gcm_config>();
const u32 addr = vm::alloc((3072 + 512) * sizeof(u16), vm::main);
cfg->offsetTable.ioAddress.set(addr);
cfg->offsetTable.eaAddress.set(addr + (3072 * sizeof(u16)));
cfg.offsetTable.ioAddress.set(addr);
cfg.offsetTable.eaAddress.set(addr + (3072 * sizeof(u16)));
std::memset(vm::base(addr), 0xFF, (3072 + 512) * sizeof(u16));
}
@ -129,7 +129,7 @@ void InitOffsetTable()
u32 cellGcmGetLabelAddress(u8 index)
{
cellGcmSys.trace("cellGcmGetLabelAddress(index=%d)", index);
return g_fxo->get<gcm_config>()->gcm_info.label_addr + 0x10 * index;
return g_fxo->get<gcm_config>().gcm_info.label_addr + 0x10 * index;
}
vm::ptr<CellGcmReportData> cellGcmGetReportDataAddressLocation(u32 index, u32 location)
@ -153,7 +153,7 @@ vm::ptr<CellGcmReportData> cellGcmGetReportDataAddressLocation(u32 index, u32 lo
cellGcmSys.error("cellGcmGetReportDataAddressLocation: Wrong local index (%d)", index);
}
return vm::cast(g_fxo->get<gcm_config>()->gcm_info.label_addr + ::offset32(&RsxReports::report) + index * 0x10);
return vm::cast(g_fxo->get<gcm_config>().gcm_info.label_addr + ::offset32(&RsxReports::report) + index * 0x10);
}
u64 cellGcmGetTimeStamp(u32 index)
@ -165,7 +165,7 @@ u64 cellGcmGetTimeStamp(u32 index)
cellGcmSys.error("cellGcmGetTimeStamp: Wrong local index (%d)", index);
}
return vm::read64(g_fxo->get<gcm_config>()->gcm_info.label_addr + ::offset32(&RsxReports::report) + index * 0x10);
return vm::read64(g_fxo->get<gcm_config>().gcm_info.label_addr + ::offset32(&RsxReports::report) + index * 0x10);
}
u32 cellGcmGetCurrentField()
@ -179,7 +179,7 @@ u32 cellGcmGetNotifyDataAddress(u32 index)
cellGcmSys.warning("cellGcmGetNotifyDataAddress(index=%d)", index);
// If entry not in use, return NULL
u16 entry = g_fxo->get<gcm_config>()->offsetTable.eaAddress[241];
u16 entry = g_fxo->get<gcm_config>().offsetTable.eaAddress[241];
if (entry == 0xFFFF) {
return 0;
}
@ -192,7 +192,7 @@ u32 cellGcmGetNotifyDataAddress(u32 index)
*/
vm::ptr<CellGcmReportData> _cellGcmFunc12()
{
return vm::ptr<CellGcmReportData>::make(g_fxo->get<gcm_config>()->gcm_info.label_addr + ::offset32(&RsxReports::report)); // TODO
return vm::ptr<CellGcmReportData>::make(g_fxo->get<gcm_config>().gcm_info.label_addr + ::offset32(&RsxReports::report)); // TODO
}
u32 cellGcmGetReport(u32 type, u32 index)
@ -221,7 +221,7 @@ u32 cellGcmGetReportDataAddress(u32 index)
cellGcmSys.error("cellGcmGetReportDataAddress: Wrong local index (%d)", index);
}
return g_fxo->get<gcm_config>()->gcm_info.label_addr + ::offset32(&RsxReports::report) + index * 0x10;
return g_fxo->get<gcm_config>().gcm_info.label_addr + ::offset32(&RsxReports::report) + index * 0x10;
}
u32 cellGcmGetReportDataLocation(u32 index, u32 location)
@ -247,19 +247,19 @@ u64 cellGcmGetTimeStampLocation(u32 index, u32 location)
u32 cellGcmGetControlRegister()
{
cellGcmSys.trace("cellGcmGetControlRegister()");
return g_fxo->get<gcm_config>()->gcm_info.control_addr;
return g_fxo->get<gcm_config>().gcm_info.control_addr;
}
u32 cellGcmGetDefaultCommandWordSize()
{
cellGcmSys.trace("cellGcmGetDefaultCommandWordSize()");
return g_fxo->get<gcm_config>()->gcm_info.command_size;
return g_fxo->get<gcm_config>().gcm_info.command_size;
}
u32 cellGcmGetDefaultSegmentWordSize()
{
cellGcmSys.trace("cellGcmGetDefaultSegmentWordSize()");
return g_fxo->get<gcm_config>()->gcm_info.segment_size;
return g_fxo->get<gcm_config>().gcm_info.segment_size;
}
error_code cellGcmInitDefaultFifoMode(s32 mode)
@ -310,7 +310,7 @@ error_code cellGcmBindZcull(u8 index, u32 offset, u32 width, u32 height, u32 cul
void cellGcmGetConfiguration(vm::ptr<CellGcmConfig> config)
{
cellGcmSys.trace("cellGcmGetConfiguration(config=*0x%x)", config);
*config = g_fxo->get<gcm_config>()->current_config;
*config = g_fxo->get<gcm_config>().current_config;
}
u32 cellGcmGetFlipStatus()
@ -359,27 +359,27 @@ error_code _cellGcmInitBody(ppu_thread& ppu, vm::pptr<CellGcmContextData> contex
{
cellGcmSys.warning("_cellGcmInitBody(context=**0x%x, cmdSize=0x%x, ioSize=0x%x, ioAddress=0x%x)", context, cmdSize, ioSize, ioAddress);
const auto gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
gcm_cfg->current_config.ioAddress = 0;
gcm_cfg->current_config.localAddress = 0;
gcm_cfg->local_size = 0;
gcm_cfg->local_addr = 0;
gcm_cfg.current_config.ioAddress = 0;
gcm_cfg.current_config.localAddress = 0;
gcm_cfg.local_size = 0;
gcm_cfg.local_addr = 0;
//if (!gcm_cfg->local_size && !gcm_cfg->local_addr)
//if (!gcm_cfg.local_size && !gcm_cfg.local_addr)
{
gcm_cfg->local_size = 0xf900000; // TODO: Get sdk_version in _cellGcmFunc15 and pass it to gcmGetLocalMemorySize
gcm_cfg->local_addr = rsx::constants::local_mem_base;
vm::falloc(gcm_cfg->local_addr, gcm_cfg->local_size, vm::video);
gcm_cfg.local_size = 0xf900000; // TODO: Get sdk_version in _cellGcmFunc15 and pass it to gcmGetLocalMemorySize
gcm_cfg.local_addr = rsx::constants::local_mem_base;
vm::falloc(gcm_cfg.local_addr, gcm_cfg.local_size, vm::video);
}
cellGcmSys.warning("*** local memory(addr=0x%x, size=0x%x)", gcm_cfg->local_addr, gcm_cfg->local_size);
cellGcmSys.warning("*** local memory(addr=0x%x, size=0x%x)", gcm_cfg.local_addr, gcm_cfg.local_size);
InitOffsetTable();
const auto render = rsx::get_current_renderer();
if (gcm_cfg->system_mode == CELL_GCM_SYSTEM_MODE_IOMAP_512MB)
if (gcm_cfg.system_mode == CELL_GCM_SYSTEM_MODE_IOMAP_512MB)
{
cellGcmSys.warning("cellGcmInit(): 512MB io address space used");
render->main_mem_size = 0x20000000;
@ -395,12 +395,12 @@ error_code _cellGcmInitBody(ppu_thread& ppu, vm::pptr<CellGcmContextData> contex
return CELL_GCM_ERROR_FAILURE;
}
gcm_cfg->current_config.ioSize = ioSize;
gcm_cfg->current_config.ioAddress = ioAddress;
gcm_cfg->current_config.localSize = gcm_cfg->local_size;
gcm_cfg->current_config.localAddress = gcm_cfg->local_addr;
gcm_cfg->current_config.memoryFrequency = 650000000;
gcm_cfg->current_config.coreFrequency = 500000000;
gcm_cfg.current_config.ioSize = ioSize;
gcm_cfg.current_config.ioAddress = ioAddress;
gcm_cfg.current_config.localSize = gcm_cfg.local_size;
gcm_cfg.current_config.localAddress = gcm_cfg.local_addr;
gcm_cfg.current_config.memoryFrequency = 650000000;
gcm_cfg.current_config.coreFrequency = 500000000;
// Create contexts
const auto area = vm::reserve_map(vm::rsx_context, 0, 0x10000000, 0x403);
@ -410,26 +410,26 @@ error_code _cellGcmInitBody(ppu_thread& ppu, vm::pptr<CellGcmContextData> contex
g_defaultCommandBufferBegin = ioAddress;
g_defaultCommandBufferFragmentCount = cmdSize / (32 * 1024);
gcm_cfg->gcm_info.context_addr = rsx_ctxaddr;
gcm_cfg->gcm_info.control_addr = rsx_ctxaddr + 0x100000;
gcm_cfg->gcm_info.label_addr = rsx_ctxaddr + 0x300000;
gcm_cfg.gcm_info.context_addr = rsx_ctxaddr;
gcm_cfg.gcm_info.control_addr = rsx_ctxaddr + 0x100000;
gcm_cfg.gcm_info.label_addr = rsx_ctxaddr + 0x300000;
gcm_cfg->current_context.begin.set(g_defaultCommandBufferBegin + 4096); // 4 kb reserved at the beginning
gcm_cfg->current_context.end.set(g_defaultCommandBufferBegin + 32 * 1024 - 4); // 4b at the end for jump
gcm_cfg->current_context.current = gcm_cfg->current_context.begin;
gcm_cfg->current_context.callback.set(ppu_function_manager::func_addr(FIND_FUNC(cellGcmCallback)));
gcm_cfg.current_context.begin.set(g_defaultCommandBufferBegin + 4096); // 4 kb reserved at the beginning
gcm_cfg.current_context.end.set(g_defaultCommandBufferBegin + 32 * 1024 - 4); // 4b at the end for jump
gcm_cfg.current_context.current = gcm_cfg.current_context.begin;
gcm_cfg.current_context.callback.set(ppu_function_manager::func_addr(FIND_FUNC(cellGcmCallback)));
gcm_cfg->ctxt_addr = context.addr();
gcm_cfg->gcm_buffers.set(vm::alloc(sizeof(CellGcmDisplayInfo) * 8, vm::main));
gcm_cfg->zculls_addr = vm::alloc(sizeof(CellGcmZcullInfo) * 8, vm::main);
gcm_cfg->tiles_addr = vm::alloc(sizeof(CellGcmTileInfo) * 15, vm::main);
gcm_cfg.ctxt_addr = context.addr();
gcm_cfg.gcm_buffers.set(vm::alloc(sizeof(CellGcmDisplayInfo) * 8, vm::main));
gcm_cfg.zculls_addr = vm::alloc(sizeof(CellGcmZcullInfo) * 8, vm::main);
gcm_cfg.tiles_addr = vm::alloc(sizeof(CellGcmTileInfo) * 15, vm::main);
vm::_ref<CellGcmContextData>(gcm_cfg->gcm_info.context_addr) = gcm_cfg->current_context;
context->set(gcm_cfg->gcm_info.context_addr);
vm::_ref<CellGcmContextData>(gcm_cfg.gcm_info.context_addr) = gcm_cfg.current_context;
context->set(gcm_cfg.gcm_info.context_addr);
// 0x40 is to offset CellGcmControl from RsxDmaControl
gcm_cfg->gcm_info.control_addr += 0x40;
auto& ctrl = vm::_ref<CellGcmControl>(gcm_cfg->gcm_info.control_addr);
gcm_cfg.gcm_info.control_addr += 0x40;
auto& ctrl = vm::_ref<CellGcmControl>(gcm_cfg.gcm_info.control_addr);
ctrl.put = 0;
ctrl.get = 0;
ctrl.ref = 0; // Set later to -1 at RSX initialization
@ -440,10 +440,10 @@ error_code _cellGcmInitBody(ppu_thread& ppu, vm::pptr<CellGcmContextData> contex
render->intr_thread = idm::get<named_thread<ppu_thread>>(static_cast<u32>(*_tid));
render->intr_thread->state -= cpu_flag::stop;
render->isHLE = true;
render->label_addr = gcm_cfg->gcm_info.label_addr;
render->device_addr = gcm_cfg->gcm_info.context_addr;
render->local_mem_size = gcm_cfg->local_size;
render->init(gcm_cfg->gcm_info.control_addr - 0x40);
render->label_addr = gcm_cfg.gcm_info.label_addr;
render->device_addr = gcm_cfg.gcm_info.context_addr;
render->local_mem_size = gcm_cfg.local_size;
render->init(gcm_cfg.gcm_info.control_addr - 0x40);
return CELL_OK;
}
@ -482,7 +482,7 @@ error_code cellGcmSetDisplayBuffer(u8 id, u32 offset, u32 pitch, u32 width, u32
{
cellGcmSys.trace("cellGcmSetDisplayBuffer(id=0x%x, offset=0x%x, pitch=%d, width=%d, height=%d)", id, offset, width ? pitch / width : pitch, width, height);
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
if (id > 7)
{
@ -498,10 +498,10 @@ error_code cellGcmSetDisplayBuffer(u8 id, u32 offset, u32 pitch, u32 width, u32
buffers[id].width = width;
buffers[id].height = height;
gcm_cfg->gcm_buffers[id].offset = offset;
gcm_cfg->gcm_buffers[id].pitch = pitch;
gcm_cfg->gcm_buffers[id].width = width;
gcm_cfg->gcm_buffers[id].height = height;
gcm_cfg.gcm_buffers[id].offset = offset;
gcm_cfg.gcm_buffers[id].pitch = pitch;
gcm_cfg.gcm_buffers[id].width = width;
gcm_cfg.gcm_buffers[id].height = height;
if (id + 1u > render->display_buffers_count)
{
@ -553,7 +553,7 @@ error_code cellGcmSetFlipStatus2()
template <bool old_api = false, typename ret_type = std::conditional_t<old_api, s32, error_code>>
ret_type gcmSetPrepareFlip(ppu_thread& ppu, vm::ptr<CellGcmContextData> ctxt, u32 id)
{
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
if (id > 7)
{
@ -571,9 +571,9 @@ ret_type gcmSetPrepareFlip(ppu_thread& ppu, vm::ptr<CellGcmContextData> ctxt, u3
const u32 cmd_size = rsx::make_command(ctxt->current, GCM_FLIP_COMMAND, { id });
if (!old_api && ctxt.addr() == gcm_cfg->gcm_info.context_addr)
if (!old_api && ctxt.addr() == gcm_cfg.gcm_info.context_addr)
{
vm::_ref<CellGcmControl>(gcm_cfg->gcm_info.control_addr).put += cmd_size;
vm::_ref<CellGcmControl>(gcm_cfg.gcm_info.control_addr).put += cmd_size;
}
return static_cast<ret_type>(not_an_error(id));
@ -623,7 +623,7 @@ error_code cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 p
cellGcmSys.warning("cellGcmSetTileInfo(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)",
index, location, offset, size, pitch, comp, base, bank);
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
if (index >= rsx::limits::tiles_count || base >= 2048 || bank >= 4)
{
@ -656,7 +656,7 @@ error_code cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 p
tile.base = base;
tile.bank = bank;
vm::_ptr<CellGcmTileInfo>(gcm_cfg->tiles_addr)[index] = tile.pack();
vm::_ptr<CellGcmTileInfo>(gcm_cfg.tiles_addr)[index] = tile.pack();
return CELL_OK;
}
@ -698,7 +698,7 @@ void cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart,
cellGcmSys.todo("cellGcmSetZcull(index=%d, offset=0x%x, width=%d, height=%d, cullStart=0x%x, zFormat=0x%x, aaFormat=0x%x, zCullDir=0x%x, zCullFormat=0x%x, sFunc=0x%x, sRef=0x%x, sMask=0x%x)",
index, offset, width, height, cullStart, zFormat, aaFormat, zCullDir, zCullFormat, sFunc, sRef, sMask);
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
if (index >= rsx::limits::zculls_count)
{
@ -722,7 +722,7 @@ void cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart,
zcull.sMask = sMask;
zcull.bound = (zCullFormat > 0);
vm::_ptr<CellGcmZcullInfo>(gcm_cfg->zculls_addr)[index] = zcull.pack();
vm::_ptr<CellGcmZcullInfo>(gcm_cfg.zculls_addr)[index] = zcull.pack();
}
error_code cellGcmUnbindTile(u8 index)
@ -756,19 +756,19 @@ error_code cellGcmUnbindZcull(u8 index)
u32 cellGcmGetTileInfo()
{
cellGcmSys.warning("cellGcmGetTileInfo()");
return g_fxo->get<gcm_config>()->tiles_addr;
return g_fxo->get<gcm_config>().tiles_addr;
}
u32 cellGcmGetZcullInfo()
{
cellGcmSys.warning("cellGcmGetZcullInfo()");
return g_fxo->get<gcm_config>()->zculls_addr;
return g_fxo->get<gcm_config>().zculls_addr;
}
u32 cellGcmGetDisplayInfo()
{
cellGcmSys.warning("cellGcmGetDisplayInfo()");
return g_fxo->get<gcm_config>()->gcm_buffers.addr();
return g_fxo->get<gcm_config>().gcm_buffers.addr();
}
error_code cellGcmGetCurrentDisplayBufferId(vm::ptr<u8> id)
@ -848,7 +848,7 @@ error_code cellGcmInitSystemMode(u64 mode)
{
cellGcmSys.trace("cellGcmInitSystemMode(mode=0x%x)", mode);
g_fxo->get<gcm_config>()->system_mode = mode;
g_fxo->get<gcm_config>().system_mode = mode;
return CELL_OK;
}
@ -907,19 +907,19 @@ error_code cellGcmAddressToOffset(u32 address, vm::ptr<u32> offset)
{
cellGcmSys.trace("cellGcmAddressToOffset(address=0x%x, offset=*0x%x)", address, offset);
const auto cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
u32 result;
// Test if address is within local memory
if (const u32 offs = address - cfg->local_addr; offs < cfg->local_size)
if (const u32 offs = address - gcm_cfg.local_addr; offs < gcm_cfg.local_size)
{
result = offs;
}
// Address in main memory else check
else
{
const u32 upper12Bits = cfg->offsetTable.ioAddress[address >> 20];
const u32 upper12Bits = gcm_cfg.offsetTable.ioAddress[address >> 20];
// If the address is mapped in IO
if (upper12Bits << 20 < rsx::get_current_renderer()->main_mem_size)
@ -940,17 +940,17 @@ u32 cellGcmGetMaxIoMapSize()
{
cellGcmSys.trace("cellGcmGetMaxIoMapSize()");
return rsx::get_current_renderer()->main_mem_size - g_fxo->get<gcm_config>()->reserved_size;
return rsx::get_current_renderer()->main_mem_size - g_fxo->get<gcm_config>().reserved_size;
}
void cellGcmGetOffsetTable(vm::ptr<CellGcmOffsetTable> table)
{
cellGcmSys.trace("cellGcmGetOffsetTable(table=*0x%x)", table);
const auto cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
table->ioAddress = cfg->offsetTable.ioAddress;
table->eaAddress = cfg->offsetTable.eaAddress;
table->ioAddress = gcm_cfg.offsetTable.ioAddress;
table->eaAddress = gcm_cfg.offsetTable.eaAddress;
}
error_code cellGcmIoOffsetToAddress(u32 ioOffset, vm::ptr<u32> address)
@ -982,17 +982,17 @@ error_code gcmMapEaIoAddress(ppu_thread& ppu, u32 ea, u32 io, u32 size, bool is_
}
// Assume lock is acquired
const auto cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
ea >>= 20, io >>= 20, size >>= 20;
// Fill the offset table
for (u32 i = 0; i < size; i++)
{
cfg->offsetTable.ioAddress[ea + i] = io + i;
cfg->offsetTable.eaAddress[io + i] = ea + i;
gcm_cfg.offsetTable.ioAddress[ea + i] = io + i;
gcm_cfg.offsetTable.eaAddress[io + i] = ea + i;
}
cfg->IoMapTable[ea] = size;
gcm_cfg.IoMapTable[ea] = size;
return CELL_OK;
}
@ -1000,8 +1000,8 @@ error_code cellGcmMapEaIoAddress(ppu_thread& ppu, u32 ea, u32 io, u32 size)
{
cellGcmSys.warning("cellGcmMapEaIoAddress(ea=0x%x, io=0x%x, size=0x%x)", ea, io, size);
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
return gcmMapEaIoAddress(ppu, ea, io, size, false);
}
@ -1012,8 +1012,8 @@ error_code cellGcmMapEaIoAddressWithFlags(ppu_thread& ppu, u32 ea, u32 io, u32 s
ensure(flags == 2 /*CELL_GCM_IOMAP_FLAG_STRICT_ORDERING*/);
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
return gcmMapEaIoAddress(ppu, ea, io, size, true);
}
@ -1022,13 +1022,13 @@ error_code cellGcmMapLocalMemory(vm::ptr<u32> address, vm::ptr<u32> size)
{
cellGcmSys.warning("cellGcmMapLocalMemory(address=*0x%x, size=*0x%x)", address, size);
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
if (!cfg->local_addr && !cfg->local_size && vm::falloc(cfg->local_addr = rsx::constants::local_mem_base, cfg->local_size = 0xf900000 /* TODO */, vm::video))
if (!gcm_cfg.local_addr && !gcm_cfg.local_size && vm::falloc(gcm_cfg.local_addr = rsx::constants::local_mem_base, gcm_cfg.local_size = 0xf900000 /* TODO */, vm::video))
{
*address = cfg->local_addr;
*size = cfg->local_size;
*address = gcm_cfg.local_addr;
*size = gcm_cfg.local_size;
return CELL_OK;
}
@ -1041,13 +1041,13 @@ error_code cellGcmMapMainMemory(ppu_thread& ppu, u32 ea, u32 size, vm::ptr<u32>
if (!size || (ea & 0xFFFFF) || (size & 0xFFFFF)) return CELL_GCM_ERROR_FAILURE;
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
// Use the offset table to find the next free io address
for (u32 io = 0, end = (rsx::get_current_renderer()->main_mem_size - cfg->reserved_size) >> 20, unmap_count = 1; io < end; unmap_count++)
for (u32 io = 0, end = (rsx::get_current_renderer()->main_mem_size - gcm_cfg.reserved_size) >> 20, unmap_count = 1; io < end; unmap_count++)
{
if (cfg->offsetTable.eaAddress[io + unmap_count - 1] > 0xBFF)
if (gcm_cfg.offsetTable.eaAddress[io + unmap_count - 1] > 0xBFF)
{
if (unmap_count >= (size >> 20))
{
@ -1081,21 +1081,21 @@ error_code cellGcmReserveIoMapSize(u32 size)
return CELL_GCM_ERROR_INVALID_ALIGNMENT;
}
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
if (size > cellGcmGetMaxIoMapSize())
{
return CELL_GCM_ERROR_INVALID_VALUE;
}
cfg->reserved_size += size;
gcm_cfg.reserved_size += size;
return CELL_OK;
}
error_code GcmUnmapIoAddress(ppu_thread& ppu, gcm_config* cfg, u32 io)
error_code GcmUnmapIoAddress(ppu_thread& ppu, gcm_config& gcm_cfg, u32 io)
{
if (u32 ea = cfg->offsetTable.eaAddress[io >>= 20], size = cfg->IoMapTable[ea]; size)
if (u32 ea = gcm_cfg.offsetTable.eaAddress[io >>= 20], size = gcm_cfg.IoMapTable[ea]; size)
{
if (auto error = sys_rsx_context_iounmap(ppu, 0x55555555, io << 20, size << 20))
{
@ -1104,11 +1104,11 @@ error_code GcmUnmapIoAddress(ppu_thread& ppu, gcm_config* cfg, u32 io)
for (u32 i = 0; i < size; i++)
{
cfg->offsetTable.ioAddress[ea + i] = 0xFFFF;
cfg->offsetTable.eaAddress[io + i] = 0xFFFF;
gcm_cfg.offsetTable.ioAddress[ea + i] = 0xFFFF;
gcm_cfg.offsetTable.eaAddress[io + i] = 0xFFFF;
}
cfg->IoMapTable[ea] = 0;
gcm_cfg.IoMapTable[ea] = 0;
return CELL_OK;
}
@ -1127,13 +1127,13 @@ error_code cellGcmUnmapEaIoAddress(ppu_thread& ppu, u32 ea)
return CELL_GCM_ERROR_FAILURE;
}
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
if (const u32 io = cfg->offsetTable.ioAddress[ea] << 20;
if (const u32 io = gcm_cfg.offsetTable.ioAddress[ea] << 20;
io < rsx::get_current_renderer()->main_mem_size)
{
return GcmUnmapIoAddress(ppu, cfg, io);
return GcmUnmapIoAddress(ppu, gcm_cfg, io);
}
return CELL_GCM_ERROR_FAILURE;
@ -1143,10 +1143,10 @@ error_code cellGcmUnmapIoAddress(ppu_thread& ppu, u32 io)
{
cellGcmSys.warning("cellGcmUnmapIoAddress(io=0x%x)", io);
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
return GcmUnmapIoAddress(ppu, cfg, io);
return GcmUnmapIoAddress(ppu, gcm_cfg, io);
}
error_code cellGcmUnreserveIoMapSize(u32 size)
@ -1158,15 +1158,15 @@ error_code cellGcmUnreserveIoMapSize(u32 size)
return CELL_GCM_ERROR_INVALID_ALIGNMENT;
}
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& gcm_cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(gcm_cfg.gcmio_mutex);
if (size > cfg->reserved_size)
if (size > gcm_cfg.reserved_size)
{
return CELL_GCM_ERROR_INVALID_VALUE;
}
cfg->reserved_size -= size;
gcm_cfg.reserved_size -= size;
return CELL_OK;
}
@ -1218,27 +1218,27 @@ void cellGcmSetDefaultCommandBuffer()
{
cellGcmSys.warning("cellGcmSetDefaultCommandBuffer()");
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
vm::write32(gcm_cfg->ctxt_addr, gcm_cfg->gcm_info.context_addr);
vm::write32(gcm_cfg.ctxt_addr, gcm_cfg.gcm_info.context_addr);
}
error_code cellGcmSetDefaultCommandBufferAndSegmentWordSize(u32 bufferSize, u32 segmentSize)
{
cellGcmSys.warning("cellGcmSetDefaultCommandBufferAndSegmentWordSize(bufferSize=0x%x, segmentSize=0x%x)", bufferSize, segmentSize);
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
const auto& put = vm::_ref<CellGcmControl>(gcm_cfg->gcm_info.control_addr).put;
const auto& get = vm::_ref<CellGcmControl>(gcm_cfg->gcm_info.control_addr).get;
const auto& put = vm::_ref<CellGcmControl>(gcm_cfg.gcm_info.control_addr).put;
const auto& get = vm::_ref<CellGcmControl>(gcm_cfg.gcm_info.control_addr).get;
if (put != 0x1000 || get != 0x1000 || bufferSize < segmentSize * 2 || segmentSize >= 0x80000000)
{
return CELL_GCM_ERROR_FAILURE;
}
gcm_cfg->gcm_info.command_size = bufferSize;
gcm_cfg->gcm_info.segment_size = segmentSize;
gcm_cfg.gcm_info.command_size = bufferSize;
gcm_cfg.gcm_info.segment_size = segmentSize;
return CELL_OK;
}
@ -1268,7 +1268,7 @@ void _cellGcmSetFlipCommandWithWaitLabel(ppu_thread& ppu, vm::ptr<CellGcmContext
{
cellGcmSys.todo("cellGcmSetFlipCommandWithWaitLabel(ctx=*0x%x, id=0x%x, label_index=0x%x, label_value=0x%x)", ctx, id, label_index, label_value);
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
if (auto error = gcmSetPrepareFlip<true>(ppu, ctx, id); error < 0)
{
@ -1277,7 +1277,7 @@ void _cellGcmSetFlipCommandWithWaitLabel(ppu_thread& ppu, vm::ptr<CellGcmContext
}
// TODO: Fix this (must enqueue WaitLabel command instead)
vm::write32(gcm_cfg->gcm_info.label_addr + 0x10 * label_index, label_value);
vm::write32(gcm_cfg.gcm_info.label_addr + 0x10 * label_index, label_value);
}
error_code cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 comp, u16 base, u8 bank)
@ -1285,7 +1285,7 @@ error_code cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch
cellGcmSys.warning("cellGcmSetTile(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)",
index, location, offset, size, pitch, comp, base, bank);
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
// Copied form cellGcmSetTileInfo
if (index >= rsx::limits::tiles_count || base >= 2048 || bank >= 4)
@ -1320,7 +1320,7 @@ error_code cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch
tile.bank = bank;
tile.bound = (pitch > 0);
vm::_ptr<CellGcmTileInfo>(gcm_cfg->tiles_addr)[index] = tile.pack();
vm::_ptr<CellGcmTileInfo>(gcm_cfg.tiles_addr)[index] = tile.pack();
return CELL_OK;
}
@ -1391,7 +1391,7 @@ static std::pair<u32, u32> getNextCommandBufferBeginEnd(u32 current)
static u32 getOffsetFromAddress(u32 address)
{
const u32 upper = g_fxo->get<gcm_config>()->offsetTable.ioAddress[address >> 20]; // 12 bits
const u32 upper = g_fxo->get<gcm_config>().offsetTable.ioAddress[address >> 20]; // 12 bits
ensure(upper != 0xFFFF);
return (upper << 20) | (address & 0xFFFFF);
}
@ -1418,9 +1418,9 @@ s32 cellGcmCallback(ppu_thread& ppu, vm::ptr<CellGcmContextData> context, u32 co
{
cellGcmSys.trace("cellGcmCallback(context=*0x%x, count=0x%x)", context, count);
const auto gcm_cfg = g_fxo->get<gcm_config>();
auto& gcm_cfg = g_fxo->get<gcm_config>();
auto& ctrl = vm::_ref<CellGcmControl>(gcm_cfg->gcm_info.control_addr);
auto& ctrl = vm::_ref<CellGcmControl>(gcm_cfg.gcm_info.control_addr);
// Flush command buffer (ie allow RSX to read up to context->current)
ctrl.put.exchange(getOffsetFromAddress(context->current.addr()));

View File

@ -274,16 +274,16 @@ static bool ds3_input_to_ext(const u32 port_no, CellGemExtPortData& ext)
*/
static bool mouse_input_to_pad(const u32 mouse_no, be_t<u16>& digital_buttons, be_t<u16>& analog_t)
{
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
std::scoped_lock lock(handler->mutex);
std::scoped_lock lock(handler.mutex);
if (mouse_no >= handler->GetMice().size())
if (mouse_no >= handler.GetMice().size())
{
return false;
}
const auto& mouse_data = handler->GetMice().at(0);
const auto& mouse_data = handler.GetMice().at(0);
digital_buttons = 0;
@ -307,16 +307,16 @@ static bool mouse_input_to_pad(const u32 mouse_no, be_t<u16>& digital_buttons, b
static bool mouse_pos_to_gem_image_state(const u32 mouse_no, vm::ptr<CellGemImageState>& gem_image_state)
{
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
std::scoped_lock lock(handler->mutex);
std::scoped_lock lock(handler.mutex);
if (!gem_image_state || mouse_no >= handler->GetMice().size())
if (!gem_image_state || mouse_no >= handler.GetMice().size())
{
return false;
}
const auto& mouse = handler->GetMice().at(0);
const auto& mouse = handler.GetMice().at(0);
const auto renderer = static_cast<GSRender*>(rsx::get_current_renderer());
const auto width = renderer->get_frame()->client_width();
@ -337,16 +337,16 @@ static bool mouse_pos_to_gem_image_state(const u32 mouse_no, vm::ptr<CellGemImag
static bool mouse_pos_to_gem_state(const u32 mouse_no, vm::ptr<CellGemState>& gem_state)
{
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
std::scoped_lock lock(handler->mutex);
std::scoped_lock lock(handler.mutex);
if (!gem_state || mouse_no >= handler->GetMice().size())
if (!gem_state || mouse_no >= handler.GetMice().size())
{
return false;
}
const auto& mouse = handler->GetMice().at(0);
const auto& mouse = handler.GetMice().at(0);
const auto renderer = static_cast<GSRender*>(rsx::get_current_renderer());
const auto width = renderer->get_frame()->client_width();
@ -382,11 +382,11 @@ error_code cellGemCalibrate(u32 gem_num)
{
cellGem.todo("cellGemCalibrate(gem_num=%d)", gem_num);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -398,10 +398,10 @@ error_code cellGemCalibrate(u32 gem_num)
if (g_cfg.io.move == move_handler::fake || g_cfg.io.move == move_handler::mouse)
{
gem->controllers[gem_num].calibrated_magnetometer = true;
gem->controllers[gem_num].enabled_tracking = true;
gem->controllers[gem_num].hue = 1;
gem->status_flags = CELL_GEM_FLAG_CALIBRATION_OCCURRED | CELL_GEM_FLAG_CALIBRATION_SUCCEEDED;
gem.controllers[gem_num].calibrated_magnetometer = true;
gem.controllers[gem_num].enabled_tracking = true;
gem.controllers[gem_num].hue = 1;
gem.status_flags = CELL_GEM_FLAG_CALIBRATION_OCCURRED | CELL_GEM_FLAG_CALIBRATION_SUCCEEDED;
}
return CELL_OK;
@ -411,11 +411,11 @@ error_code cellGemClearStatusFlags(u32 gem_num, u64 mask)
{
cellGem.todo("cellGemClearStatusFlags(gem_num=%d, mask=0x%x)", gem_num, mask);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -425,7 +425,7 @@ error_code cellGemClearStatusFlags(u32 gem_num, u64 mask)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
gem->status_flags &= ~mask;
gem.status_flags &= ~mask;
return CELL_OK;
}
@ -434,9 +434,9 @@ error_code cellGemConvertVideoFinish()
{
cellGem.todo("cellGemConvertVideoFinish()");
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -448,9 +448,9 @@ error_code cellGemConvertVideoStart(vm::cptr<void> video_frame)
{
cellGem.todo("cellGemConvertVideoStart(video_frame=*0x%x)", video_frame);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -462,16 +462,16 @@ error_code cellGemEnableCameraPitchAngleCorrection(u32 enable_flag)
{
cellGem.todo("cellGemEnableCameraPitchAngleCorrection(enable_flag=%d)", enable_flag);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
gem->enable_pitch_correction = !!enable_flag;
gem.enable_pitch_correction = !!enable_flag;
return CELL_OK;
}
@ -480,21 +480,21 @@ error_code cellGemEnableMagnetometer(u32 gem_num, u32 enable)
{
cellGem.todo("cellGemEnableMagnetometer(gem_num=%d, enable=0x%x)", gem_num, enable);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
if (!gem->is_controller_ready(gem_num))
if (!gem.is_controller_ready(gem_num))
{
return CELL_GEM_NOT_CONNECTED;
}
gem->controllers[gem_num].enabled_magnetometer = !!enable;
gem.controllers[gem_num].enabled_magnetometer = !!enable;
return CELL_OK;
}
@ -509,13 +509,13 @@ error_code cellGemEnd(ppu_thread& ppu)
{
cellGem.warning("cellGemEnd()");
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (gem->state.compare_and_swap_test(1, 0))
if (gem.state.compare_and_swap_test(1, 0))
{
if (u32 addr = gem->memory_ptr)
if (u32 addr = gem.memory_ptr)
{
sys_memory_free(ppu, addr);
}
@ -530,11 +530,11 @@ error_code cellGemFilterState(u32 gem_num, u32 enable)
{
cellGem.warning("cellGemFilterState(gem_num=%d, enable=%d)", gem_num, enable);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -544,7 +544,7 @@ error_code cellGemFilterState(u32 gem_num, u32 enable)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
gem->controllers[gem_num].enabled_filtering = !!enable;
gem.controllers[gem_num].enabled_filtering = !!enable;
return CELL_OK;
}
@ -553,11 +553,11 @@ error_code cellGemForceRGB(u32 gem_num, float r, float g, float b)
{
cellGem.todo("cellGemForceRGB(gem_num=%d, r=%f, g=%f, b=%f)", gem_num, r, g, b);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -567,7 +567,7 @@ error_code cellGemForceRGB(u32 gem_num, float r, float g, float b)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
gem->controllers[gem_num].sphere_rgb = gem_config::gem_color(r, g, b);
gem.controllers[gem_num].sphere_rgb = gem_config::gem_color(r, g, b);
return CELL_OK;
}
@ -582,9 +582,9 @@ error_code cellGemGetAllTrackableHues(vm::ptr<u8> hues)
{
cellGem.todo("cellGemGetAllTrackableHues(hues=*0x%x)");
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -601,9 +601,9 @@ error_code cellGemGetCameraState(vm::ptr<CellGemCameraState> camera_state)
{
cellGem.todo("cellGemGetCameraState(camera_state=0x%x)", camera_state);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -623,9 +623,9 @@ error_code cellGemGetEnvironmentLightingColor(vm::ptr<f32> r, vm::ptr<f32> g, vm
{
cellGem.todo("cellGemGetEnvironmentLightingColor(r=*0x%x, g=*0x%x, b=*0x%x)", r, g, b);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -647,9 +647,9 @@ error_code cellGemGetHuePixels(vm::cptr<void> camera_frame, u32 hue, vm::ptr<u8>
{
cellGem.todo("cellGemGetHuePixels(camera_frame=*0x%x, hue=%d, pixels=*0x%x)", camera_frame, hue, pixels);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -666,9 +666,9 @@ error_code cellGemGetImageState(u32 gem_num, vm::ptr<CellGemImageState> gem_imag
{
cellGem.todo("cellGemGetImageState(gem_num=%d, image_state=&0x%x)", gem_num, gem_image_state);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -678,7 +678,7 @@ error_code cellGemGetImageState(u32 gem_num, vm::ptr<CellGemImageState> gem_imag
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
auto shared_data = g_fxo->get<gem_camera_shared>();
auto& shared_data = g_fxo->get<gem_camera_shared>();
if (g_cfg.io.move == move_handler::fake)
{
@ -694,7 +694,7 @@ error_code cellGemGetImageState(u32 gem_num, vm::ptr<CellGemImageState> gem_imag
if (g_cfg.io.move == move_handler::fake || g_cfg.io.move == move_handler::mouse)
{
gem_image_state->frame_timestamp = shared_data->frame_timestamp.load();
gem_image_state->frame_timestamp = shared_data.frame_timestamp.load();
gem_image_state->timestamp = gem_image_state->frame_timestamp + 10;
gem_image_state->r = 10;
gem_image_state->distance = 2 * 1000; // 2 meters away from camera
@ -709,16 +709,16 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v
{
cellGem.warning("cellGemGetInertialState(gem_num=%d, state_flag=%d, timestamp=0x%x, inertial_state=0x%x)", gem_num, state_flag, timestamp, inertial_state);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
if (!check_gem_num(gem_num) || state_flag > CELL_GEM_INERTIAL_STATE_FLAG_NEXT || !inertial_state || !gem->is_controller_ready(gem_num))
if (!check_gem_num(gem_num) || state_flag > CELL_GEM_INERTIAL_STATE_FLAG_NEXT || !inertial_state || !gem.is_controller_ready(gem_num))
{
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
@ -736,8 +736,8 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v
{
ds3_input_to_ext(gem_num, inertial_state->ext);
inertial_state->timestamp = gem->timer.GetElapsedTimeInMicroSec();
inertial_state->counter = gem->inertial_counter++;
inertial_state->timestamp = gem.timer.GetElapsedTimeInMicroSec();
inertial_state->counter = gem.inertial_counter++;
inertial_state->accelerometer[0] = 10;
}
@ -748,11 +748,11 @@ error_code cellGemGetInfo(vm::ptr<CellGemInfo> info)
{
cellGem.warning("cellGemGetInfo(info=*0x%x)", info);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
reader_lock lock(gem->mtx);
reader_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -763,13 +763,13 @@ error_code cellGemGetInfo(vm::ptr<CellGemInfo> info)
}
// TODO: Support connecting PlayStation Move controllers
info->max_connect = gem->attribute.max_connect;
info->now_connect = gem->connected_controllers;
info->max_connect = gem.attribute.max_connect;
info->now_connect = gem.connected_controllers;
for (int i = 0; i < CELL_GEM_MAX_NUM; i++)
{
info->status[i] = gem->controllers[i].status;
info->port[i] = gem->controllers[i].port;
info->status[i] = gem.controllers[i].status;
info->port[i] = gem.controllers[i].port;
}
return CELL_OK;
@ -796,11 +796,11 @@ error_code cellGemGetRGB(u32 gem_num, vm::ptr<float> r, vm::ptr<float> g, vm::pt
{
cellGem.todo("cellGemGetRGB(gem_num=%d, r=*0x%x, g=*0x%x, b=*0x%x)", gem_num, r, g, b);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
reader_lock lock(gem->mtx);
reader_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -810,7 +810,7 @@ error_code cellGemGetRGB(u32 gem_num, vm::ptr<float> r, vm::ptr<float> g, vm::pt
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
auto& sphere_color = gem->controllers[gem_num].sphere_rgb;
auto& sphere_color = gem.controllers[gem_num].sphere_rgb;
*r = sphere_color.r;
*g = sphere_color.g;
*b = sphere_color.b;
@ -822,11 +822,11 @@ error_code cellGemGetRumble(u32 gem_num, vm::ptr<u8> rumble)
{
cellGem.todo("cellGemGetRumble(gem_num=%d, rumble=*0x%x)", gem_num, rumble);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
reader_lock lock(gem->mtx);
reader_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -836,7 +836,7 @@ error_code cellGemGetRumble(u32 gem_num, vm::ptr<u8> rumble)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
*rumble = gem->controllers[gem_num].rumble;
*rumble = gem.controllers[gem_num].rumble;
return CELL_OK;
}
@ -845,11 +845,11 @@ error_code cellGemGetState(u32 gem_num, u32 flag, u64 time_parameter, vm::ptr<Ce
{
cellGem.warning("cellGemGetState(gem_num=%d, flag=0x%x, time=0x%llx, gem_state=*0x%x)", gem_num, flag, time_parameter, gem_state);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
reader_lock lock(gem->mtx);
reader_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -874,7 +874,7 @@ error_code cellGemGetState(u32 gem_num, u32 flag, u64 time_parameter, vm::ptr<Ce
ds3_input_to_ext(gem_num, gem_state->ext);
gem_state->tracking_flags = CELL_GEM_TRACKING_FLAG_POSITION_TRACKED | CELL_GEM_TRACKING_FLAG_VISIBLE;
gem_state->timestamp = gem->timer.GetElapsedTimeInMicroSec();
gem_state->timestamp = gem.timer.GetElapsedTimeInMicroSec();
gem_state->quat[3] = 1.f;
return CELL_OK;
@ -887,11 +887,11 @@ error_code cellGemGetStatusFlags(u32 gem_num, vm::ptr<u64> flags)
{
cellGem.todo("cellGemGetStatusFlags(gem_num=%d, flags=*0x%x)", gem_num, flags);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
reader_lock lock(gem->mtx);
reader_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -901,7 +901,7 @@ error_code cellGemGetStatusFlags(u32 gem_num, vm::ptr<u64> flags)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
*flags = gem->status_flags;
*flags = gem.status_flags;
return CELL_OK;
}
@ -910,11 +910,11 @@ error_code cellGemGetTrackerHue(u32 gem_num, vm::ptr<u32> hue)
{
cellGem.warning("cellGemGetTrackerHue(gem_num=%d, hue=*0x%x)", gem_num, hue);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
reader_lock lock(gem->mtx);
reader_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -924,12 +924,12 @@ error_code cellGemGetTrackerHue(u32 gem_num, vm::ptr<u32> hue)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
if (!gem->controllers[gem_num].enabled_tracking || gem->controllers[gem_num].hue > 359)
if (!gem.controllers[gem_num].enabled_tracking || gem.controllers[gem_num].hue > 359)
{
return CELL_GEM_ERROR_NOT_A_HUE;
}
*hue = gem->controllers[gem_num].hue;
*hue = gem.controllers[gem_num].hue;
return CELL_OK;
}
@ -954,16 +954,16 @@ error_code cellGemInit(ppu_thread& ppu, vm::cptr<CellGemAttribute> attribute)
{
cellGem.warning("cellGemInit(attribute=*0x%x)", attribute);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!attribute || !attribute->spurs_addr || !attribute->max_connect || attribute->max_connect > CELL_GEM_MAX_NUM)
{
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state.compare_and_swap_test(0, 1))
if (!gem.state.compare_and_swap_test(0, 1))
{
return CELL_GEM_ERROR_ALREADY_INITIALIZED;
}
@ -978,33 +978,33 @@ error_code cellGemInit(ppu_thread& ppu, vm::cptr<CellGemAttribute> attribute)
return CELL_GEM_ERROR_RESOURCE_ALLOCATION_FAILED;
}
gem->memory_ptr = *addr;
gem.memory_ptr = *addr;
}
else
{
gem->memory_ptr = 0;
gem.memory_ptr = 0;
}
gem->update_started = false;
gem->camera_frame = 0;
gem->status_flags = 0;
gem->attribute = *attribute;
gem.update_started = false;
gem.camera_frame = 0;
gem.status_flags = 0;
gem.attribute = *attribute;
if (g_cfg.io.move == move_handler::mouse)
{
// init mouse handler
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
handler->Init(std::min<u32>(attribute->max_connect, CELL_GEM_MAX_NUM));
handler.Init(std::min<u32>(attribute->max_connect, CELL_GEM_MAX_NUM));
}
for (int gem_num = 0; gem_num < CELL_GEM_MAX_NUM; gem_num++)
{
gem->reset_controller(gem_num);
gem.reset_controller(gem_num);
}
// TODO: is this correct?
gem->timer.Start();
gem.timer.Start();
return CELL_OK;
}
@ -1013,11 +1013,11 @@ error_code cellGemInvalidateCalibration(s32 gem_num)
{
cellGem.todo("cellGemInvalidateCalibration(gem_num=%d)", gem_num);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -1029,8 +1029,8 @@ error_code cellGemInvalidateCalibration(s32 gem_num)
if (g_cfg.io.move == move_handler::fake || g_cfg.io.move == move_handler::mouse)
{
gem->controllers[gem_num].calibrated_magnetometer = false;
// TODO: gem->status_flags
gem.controllers[gem_num].calibrated_magnetometer = false;
// TODO: gem.status_flags
}
return CELL_OK;
@ -1040,9 +1040,9 @@ s32 cellGemIsTrackableHue(u32 hue)
{
cellGem.todo("cellGemIsTrackableHue(hue=%d)", hue);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state || hue > 359)
if (!gem.state || hue > 359)
{
return false;
}
@ -1054,9 +1054,9 @@ error_code cellGemPrepareCamera(s32 max_exposure, f32 image_quality)
{
cellGem.todo("cellGemPrepareCamera(max_exposure=%d, image_quality=%f)", max_exposure, image_quality);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -1073,9 +1073,9 @@ error_code cellGemPrepareVideoConvert(vm::cptr<CellGemVideoConvertAttribute> vc_
{
cellGem.todo("cellGemPrepareVideoConvert(vc_attribute=*0x%x)", vc_attribute);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -1098,7 +1098,7 @@ error_code cellGemPrepareVideoConvert(vm::cptr<CellGemVideoConvertAttribute> vc_
return CELL_GEM_ERROR_INVALID_ALIGNMENT;
}
gem->vc_attribute = vc;
gem.vc_attribute = vc;
return CELL_OK;
}
@ -1107,9 +1107,9 @@ error_code cellGemReadExternalPortDeviceInfo(u32 gem_num, vm::ptr<u32> ext_id, v
{
cellGem.todo("cellGemReadExternalPortDeviceInfo(gem_num=%d, ext_id=*0x%x, ext_info=%s)", gem_num, ext_id, ext_info);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -1119,12 +1119,12 @@ error_code cellGemReadExternalPortDeviceInfo(u32 gem_num, vm::ptr<u32> ext_id, v
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
if (gem->controllers[gem_num].status & CELL_GEM_STATUS_DISCONNECTED)
if (gem.controllers[gem_num].status & CELL_GEM_STATUS_DISCONNECTED)
{
return CELL_GEM_NOT_CONNECTED;
}
if (!(gem->controllers[gem_num].ext_status & CELL_GEM_EXT_CONNECTED))
if (!(gem.controllers[gem_num].ext_status & CELL_GEM_EXT_CONNECTED))
{
return CELL_GEM_NO_EXTERNAL_PORT_DEVICE;
}
@ -1136,9 +1136,9 @@ error_code cellGemReset(u32 gem_num)
{
cellGem.todo("cellGemReset(gem_num=%d)", gem_num);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -1148,10 +1148,10 @@ error_code cellGemReset(u32 gem_num)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
gem->reset_controller(gem_num);
gem.reset_controller(gem_num);
// TODO: is this correct?
gem->timer.Start();
gem.timer.Start();
return CELL_OK;
}
@ -1160,11 +1160,11 @@ error_code cellGemSetRumble(u32 gem_num, u8 rumble)
{
cellGem.todo("cellGemSetRumble(gem_num=%d, rumble=0x%x)", gem_num, rumble);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -1174,7 +1174,7 @@ error_code cellGemSetRumble(u32 gem_num, u8 rumble)
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
gem->controllers[gem_num].rumble = rumble;
gem.controllers[gem_num].rumble = rumble;
return CELL_OK;
}
@ -1189,11 +1189,11 @@ error_code cellGemTrackHues(vm::cptr<u32> req_hues, vm::ptr<u32> res_hues)
{
cellGem.todo("cellGemTrackHues(req_hues=*0x%x, res_hues=*0x%x)", req_hues, res_hues);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
@ -1211,8 +1211,8 @@ error_code cellGemTrackHues(vm::cptr<u32> req_hues, vm::ptr<u32> res_hues)
}
else if (req_hues[i] == u32{CELL_GEM_DONT_TRACK_HUE})
{
gem->controllers[i].enabled_tracking = false;
gem->controllers[i].enabled_LED = false;
gem.controllers[i].enabled_tracking = false;
gem.controllers[i].enabled_LED = false;
}
else
{
@ -1230,21 +1230,21 @@ error_code cellGemUpdateFinish()
{
cellGem.warning("cellGemUpdateFinish()");
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
if (!std::exchange(gem->update_started, false))
if (!std::exchange(gem.update_started, false))
{
return CELL_GEM_ERROR_UPDATE_NOT_STARTED;
}
if (!gem->camera_frame)
if (!gem.camera_frame)
{
return not_an_error(CELL_GEM_NO_VIDEO);
}
@ -1256,22 +1256,22 @@ error_code cellGemUpdateStart(vm::cptr<void> camera_frame, u64 timestamp)
{
cellGem.warning("cellGemUpdateStart(camera_frame=*0x%x, timestamp=%d)", camera_frame, timestamp);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}
std::scoped_lock lock(gem->mtx);
std::scoped_lock lock(gem.mtx);
// Update is starting even when camera_frame is null
if (std::exchange(gem->update_started, true))
if (std::exchange(gem.update_started, true))
{
return CELL_GEM_ERROR_UPDATE_NOT_FINISHED;
}
gem->camera_frame = camera_frame.addr();
gem.camera_frame = camera_frame.addr();
if (!camera_frame)
{
return not_an_error(CELL_GEM_NO_VIDEO);
@ -1284,9 +1284,9 @@ error_code cellGemWriteExternalPort(u32 gem_num, vm::ptr<u8[CELL_GEM_EXTERNAL_PO
{
cellGem.todo("cellGemWriteExternalPort(gem_num=%d, data=%s)", gem_num, data);
const auto gem = g_fxo->get<gem_config>();
auto& gem = g_fxo->get<gem_config>();
if (!gem->state)
if (!gem.state)
{
return CELL_GEM_ERROR_UNINITIALIZED;
}

View File

@ -128,10 +128,10 @@ error_code cellImeJpOpen(sys_memory_container_t container_id, vm::ptr<CellImeJpH
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (manager->is_initialized)
if (manager.is_initialized)
{
return CELL_IMEJP_ERROR_ALREADY_OPEN;
}
@ -140,11 +140,11 @@ error_code cellImeJpOpen(sys_memory_container_t container_id, vm::ptr<CellImeJpH
{
cellImeJp.warning("cellImeJpOpen dictionary path = %s", addDicPath->path);
manager->dictionary_paths.emplace_back(addDicPath->path);
manager.dictionary_paths.emplace_back(addDicPath->path);
}
*hImeJpHandle = vm::cast(ime_jp_address);
manager->is_initialized = true;
manager.is_initialized = true;
return CELL_OK;
}
@ -158,10 +158,10 @@ error_code cellImeJpOpen2(sys_memory_container_t container_id, vm::ptr<CellImeJp
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (manager->is_initialized)
if (manager.is_initialized)
{
return CELL_IMEJP_ERROR_ALREADY_OPEN;
}
@ -170,12 +170,12 @@ error_code cellImeJpOpen2(sys_memory_container_t container_id, vm::ptr<CellImeJp
{
cellImeJp.warning("cellImeJpOpen2 dictionary path = %s", addDicPath->path);
manager->dictionary_paths.emplace_back(addDicPath->path);
manager.dictionary_paths.emplace_back(addDicPath->path);
}
*hImeJpHandle = vm::cast(ime_jp_address);
manager->is_initialized = true;
manager.is_initialized = true;
return CELL_OK;
}
@ -189,10 +189,10 @@ error_code cellImeJpOpen3(sys_memory_container_t container_id, vm::ptr<CellImeJp
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (manager->is_initialized)
if (manager.is_initialized)
{
return CELL_IMEJP_ERROR_ALREADY_OPEN;
}
@ -205,14 +205,14 @@ error_code cellImeJpOpen3(sys_memory_container_t container_id, vm::ptr<CellImeJp
{
cellImeJp.warning("cellImeJpOpen3 dictionary %d path = %s", i, addDicPath[i]->path);
manager->dictionary_paths.emplace_back(addDicPath[i]->path);
manager.dictionary_paths.emplace_back(addDicPath[i]->path);
}
}
}
*hImeJpHandle = vm::cast(ime_jp_address);
manager->is_initialized = true;
manager.is_initialized = true;
return CELL_OK;
}
@ -227,21 +227,21 @@ error_code cellImeJpClose(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpClose(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
manager->input_state = CELL_IMEJP_BEFORE_INPUT;
manager->input_string.clear();
manager->converted_string.clear();
manager->confirmed_string.clear();
manager->cursor = 0;
manager->cursor_end = 0;
manager->is_initialized = false;
manager.input_state = CELL_IMEJP_BEFORE_INPUT;
manager.input_string.clear();
manager.converted_string.clear();
manager.confirmed_string.clear();
manager.cursor = 0;
manager.cursor_end = 0;
manager.is_initialized = false;
return CELL_OK;
}
@ -250,20 +250,20 @@ error_code cellImeJpSetKanaInputMode(CellImeJpHandle hImeJpHandle, s16 inputOpti
{
cellImeJp.todo("cellImeJpSetKanaInputMode(hImeJpHandle=*0x%x, inputOption=%d)", hImeJpHandle, inputOption);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state != CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->kana_input_mode = inputOption;
manager.kana_input_mode = inputOption;
return CELL_OK;
}
@ -272,15 +272,15 @@ error_code cellImeJpSetInputCharType(CellImeJpHandle hImeJpHandle, s16 charTypeO
{
cellImeJp.todo("cellImeJpSetInputCharType(hImeJpHandle=*0x%x, charTypeOption=%d)", hImeJpHandle, charTypeOption);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
manager->input_char_type = charTypeOption;
manager.input_char_type = charTypeOption;
return CELL_OK;
}
@ -289,15 +289,15 @@ error_code cellImeJpSetFixInputMode(CellImeJpHandle hImeJpHandle, s16 fixInputMo
{
cellImeJp.todo("cellImeJpSetFixInputMode(hImeJpHandle=*0x%x, fixInputMode=%d)", hImeJpHandle, fixInputMode);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
manager->fix_input_mode = fixInputMode;
manager.fix_input_mode = fixInputMode;
return CELL_OK;
}
@ -306,20 +306,20 @@ error_code cellImeJpAllowExtensionCharacters(CellImeJpHandle hImeJpHandle, s16 e
{
cellImeJp.todo("cellImeJpSetFixInputMode(hImeJpHandle=*0x%x, extensionCharacters=%d)", hImeJpHandle, extensionCharacters);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state != CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->allowed_extensions = extensionCharacters;
manager.allowed_extensions = extensionCharacters;
return CELL_OK;
}
@ -328,20 +328,20 @@ error_code cellImeJpReset(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpReset(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
manager->input_state = CELL_IMEJP_BEFORE_INPUT;
manager->input_string.clear();
manager->converted_string.clear();
manager->confirmed_string.clear();
manager->cursor = 0;
manager->cursor_end = 0;
manager.input_state = CELL_IMEJP_BEFORE_INPUT;
manager.input_string.clear();
manager.converted_string.clear();
manager.confirmed_string.clear();
manager.cursor = 0;
manager.cursor_end = 0;
return CELL_OK;
}
@ -355,15 +355,15 @@ error_code cellImeJpGetStatus(CellImeJpHandle hImeJpHandle, vm::ptr<s16> pInputS
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
*pInputStatus = manager->input_state;
*pInputStatus = manager.input_state;
return CELL_OK;
}
@ -377,20 +377,20 @@ error_code cellImeJpEnterChar(CellImeJpHandle hImeJpHandle, u16 inputChar, vm::p
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_MOVE_CLAUSE_GAP)
if (manager.input_state == CELL_IMEJP_MOVE_CLAUSE_GAP)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->addChar(inputChar);
manager.addChar(inputChar);
*pOutputStatus = CELL_IMEJP_RET_CONFIRMED;
@ -412,20 +412,20 @@ error_code cellImeJpEnterString(CellImeJpHandle hImeJpHandle, vm::cptr<u16> pInp
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_MOVE_CLAUSE_GAP)
if (manager.input_state == CELL_IMEJP_MOVE_CLAUSE_GAP)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->addString(pInputString);
manager.addString(pInputString);
*pOutputStatus = CELL_IMEJP_RET_CONFIRMED;
@ -442,20 +442,20 @@ error_code cellImeJpModeCaretRight(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpModeCaretRight(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state != CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->moveCursor(1);
manager.moveCursor(1);
return CELL_OK;
}
@ -464,20 +464,20 @@ error_code cellImeJpModeCaretLeft(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpModeCaretLeft(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state != CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->moveCursor(-1);
manager.moveCursor(-1);
return CELL_OK;
}
@ -486,20 +486,20 @@ error_code cellImeJpBackspaceWord(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpBackspaceWord(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state != CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->backspaceWord();
manager.backspaceWord();
return CELL_OK;
}
@ -508,20 +508,20 @@ error_code cellImeJpDeleteWord(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpDeleteWord(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state != CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->deleteWord();
manager.deleteWord();
return CELL_OK;
}
@ -530,24 +530,24 @@ error_code cellImeJpAllDeleteConvertString(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpAllDeleteConvertString(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->cursor = 0;
manager->cursor_end = 0;
manager->input_string.clear();
manager->converted_string.clear();
manager->input_state = CELL_IMEJP_BEFORE_INPUT;
manager.cursor = 0;
manager.cursor_end = 0;
manager.input_string.clear();
manager.converted_string.clear();
manager.input_state = CELL_IMEJP_BEFORE_INPUT;
return CELL_OK;
}
@ -556,20 +556,20 @@ error_code cellImeJpConvertForward(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpConvertForward(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->input_state = CELL_IMEJP_CANDIDATES;
manager.input_state = CELL_IMEJP_CANDIDATES;
return CELL_OK;
}
@ -578,20 +578,20 @@ error_code cellImeJpConvertBackward(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpConvertBackward(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->input_state = CELL_IMEJP_CANDIDATES;
manager.input_state = CELL_IMEJP_CANDIDATES;
return CELL_OK;
}
@ -600,15 +600,15 @@ error_code cellImeJpCurrentPartConfirm(CellImeJpHandle hImeJpHandle, s16 listIte
{
cellImeJp.todo("cellImeJpCurrentPartConfirm(hImeJpHandle=*0x%x, listItem=%d)", hImeJpHandle, listItem);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -620,26 +620,26 @@ error_code cellImeJpAllConfirm(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpAllConfirm(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
// Use input_string for now
manager->confirmed_string = manager->input_string;
manager->cursor = 0;
manager->cursor_end = 0;
manager->input_string.clear();
manager->converted_string.clear();
manager->input_state = CELL_IMEJP_BEFORE_INPUT;
manager.confirmed_string = manager.input_string;
manager.cursor = 0;
manager.cursor_end = 0;
manager.input_string.clear();
manager.converted_string.clear();
manager.input_state = CELL_IMEJP_BEFORE_INPUT;
return CELL_OK;
}
@ -648,21 +648,21 @@ error_code cellImeJpAllConvertCancel(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpAllConvertCancel(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT || manager->input_state == CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT || manager.input_state == CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->converted_string.clear();
manager->input_state = CELL_IMEJP_BEFORE_CONVERT;
manager.converted_string.clear();
manager.input_state = CELL_IMEJP_BEFORE_CONVERT;
return CELL_OK;
}
@ -671,15 +671,15 @@ error_code cellImeJpConvertCancel(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpConvertCancel(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT || manager->input_state == CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT || manager.input_state == CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -692,20 +692,20 @@ error_code cellImeJpExtendConvertArea(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpExtendConvertArea(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT || manager->input_state == CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT || manager.input_state == CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->moveCursorEnd(1);
manager.moveCursorEnd(1);
return CELL_OK;
}
@ -714,20 +714,20 @@ error_code cellImeJpShortenConvertArea(CellImeJpHandle hImeJpHandle)
{
cellImeJp.todo("cellImeJpShortenConvertArea(hImeJpHandle=*0x%x)", hImeJpHandle);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT || manager->input_state == CELL_IMEJP_BEFORE_CONVERT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT || manager.input_state == CELL_IMEJP_BEFORE_CONVERT)
{
return CELL_IMEJP_ERROR_ERR;
}
manager->moveCursorEnd(-1);
manager.moveCursorEnd(-1);
return CELL_OK;
}
@ -736,15 +736,15 @@ error_code cellImeJpTemporalConfirm(CellImeJpHandle hImeJpHandle, s16 selectInde
{
cellImeJp.todo("cellImeJpTemporalConfirm(hImeJpHandle=*0x%x, selectIndex=%d)", hImeJpHandle, selectIndex);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_CANDIDATES)
if (manager.input_state != CELL_IMEJP_CANDIDATES)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -756,15 +756,15 @@ error_code cellImeJpPostConvert(CellImeJpHandle hImeJpHandle, s16 postType)
{
cellImeJp.todo("cellImeJpPostConvert(hImeJpHandle=*0x%x, postType=%d)", hImeJpHandle, postType);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -776,15 +776,15 @@ error_code cellImeJpMoveFocusClause(CellImeJpHandle hImeJpHandle, s16 moveType)
{
cellImeJp.todo("cellImeJpMoveFocusClause(hImeJpHandle=*0x%x, moveType=%d)", hImeJpHandle, moveType);
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state == CELL_IMEJP_BEFORE_INPUT || manager->input_state == CELL_IMEJP_BEFORE_CONVERT || manager->input_state == CELL_IMEJP_MOVE_CLAUSE_GAP)
if (manager.input_state == CELL_IMEJP_BEFORE_INPUT || manager.input_state == CELL_IMEJP_BEFORE_CONVERT || manager.input_state == CELL_IMEJP_MOVE_CLAUSE_GAP)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -792,23 +792,23 @@ error_code cellImeJpMoveFocusClause(CellImeJpHandle hImeJpHandle, s16 moveType)
switch (moveType)
{
case CELL_IMEJP_FOCUS_NEXT:
manager->moveCursor(1);
manager.moveCursor(1);
break;
case CELL_IMEJP_FOCUS_BEFORE:
manager->moveCursor(-1);
manager.moveCursor(-1);
break;
case CELL_IMEJP_FOCUS_TOP:
manager->moveCursor(-1 * ::narrow<s8>(manager->input_string.length()));
manager.moveCursor(-1 * ::narrow<s8>(manager.input_string.length()));
break;
case CELL_IMEJP_FOCUS_END:
manager->moveCursor(::narrow<s8>(manager->input_string.length()));
manager->moveCursor(-1);
manager.moveCursor(::narrow<s8>(manager.input_string.length()));
manager.moveCursor(-1);
break;
default:
break;
}
manager->input_state = CELL_IMEJP_CONVERTING;
manager.input_state = CELL_IMEJP_CONVERTING;
return CELL_OK;
}
@ -822,15 +822,15 @@ error_code cellImeJpGetFocusTop(CellImeJpHandle hImeJpHandle, vm::ptr<s16> pFocu
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
*pFocusTop = static_cast<u16>(manager->cursor * 2); // offset in bytes
*pFocusTop = static_cast<u16>(manager.cursor * 2); // offset in bytes
return CELL_OK;
}
@ -844,21 +844,21 @@ error_code cellImeJpGetFocusLength(CellImeJpHandle hImeJpHandle, vm::ptr<s16> pF
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->cursor >= (CELL_IMEJP_STRING_MAXLENGTH - 1))
if (manager.cursor >= (CELL_IMEJP_STRING_MAXLENGTH - 1))
{
*pFocusLength = 0;
}
else
{
*pFocusLength = static_cast<u16>((manager->cursor_end - manager->cursor + 1) * 2); // offset in bytes
*pFocusLength = static_cast<u16>((manager.cursor_end - manager.cursor + 1) * 2); // offset in bytes
}
return CELL_OK;
@ -873,10 +873,10 @@ error_code cellImeJpGetConfirmYomiString(CellImeJpHandle hImeJpHandle, vm::ptr<u
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
@ -886,11 +886,11 @@ error_code cellImeJpGetConfirmYomiString(CellImeJpHandle hImeJpHandle, vm::ptr<u
pYomiString[i] = 0;
}
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length());
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager.confirmed_string.length());
for (u32 i = 0; i < max_len; i++)
{
pYomiString[i] = manager->confirmed_string[i];
pYomiString[i] = manager.confirmed_string[i];
}
return CELL_OK;
@ -905,10 +905,10 @@ error_code cellImeJpGetConfirmString(CellImeJpHandle hImeJpHandle, vm::ptr<u16>
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
@ -918,11 +918,11 @@ error_code cellImeJpGetConfirmString(CellImeJpHandle hImeJpHandle, vm::ptr<u16>
pConfirmString[i] = 0;
}
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length());
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager.confirmed_string.length());
for (u32 i = 0; i < max_len; i++)
{
pConfirmString[i] = manager->confirmed_string[i];
pConfirmString[i] = manager.confirmed_string[i];
}
return CELL_OK;
@ -937,10 +937,10 @@ error_code cellImeJpGetConvertYomiString(CellImeJpHandle hImeJpHandle, vm::ptr<u
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
@ -950,11 +950,11 @@ error_code cellImeJpGetConvertYomiString(CellImeJpHandle hImeJpHandle, vm::ptr<u
pYomiString[i] = 0;
}
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length());
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager.input_string.length());
for (u32 i = 0; i < max_len; i++)
{
pYomiString[i] = manager->input_string[i];
pYomiString[i] = manager.input_string[i];
}
return CELL_OK;
@ -969,10 +969,10 @@ error_code cellImeJpGetConvertString(CellImeJpHandle hImeJpHandle, vm::ptr<u16>
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
@ -982,11 +982,11 @@ error_code cellImeJpGetConvertString(CellImeJpHandle hImeJpHandle, vm::ptr<u16>
pConvertString[i] = 0;
}
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length());
const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager.input_string.length());
for (u32 i = 0; i < max_len; i++)
{
pConvertString[i] = manager->input_string[i];
pConvertString[i] = manager.input_string[i];
}
return CELL_OK;
@ -1001,15 +1001,15 @@ error_code cellImeJpGetCandidateListSize(CellImeJpHandle hImeJpHandle, vm::ptr<s
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_CANDIDATES)
if (manager.input_state != CELL_IMEJP_CANDIDATES)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -1028,15 +1028,15 @@ error_code cellImeJpGetCandidateList(CellImeJpHandle hImeJpHandle, vm::ptr<s16>
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_CANDIDATES)
if (manager.input_state != CELL_IMEJP_CANDIDATES)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -1055,15 +1055,15 @@ error_code cellImeJpGetCandidateSelect(CellImeJpHandle hImeJpHandle, vm::ptr<s16
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
if (manager->input_state != CELL_IMEJP_CANDIDATES)
if (manager.input_state != CELL_IMEJP_CANDIDATES)
{
return CELL_IMEJP_ERROR_ERR;
}
@ -1082,10 +1082,10 @@ error_code cellImeJpGetPredictList(CellImeJpHandle hImeJpHandle, vm::ptr<s16> pY
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}
@ -1104,10 +1104,10 @@ error_code cellImeJpConfirmPrediction(CellImeJpHandle hImeJpHandle, vm::ptr<Cell
return CELL_IMEJP_ERROR_PARAM;
}
const auto manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager->mutex);
auto& manager = g_fxo->get<ime_jp_manager>();
std::lock_guard lock(manager.mutex);
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return CELL_IMEJP_ERROR_CONTEXT;
}

View File

@ -35,9 +35,9 @@ error_code cellKbInit(u32 max_connect)
{
sys_io.warning("cellKbInit(max_connect=%d)", max_connect);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.init();
const auto init = handler.init.init();
if (!init)
return CELL_KB_ERROR_ALREADY_INITIALIZED;
@ -46,7 +46,7 @@ error_code cellKbInit(u32 max_connect)
return CELL_KB_ERROR_INVALID_PARAMETER;
libio_sys_config_init();
handler->Init(std::min(max_connect, 7u));
handler.Init(std::min(max_connect, 7u));
return CELL_OK;
}
@ -55,9 +55,9 @@ error_code cellKbEnd()
{
sys_io.notice("cellKbEnd()");
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.reset();
const auto init = handler.init.reset();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -71,9 +71,9 @@ error_code cellKbClearBuf(u32 port_no)
{
sys_io.trace("cellKbClearBuf(port_no=%d)", port_no);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -81,14 +81,14 @@ error_code cellKbClearBuf(u32 port_no)
if (port_no >= CELL_KB_MAX_KEYBOARDS)
return CELL_KB_ERROR_INVALID_PARAMETER;
std::lock_guard<std::mutex> lock(handler->m_mutex);
std::lock_guard<std::mutex> lock(handler.m_mutex);
const KbInfo& current_info = handler->GetInfo();
const KbInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
if (port_no >= handler.GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
return CELL_KB_ERROR_NO_DEVICE;
KbData& current_data = handler->GetData(port_no);
KbData& current_data = handler.GetData(port_no);
current_data.len = 0;
current_data.led = 0;
current_data.mkey = 0;
@ -245,9 +245,9 @@ error_code cellKbGetInfo(vm::ptr<CellKbInfo> info)
{
sys_io.trace("cellKbGetInfo(info=*0x%x)", info);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -257,9 +257,9 @@ error_code cellKbGetInfo(vm::ptr<CellKbInfo> info)
std::memset(info.get_ptr(), 0, info.size());
std::lock_guard<std::mutex> lock(handler->m_mutex);
std::lock_guard<std::mutex> lock(handler.m_mutex);
const KbInfo& current_info = handler->GetInfo();
const KbInfo& current_info = handler.GetInfo();
info->max_connect = current_info.max_connect;
info->now_connect = current_info.now_connect;
info->info = current_info.info;
@ -276,9 +276,9 @@ error_code cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
{
sys_io.trace("cellKbRead(port_no=%d, data=*0x%x)", port_no, data);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -286,14 +286,14 @@ error_code cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
if (port_no >= CELL_KB_MAX_KEYBOARDS || !data)
return CELL_KB_ERROR_INVALID_PARAMETER;
std::lock_guard<std::mutex> lock(handler->m_mutex);
std::lock_guard<std::mutex> lock(handler.m_mutex);
const KbInfo& current_info = handler->GetInfo();
const KbInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
if (port_no >= handler.GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
return CELL_KB_ERROR_NO_DEVICE;
KbData& current_data = handler->GetData(port_no);
KbData& current_data = handler.GetData(port_no);
data->led = current_data.led;
data->mkey = current_data.mkey;
data->len = std::min<s32>(CELL_KB_MAX_KEYCODES, current_data.len);
@ -310,9 +310,9 @@ error_code cellKbSetCodeType(u32 port_no, u32 type)
{
sys_io.trace("cellKbSetCodeType(port_no=%d, type=%d)", port_no, type);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -320,12 +320,12 @@ error_code cellKbSetCodeType(u32 port_no, u32 type)
if (port_no >= CELL_KB_MAX_KEYBOARDS || type > CELL_KB_CODETYPE_ASCII)
return CELL_KB_ERROR_INVALID_PARAMETER;
if (port_no >= handler->GetKeyboards().size())
if (port_no >= handler.GetKeyboards().size())
return CELL_OK;
std::lock_guard<std::mutex> lock(handler->m_mutex);
std::lock_guard<std::mutex> lock(handler.m_mutex);
KbConfig& current_config = handler->GetConfig(port_no);
KbConfig& current_config = handler.GetConfig(port_no);
current_config.code_type = type;
// can also return CELL_KB_ERROR_SYS_SETTING_FAILED
@ -337,9 +337,9 @@ error_code cellKbSetLEDStatus(u32 port_no, u8 led)
{
sys_io.trace("cellKbSetLEDStatus(port_no=%d, led=%d)", port_no, led);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -350,12 +350,12 @@ error_code cellKbSetLEDStatus(u32 port_no, u8 led)
if (led > 7)
return CELL_KB_ERROR_SYS_SETTING_FAILED;
if (port_no >= handler->GetKeyboards().size() || handler->GetInfo().status[port_no] != CELL_KB_STATUS_CONNECTED)
if (port_no >= handler.GetKeyboards().size() || handler.GetInfo().status[port_no] != CELL_KB_STATUS_CONNECTED)
return CELL_KB_ERROR_FATAL;
std::lock_guard<std::mutex> lock(handler->m_mutex);
std::lock_guard<std::mutex> lock(handler.m_mutex);
KbData& current_data = handler->GetData(port_no);
KbData& current_data = handler.GetData(port_no);
current_data.led = static_cast<u32>(led);
return CELL_OK;
@ -365,9 +365,9 @@ error_code cellKbSetReadMode(u32 port_no, u32 rmode)
{
sys_io.trace("cellKbSetReadMode(port_no=%d, rmode=%d)", port_no, rmode);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -375,12 +375,12 @@ error_code cellKbSetReadMode(u32 port_no, u32 rmode)
if (port_no >= CELL_KB_MAX_KEYBOARDS || rmode > CELL_KB_RMODE_PACKET)
return CELL_KB_ERROR_INVALID_PARAMETER;
if (port_no >= handler->GetKeyboards().size())
if (port_no >= handler.GetKeyboards().size())
return CELL_OK;
std::lock_guard<std::mutex> lock(handler->m_mutex);
std::lock_guard<std::mutex> lock(handler.m_mutex);
KbConfig& current_config = handler->GetConfig(port_no);
KbConfig& current_config = handler.GetConfig(port_no);
current_config.read_mode = rmode;
// can also return CELL_KB_ERROR_SYS_SETTING_FAILED
@ -392,9 +392,9 @@ error_code cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config)
{
sys_io.trace("cellKbGetConfiguration(port_no=%d, config=*0x%x)", port_no, config);
const auto handler = g_fxo->get<KeyboardHandlerBase>();
auto& handler = g_fxo->get<KeyboardHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_KB_ERROR_UNINITIALIZED;
@ -402,18 +402,18 @@ error_code cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config)
if (port_no >= CELL_KB_MAX_KEYBOARDS)
return CELL_KB_ERROR_INVALID_PARAMETER;
std::lock_guard<std::mutex> lock(handler->m_mutex);
std::lock_guard<std::mutex> lock(handler.m_mutex);
const KbInfo& current_info = handler->GetInfo();
const KbInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
if (port_no >= handler.GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
return CELL_KB_ERROR_NO_DEVICE;
// tests show that config is checked only after the device's status
if (!config)
return CELL_KB_ERROR_INVALID_PARAMETER;
const KbConfig& current_config = handler->GetConfig(port_no);
const KbConfig& current_config = handler.GetConfig(port_no);
config->arrange = current_config.arrange;
config->read_mode = current_config.read_mode;
config->code_type = current_config.code_type;

View File

@ -503,13 +503,13 @@ error_code cellMicInit()
{
cellMic.notice("cellMicInit()");
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (mic_thr.init)
return CELL_MICIN_ERROR_ALREADY_INIT;
mic_thr->load_config_and_init();
mic_thr->init = 1;
mic_thr.load_config_and_init();
mic_thr.init = 1;
return CELL_OK;
}
@ -518,14 +518,14 @@ error_code cellMicEnd(ppu_thread& ppu)
{
cellMic.notice("cellMicEnd()");
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
// TODO
mic_thr->init = 0;
mic_thr->event_queue_key = 0;
mic_thr.init = 0;
mic_thr.event_queue_key = 0;
return CELL_OK;
}
@ -536,15 +536,15 @@ error_code cellMicOpen(s32 dev_num, s32 sampleRate)
{
cellMic.trace("cellMicOpen(dev_num=%d sampleRate=%d)", dev_num, sampleRate);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
if (device.is_opened())
return CELL_MICIN_ERROR_ALREADY_OPEN;
@ -556,15 +556,15 @@ error_code cellMicOpenRaw(s32 dev_num, s32 sampleRate, s32 maxChannels)
{
cellMic.trace("cellMicOpenRaw(dev_num=%d, sampleRate=%d, maxChannels=%d)", dev_num, sampleRate, maxChannels);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
if (device.is_opened())
return CELL_MICIN_ERROR_ALREADY_OPEN;
@ -577,15 +577,15 @@ error_code cellMicOpenEx(s32 dev_num, s32 rawSampleRate, s32 rawChannel, s32 DSP
cellMic.trace("cellMicOpenEx(dev_num=%d, rawSampleRate=%d, rawChannel=%d, DSPSampleRate=%d, bufferSizeMS=%d, signalType=0x%x)",
dev_num, rawSampleRate, rawChannel, DSPSampleRate, bufferSizeMS, signalType);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
if (device.is_opened())
return CELL_MICIN_ERROR_ALREADY_OPEN;
@ -599,15 +599,15 @@ u8 cellMicIsOpen(s32 dev_num)
{
cellMic.trace("cellMicIsOpen(dev_num=%d)", dev_num);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return false;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return false;
return mic_thr->mic_list.at(dev_num).is_opened();
return mic_thr.mic_list.at(dev_num).is_opened();
}
s32 cellMicIsAttached(s32 dev_num)
@ -620,15 +620,15 @@ error_code cellMicClose(s32 dev_num)
{
cellMic.trace("cellMicClose(dev_num=%d)", dev_num);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
if (!device.is_opened())
return CELL_MICIN_ERROR_NOT_OPEN;
@ -642,15 +642,15 @@ error_code cellMicStart(s32 dev_num)
{
cellMic.trace("cellMicStart(dev_num=%d)", dev_num);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
if (!device.is_opened())
return CELL_MICIN_ERROR_NOT_OPEN;
@ -664,15 +664,15 @@ error_code cellMicStartEx(s32 dev_num, u32 iflags)
// TODO: flags
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
if (!device.is_opened())
return CELL_MICIN_ERROR_NOT_OPEN;
@ -686,15 +686,15 @@ error_code cellMicStop(s32 dev_num)
{
cellMic.trace("cellMicStop(dev_num=%d)", dev_num);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
if (!device.is_opened())
return CELL_MICIN_ERROR_NOT_OPEN;
@ -716,15 +716,15 @@ error_code cellMicGetDeviceAttr(s32 dev_num, CellMicDeviceAttr deviceAttributes,
if (!arg1 || (!arg2 && deviceAttributes == CELLMIC_DEVATTR_CHANVOL))
return CELL_MICIN_ERROR_PARAM;
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
switch (deviceAttributes)
{
@ -744,15 +744,15 @@ error_code cellMicSetDeviceAttr(s32 dev_num, CellMicDeviceAttr deviceAttributes,
{
cellMic.trace("cellMicSetDeviceAttr(dev_num=%d, deviceAttributes=%d, arg1=%d, arg2=%d)", dev_num, +deviceAttributes, arg1, arg2);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
switch (deviceAttributes)
{
@ -789,9 +789,9 @@ error_code cellMicGetSignalState(s32 dev_num, CellMicSignalState sig_state, vm::
{
cellMic.todo("cellMicGetSignalState(dev_num=%d, sig_state=%d, value=*0x%x)", dev_num, +sig_state, value);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
be_t<u32>* ival = vm::_ptr<u32>(value.addr());
@ -827,15 +827,15 @@ error_code cellMicGetFormatRaw(s32 dev_num, vm::ptr<CellMicInputFormatI> format)
{
cellMic.trace("cellMicGetFormatRaw(dev_num=%d, format=0x%x)", dev_num, format);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& device = mic_thr->mic_list.at(dev_num);
auto& device = mic_thr.mic_list.at(dev_num);
format->subframeSize = device.get_bit_resolution() / 8; // Probably?
format->bitResolution = device.get_bit_resolution();
@ -866,9 +866,9 @@ error_code cellMicSetNotifyEventQueue(u64 key)
{
cellMic.todo("cellMicSetNotifyEventQueue(key=0x%llx)", key);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
// default mic queue size = 4
@ -876,9 +876,9 @@ error_code cellMicSetNotifyEventQueue(u64 key)
if (!mic_queue)
return CELL_MICIN_ERROR_EVENT_QUEUE;
mic_thr->event_queue_key = key;
mic_thr.event_queue_key = key;
for (auto& mic_entry : mic_thr->mic_list)
for (auto& mic_entry : mic_thr.mic_list)
{
mic_queue->send(0, CELLMIC_ATTACH, mic_entry.first, 0);
}
@ -891,9 +891,9 @@ error_code cellMicSetNotifyEventQueue2(u64 key, u64 source, u64 flag)
// TODO: Actually do things with the source variable
cellMic.todo("cellMicSetNotifyEventQueue2(key=0x%llx, source=0x%llx, flag=0x%llx", key, source, flag);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
// default mic queue size = 4
@ -902,7 +902,7 @@ error_code cellMicSetNotifyEventQueue2(u64 key, u64 source, u64 flag)
return CELL_MICIN_ERROR_EVENT_QUEUE;
mic_queue->send(0, CELLMIC_ATTACH, 0, 0);
mic_thr->event_queue_key = key;
mic_thr.event_queue_key = key;
return CELL_OK;
}
@ -911,12 +911,12 @@ error_code cellMicRemoveNotifyEventQueue(u64 key)
{
cellMic.warning("cellMicRemoveNotifyEventQueue(key=0x%llx)", key);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
mic_thr->event_queue_key = 0;
mic_thr.event_queue_key = 0;
return CELL_OK;
}
@ -927,15 +927,15 @@ error_code cellMicReadRaw(s32 dev_num, vm::ptr<void> data, s32 max_bytes)
{
cellMic.trace("cellMicReadRaw(dev_num=%d, data=0x%x, maxBytes=%d)", dev_num, data, max_bytes);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& mic = mic_thr->mic_list.at(dev_num);
auto& mic = mic_thr.mic_list.at(dev_num);
if (!mic.is_opened() || !(mic.get_signal_types() & CELLMIC_SIGTYPE_RAW))
return CELL_MICIN_ERROR_NOT_OPEN;
@ -947,15 +947,15 @@ error_code cellMicRead(s32 dev_num, vm::ptr<void> data, u32 max_bytes)
{
cellMic.todo("cellMicRead(dev_num=%d, data=0x%x, maxBytes=0x%x)", dev_num, data, max_bytes);
const auto mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr->mutex);
if (!mic_thr->init)
auto& mic_thr = g_fxo->get<mic_thread>();
const std::lock_guard lock(mic_thr.mutex);
if (!mic_thr.init)
return CELL_MICIN_ERROR_NOT_INIT;
if (!mic_thr->mic_list.count(dev_num))
if (!mic_thr.mic_list.count(dev_num))
return CELL_MICIN_ERROR_DEVICE_NOT_FOUND;
auto& mic = mic_thr->mic_list.at(dev_num);
auto& mic = mic_thr.mic_list.at(dev_num);
if (!mic.is_opened() || !(mic.get_signal_types() & CELLMIC_SIGTYPE_DSP))
return CELL_MICIN_ERROR_NOT_OPEN;

View File

@ -36,9 +36,9 @@ error_code cellMouseInit(u32 max_connect)
{
sys_io.warning("cellMouseInit(max_connect=%d)", max_connect);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.init();
const auto init = handler.init.init();
if (!init)
return CELL_MOUSE_ERROR_ALREADY_INITIALIZED;
@ -49,7 +49,7 @@ error_code cellMouseInit(u32 max_connect)
}
libio_sys_config_init();
handler->Init(std::min(max_connect, 7u));
handler.Init(std::min(max_connect, 7u));
return CELL_OK;
}
@ -58,9 +58,9 @@ error_code cellMouseClearBuf(u32 port_no)
{
sys_io.trace("cellMouseClearBuf(port_no=%d)", port_no);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -70,17 +70,17 @@ error_code cellMouseClearBuf(u32 port_no)
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
const MouseInfo& current_info = handler->GetInfo();
const MouseInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
}
handler->GetDataList(port_no).clear();
handler->GetTabletDataList(port_no).clear();
handler.GetDataList(port_no).clear();
handler.GetTabletDataList(port_no).clear();
MouseRawData& raw_data = handler->GetRawData(port_no);
MouseRawData& raw_data = handler.GetRawData(port_no);
raw_data.len = 0;
for (int i = 0; i < CELL_MOUSE_MAX_CODES; i++)
@ -95,9 +95,9 @@ error_code cellMouseEnd()
{
sys_io.notice("cellMouseEnd()");
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.reset();
const auto init = handler.init.reset();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -111,9 +111,9 @@ error_code cellMouseGetInfo(vm::ptr<CellMouseInfo> info)
{
sys_io.trace("cellMouseGetInfo(info=*0x%x)", info);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -125,7 +125,7 @@ error_code cellMouseGetInfo(vm::ptr<CellMouseInfo> info)
std::memset(info.get_ptr(), 0, info.size());
const MouseInfo& current_info = handler->GetInfo();
const MouseInfo& current_info = handler.GetInfo();
info->max_connect = current_info.max_connect;
info->now_connect = current_info.now_connect;
info->info = current_info.info;
@ -144,9 +144,9 @@ error_code cellMouseInfoTabletMode(u32 port_no, vm::ptr<CellMouseInfoTablet> inf
{
sys_io.trace("cellMouseInfoTabletMode(port_no=%d, info=*0x%x)", port_no, info);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -157,9 +157,9 @@ error_code cellMouseInfoTabletMode(u32 port_no, vm::ptr<CellMouseInfoTablet> inf
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
const MouseInfo& current_info = handler->GetInfo();
const MouseInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_FATAL;
}
@ -181,9 +181,9 @@ error_code cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)
{
sys_io.trace("cellMouseGetData(port_no=%d, data=*0x%x)", port_no, data);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -193,11 +193,11 @@ error_code cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
std::lock_guard lock(handler->mutex);
std::lock_guard lock(handler.mutex);
const MouseInfo& current_info = handler->GetInfo();
const MouseInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
}
@ -206,7 +206,7 @@ error_code cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_MOUSE_MODE) has any impact
MouseDataList& data_list = handler->GetDataList(port_no);
MouseDataList& data_list = handler.GetDataList(port_no);
if (data_list.empty())
{
@ -230,9 +230,9 @@ error_code cellMouseGetDataList(u32 port_no, vm::ptr<CellMouseDataList> data)
{
sys_io.warning("cellMouseGetDataList(port_no=%d, data=0x%x)", port_no, data);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -242,18 +242,18 @@ error_code cellMouseGetDataList(u32 port_no, vm::ptr<CellMouseDataList> data)
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
std::lock_guard lock(handler->mutex);
std::lock_guard lock(handler.mutex);
const MouseInfo& current_info = handler->GetInfo();
const MouseInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
}
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_MOUSE_MODE) has any impact
auto& list = handler->GetDataList(port_no);
auto& list = handler.GetDataList(port_no);
data->list_num = std::min<u32>(CELL_MOUSE_MAX_DATA_LIST_NUM, static_cast<u32>(list.size()));
int i = 0;
@ -276,9 +276,9 @@ error_code cellMouseSetTabletMode(u32 port_no, u32 mode)
{
sys_io.warning("cellMouseSetTabletMode(port_no=%d, mode=%d)", port_no, mode);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -289,9 +289,9 @@ error_code cellMouseSetTabletMode(u32 port_no, u32 mode)
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
MouseInfo& current_info = handler->GetInfo();
MouseInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_FATAL;
}
@ -312,9 +312,9 @@ error_code cellMouseGetTabletDataList(u32 port_no, vm::ptr<CellMouseTabletDataLi
{
sys_io.warning("cellMouseGetTabletDataList(port_no=%d, data=0x%x)", port_no, data);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -324,9 +324,9 @@ error_code cellMouseGetTabletDataList(u32 port_no, vm::ptr<CellMouseTabletDataLi
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
const MouseInfo& current_info = handler->GetInfo();
const MouseInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
}
@ -334,7 +334,7 @@ error_code cellMouseGetTabletDataList(u32 port_no, vm::ptr<CellMouseTabletDataLi
// TODO: decr tests show that CELL_MOUSE_ERROR_DATA_READ_FAILED is returned when a mouse is connected
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_TABLET_MODE) has any impact
auto& list = handler->GetTabletDataList(port_no);
auto& list = handler.GetTabletDataList(port_no);
data->list_num = std::min<u32>(CELL_MOUSE_MAX_DATA_LIST_NUM, static_cast<u32>(list.size()));
int i = 0;
@ -357,9 +357,9 @@ error_code cellMouseGetRawData(u32 port_no, vm::ptr<CellMouseRawData> data)
{
sys_io.warning("cellMouseGetRawData(port_no=%d, data=*0x%x)", port_no, data);
const auto handler = g_fxo->get<MouseHandlerBase>();
auto& handler = g_fxo->get<MouseHandlerBase>();
const auto init = handler->init.access();
const auto init = handler.init.access();
if (!init)
return CELL_MOUSE_ERROR_UNINITIALIZED;
@ -369,9 +369,9 @@ error_code cellMouseGetRawData(u32 port_no, vm::ptr<CellMouseRawData> data)
return CELL_MOUSE_ERROR_INVALID_PARAMETER;
}
const MouseInfo& current_info = handler->GetInfo();
const MouseInfo& current_info = handler.GetInfo();
if (port_no >= handler->GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
}
@ -379,7 +379,7 @@ error_code cellMouseGetRawData(u32 port_no, vm::ptr<CellMouseRawData> data)
// TODO: decr tests show that CELL_MOUSE_ERROR_DATA_READ_FAILED is returned when a mouse is connected
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_MOUSE_MODE) has any impact
MouseRawData& current_data = handler->GetRawData(port_no);
MouseRawData& current_data = handler.GetRawData(port_no);
data->len = current_data.len;
current_data.len = 0;

View File

@ -119,7 +119,7 @@ struct msg_dlg_thread_info
dlg->close(true, true);
}
}
else if (const auto dlg = g_fxo->get<msg_info>()->get())
else if (const auto dlg = g_fxo->get<msg_info>().get())
{
if (!wait_until.compare_and_swap_test(new_value, 0))
{
@ -173,7 +173,7 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
return res;
}
const auto dlg = g_fxo->get<msg_info>()->make();
const auto dlg = g_fxo->get<msg_info>().make();
if (!dlg)
{
@ -197,8 +197,8 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
});
}
g_fxo->get<msg_dlg_thread>()->wait_until = 0;
g_fxo->get<msg_info>()->remove();
g_fxo->get<msg_dlg_thread>().wait_until = 0;
g_fxo->get<msg_info>().remove();
}
input::SetIntercepted(false);
@ -234,7 +234,7 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
if (is_blocking)
{
while (auto dlg = g_fxo->get<msg_info>()->get())
while (auto dlg = g_fxo->get<msg_info>().get())
{
if (Emu.IsStopped() || dlg->state != MsgDialogState::Open)
{
@ -437,25 +437,25 @@ error_code cellMsgDialogClose(f32 delay)
{
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
const auto thr = g_fxo->get<msg_dlg_thread>();
thr->wait_until = wait_until;
thr->wait_until.notify_one();
auto& thr = g_fxo->get<msg_dlg_thread>();
thr.wait_until = wait_until;
thr.wait_until.notify_one();
return CELL_OK;
}
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
}
const auto dlg = g_fxo->get<msg_info>()->get();
const auto dlg = g_fxo->get<msg_info>().get();
if (!dlg)
{
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
}
const auto thr = g_fxo->get<msg_dlg_thread>();
thr->wait_until = wait_until;
thr->wait_until.notify_one();
auto& thr = g_fxo->get<msg_dlg_thread>();
thr.wait_until = wait_until;
thr.wait_until.notify_one();
return CELL_OK;
}
@ -467,13 +467,13 @@ error_code cellMsgDialogAbort()
{
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
g_fxo->get<msg_dlg_thread>()->wait_until = 0;
g_fxo->get<msg_dlg_thread>().wait_until = 0;
dlg->close(false, true);
return CELL_OK;
}
}
const auto dlg = g_fxo->get<msg_info>()->get();
const auto dlg = g_fxo->get<msg_info>().get();
if (!dlg)
{
@ -485,8 +485,8 @@ error_code cellMsgDialogAbort()
return CELL_SYSUTIL_ERROR_BUSY;
}
g_fxo->get<msg_dlg_thread>()->wait_until = 0;
g_fxo->get<msg_info>()->remove(); // this shouldn't call on_close
g_fxo->get<msg_dlg_thread>().wait_until = 0;
g_fxo->get<msg_info>().remove(); // this shouldn't call on_close
input::SetIntercepted(false); // so we need to reenable the pads here
return CELL_OK;
@ -522,7 +522,7 @@ error_code cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr<char> m
}
}
const auto dlg = g_fxo->get<msg_info>()->get();
const auto dlg = g_fxo->get<msg_info>().get();
if (!dlg)
{
@ -554,7 +554,7 @@ error_code cellMsgDialogProgressBarReset(u32 progressBarIndex)
}
}
const auto dlg = g_fxo->get<msg_info>()->get();
const auto dlg = g_fxo->get<msg_info>().get();
if (!dlg)
{
@ -586,7 +586,7 @@ error_code cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta)
}
}
const auto dlg = g_fxo->get<msg_info>()->get();
const auto dlg = g_fxo->get<msg_info>().get();
if (!dlg)
{

View File

@ -84,14 +84,14 @@ error_code cellMusicSetSelectionContext2(vm::ptr<CellMusicSelectionContext> cont
if (!context)
return CELL_MUSIC2_ERROR_PARAM;
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC2_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC2_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC2_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
@ -104,14 +104,14 @@ error_code cellMusicSetVolume2(f32 level)
level = std::clamp(level, 0.0f, 1.0f);
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC2_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC2_EVENT_SET_VOLUME_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC2_EVENT_SET_VOLUME_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
@ -135,14 +135,14 @@ error_code cellMusicSetSelectionContext(vm::ptr<CellMusicSelectionContext> conte
if (!context)
return CELL_MUSIC_ERROR_PARAM;
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
@ -162,13 +162,13 @@ error_code cellMusicInitialize2SystemWorkload(s32 mode, vm::ptr<CellMusic2Callba
return CELL_MUSIC2_ERROR_PARAM;
}
const auto music = g_fxo->get<music_state>();
music->func = func;
music->userData = userData;
auto& music = g_fxo->get<music_state>();
music.func = func;
music.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
music.func(ppu, CELL_MUSIC2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -199,13 +199,13 @@ error_code cellMusicFinalize()
{
cellMusic.todo("cellMusicFinalize()");
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (music->func)
if (music.func)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
}
@ -226,13 +226,13 @@ error_code cellMusicInitializeSystemWorkload(s32 mode, u32 container, vm::ptr<Ce
return CELL_MUSIC_ERROR_PARAM;
}
const auto music = g_fxo->get<music_state>();
music->func = func;
music->userData = userData;
auto& music = g_fxo->get<music_state>();
music.func = func;
music.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
music.func(ppu, CELL_MUSIC_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -252,13 +252,13 @@ error_code cellMusicInitialize(s32 mode, u32 container, s32 spuPriority, vm::ptr
return CELL_MUSIC_ERROR_PARAM;
}
const auto music = g_fxo->get<music_state>();
music->func = func;
music->userData = userData;
auto& music = g_fxo->get<music_state>();
music.func = func;
music.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
music.func(ppu, CELL_MUSIC_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -269,13 +269,13 @@ error_code cellMusicFinalize2()
{
cellMusic.todo("cellMusicFinalize2()");
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (music->func)
if (music.func)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC2_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC2_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
}
@ -320,14 +320,14 @@ error_code cellMusicSetPlaybackCommand2(s32 command, vm::ptr<void> param)
if (command < CELL_MUSIC_PB_CMD_STOP || command > CELL_MUSIC_PB_CMD_FASTREVERSE)
return CELL_MUSIC2_ERROR_PARAM;
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC2_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC2_EVENT_SET_PLAYBACK_COMMAND_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC2_EVENT_SET_PLAYBACK_COMMAND_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
@ -341,14 +341,14 @@ error_code cellMusicSetPlaybackCommand(s32 command, vm::ptr<void> param)
if (command < CELL_MUSIC_PB_CMD_STOP || command > CELL_MUSIC_PB_CMD_FASTREVERSE)
return CELL_MUSIC_ERROR_PARAM;
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC_EVENT_SET_PLAYBACK_COMMAND_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC_EVENT_SET_PLAYBACK_COMMAND_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
@ -359,14 +359,14 @@ error_code cellMusicSelectContents2()
{
cellMusic.todo("cellMusicSelectContents2()");
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC2_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC2_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC2_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
@ -377,14 +377,14 @@ error_code cellMusicSelectContents(u32 container)
{
cellMusic.todo("cellMusicSelectContents(container=0x%x)", container);
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
@ -404,13 +404,13 @@ error_code cellMusicInitialize2(s32 mode, s32 spuPriority, vm::ptr<CellMusic2Cal
return CELL_MUSIC2_ERROR_PARAM;
}
const auto music = g_fxo->get<music_state>();
music->func = func;
music->userData = userData;
auto& music = g_fxo->get<music_state>();
music.func = func;
music.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
music.func(ppu, CELL_MUSIC2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -423,14 +423,14 @@ error_code cellMusicSetVolume(f32 level)
level = std::clamp(level, 0.0f, 1.0f);
const auto music = g_fxo->get<music_state>();
auto& music = g_fxo->get<music_state>();
if (!music->func)
if (!music.func)
return CELL_MUSIC_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music->func(ppu, CELL_MUSIC_EVENT_SET_VOLUME_RESULT, vm::addr_t(CELL_OK), music->userData);
music.func(ppu, CELL_MUSIC_EVENT_SET_VOLUME_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});

View File

@ -99,13 +99,13 @@ error_code cellMusicDecodeInitialize(s32 mode, u32 container, s32 spuPriority, v
{
cellMusicDecode.todo("cellMusicDecodeInitialize(mode=0x%x, container=0x%x, spuPriority=0x%x, func=*0x%x, userData=*0x%x)", mode, container, spuPriority, func, userData);
const auto musicDecode = g_fxo->get<music_decode>();
musicDecode->func = func;
musicDecode->userData = userData;
auto& dec = g_fxo->get<music_decode>();
dec.func = func;
dec.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
dec.func(ppu, CELL_MUSIC_DECODE_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -116,13 +116,13 @@ error_code cellMusicDecodeInitializeSystemWorkload(s32 mode, u32 container, vm::
{
cellMusicDecode.todo("cellMusicDecodeInitializeSystemWorkload(mode=0x%x, container=0x%x, func=*0x%x, userData=*0x%x, spuUsageRate=0x%x, spurs=*0x%x, priority=*0x%x, attr=*0x%x)", mode, container, func, userData, spuUsageRate, spurs, priority, attr);
const auto musicDecode = g_fxo->get<music_decode>();
musicDecode->func = func;
musicDecode->userData = userData;
auto& dec = g_fxo->get<music_decode>();
dec.func = func;
dec.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
dec.func(ppu, CELL_MUSIC_DECODE_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -133,13 +133,13 @@ error_code cellMusicDecodeFinalize()
{
cellMusicDecode.todo("cellMusicDecodeFinalize()");
const auto musicDecode = g_fxo->get<music_decode>();
auto& dec = g_fxo->get<music_decode>();
if (musicDecode->func)
if (dec.func)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});
}
@ -151,14 +151,14 @@ error_code cellMusicDecodeSelectContents()
{
cellMusicDecode.todo("cellMusicDecodeSelectContents()");
const auto musicDecode = g_fxo->get<music_decode>();
auto& dec = g_fxo->get<music_decode>();
if (!musicDecode->func)
if (!dec.func)
return CELL_MUSIC_DECODE_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});
@ -169,14 +169,14 @@ error_code cellMusicDecodeSetDecodeCommand(s32 command)
{
cellMusicDecode.todo("cellMusicDecodeSetDecodeCommand(command=0x%x)", command);
const auto musicDecode = g_fxo->get<music_decode>();
auto& dec = g_fxo->get<music_decode>();
if (!musicDecode->func)
if (!dec.func)
return CELL_MUSIC_DECODE_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE_EVENT_SET_DECODE_COMMAND_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE_EVENT_SET_DECODE_COMMAND_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});
@ -205,14 +205,14 @@ error_code cellMusicDecodeSetSelectionContext(vm::ptr<CellMusicSelectionContext>
{
cellMusicDecode.todo("cellMusicDecodeSetSelectionContext(context=*0x%x)", context);
const auto musicDecode = g_fxo->get<music_decode>();
auto& dec = g_fxo->get<music_decode>();
if (!musicDecode->func)
if (!dec.func)
return CELL_MUSIC_DECODE_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});
@ -229,13 +229,13 @@ error_code cellMusicDecodeInitialize2(s32 mode, u32 container, s32 spuPriority,
{
cellMusicDecode.todo("cellMusicDecodeInitialize2(mode=0x%x, container=0x%x, spuPriority=0x%x, func=*0x%x, userData=*0x%x, speed=0x%x, bufsize=0x%x)", mode, container, spuPriority, func, userData, speed, bufsize);
const auto musicDecode = g_fxo->get<music_decode2>();
musicDecode->func = func;
musicDecode->userData = userData;
auto& dec = g_fxo->get<music_decode2>();
dec.func = func;
dec.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
dec.func(ppu, CELL_MUSIC_DECODE2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -246,13 +246,13 @@ error_code cellMusicDecodeInitialize2SystemWorkload(s32 mode, u32 container, vm:
{
cellMusicDecode.todo("cellMusicDecodeInitialize2SystemWorkload(mode=0x%x, container=0x%x, func=*0x%x, userData=*0x%x, spuUsageRate=0x%x, bufsize=0x%x, spurs=*0x%x, priority=*0x%x, attr=*0x%x)", mode, container, func, userData, spuUsageRate, bufsize, spurs, priority, attr);
const auto musicDecode = g_fxo->get<music_decode2>();
musicDecode->func = func;
musicDecode->userData = userData;
auto& dec = g_fxo->get<music_decode2>();
dec.func = func;
dec.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
dec.func(ppu, CELL_MUSIC_DECODE2_EVENT_INITIALIZE_RESULT, vm::addr_t(CELL_OK), userData);
return CELL_OK;
});
@ -263,13 +263,13 @@ error_code cellMusicDecodeFinalize2()
{
cellMusicDecode.todo("cellMusicDecodeFinalize2()");
const auto musicDecode = g_fxo->get<music_decode2>();
auto& dec = g_fxo->get<music_decode2>();
if (musicDecode->func)
if (dec.func)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE2_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE2_EVENT_FINALIZE_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});
}
@ -281,14 +281,14 @@ error_code cellMusicDecodeSelectContents2()
{
cellMusicDecode.todo("cellMusicDecodeSelectContents2()");
const auto musicDecode = g_fxo->get<music_decode2>();
auto& dec = g_fxo->get<music_decode2>();
if (!musicDecode->func)
if (!dec.func)
return CELL_MUSIC_DECODE_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE2_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE2_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});
@ -299,14 +299,14 @@ error_code cellMusicDecodeSetDecodeCommand2(s32 command)
{
cellMusicDecode.todo("cellMusicDecodeSetDecodeCommand2(command=0x%x)", command);
const auto musicDecode = g_fxo->get<music_decode2>();
auto& dec = g_fxo->get<music_decode2>();
if (!musicDecode->func)
if (!dec.func)
return CELL_MUSIC_DECODE_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE2_EVENT_SET_DECODE_COMMAND_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE2_EVENT_SET_DECODE_COMMAND_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});
@ -335,14 +335,14 @@ error_code cellMusicDecodeSetSelectionContext2(vm::ptr<CellMusicSelectionContext
{
cellMusicDecode.todo("cellMusicDecodeSetSelectionContext2(context=*0x%x)", context);
const auto musicDecode = g_fxo->get<music_decode2>();
auto& dec = g_fxo->get<music_decode2>();
if (!musicDecode->func)
if (!dec.func)
return CELL_MUSIC_DECODE_ERROR_GENERIC;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &dec](ppu_thread& ppu) -> s32
{
musicDecode->func(ppu, CELL_MUSIC_DECODE2_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), musicDecode->userData);
dec.func(ppu, CELL_MUSIC_DECODE2_EVENT_SET_SELECTION_CONTEXT_RESULT, vm::addr_t(CELL_OK), dec.userData);
return CELL_OK;
});

View File

@ -96,14 +96,14 @@ error_code cellNetCtlInit()
{
cellNetCtl.warning("cellNetCtlInit()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (nph->is_netctl_init)
if (nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_TERMINATED;
}
nph->is_netctl_init = true;
nph.is_netctl_init = true;
return CELL_OK;
}
@ -112,17 +112,18 @@ void cellNetCtlTerm()
{
cellNetCtl.warning("cellNetCtlTerm()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
nph->is_netctl_init = false;
auto& nph = g_fxo->get<named_thread<np_handler>>();
nph.is_netctl_init = false;
}
error_code cellNetCtlGetState(vm::ptr<s32> state)
{
cellNetCtl.trace("cellNetCtlGetState(state=*0x%x)", state);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}
@ -132,7 +133,7 @@ error_code cellNetCtlGetState(vm::ptr<s32> state)
return CELL_NET_CTL_ERROR_INVALID_ADDR;
}
*state = nph->get_net_status();
*state = nph.get_net_status();
return CELL_OK;
}
@ -141,9 +142,9 @@ error_code cellNetCtlAddHandler(vm::ptr<cellNetCtlHandler> handler, vm::ptr<void
{
cellNetCtl.todo("cellNetCtlAddHandler(handler=*0x%x, arg=*0x%x, hid=*0x%x)", handler, arg, hid);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}
@ -160,9 +161,9 @@ error_code cellNetCtlDelHandler(s32 hid)
{
cellNetCtl.todo("cellNetCtlDelHandler(hid=0x%x)", hid);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}
@ -179,9 +180,9 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
{
cellNetCtl.warning("cellNetCtlGetInfo(code=0x%x (%s), info=*0x%x)", code, InfoCodeToName(code), info);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}
@ -193,11 +194,11 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
if (code == CELL_NET_CTL_INFO_ETHER_ADDR)
{
memcpy(info->ether_addr.data, nph->get_ether_addr().data(), 6);
memcpy(info->ether_addr.data, nph.get_ether_addr().data(), 6);
return CELL_OK;
}
if (nph->get_net_status() == CELL_NET_CTL_STATE_Disconnected)
if (nph.get_net_status() == CELL_NET_CTL_STATE_Disconnected)
{
return CELL_NET_CTL_ERROR_NOT_CONNECTED;
}
@ -211,12 +212,12 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
case CELL_NET_CTL_INFO_LINK_TYPE: info->link_type = CELL_NET_CTL_LINK_TYPE_10BASE_FULL; break;
case CELL_NET_CTL_INFO_IP_CONFIG: info->ip_config = CELL_NET_CTL_IP_STATIC; break;
case CELL_NET_CTL_INFO_DEFAULT_ROUTE: strcpy_trunc(info->default_route, "192.168.1.1"); break;
case CELL_NET_CTL_INFO_PRIMARY_DNS: strcpy_trunc(info->primary_dns, np_handler::ip_to_string(nph->get_dns_ip())); break;
case CELL_NET_CTL_INFO_SECONDARY_DNS: strcpy_trunc(info->secondary_dns, np_handler::ip_to_string(nph->get_dns_ip())); break;
case CELL_NET_CTL_INFO_IP_ADDRESS: strcpy_trunc(info->ip_address, np_handler::ip_to_string(nph->get_local_ip_addr())); break;
case CELL_NET_CTL_INFO_PRIMARY_DNS: strcpy_trunc(info->primary_dns, np_handler::ip_to_string(nph.get_dns_ip())); break;
case CELL_NET_CTL_INFO_SECONDARY_DNS: strcpy_trunc(info->secondary_dns, np_handler::ip_to_string(nph.get_dns_ip())); break;
case CELL_NET_CTL_INFO_IP_ADDRESS: strcpy_trunc(info->ip_address, np_handler::ip_to_string(nph.get_local_ip_addr())); break;
case CELL_NET_CTL_INFO_NETMASK: strcpy_trunc(info->netmask, "255.255.255.255"); break;
case CELL_NET_CTL_INFO_HTTP_PROXY_CONFIG: info->http_proxy_config = 0; break;
case CELL_NET_CTL_INFO_DHCP_HOSTNAME: strcpy_trunc(info->dhcp_hostname, nph->get_hostname()); break;
case CELL_NET_CTL_INFO_DHCP_HOSTNAME: strcpy_trunc(info->dhcp_hostname, nph.get_hostname()); break;
default: cellNetCtl.error("Unsupported request: %s", InfoCodeToName(code)); break;
}
@ -240,9 +241,9 @@ error_code cellNetCtlNetStartDialogLoadAsync(vm::cptr<CellNetCtlNetStartDialogPa
{
cellNetCtl.error("cellNetCtlNetStartDialogLoadAsync(param=*0x%x)", param);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}
@ -263,7 +264,7 @@ error_code cellNetCtlNetStartDialogLoadAsync(vm::cptr<CellNetCtlNetStartDialogPa
}
// This is a hack for Diva F 2nd that registers the sysutil callback after calling this function.
g_fxo->get<named_thread<netstart_hack>>()->operator()(0);
g_fxo->get<named_thread<netstart_hack>>()(0);
return CELL_OK;
}
@ -272,9 +273,9 @@ error_code cellNetCtlNetStartDialogAbortAsync()
{
cellNetCtl.error("cellNetCtlNetStartDialogAbortAsync()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}
@ -286,9 +287,9 @@ error_code cellNetCtlNetStartDialogUnloadAsync(vm::ptr<CellNetCtlNetStartDialogR
{
cellNetCtl.warning("cellNetCtlNetStartDialogUnloadAsync(result=*0x%x)", result);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}
@ -303,7 +304,7 @@ error_code cellNetCtlNetStartDialogUnloadAsync(vm::ptr<CellNetCtlNetStartDialogR
return CELL_NET_CTL_ERROR_INVALID_SIZE;
}
result->result = nph->get_net_status() == CELL_NET_CTL_STATE_IPObtained ? 0 : CELL_NET_CTL_ERROR_DIALOG_CANCELED;
result->result = nph.get_net_status() == CELL_NET_CTL_STATE_IPObtained ? 0 : CELL_NET_CTL_ERROR_DIALOG_CANCELED;
sysutil_send_system_cmd(CELL_SYSUTIL_NET_CTL_NETSTART_UNLOADED, 0);
return CELL_OK;
@ -313,9 +314,9 @@ error_code cellNetCtlGetNatInfo(vm::ptr<CellNetCtlNatInfo> natInfo)
{
cellNetCtl.warning("cellNetCtlGetNatInfo(natInfo=*0x%x)", natInfo);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_netctl_init)
if (!nph.is_netctl_init)
{
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
}

View File

@ -53,11 +53,11 @@ struct osk_info
// TODO: don't use this function
std::shared_ptr<OskDialogBase> _get_osk_dialog(bool create = false)
{
const auto osk = g_fxo->get<osk_info>();
auto& osk = g_fxo->get<osk_info>();
if (create)
{
const auto init = osk->init.init();
const auto init = osk.init.init();
if (!init)
{
@ -67,25 +67,25 @@ std::shared_ptr<OskDialogBase> _get_osk_dialog(bool create = false)
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
{
std::shared_ptr<rsx::overlays::osk_dialog> dlg = std::make_shared<rsx::overlays::osk_dialog>();
osk->dlg = manager->add(dlg);
osk.dlg = manager->add(dlg);
}
else
{
osk->dlg = Emu.GetCallbacks().get_osk_dialog();
osk.dlg = Emu.GetCallbacks().get_osk_dialog();
}
return osk->dlg;
return osk.dlg;
}
else
{
const auto init = osk->init.access();
const auto init = osk.init.access();
if (!init)
{
return nullptr;
}
return osk->dlg;
return osk.dlg;
}
}
@ -164,7 +164,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
if (accepted)
{
if (auto ccb = g_fxo->get<osk_info>()->osk_confirm_callback.exchange({}))
if (auto ccb = g_fxo->get<osk_info>().osk_confirm_callback.exchange({}))
{
vm::ptr<u16> string_to_send = vm::cast(vm::alloc(CELL_OSKDIALOG_STRING_SIZE * 2, vm::main));
atomic_t<bool> done = false;
@ -198,7 +198,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
}
}
if (g_fxo->get<osk_info>()->use_separate_windows.load() && osk->osk_text[0] == 0)
if (g_fxo->get<osk_info>().use_separate_windows.load() && osk->osk_text[0] == 0)
{
cellOskDialog.warning("cellOskDialogLoadAsync: input result is CELL_OSKDIALOG_INPUT_FIELD_RESULT_NO_INPUT_TEXT");
osk->osk_input_result = CELL_OSKDIALOG_INPUT_FIELD_RESULT_NO_INPUT_TEXT;
@ -214,7 +214,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
}
// Send OSK status
if (g_fxo->get<osk_info>()->use_separate_windows.load() && (g_fxo->get<osk_info>()->osk_continuous_mode.load() != CELL_OSKDIALOG_CONTINUOUS_MODE_NONE))
if (g_fxo->get<osk_info>().use_separate_windows.load() && (g_fxo->get<osk_info>().osk_continuous_mode.load() != CELL_OSKDIALOG_CONTINUOUS_MODE_NONE))
{
if (accepted)
{
@ -237,7 +237,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
{
const auto osk = wptr.lock();
if (g_fxo->get<osk_info>()->use_separate_windows.load())
if (g_fxo->get<osk_info>().use_separate_windows.load())
{
sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_INPUT_ENTERED, 0);
}
@ -325,10 +325,10 @@ error_code getText(vm::ptr<CellOskDialogCallbackReturnParam> OutputInfo, bool is
if (is_unload)
{
// Unload should be called last, so remove the dialog here
if (const auto reset_lock = g_fxo->get<osk_info>()->init.reset())
if (const auto reset_lock = g_fxo->get<osk_info>().init.reset())
{
// TODO
g_fxo->get<osk_info>()->dlg.reset();
g_fxo->get<osk_info>().dlg.reset();
}
sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_UNLOADED, 0);
@ -422,10 +422,10 @@ error_code cellOskDialogSetSeparateWindowOption(vm::ptr<CellOskDialogSeparateWin
return CELL_OSKDIALOG_ERROR_PARAM;
}
if (const auto osk = g_fxo->get<osk_info>(); true)
if (auto& osk = g_fxo->get<osk_info>(); true)
{
osk->use_separate_windows = true;
osk->osk_continuous_mode = static_cast<CellOskDialogContinuousMode>(+windowOption->continuousMode);
osk.use_separate_windows = true;
osk.osk_continuous_mode = static_cast<CellOskDialogContinuousMode>(+windowOption->continuousMode);
}
return CELL_OK;
@ -583,9 +583,9 @@ error_code cellOskDialogExtRegisterConfirmWordFilterCallback(vm::ptr<cellOskDial
return CELL_OSKDIALOG_ERROR_PARAM;
}
if (const auto osk = g_fxo->get<osk_info>(); true)
if (auto& osk = g_fxo->get<osk_info>(); true)
{
osk->osk_confirm_callback = pCallback;
osk.osk_confirm_callback = pCallback;
}
return CELL_OK;

View File

@ -56,17 +56,17 @@ error_code cellPadInit(u32 max_connect)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (config->max_connect)
if (config.max_connect)
return CELL_PAD_ERROR_ALREADY_INITIALIZED;
if (max_connect == 0 || max_connect > CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
libio_sys_config_init();
config->max_connect = std::min<u32>(max_connect, CELL_PAD_MAX_PORT_NUM);
config->port_setting.fill(CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF);
config.max_connect = std::min<u32>(max_connect, CELL_PAD_MAX_PORT_NUM);
config.port_setting.fill(CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF);
return CELL_OK;
}
@ -76,9 +76,9 @@ error_code cellPadEnd()
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect.exchange(0))
if (!config.max_connect.exchange(0))
return CELL_PAD_ERROR_UNINITIALIZED;
libio_sys_config_end();
@ -112,9 +112,9 @@ error_code cellPadClearBuf(u32 port_no)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -124,7 +124,7 @@ error_code cellPadClearBuf(u32 port_no)
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -143,9 +143,9 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -155,7 +155,7 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -171,7 +171,7 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
return CELL_OK;
}
const auto setting = config->port_setting[port_no];
const auto setting = config.port_setting[port_no];
bool btnChanged = false;
if (rinfo.ignore_input)
@ -419,9 +419,9 @@ error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -433,7 +433,7 @@ error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
std::memset(info.get_ptr(), 0, sizeof(CellPadPeriphInfo));
info->max_connect = config->max_connect;
info->max_connect = config.max_connect;
info->now_connect = rinfo.now_connect;
info->system_info = rinfo.system_info;
@ -441,12 +441,12 @@ error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i)
{
if (i >= config->max_connect)
if (i >= config.max_connect)
break;
info->port_status[i] = pads[i]->m_port_status;
pads[i]->m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
info->port_setting[i] = config->port_setting[i];
info->port_setting[i] = config.port_setting[i];
info->device_capability[i] = pads[i]->m_device_capability;
info->device_type[i] = pads[i]->m_device_type;
info->pclass_type[i] = pads[i]->m_class_type;
@ -462,9 +462,9 @@ error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -475,7 +475,7 @@ error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -496,9 +496,9 @@ error_code cellPadGetRawData(u32 port_no, vm::ptr<CellPadData> data)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -508,7 +508,7 @@ error_code cellPadGetRawData(u32 port_no, vm::ptr<CellPadData> data)
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -527,9 +527,9 @@ error_code cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<Ce
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -539,7 +539,7 @@ error_code cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<Ce
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -568,9 +568,9 @@ error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -591,7 +591,7 @@ error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -614,9 +614,9 @@ error_code cellPadGetInfo(vm::ptr<CellPadInfo> info)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -627,7 +627,7 @@ error_code cellPadGetInfo(vm::ptr<CellPadInfo> info)
std::memset(info.get_ptr(), 0, sizeof(CellPadInfo));
const PadInfo& rinfo = handler->GetInfo();
info->max_connect = config->max_connect;
info->max_connect = config.max_connect;
info->now_connect = rinfo.now_connect;
info->system_info = rinfo.system_info;
@ -635,7 +635,7 @@ error_code cellPadGetInfo(vm::ptr<CellPadInfo> info)
for (u32 i = 0; i < CELL_MAX_PADS; ++i)
{
if (i >= config->max_connect)
if (i >= config.max_connect)
break;
pads[i]->m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES; // TODO: should ASSIGN flags be cleared here?
@ -687,9 +687,9 @@ error_code cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -700,7 +700,7 @@ error_code cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
std::memset(info.get_ptr(), 0, sizeof(CellPadInfo2));
const PadInfo& rinfo = handler->GetInfo();
info->max_connect = config->max_connect;
info->max_connect = config.max_connect;
info->now_connect = rinfo.now_connect;
info->system_info = rinfo.system_info;
@ -708,12 +708,12 @@ error_code cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i)
{
if (i >= config->max_connect)
if (i >= config.max_connect)
break;
info->port_status[i] = pads[i]->m_port_status;
pads[i]->m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
info->port_setting[i] = config->port_setting[i];
info->port_setting[i] = config.port_setting[i];
info->device_capability[i] = pads[i]->m_device_capability;
info->device_type[i] = pads[i]->m_device_type;
}
@ -727,9 +727,9 @@ error_code cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellPadCapabilityInfo>
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -739,7 +739,7 @@ error_code cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellPadCapabilityInfo>
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -760,9 +760,9 @@ error_code cellPadSetPortSetting(u32 port_no, u32 port_setting)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
if (port_no >= CELL_MAX_PADS)
@ -772,7 +772,7 @@ error_code cellPadSetPortSetting(u32 port_no, u32 port_setting)
if (port_no >= CELL_PAD_MAX_PORT_NUM)
return CELL_OK;
config->port_setting[port_no] = port_setting;
config.port_setting[port_no] = port_setting;
// can also return CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD
@ -785,9 +785,9 @@ error_code cellPadInfoPressMode(u32 port_no)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -797,7 +797,7 @@ error_code cellPadInfoPressMode(u32 port_no)
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -814,9 +814,9 @@ error_code cellPadInfoSensorMode(u32 port_no)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -826,7 +826,7 @@ error_code cellPadInfoSensorMode(u32 port_no)
const auto& pads = handler->GetPads();
if (port_no >= config->max_connect)
if (port_no >= config.max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
@ -843,9 +843,9 @@ error_code cellPadSetPressMode(u32 port_no, u32 mode)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -866,9 +866,9 @@ error_code cellPadSetPressMode(u32 port_no, u32 mode)
return CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD;
if (mode)
config->port_setting[port_no] |= CELL_PAD_SETTING_PRESS_ON;
config.port_setting[port_no] |= CELL_PAD_SETTING_PRESS_ON;
else
config->port_setting[port_no] &= ~CELL_PAD_SETTING_PRESS_ON;
config.port_setting[port_no] &= ~CELL_PAD_SETTING_PRESS_ON;
return CELL_OK;
}
@ -879,9 +879,9 @@ error_code cellPadSetSensorMode(u32 port_no, u32 mode)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -902,9 +902,9 @@ error_code cellPadSetSensorMode(u32 port_no, u32 mode)
return CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD;
if (mode)
config->port_setting[port_no] |= CELL_PAD_SETTING_SENSOR_ON;
config.port_setting[port_no] |= CELL_PAD_SETTING_SENSOR_ON;
else
config->port_setting[port_no] &= ~CELL_PAD_SETTING_SENSOR_ON;
config.port_setting[port_no] &= ~CELL_PAD_SETTING_SENSOR_ON;
return CELL_OK;
}
@ -915,9 +915,9 @@ error_code cellPadLddRegisterController()
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -927,7 +927,7 @@ error_code cellPadLddRegisterController()
if (handle < 0)
return CELL_PAD_ERROR_TOO_MANY_DEVICES;
config->port_setting[handle] = 0;
config.port_setting[handle] = 0;
return not_an_error(handle);
}
@ -938,9 +938,9 @@ error_code cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -963,9 +963,9 @@ error_code cellPadLddGetPortNo(s32 handle)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();
@ -987,9 +987,9 @@ error_code cellPadLddUnregisterController(s32 handle)
std::lock_guard lock(pad::g_pad_mutex);
const auto config = g_fxo->get<pad_info>();
auto& config = g_fxo->get<pad_info>();
if (!config->max_connect)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;
const auto handler = pad::get_current_handler();

View File

@ -66,11 +66,11 @@ error_code cellRecOpen(vm::cptr<char> pDirName, vm::cptr<char> pFileName, vm::cp
{
cellRec.todo("cellRecOpen(pDirName=%s, pFileName=%s, pParam=*0x%x, container=0x%x, cb=*0x%x, cbUserData=*0x%x)", pDirName, pFileName, pParam, container, cb, cbUserData);
const auto rec = g_fxo->get<rec_info>();
rec->cb = cb;
rec->cbUserData = cbUserData;
auto& rec = g_fxo->get<rec_info>();
rec.cb = cb;
rec.cbUserData = cbUserData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32
{
cb(ppu, CELL_REC_STATUS_OPEN, CELL_OK, cbUserData);
return CELL_OK;
@ -83,11 +83,11 @@ error_code cellRecClose(s32 isDiscard)
{
cellRec.todo("cellRecClose(isDiscard=0x%x)", isDiscard);
const auto rec = g_fxo->get<rec_info>();
auto& rec = g_fxo->get<rec_info>();
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32
{
rec->cb(ppu, CELL_REC_STATUS_CLOSE, CELL_OK, rec->cbUserData);
rec.cb(ppu, CELL_REC_STATUS_CLOSE, CELL_OK, rec.cbUserData);
return CELL_OK;
});
@ -103,11 +103,11 @@ error_code cellRecStop()
{
cellRec.todo("cellRecStop()");
const auto rec = g_fxo->get<rec_info>();
auto& rec = g_fxo->get<rec_info>();
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32
{
rec->cb(ppu, CELL_REC_STATUS_STOP, CELL_OK, rec->cbUserData);
rec.cb(ppu, CELL_REC_STATUS_STOP, CELL_OK, rec.cbUserData);
return CELL_OK;
});
@ -118,11 +118,11 @@ error_code cellRecStart()
{
cellRec.todo("cellRecStart()");
const auto rec = g_fxo->get<rec_info>();
auto& rec = g_fxo->get<rec_info>();
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32
{
rec->cb(ppu, CELL_REC_STATUS_START, CELL_OK, rec->cbUserData);
rec.cb(ppu, CELL_REC_STATUS_START, CELL_OK, rec.cbUserData);
return CELL_OK;
});

View File

@ -33,9 +33,9 @@ error_code cellRescInit(vm::cptr<CellRescInitConfig> initConfig)
{
cellResc.todo("cellRescInit(initConfig=*0x%x)", initConfig);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (resc_manager->is_initialized)
if (resc_manager.is_initialized)
{
return CELL_RESC_ERROR_REINITIALIZED;
}
@ -45,7 +45,7 @@ error_code cellRescInit(vm::cptr<CellRescInitConfig> initConfig)
return CELL_RESC_ERROR_BAD_ARGUMENT;
}
resc_manager->config =
resc_manager.config =
{
initConfig->size,
initConfig->resourcePolicy,
@ -55,7 +55,7 @@ error_code cellRescInit(vm::cptr<CellRescInitConfig> initConfig)
initConfig->interlaceMode,
initConfig->flipMode
};
resc_manager->is_initialized = true;
resc_manager.is_initialized = true;
return CELL_OK;
}
@ -64,8 +64,8 @@ void cellRescExit()
{
cellResc.todo("cellRescExit()");
auto resc_manager = g_fxo->get<cell_resc_manager>();
resc_manager->is_initialized = false;
auto& resc_manager = g_fxo->get<cell_resc_manager>();
resc_manager.is_initialized = false;
}
error_code cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, vm::cptr<u32> bufferMode)
@ -84,9 +84,9 @@ error_code cellRescSetDsts(u32 bufferMode, vm::cptr<CellRescDsts> dsts)
{
cellResc.todo("cellRescSetDsts(bufferMode=%d, dsts=*0x%x)", bufferMode, dsts);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
@ -103,22 +103,22 @@ error_code cellRescSetDisplayMode(u32 bufferMode)
{
cellResc.todo("cellRescSetDisplayMode(bufferMode=%d)", bufferMode);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
if (!bufferMode || bufferMode > CELL_RESC_1920x1080 || !(resc_manager->config.support_modes & bufferMode)) // TODO: is the bufferMode check correct?
if (!bufferMode || bufferMode > CELL_RESC_1920x1080 || !(resc_manager.config.support_modes & bufferMode)) // TODO: is the bufferMode check correct?
{
return CELL_RESC_ERROR_BAD_ARGUMENT;
}
if (bufferMode == CELL_RESC_720x576)
{
const u32 pal_mode = resc_manager->config.pal_temporal_mode;
const u32 flip_mode = resc_manager->config.flip_mode;
const u32 pal_mode = resc_manager.config.pal_temporal_mode;
const u32 flip_mode = resc_manager.config.flip_mode;
// Check if palTemporalMode is any INTERPOLATE mode or CELL_RESC_PAL_60_DROP
if ((pal_mode - CELL_RESC_PAL_60_INTERPOLATE) <= CELL_RESC_PAL_60_INTERPOLATE || pal_mode == CELL_RESC_PAL_60_DROP)
@ -138,7 +138,7 @@ error_code cellRescSetDisplayMode(u32 bufferMode)
}
}
resc_manager->buffer_mode = bufferMode;
resc_manager.buffer_mode = bufferMode;
return CELL_OK;
}
@ -147,9 +147,9 @@ error_code cellRescAdjustAspectRatio(f32 horizontal, f32 vertical)
{
cellResc.todo("cellRescAdjustAspectRatio(horizontal=%f, vertical=%f)", horizontal, vertical);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
@ -166,9 +166,9 @@ error_code cellRescSetPalInterpolateDropFlexRatio(f32 ratio)
{
cellResc.todo("cellRescSetPalInterpolateDropFlexRatio(ratio=%f)", ratio);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
@ -185,9 +185,9 @@ error_code cellRescGetBufferSize(vm::ptr<s32> colorBuffers, vm::ptr<s32> vertexA
{
cellResc.todo("cellRescGetBufferSize(colorBuffers=*0x%x, vertexArray=*0x%x, fragmentShader=*0x%x)", colorBuffers, vertexArray, fragmentShader);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
@ -257,9 +257,9 @@ error_code cellRescSetSrc(s32 idx, vm::cptr<CellRescSrc> src)
{
cellResc.todo("cellRescSetSrc(idx=0x%x, src=*0x%x)", idx, src);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
@ -276,9 +276,9 @@ error_code cellRescSetConvertAndFlip(ppu_thread& ppu, vm::ptr<CellGcmContextData
{
cellResc.todo("cellRescSetConvertAndFlip(con=*0x%x, idx=0x%x)", con, idx);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
@ -302,9 +302,9 @@ error_code cellRescSetBufferAddress(vm::cptr<u32> colorBuffers, vm::cptr<u32> ve
{
cellResc.todo("cellRescSetBufferAddress(colorBuffers=*0x%x, vertexArray=*0x%x, fragmentShader=*0x%x)", colorBuffers, vertexArray, fragmentShader);
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->is_initialized)
if (!resc_manager.is_initialized)
{
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
@ -371,9 +371,9 @@ error_code cellRescCreateInterlaceTable(vm::ptr<void> ea_addr, f32 srcH, CellRes
return CELL_RESC_ERROR_BAD_ARGUMENT;
}
auto resc_manager = g_fxo->get<cell_resc_manager>();
auto& resc_manager = g_fxo->get<cell_resc_manager>();
if (!resc_manager->buffer_mode)
if (!resc_manager.buffer_mode)
{
return CELL_RESC_ERROR_BAD_COMBINATION;
}

View File

@ -72,26 +72,26 @@ error_code cellRudpInit(vm::ptr<CellRudpAllocator> allocator)
{
cellRudp.warning("cellRudpInit(allocator=*0x%x)", allocator);
const auto rudp = g_fxo->get<rudp_info>();
auto& rudp = g_fxo->get<rudp_info>();
if (rudp->malloc)
if (rudp.malloc)
{
return CELL_RUDP_ERROR_ALREADY_INITIALIZED;
}
if (allocator)
{
rudp->malloc = allocator->app_malloc;
rudp->free = allocator->app_free;
rudp.malloc = allocator->app_malloc;
rudp.free = allocator->app_free;
}
else
{
rudp->malloc = [](ppu_thread& ppu, u32 size)
rudp.malloc = [](ppu_thread& ppu, u32 size)
{
return vm::ptr<void>::make(vm::alloc(size, vm::main));
};
rudp->free = [](ppu_thread& ppu, vm::ptr<void> ptr)
rudp.free = [](ppu_thread& ppu, vm::ptr<void> ptr)
{
if (!vm::dealloc(ptr.addr(), vm::main))
{
@ -107,16 +107,16 @@ error_code cellRudpEnd()
{
cellRudp.warning("cellRudpEnd()");
const auto rudp = g_fxo->get<rudp_info>();
auto& rudp = g_fxo->get<rudp_info>();
if (!rudp->malloc)
if (!rudp.malloc)
{
return CELL_RUDP_ERROR_NOT_INITIALIZED;
}
rudp->malloc = nullptr;
rudp->free = nullptr;
rudp->handler = vm::null;
rudp.malloc = nullptr;
rudp.free = nullptr;
rudp.handler = vm::null;
return CELL_OK;
}
@ -131,15 +131,15 @@ error_code cellRudpSetEventHandler(vm::ptr<CellRudpEventHandler> handler, vm::pt
{
cellRudp.todo("cellRudpSetEventHandler(handler=*0x%x, arg=*0x%x)", handler, arg);
const auto rudp = g_fxo->get<rudp_info>();
auto& rudp = g_fxo->get<rudp_info>();
if (!rudp->malloc)
if (!rudp.malloc)
{
return CELL_RUDP_ERROR_NOT_INITIALIZED;
}
rudp->handler = handler;
rudp->handler_arg = arg;
rudp.handler = handler;
rudp.handler_arg = arg;
return CELL_OK;
}

View File

@ -163,7 +163,7 @@ static std::vector<SaveDataEntry> get_save_entries(const std::string& base_dir,
static error_code select_and_delete(ppu_thread& ppu)
{
std::unique_lock lock(g_fxo->get<savedata_mutex>()->mutex, std::try_to_lock);
std::unique_lock lock(g_fxo->get<savedata_mutex>().mutex, std::try_to_lock);
if (!lock)
{
@ -558,7 +558,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
return {CELL_SAVEDATA_ERROR_PARAM, std::to_string(ecode)};
}
std::unique_lock lock(g_fxo->get<savedata_mutex>()->mutex, std::try_to_lock);
std::unique_lock lock(g_fxo->get<savedata_mutex>().mutex, std::try_to_lock);
if (!lock)
{

View File

@ -85,25 +85,25 @@ error_code cellScreenShotSetParameter(vm::cptr<CellScreenShotSetParam> param)
if (param->game_comment && !memchr(param->game_comment.get_ptr(), '\0', CELL_SCREENSHOT_GAME_COMMENT_MAX_SIZE))
return CELL_SCREENSHOT_ERROR_PARAM;
const auto manager = g_fxo->get<screenshot_manager>();
auto& manager = g_fxo->get<screenshot_manager>();
std::lock_guard lock(screenshot_mtx);
if (param->photo_title && param->photo_title[0] != '\0')
manager->photo_title = std::string(param->photo_title.get_ptr());
manager.photo_title = std::string(param->photo_title.get_ptr());
else
manager->photo_title = "";
manager.photo_title = "";
if (param->game_title && param->game_title[0] != '\0')
manager->game_title = std::string(param->game_title.get_ptr());
manager.game_title = std::string(param->game_title.get_ptr());
else
manager->game_title = "";
manager.game_title = "";
if (param->game_comment && param->game_comment[0] != '\0')
manager->game_comment = std::string(param->game_comment.get_ptr());
manager.game_comment = std::string(param->game_comment.get_ptr());
else
manager->game_comment = "";
manager.game_comment = "";
cellScreenshot.notice("cellScreenShotSetParameter(photo_title=%s, game_title=%s, game_comment=%s)", manager->photo_title, manager->game_title, manager->game_comment);
cellScreenshot.notice("cellScreenShotSetParameter(photo_title=%s, game_title=%s, game_comment=%s)", manager.photo_title, manager.game_title, manager.game_comment);
return CELL_OK;
}
@ -123,13 +123,13 @@ error_code cellScreenShotSetOverlayImage(vm::cptr<char> srcDir, vm::cptr<char> s
return CELL_SCREENSHOT_ERROR_PARAM;
}
const auto manager = g_fxo->get<screenshot_manager>();
auto& manager = g_fxo->get<screenshot_manager>();
std::lock_guard lock(screenshot_mtx);
manager->overlay_dir_name = std::string(srcDir.get_ptr());
manager->overlay_file_name = std::string(srcFile.get_ptr());
manager->overlay_offset_x = offset_x;
manager->overlay_offset_y = offset_y;
manager.overlay_dir_name = std::string(srcDir.get_ptr());
manager.overlay_file_name = std::string(srcFile.get_ptr());
manager.overlay_offset_x = offset_x;
manager.overlay_offset_y = offset_y;
return CELL_OK;
}
@ -138,10 +138,10 @@ error_code cellScreenShotEnable()
{
cellScreenshot.warning("cellScreenShotEnable()");
const auto manager = g_fxo->get<screenshot_manager>();
auto& manager = g_fxo->get<screenshot_manager>();
std::lock_guard lock(screenshot_mtx);
manager->is_enabled = true;
manager.is_enabled = true;
return CELL_OK;
}
@ -150,10 +150,10 @@ error_code cellScreenShotDisable()
{
cellScreenshot.warning("cellScreenShotDisable()");
const auto manager = g_fxo->get<screenshot_manager>();
auto& manager = g_fxo->get<screenshot_manager>();
std::lock_guard lock(screenshot_mtx);
manager->is_enabled = false;
manager.is_enabled = false;
return CELL_OK;
}

View File

@ -122,9 +122,9 @@ error_code cellSearchInitialize(CellSearchMode mode, u32 container, vm::ptr<Cell
return CELL_SEARCH_ERROR_UNKNOWN_MODE;
}
const auto search = g_fxo->get<search_info>();
auto& search = g_fxo->get<search_info>();
switch (search->state.compare_and_swap(search_state::not_initialized, search_state::initializing))
switch (search.state.compare_and_swap(search_state::not_initialized, search_state::initializing))
{
case search_state::not_initialized:
break;
@ -136,12 +136,12 @@ error_code cellSearchInitialize(CellSearchMode mode, u32 container, vm::ptr<Cell
return CELL_SEARCH_ERROR_ALREADY_INITIALIZED;
}
search->func = func;
search->userData = userData;
search.func = func;
search.userData = userData;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &search](ppu_thread& ppu) -> s32
{
search->state.store(search_state::idle);
search.state.store(search_state::idle);
func(ppu, CELL_SEARCH_EVENT_INITIALIZE_RESULT, CELL_OK, vm::null, userData);
return CELL_OK;
});
@ -153,9 +153,9 @@ error_code cellSearchFinalize()
{
cellSearch.todo("cellSearchFinalize()");
const auto search = g_fxo->get<search_info>();
auto& search = g_fxo->get<search_info>();
switch (search->state.compare_and_swap(search_state::idle, search_state::finalizing))
switch (search.state.compare_and_swap(search_state::idle, search_state::finalizing))
{
case search_state::idle:
break;
@ -171,14 +171,14 @@ error_code cellSearchFinalize()
return CELL_SEARCH_ERROR_GENERIC;
}
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &search](ppu_thread& ppu) -> s32
{
{
std::lock_guard lock(search->links_mutex);
search->content_links.clear();
std::lock_guard lock(search.links_mutex);
search.content_links.clear();
}
search->state.store(search_state::not_initialized);
search->func(ppu, CELL_SEARCH_EVENT_FINALIZE_RESULT, CELL_OK, vm::null, search->userData);
search.state.store(search_state::not_initialized);
search.func(ppu, CELL_SEARCH_EVENT_FINALIZE_RESULT, CELL_OK, vm::null, search.userData);
return CELL_OK;
});
@ -222,9 +222,9 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo
return CELL_SEARCH_ERROR_PARAM;
}
const auto search = g_fxo->get<search_info>();
auto& search = g_fxo->get<search_info>();
switch (search->state.compare_and_swap(search_state::idle, search_state::in_progress))
switch (search.state.compare_and_swap(search_state::idle, search_state::in_progress))
{
case search_state::idle:
break;
@ -242,7 +242,7 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo
const u32 id = *outSearchId = idm::make<search_object_t>();
sysutil_register_cb([=, content_map = g_fxo->get<ContentIdMap>()](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &content_map = g_fxo->get<ContentIdMap>(), &search](ppu_thread& ppu) -> s32
{
auto curr_search = idm::get<search_object_t>(id);
vm::var<CellSearchResultParam> resultParam;
@ -320,8 +320,8 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo
}
const u64 hash = std::hash<std::string>()(item_path);
auto found = content_map->find(hash);
if (found == content_map->end()) // content isn't yet being tracked
auto found = content_map.find(hash);
if (found == content_map.end()) // content isn't yet being tracked
{
//auto ext_offset = item.name.find_last_of('.'); // used later if no "Title" found
@ -334,8 +334,8 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo
// std::string link = "/.tmp/" + std::to_string(hash) + item.name.substr(ext_offset);
// strcpy_trunc(curr_find->infoPath.contentPath, link);
// std::lock_guard lock(search->links_mutex);
// search->content_links.emplace(std::move(link), item_path);
// std::lock_guard lock(search.links_mutex);
// search.content_links.emplace(std::move(link), item_path);
}
else
{
@ -391,7 +391,7 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo
}
}
content_map->emplace(hash, curr_find);
content_map.emplace(hash, curr_find);
curr_search->content_ids.emplace_back(hash, curr_find); // place this file's "ID" into the list of found types
cellSearch.notice("cellSearchStartListSearch(): Content ID: %08X Path: \"%s\"", hash, item_path);
@ -410,8 +410,8 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo
searchInFolder(fmt::format("/dev_hdd0/%s", media_dir));
resultParam->resultNum = ::narrow<s32>(curr_search->content_ids.size());
search->state.store(search_state::idle);
search->func(ppu, CELL_SEARCH_EVENT_LISTSEARCH_RESULT, CELL_OK, vm::cast(resultParam.addr()), search->userData);
search.state.store(search_state::idle);
search.func(ppu, CELL_SEARCH_EVENT_LISTSEARCH_RESULT, CELL_OK, vm::cast(resultParam.addr()), search.userData);
return CELL_OK;
});
@ -449,9 +449,9 @@ error_code cellSearchStartContentSearchInList(vm::cptr<CellSearchContentId> list
return CELL_SEARCH_ERROR_PARAM;
}
const auto search = g_fxo->get<search_info>();
auto& search = g_fxo->get<search_info>();
switch (search->state.compare_and_swap(search_state::idle, search_state::in_progress))
switch (search.state.compare_and_swap(search_state::idle, search_state::in_progress))
{
case search_state::idle:
break;
@ -467,9 +467,9 @@ error_code cellSearchStartContentSearchInList(vm::cptr<CellSearchContentId> list
return CELL_SEARCH_ERROR_GENERIC;
}
const auto content_map = g_fxo->get<ContentIdMap>();
auto found = content_map->find(*reinterpret_cast<const u64*>(listId->data));
if (found == content_map->end())
auto& content_map = g_fxo->get<ContentIdMap>();
auto found = content_map.find(*reinterpret_cast<const u64*>(listId->data));
if (found == content_map.end())
{
// content ID not found, perform a search first
return CELL_SEARCH_ERROR_CONTENT_NOT_FOUND;
@ -499,7 +499,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr<CellSearchContentId> list
const u32 id = *outSearchId = idm::make<search_object_t>();
sysutil_register_cb([=, list_path = std::string(content_info->infoPath.contentPath)](ppu_thread& ppu) -> s32
sysutil_register_cb([=, list_path = std::string(content_info->infoPath.contentPath), &search, &content_map](ppu_thread& ppu) -> s32
{
auto curr_search = idm::get<search_object_t>(id);
vm::var<CellSearchResultParam> resultParam;
@ -553,8 +553,8 @@ error_code cellSearchStartContentSearchInList(vm::cptr<CellSearchContentId> list
const std::string item_path(vpath + "/" + item.name);
const u64 hash = std::hash<std::string>()(item_path);
auto found = content_map->find(hash);
if (found == content_map->end()) // content isn't yet being tracked
auto found = content_map.find(hash);
if (found == content_map.end()) // content isn't yet being tracked
{
auto ext_offset = item.name.find_last_of('.'); // used later if no "Title" found
@ -565,8 +565,8 @@ error_code cellSearchStartContentSearchInList(vm::cptr<CellSearchContentId> list
std::string link = "/.tmp/" + std::to_string(hash) + item.name.substr(ext_offset);
strcpy_trunc(curr_find->infoPath.contentPath, link);
std::lock_guard lock(search->links_mutex);
search->content_links.emplace(std::move(link), item_path);
std::lock_guard lock(search.links_mutex);
search.content_links.emplace(std::move(link), item_path);
}
else
{
@ -783,7 +783,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr<CellSearchContentId> list
strcpy_trunc(info.albumTitle, "ALBUM TITLE");
}
content_map->emplace(hash, curr_find);
content_map.emplace(hash, curr_find);
curr_search->content_ids.emplace_back(hash, curr_find); // place this file's "ID" into the list of found types
cellSearch.notice("cellSearchStartContentSearchInList(): Content ID: %08X Path: \"%s\"", hash, item_path);
@ -802,8 +802,8 @@ error_code cellSearchStartContentSearchInList(vm::cptr<CellSearchContentId> list
searchInFolder(list_path);
resultParam->resultNum = ::narrow<s32>(curr_search->content_ids.size());
search->state.store(search_state::idle);
search->func(ppu, CELL_SEARCH_EVENT_CONTENTSEARCH_INLIST_RESULT, CELL_OK, vm::cast(resultParam.addr()), search->userData);
search.state.store(search_state::idle);
search.func(ppu, CELL_SEARCH_EVENT_CONTENTSEARCH_INLIST_RESULT, CELL_OK, vm::cast(resultParam.addr()), search.userData);
return CELL_OK;
});
@ -851,9 +851,9 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
return CELL_SEARCH_ERROR_PARAM;
}
const auto search = g_fxo->get<search_info>();
auto& search = g_fxo->get<search_info>();
switch (search->state.compare_and_swap(search_state::idle, search_state::in_progress))
switch (search.state.compare_and_swap(search_state::idle, search_state::in_progress))
{
case search_state::idle:
break;
@ -871,7 +871,7 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
const u32 id = *outSearchId = idm::make<search_object_t>();
sysutil_register_cb([=, content_map = g_fxo->get<ContentIdMap>()](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &content_map = g_fxo->get<ContentIdMap>(), &search](ppu_thread& ppu) -> s32
{
auto curr_search = idm::get<search_object_t>(id);
vm::var<CellSearchResultParam> resultParam;
@ -906,8 +906,8 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
const std::string item_path(relative_vpath + "/" + item.name);
const u64 hash = std::hash<std::string>()(item_path);
auto found = content_map->find(hash);
if (found == content_map->end()) // content isn't yet being tracked
auto found = content_map.find(hash);
if (found == content_map.end()) // content isn't yet being tracked
{
auto ext_offset = item.name.find_last_of('.'); // used later if no "Title" found
@ -918,8 +918,8 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
std::string link = "/.tmp/" + std::to_string(hash) + item.name.substr(ext_offset);
strcpy_trunc(curr_find->infoPath.contentPath, link);
std::lock_guard lock(search->links_mutex);
search->content_links.emplace(std::move(link), item_path);
std::lock_guard lock(search.links_mutex);
search.content_links.emplace(std::move(link), item_path);
}
else
{
@ -985,7 +985,7 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
strcpy_trunc(info.albumTitle, "ALBUM TITLE");
}
content_map->emplace(hash, curr_find);
content_map.emplace(hash, curr_find);
curr_search->content_ids.emplace_back(hash, curr_find); // place this file's "ID" into the list of found types
cellSearch.notice("cellSearchStartContentSearch(): Content ID: %08X Path: \"%s\"", hash, item_path);
@ -1003,8 +1003,8 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe
searchInFolder(fmt::format("/dev_hdd0/%s", media_dir), "");
resultParam->resultNum = ::narrow<s32>(curr_search->content_ids.size());
search->state.store(search_state::idle);
search->func(ppu, CELL_SEARCH_EVENT_CONTENTSEARCH_RESULT, CELL_OK, vm::cast(resultParam.addr()), search->userData);
search.state.store(search_state::idle);
search.func(ppu, CELL_SEARCH_EVENT_CONTENTSEARCH_RESULT, CELL_OK, vm::cast(resultParam.addr()), search.userData);
return CELL_OK;
});
@ -1038,9 +1038,9 @@ error_code cellSearchStartSceneSearchInVideo(vm::cptr<CellSearchContentId> video
return CELL_SEARCH_ERROR_PARAM;
}
const auto search = g_fxo->get<search_info>();
auto& search = g_fxo->get<search_info>();
switch (search->state.compare_and_swap(search_state::idle, search_state::in_progress))
switch (search.state.compare_and_swap(search_state::idle, search_state::in_progress))
{
case search_state::idle:
break;
@ -1058,14 +1058,14 @@ error_code cellSearchStartSceneSearchInVideo(vm::cptr<CellSearchContentId> video
const u32 id = *outSearchId = idm::make<search_object_t>();
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &search](ppu_thread& ppu) -> s32
{
vm::var<CellSearchResultParam> resultParam;
resultParam->searchId = id;
resultParam->resultNum = 0; // TODO
search->state.store(search_state::idle);
search->func(ppu, CELL_SEARCH_EVENT_SCENESEARCH_INVIDEO_RESULT, CELL_OK, vm::cast(resultParam.addr()), search->userData);
search.state.store(search_state::idle);
search.func(ppu, CELL_SEARCH_EVENT_SCENESEARCH_INVIDEO_RESULT, CELL_OK, vm::cast(resultParam.addr()), search.userData);
return CELL_OK;
});
@ -1094,9 +1094,9 @@ error_code cellSearchStartSceneSearch(CellSearchSceneSearchType searchType, vm::
return CELL_SEARCH_ERROR_PARAM;
}
const auto search = g_fxo->get<search_info>();
auto& search = g_fxo->get<search_info>();
switch (search->state.compare_and_swap(search_state::idle, search_state::in_progress))
switch (search.state.compare_and_swap(search_state::idle, search_state::in_progress))
{
case search_state::idle:
break;
@ -1114,14 +1114,14 @@ error_code cellSearchStartSceneSearch(CellSearchSceneSearchType searchType, vm::
const u32 id = *outSearchId = idm::make<search_object_t>();
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &search](ppu_thread& ppu) -> s32
{
vm::var<CellSearchResultParam> resultParam;
resultParam->searchId = id;
resultParam->resultNum = 0; // TODO
search->state.store(search_state::idle);
search->func(ppu, CELL_SEARCH_EVENT_SCENESEARCH_RESULT, CELL_OK, vm::cast(resultParam.addr()), search->userData);
search.state.store(search_state::idle);
search.func(ppu, CELL_SEARCH_EVENT_SCENESEARCH_RESULT, CELL_OK, vm::cast(resultParam.addr()), search.userData);
return CELL_OK;
});
@ -1144,7 +1144,7 @@ error_code cellSearchGetContentInfoByOffset(CellSearchId searchId, s32 offset, v
return CELL_SEARCH_ERROR_INVALID_SEARCHID;
}
switch (g_fxo->get<search_info>()->state.load())
switch (g_fxo->get<search_info>().state.load())
{
case search_state::idle:
break;
@ -1212,7 +1212,7 @@ error_code cellSearchGetContentInfoByContentId(vm::cptr<CellSearchContentId> con
return CELL_SEARCH_ERROR_PARAM;
}
switch (g_fxo->get<search_info>()->state.load())
switch (g_fxo->get<search_info>().state.load())
{
case search_state::idle:
break;
@ -1228,9 +1228,9 @@ error_code cellSearchGetContentInfoByContentId(vm::cptr<CellSearchContentId> con
return CELL_SEARCH_ERROR_GENERIC;
}
const auto content_map = g_fxo->get<ContentIdMap>();
auto found = content_map->find(*reinterpret_cast<const u64*>(contentId->data));
if (found != content_map->end())
auto& content_map = g_fxo->get<ContentIdMap>();
auto found = content_map.find(*reinterpret_cast<const u64*>(contentId->data));
if (found != content_map.end())
{
const auto& content_info = found->second;
switch (content_info->type)
@ -1279,7 +1279,7 @@ error_code cellSearchGetOffsetByContentId(CellSearchId searchId, vm::cptr<CellSe
return CELL_SEARCH_ERROR_PARAM;
}
switch (g_fxo->get<search_info>()->state.load())
switch (g_fxo->get<search_info>().state.load())
{
case search_state::idle:
break;
@ -1333,7 +1333,7 @@ error_code cellSearchGetContentIdByOffset(CellSearchId searchId, s32 offset, vm:
return CELL_SEARCH_ERROR_INVALID_SEARCHID;
}
switch (g_fxo->get<search_info>()->state.load())
switch (g_fxo->get<search_info>().state.load())
{
case search_state::idle:
break;
@ -1422,7 +1422,7 @@ error_code cellSearchGetContentInfoPath(vm::cptr<CellSearchContentId> contentId,
return CELL_SEARCH_ERROR_PARAM;
}
switch (g_fxo->get<search_info>()->state.load())
switch (g_fxo->get<search_info>().state.load())
{
case search_state::idle:
break;
@ -1439,9 +1439,9 @@ error_code cellSearchGetContentInfoPath(vm::cptr<CellSearchContentId> contentId,
}
const u64 id = *reinterpret_cast<const u64*>(contentId->data);
const auto content_map = g_fxo->get<ContentIdMap>();
auto found = content_map->find(id);
if(found != content_map->end())
auto& content_map = g_fxo->get<ContentIdMap>();
auto found = content_map.find(id);
if(found != content_map.end())
{
std::memcpy(infoPath.get_ptr(), &found->second->infoPath, sizeof(found->second->infoPath));
}
@ -1477,8 +1477,8 @@ error_code cellSearchPrepareFile(vm::cptr<char> path)
return CELL_SEARCH_ERROR_PARAM;
}
const auto search = g_fxo->get<search_info>();
switch (search->state.load())
auto& search = g_fxo->get<search_info>();
switch (search.state.load())
{
case search_state::idle:
break;
@ -1494,9 +1494,9 @@ error_code cellSearchPrepareFile(vm::cptr<char> path)
return CELL_SEARCH_ERROR_GENERIC;
}
reader_lock lock(search->links_mutex);
auto found = search->content_links.find(path.get_ptr());
if (found != search->content_links.end())
reader_lock lock(search.links_mutex);
auto found = search.content_links.find(path.get_ptr());
if (found != search.content_links.end())
{
vfs::mount(found->first, vfs::get(found->second));
}
@ -1539,7 +1539,7 @@ error_code cellSearchCancel(CellSearchId searchId)
return CELL_SEARCH_ERROR_INVALID_SEARCHID;
}
switch (g_fxo->get<search_info>()->state.load())
switch (g_fxo->get<search_info>().state.load())
{
case search_state::in_progress:
break;
@ -1565,7 +1565,7 @@ error_code cellSearchEnd(CellSearchId searchId)
{
cellSearch.todo("cellSearchEnd(searchId=0x%x)", searchId);
switch (g_fxo->get<search_info>()->state.load())
switch (g_fxo->get<search_info>().state.load())
{
case search_state::idle:
break;

View File

@ -45,12 +45,12 @@ error_code cellSslInit(vm::ptr<void> pool, u32 poolSize)
{
cellSsl.todo("cellSslInit(pool=*0x%x, poolSize=%d)", pool, poolSize);
const auto manager = g_fxo->get<ssl_manager>();
auto& manager = g_fxo->get<ssl_manager>();
if (manager->is_init)
if (manager.is_init)
return CELL_SSL_ERROR_ALREADY_INITIALIZED;
manager->is_init = true;
manager.is_init = true;
return CELL_OK;
}
@ -59,12 +59,12 @@ error_code cellSslEnd()
{
cellSsl.todo("cellSslEnd()");
const auto manager = g_fxo->get<ssl_manager>();
auto& manager = g_fxo->get<ssl_manager>();
if (!manager->is_init)
if (!manager.is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
manager->is_init = false;
manager.is_init = false;
return CELL_OK;
}
@ -142,7 +142,7 @@ error_code cellSslCertGetSerialNumber(vm::cptr<void> sslCert, vm::cpptr<u8> sboD
{
cellSsl.todo("cellSslCertGetSerialNumber(sslCert=*0x%x, sboData=**0x%x, sboLength=*0x%x)", sslCert, sboData, sboLength);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -158,7 +158,7 @@ error_code cellSslCertGetPublicKey(vm::cptr<void> sslCert, vm::cpptr<u8> sboData
{
cellSsl.todo("cellSslCertGetPublicKey(sslCert=*0x%x, sboData=**0x%x, sboLength=*0x%x)", sslCert, sboData, sboLength);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -174,7 +174,7 @@ error_code cellSslCertGetRsaPublicKeyModulus(vm::cptr<void> sslCert, vm::cpptr<u
{
cellSsl.todo("cellSslCertGetRsaPublicKeyModulus(sslCert=*0x%x, sboData=**0x%x, sboLength=*0x%x)", sslCert, sboData, sboLength);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -190,7 +190,7 @@ error_code cellSslCertGetRsaPublicKeyExponent(vm::cptr<void> sslCert, vm::cpptr<
{
cellSsl.todo("cellSslCertGetRsaPublicKeyExponent(sslCert=*0x%x, sboData=**0x%x, sboLength=*0x%x)", sslCert, sboData, sboLength);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -206,7 +206,7 @@ error_code cellSslCertGetNotBefore(vm::cptr<void> sslCert, vm::ptr<CellRtcTick>
{
cellSsl.todo("cellSslCertGetNotBefore(sslCert=*0x%x, begin=*0x%x)", sslCert, begin);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -222,7 +222,7 @@ error_code cellSslCertGetNotAfter(vm::cptr<void> sslCert, vm::ptr<CellRtcTick> l
{
cellSsl.todo("cellSslCertGetNotAfter(sslCert=*0x%x, limit=*0x%x)", sslCert, limit);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -238,7 +238,7 @@ error_code cellSslCertGetSubjectName(vm::cptr<void> sslCert, vm::cpptr<void> cer
{
cellSsl.todo("cellSslCertGetSubjectName(sslCert=*0x%x, certName=**0x%x)", sslCert, certName);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -254,7 +254,7 @@ error_code cellSslCertGetIssuerName(vm::cptr<void> sslCert, vm::cpptr<void> cert
{
cellSsl.todo("cellSslCertGetIssuerName(sslCert=*0x%x, certName=**0x%x)", sslCert, certName);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)
@ -270,7 +270,7 @@ error_code cellSslCertGetNameEntryCount(vm::cptr<void> certName, vm::ptr<u32> en
{
cellSsl.todo("cellSslCertGetNameEntryCount(certName=*0x%x, entryCount=*0x%x)", certName, entryCount);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!certName)
@ -286,7 +286,7 @@ error_code cellSslCertGetNameEntryInfo(vm::cptr<void> certName, u32 entryNum, vm
{
cellSsl.todo("cellSslCertGetNameEntryInfo(certName=*0x%x, entryNum=%d, oidName=**0x%x, value=**0x%x, valueLength=*0x%x, flag=0x%x)", certName, entryNum, oidName, value, valueLength, flag);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!certName)
@ -302,7 +302,7 @@ error_code cellSslCertGetMd5Fingerprint(vm::cptr<void> sslCert, vm::cptr<u8> buf
{
cellSsl.todo("cellSslCertGetMd5Fingerprint(sslCert=*0x%x, buf=*0x%x, plen=*0x%x)", sslCert, buf, plen);
if (!g_fxo->get<ssl_manager>()->is_init)
if (!g_fxo->get<ssl_manager>().is_init)
return CELL_SSL_ERROR_NOT_INITIALIZED;
if (!sslCert)

View File

@ -94,9 +94,9 @@ error_code cellSysCacheClear()
{
cellSysutil.notice("cellSysCacheClear()");
const auto cache = g_fxo->get<syscache_info>();
auto& cache = g_fxo->get<syscache_info>();
const auto lock = cache->init.access();
const auto lock = cache.init.access();
if (!lock)
{
@ -104,10 +104,10 @@ error_code cellSysCacheClear()
}
// Clear existing cache
if (!cache->cache_id.empty())
if (!cache.cache_id.empty())
{
std::lock_guard lock0(g_mp_sys_dev_hdd1.mutex);
cache->clear(false);
cache.clear(false);
}
return not_an_error(CELL_SYSCACHE_RET_OK_CLEARED);
@ -117,7 +117,7 @@ error_code cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
{
cellSysutil.notice("cellSysCacheMount(param=*0x%x)", param);
const auto cache = g_fxo->get<syscache_info>();
auto& cache = g_fxo->get<syscache_info>();
if (!param || (param->cacheId[0] && sysutil_check_name_string(param->cacheId, 1, CELL_SYSCACHE_ID_SIZE) != 0))
{
@ -128,18 +128,18 @@ error_code cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
std::string cache_id = vfs::escape(Emu.GetTitleID() + '_' + param->cacheId);
// Full path to virtual cache root (/dev_hdd1)
std::string new_path = cache->cache_root + cache_id + '/';
std::string new_path = cache.cache_root + cache_id + '/';
// Set fixed VFS path
strcpy_trunc(param->getCachePath, "/dev_hdd1");
// Lock pseudo-mutex
const auto lock = cache->init.init_always([&]
const auto lock = cache.init.init_always([&]
{
});
// Check if can reuse existing cache (won't if cache id is an empty string)
if (param->cacheId[0] && cache_id == cache->cache_id)
if (param->cacheId[0] && cache_id == cache.cache_id)
{
// Isn't mounted yet on first call to cellSysCacheMount
vfs::mount("/dev_hdd1", new_path);
@ -151,13 +151,13 @@ error_code cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
std::lock_guard lock0(g_mp_sys_dev_hdd1.mutex);
// Clear existing cache
if (!cache->cache_id.empty())
if (!cache.cache_id.empty())
{
cache->clear(true);
cache.clear(true);
}
// Set new cache id
cache->cache_id = std::move(cache_id);
cache.cache_id = std::move(cache_id);
fs::create_dir(new_path);
vfs::mount("/dev_hdd1", new_path);

View File

@ -50,21 +50,20 @@ struct sysutil_cb_manager
extern void sysutil_register_cb(std::function<s32(ppu_thread&)>&& cb)
{
const auto cbm = g_fxo->get<sysutil_cb_manager>();
auto& cbm = g_fxo->get<sysutil_cb_manager>();
cbm->registered.push(std::move(cb));
cbm.registered.push(std::move(cb));
}
extern void sysutil_send_system_cmd(u64 status, u64 param)
{
// May be nullptr if emulation is stopped
if (const auto cbm = g_fxo->get<sysutil_cb_manager>())
if (auto& cbm = g_fxo->get<sysutil_cb_manager>(); g_fxo->is_init<sysutil_cb_manager>() && !Emu.IsStopped())
{
for (sysutil_cb_manager::registered_cb cb : cbm->callbacks)
for (sysutil_cb_manager::registered_cb cb : cbm.callbacks)
{
if (cb.first)
{
cbm->registered.push([=](ppu_thread& ppu) -> s32
cbm.registered.push([=](ppu_thread& ppu) -> s32
{
// TODO: check it and find the source of the return value (void isn't equal to CELL_OK)
cb.first(ppu, status, param, cb.second);
@ -401,9 +400,9 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu)
{
cellSysutil.trace("cellSysutilCheckCallback()");
const auto cbm = g_fxo->get<sysutil_cb_manager>();
auto& cbm = g_fxo->get<sysutil_cb_manager>();
for (auto&& func : cbm->registered.pop_all())
for (auto&& func : cbm.registered.pop_all())
{
if (s32 res = func(ppu))
{
@ -429,9 +428,9 @@ error_code cellSysutilRegisterCallback(s32 slot, vm::ptr<CellSysutilCallback> fu
return CELL_SYSUTIL_ERROR_VALUE;
}
const auto cbm = g_fxo->get<sysutil_cb_manager>();
auto& cbm = g_fxo->get<sysutil_cb_manager>();
cbm->callbacks[slot].store({func, userdata});
cbm.callbacks[slot].store({func, userdata});
return CELL_OK;
}
@ -445,9 +444,9 @@ error_code cellSysutilUnregisterCallback(u32 slot)
return CELL_SYSUTIL_ERROR_VALUE;
}
const auto cbm = g_fxo->get<sysutil_cb_manager>();
auto& cbm = g_fxo->get<sysutil_cb_manager>();
cbm->callbacks[slot].store({});
cbm.callbacks[slot].store({});
return CELL_OK;
}

View File

@ -134,7 +134,8 @@ error_code cellSysutilAvc2LoadAsync(SceNpMatching2ContextId ctx_id, u32 containe
if (avc2_cb)
{
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
avc2_cb(cb_ppu, CELL_AVC2_EVENT_LOAD_SUCCEEDED, 0, avc2_cb_arg);
return 0;
});
@ -230,7 +231,8 @@ error_code cellSysutilAvc2JoinChatRequest(vm::cptr<SceNpMatching2RoomId> room_id
if (avc2_cb)
{
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
avc2_cb(cb_ppu, CELL_AVC2_EVENT_JOIN_SUCCEEDED, 0, avc2_cb_arg);
return 0;
});
@ -322,7 +324,8 @@ error_code cellSysutilAvc2LeaveChatRequest()
if (avc2_cb)
{
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
avc2_cb(cb_ppu, CELL_AVC2_EVENT_LEAVE_SUCCEEDED, 0, avc2_cb_arg);
return 0;
});
@ -371,7 +374,7 @@ error_code cellSysutilAvc2EnumPlayers(vm::ptr<s32> players_num, vm::ptr<SceNpMat
if (players_num)
*players_num = 1;
if (players_id)
*players_id = 1;

View File

@ -119,13 +119,13 @@ error_code cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr<CellVideo
{
case CELL_VIDEO_OUT_PRIMARY:
{
const auto conf = g_fxo->get<rsx::avconf>();
auto& conf = g_fxo->get<rsx::avconf>();
state->state = CELL_VIDEO_OUT_OUTPUT_STATE_ENABLED;
state->colorSpace = CELL_VIDEO_OUT_COLOR_SPACE_RGB;
state->displayMode.resolutionId = conf->state? conf->resolution_id : g_video_out_resolution_id.at(g_cfg.video.resolution);
state->displayMode.resolutionId = conf.state ? conf.resolution_id : g_video_out_resolution_id.at(g_cfg.video.resolution);
state->displayMode.scanMode = CELL_VIDEO_OUT_SCAN_MODE_PROGRESSIVE;
state->displayMode.conversion = CELL_VIDEO_OUT_DISPLAY_CONVERSION_NONE;
state->displayMode.aspect = conf->state? conf->aspect : g_video_out_aspect_id.at(g_cfg.video.aspect_ratio);
state->displayMode.aspect = conf.state ? conf.aspect : g_video_out_aspect_id.at(g_cfg.video.aspect_ratio);
state->displayMode.refreshRates = CELL_VIDEO_OUT_REFRESH_RATE_59_94HZ;
return CELL_OK;
@ -187,20 +187,20 @@ error_code cellVideoOutConfigure(u32 videoOut, vm::ptr<CellVideoOutConfiguration
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_DISPLAY_MODE;
}
auto conf = g_fxo->get<rsx::avconf>();
conf->resolution_id = config->resolutionId;
conf->_3d = config->resolutionId >= CELL_VIDEO_OUT_RESOLUTION_720_3D_FRAME_PACKING;
conf->aspect = config->aspect;
conf->format = config->format;
conf->scanline_pitch = config->pitch;
conf->resolution_x = res.width;
conf->resolution_y = res.height;
conf->state = 1;
auto& conf = g_fxo->get<rsx::avconf>();
conf.resolution_id = config->resolutionId;
conf._3d = config->resolutionId >= CELL_VIDEO_OUT_RESOLUTION_720_3D_FRAME_PACKING;
conf.aspect = config->aspect;
conf.format = config->format;
conf.scanline_pitch = config->pitch;
conf.resolution_x = res.width;
conf.resolution_y = res.height;
conf.state = 1;
if (conf->aspect == CELL_VIDEO_OUT_ASPECT_AUTO)
if (conf.aspect == CELL_VIDEO_OUT_ASPECT_AUTO)
{
// Resolve 'auto' option to actual aspect ratio
conf->aspect = g_video_out_aspect_id.at(g_cfg.video.aspect_ratio);
conf.aspect = g_video_out_aspect_id.at(g_cfg.video.aspect_ratio);
}
cellSysutil.notice("Selected video resolution 0x%x", config->resolutionId);
@ -224,12 +224,12 @@ error_code cellVideoOutGetConfiguration(u32 videoOut, vm::ptr<CellVideoOutConfig
{
case CELL_VIDEO_OUT_PRIMARY:
{
if (auto conf = g_fxo->get<rsx::avconf>(); conf->state)
if (auto& conf = g_fxo->get<rsx::avconf>(); conf.state)
{
config->resolutionId = conf->resolution_id;
config->format = conf->format;
config->aspect = conf->aspect;
config->pitch = conf->scanline_pitch;
config->resolutionId = conf.resolution_id;
config->format = conf.format;
config->aspect = conf.aspect;
config->pitch = conf.scanline_pitch;
}
else
{

View File

@ -50,19 +50,19 @@ error_code cellVoiceConnectIPortToOPort(u32 ips, u32 ops)
{
cellVoice.todo("cellVoiceConnectIPortToOPort(ips=%d, ops=%d)", ips, ops);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto iport = manager->access_port(ips);
auto iport = manager.access_port(ips);
if (!iport || iport->info.portType >= CELLVOICE_PORTTYPE_OUT_PCMAUDIO)
return CELL_VOICE_ERROR_TOPOLOGY;
auto oport = manager->access_port(ops);
auto oport = manager.access_port(ops);
if (!oport || oport->info.portType <= CELLVOICE_PORTTYPE_IN_VOICE)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -74,11 +74,11 @@ error_code cellVoiceCreateNotifyEventQueue(ppu_thread& ppu, vm::ptr<u32> id, vm:
{
cellVoice.warning("cellVoiceCreateNotifyEventQueue(id=*0x%x, key=*0x%x)", id, key);
auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
vm::var<sys_event_queue_attribute_t> attr;
@ -111,11 +111,11 @@ error_code cellVoiceCreatePort(vm::ptr<u32> portId, vm::cptr<CellVoicePortParam>
{
cellVoice.warning("cellVoiceCreatePort(portId=*0x%x, pArg=*0x%x)", portId, pArg);
auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
if (!pArg)
@ -160,20 +160,20 @@ error_code cellVoiceCreatePort(vm::ptr<u32> portId, vm::cptr<CellVoicePortParam>
return CELL_VOICE_ERROR_ARGUMENT_INVALID;
}
if (manager->ports.size() > CELLVOICE_MAX_PORT)
if (manager.ports.size() > CELLVOICE_MAX_PORT)
return CELL_VOICE_ERROR_RESOURCE_INSUFFICIENT;
// Id: bits [8,15] seem to contain a "random" value
// bits [0,7] are based on creation counter modulo 0xa0
// The rest are set to zero and ignored.
manager->id_ctr++; manager->id_ctr %= 0xa0;
manager.id_ctr++; manager.id_ctr %= 0xa0;
// It isn't known whether bits[8,15] are guaranteed to be non-zero
constexpr u32 min_value = 1;
for (u32 ctr2 = min_value; ctr2 < CELLVOICE_MAX_PORT + min_value; ctr2++)
{
const auto [port, success] = manager->ports.try_emplace(static_cast<u16>((ctr2 << 8) | manager->id_ctr));
const auto [port, success] = manager.ports.try_emplace(static_cast<u16>((ctr2 << 8) | manager.id_ctr));
if (success)
{
@ -190,14 +190,14 @@ error_code cellVoiceDeletePort(u32 portId)
{
cellVoice.warning("cellVoiceDeletePort(portId=%d)", portId);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
if (manager->ports.erase(static_cast<u16>(portId)) == 0)
if (manager.ports.erase(static_cast<u16>(portId)) == 0)
return CELL_VOICE_ERROR_TOPOLOGY;
return CELL_OK;
@ -207,19 +207,19 @@ error_code cellVoiceDisconnectIPortFromOPort(u32 ips, u32 ops)
{
cellVoice.todo("cellVoiceDisconnectIPortFromOPort(ips=%d, ops=%d)", ips, ops);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto iport = manager->access_port(ips);
auto iport = manager.access_port(ips);
if (!iport || iport->info.portType >= CELLVOICE_PORTTYPE_OUT_PCMAUDIO)
return CELL_VOICE_ERROR_TOPOLOGY;
auto oport = manager->access_port(ops);
auto oport = manager.access_port(ops);
if (!oport || oport->info.portType <= CELLVOICE_PORTTYPE_IN_VOICE)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -231,16 +231,16 @@ error_code cellVoiceEnd()
{
cellVoice.warning("cellVoiceEnd()");
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
if (std::exchange(manager->voice_service_started, false))
if (std::exchange(manager.voice_service_started, false))
{
for (auto& key_pair : manager->queue_keys)
for (auto& key_pair : manager.queue_keys)
{
if (auto queue = lv2_event_queue::find(key_pair.first))
{
@ -252,8 +252,8 @@ error_code cellVoiceEnd()
}
}
manager->reset();
manager->is_init = false;
manager.reset();
manager.is_init = false;
return CELL_OK;
}
@ -262,11 +262,11 @@ error_code cellVoiceGetBitRate(u32 portId, vm::ptr<u32> bitrate)
{
cellVoice.warning("cellVoiceGetBitRate(portId=%d, bitrate=*0x%x)", portId, bitrate);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
// No nullptr check!
@ -274,7 +274,7 @@ error_code cellVoiceGetBitRate(u32 portId, vm::ptr<u32> bitrate)
// Constant value for errors (meaning unknown)
*bitrate = 0x4f323285;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port || (port->info.portType != CELLVOICE_PORTTYPE_IN_VOICE && port->info.portType != CELLVOICE_PORTTYPE_OUT_VOICE))
return CELL_VOICE_ERROR_TOPOLOGY;
@ -287,14 +287,14 @@ error_code cellVoiceGetMuteFlag(u32 portId, vm::ptr<u16> bMuted)
{
cellVoice.warning("cellVoiceGetMuteFlag(portId=%d, bMuted=*0x%x)", portId, bMuted);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -307,14 +307,14 @@ error_code cellVoiceGetPortAttr(u32 portId, u32 attr, vm::ptr<void> attrValue)
{
cellVoice.todo("cellVoiceGetPortAttr(portId=%d, attr=%d, attrValue=*0x%x)", portId, attr, attrValue);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -327,19 +327,19 @@ error_code cellVoiceGetPortInfo(u32 portId, vm::ptr<CellVoiceBasePortInfo> pInfo
{
cellVoice.todo("cellVoiceGetPortInfo(portId=%d, pInfo=*0x%x)", portId, pInfo);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
if (!manager->voice_service_started)
if (!manager.voice_service_started)
return CELL_VOICE_ERROR_SERVICE_DETACHED;
// No nullptr check!
@ -354,14 +354,14 @@ error_code cellVoiceGetSignalState(u32 portId, u32 attr, vm::ptr<void> attrValue
{
cellVoice.todo("cellVoiceGetSignalState(portId=%d, attr=%d, attrValue=*0x%x)", portId, attr, attrValue);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -374,14 +374,14 @@ error_code cellVoiceGetVolume(u32 portId, vm::ptr<f32> volume)
{
cellVoice.warning("cellVoiceGetVolume(portId=%d, volume=*0x%x)", portId, volume);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
// No nullptr check!
@ -399,17 +399,17 @@ error_code cellVoiceInit(vm::ptr<CellVoiceInitParam> pArg)
{
cellVoice.todo("cellVoiceInit(pArg=*0x%x)", pArg);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (manager->is_init)
if (manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_INITIALIZED;
if (!pArg)
return CELL_VOICE_ERROR_ARGUMENT_INVALID;
manager->is_init = true;
manager.is_init = true;
return CELL_OK;
}
@ -418,15 +418,15 @@ error_code cellVoiceInitEx(vm::ptr<CellVoiceInitParam> pArg)
{
cellVoice.todo("cellVoiceInitEx(pArg=*0x%x)", pArg);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
if (manager->is_init)
if (manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_INITIALIZED;
if (!pArg)
return CELL_VOICE_ERROR_ARGUMENT_INVALID;
manager->is_init = true;
manager.is_init = true;
return CELL_OK;
}
@ -435,14 +435,14 @@ error_code cellVoicePausePort(u32 portId)
{
cellVoice.todo("cellVoicePausePort(portId=%d)", portId);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -454,11 +454,11 @@ error_code cellVoicePausePortAll()
{
cellVoice.todo("cellVoicePausePortAll()");
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
return CELL_OK;
@ -468,14 +468,14 @@ error_code cellVoiceRemoveNotifyEventQueue(u64 key)
{
cellVoice.warning("cellVoiceRemoveNotifyEventQueue(key=0x%llx)", key);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
if (manager->queue_keys.erase(key) == 0)
if (manager.queue_keys.erase(key) == 0)
return CELL_VOICE_ERROR_EVENT_QUEUE;
return CELL_OK;
@ -485,14 +485,14 @@ error_code cellVoiceResetPort(u32 portId)
{
cellVoice.todo("cellVoiceResetPort(portId=%d)", portId);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -504,14 +504,14 @@ error_code cellVoiceResumePort(u32 portId)
{
cellVoice.todo("cellVoiceResumePort(portId=%d)", portId);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -523,11 +523,11 @@ error_code cellVoiceResumePortAll()
{
cellVoice.todo("cellVoiceResumePortAll()");
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
return CELL_OK;
@ -537,14 +537,14 @@ error_code cellVoiceSetBitRate(u32 portId, CellVoiceBitRate bitrate)
{
cellVoice.warning("cellVoiceSetBitRate(portId=%d, bitrate=%d)", portId, +bitrate);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port || (port->info.portType != CELLVOICE_PORTTYPE_IN_VOICE && port->info.portType != CELLVOICE_PORTTYPE_OUT_VOICE))
return CELL_VOICE_ERROR_TOPOLOGY;
@ -574,14 +574,14 @@ error_code cellVoiceSetMuteFlag(u32 portId, u16 bMuted)
{
cellVoice.warning("cellVoiceSetMuteFlag(portId=%d, bMuted=%d)", portId, bMuted);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -594,11 +594,11 @@ error_code cellVoiceSetMuteFlagAll(u16 bMuted)
{
cellVoice.warning("cellVoiceSetMuteFlagAll(bMuted=%d)", bMuted);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
// Doesn't change port->bMute value
@ -609,11 +609,11 @@ error_code cellVoiceSetNotifyEventQueue(u64 key, u64 source)
{
cellVoice.warning("cellVoiceSetNotifyEventQueue(key=0x%llx, source=0x%llx)", key, source);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
// Note: it is allowed to enqueue the key twice (another source is enqueued with FIFO ordering)
@ -626,11 +626,11 @@ error_code cellVoiceSetNotifyEventQueue(u64 key, u64 source)
{
// same thing as sys_event_port_send with port.name == 0
// Try to give different port id everytime
source = ((process_getpid() + 1ull) << 32) | (lv2_event_port::id_base + manager->port_source * lv2_event_port::id_step);
manager->port_source = (manager->port_source + 1) % lv2_event_port::id_count;
source = ((process_getpid() + 1ull) << 32) | (lv2_event_port::id_base + manager.port_source * lv2_event_port::id_step);
manager.port_source = (manager.port_source + 1) % lv2_event_port::id_count;
}
manager->queue_keys[key].push_back(source);
manager.queue_keys[key].push_back(source);
return CELL_OK;
}
@ -638,14 +638,14 @@ error_code cellVoiceSetPortAttr(u32 portId, u32 attr, vm::ptr<void> attrValue)
{
cellVoice.todo("cellVoiceSetPortAttr(portId=%d, attr=%d, attrValue=*0x%x)", portId, attr, attrValue);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -658,14 +658,14 @@ error_code cellVoiceSetVolume(u32 portId, f32 volume)
{
cellVoice.warning("cellVoiceSetVolume(portId=%d, volume=%f)", portId, volume);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -674,12 +674,12 @@ error_code cellVoiceSetVolume(u32 portId, f32 volume)
return CELL_OK;
}
error_code VoiceStart(voice_manager* manager)
error_code VoiceStart(voice_manager& manager)
{
if (std::exchange(manager->voice_service_started, true))
if (std::exchange(manager.voice_service_started, true))
return CELL_OK;
for (auto& key_pair : manager->queue_keys)
for (auto& key_pair : manager.queue_keys)
{
if (auto queue = lv2_event_queue::find(key_pair.first))
{
@ -697,11 +697,11 @@ error_code cellVoiceStart()
{
cellVoice.warning("cellVoiceStart()");
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
return VoiceStart(manager);
@ -711,11 +711,11 @@ error_code cellVoiceStartEx(vm::ptr<CellVoiceStartParam> pArg)
{
cellVoice.todo("cellVoiceStartEx(pArg=*0x%x)", pArg);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
if (!pArg)
@ -730,17 +730,17 @@ error_code cellVoiceStop()
{
cellVoice.warning("cellVoiceStop()");
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
if (!std::exchange(manager->voice_service_started, false))
if (!std::exchange(manager.voice_service_started, false))
return CELL_OK;
for (auto& key_pair : manager->queue_keys)
for (auto& key_pair : manager.queue_keys)
{
if (auto queue = lv2_event_queue::find(key_pair.first))
{
@ -758,17 +758,17 @@ error_code cellVoiceUpdatePort(u32 portId, vm::cptr<CellVoicePortParam> pArg)
{
cellVoice.warning("cellVoiceUpdatePort(portId=%d, pArg=*0x%x)", portId, pArg);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
std::scoped_lock lock(manager->mtx);
std::scoped_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
if (!pArg)
return CELL_VOICE_ERROR_ARGUMENT_INVALID;
auto port = manager->access_port(portId);
auto port = manager.access_port(portId);
if (!port)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -790,14 +790,14 @@ error_code cellVoiceWriteToIPort(u32 ips, vm::cptr<void> data, vm::ptr<u32> size
{
cellVoice.todo("cellVoiceWriteToIPort(ips=%d, data=*0x%x, size=*0x%x)", ips, data, size);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto iport = manager->access_port(ips);
auto iport = manager.access_port(ips);
if (!iport || iport->info.portType >= CELLVOICE_PORTTYPE_OUT_PCMAUDIO)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -809,14 +809,14 @@ error_code cellVoiceWriteToIPortEx(u32 ips, vm::cptr<void> data, vm::ptr<u32> si
{
cellVoice.todo("cellVoiceWriteToIPortEx(ips=%d, data=*0x%x, size=*0x%x, numFrameLost=%d)", ips, data, size, numFrameLost);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto iport = manager->access_port(ips);
auto iport = manager.access_port(ips);
if (!iport || iport->info.portType >= CELLVOICE_PORTTYPE_OUT_PCMAUDIO)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -828,14 +828,14 @@ error_code cellVoiceWriteToIPortEx2(u32 ips, vm::cptr<void> data, vm::ptr<u32> s
{
cellVoice.todo("cellVoiceWriteToIPortEx2(ips=%d, data=*0x%x, size=*0x%x, frameGaps=%d)", ips, data, size, frameGaps);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto iport = manager->access_port(ips);
auto iport = manager.access_port(ips);
if (!iport || iport->info.portType >= CELLVOICE_PORTTYPE_OUT_PCMAUDIO)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -847,14 +847,14 @@ error_code cellVoiceReadFromOPort(u32 ops, vm::ptr<void> data, vm::ptr<u32> size
{
cellVoice.todo("cellVoiceReadFromOPort(ops=%d, data=*0x%x, size=*0x%x)", ops, data, size);
const auto manager = g_fxo->get<voice_manager>();
auto& manager = g_fxo->get<voice_manager>();
reader_lock lock(manager->mtx);
reader_lock lock(manager.mtx);
if (!manager->is_init)
if (!manager.is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
auto oport = manager->access_port(ops);
auto oport = manager.access_port(ops);
if (!oport || oport->info.portType <= CELLVOICE_PORTTYPE_IN_VOICE)
return CELL_VOICE_ERROR_TOPOLOGY;
@ -869,7 +869,7 @@ error_code cellVoiceDebugTopology()
{
UNIMPLEMENTED_FUNC(cellVoice);
if (!g_fxo->get<voice_manager>()->is_init)
if (!g_fxo->get<voice_manager>().is_init)
return CELL_VOICE_ERROR_LIBVOICE_NOT_INIT;
return CELL_VOICE_ERROR_NOT_IMPLEMENTED;

View File

@ -242,12 +242,12 @@ error_code cellWebBrowserInitialize(vm::ptr<CellWebBrowserSystemCallback> system
{
cellSysutil.todo("cellWebBrowserInitialize(system_cb=*0x%x, container=0x%x)", system_cb, container);
const auto browser = g_fxo->get<browser_info>();
browser->system_cb = system_cb;
auto& browser = g_fxo->get<browser_info>();
browser.system_cb = system_cb;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &browser](ppu_thread& ppu) -> s32
{
system_cb(ppu, CELL_SYSUTIL_WEBBROWSER_INITIALIZING_FINISHED, browser->userData);
system_cb(ppu, CELL_SYSUTIL_WEBBROWSER_INITIALIZING_FINISHED, browser.userData);
return CELL_OK;
});
@ -276,11 +276,11 @@ void cellWebBrowserShutdown()
{
cellSysutil.todo("cellWebBrowserShutdown()");
const auto browser = g_fxo->get<browser_info>();
auto& browser = g_fxo->get<browser_info>();
sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([=, &browser](ppu_thread& ppu) -> s32
{
browser->system_cb(ppu, CELL_SYSUTIL_WEBBROWSER_SHUTDOWN_FINISHED, browser->userData);
browser.system_cb(ppu, CELL_SYSUTIL_WEBBROWSER_SHUTDOWN_FINISHED, browser.userData);
return CELL_OK;
});
}

View File

@ -351,9 +351,9 @@ struct surmixer_thread : ppu_thread
void non_task()
{
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
audio_port& port = g_audio->ports[g_surmx.audio_port];
audio_port& port = g_audio.ports[g_surmx.audio_port];
while (port.state != audio_port_state::closed)
{
@ -479,9 +479,9 @@ s32 cellSurMixerCreate(vm::cptr<CellSurMixerConfig> config)
{
libmixer.warning("cellSurMixerCreate(config=*0x%x)", config);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
const auto port = g_audio->open_port();
const auto port = g_audio.open_port();
if (!port)
{
@ -563,14 +563,14 @@ s32 cellSurMixerStart()
{
libmixer.warning("cellSurMixerStart()");
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
if (g_surmx.audio_port >= AUDIO_PORT_COUNT)
{
return CELL_LIBMIXER_ERROR_NOT_INITIALIZED;
}
g_audio->ports[g_surmx.audio_port].state.compare_and_swap(audio_port_state::opened, audio_port_state::started);
g_audio.ports[g_surmx.audio_port].state.compare_and_swap(audio_port_state::opened, audio_port_state::started);
return CELL_OK;
}
@ -585,14 +585,14 @@ s32 cellSurMixerFinalize()
{
libmixer.warning("cellSurMixerFinalize()");
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
if (g_surmx.audio_port >= AUDIO_PORT_COUNT)
{
return CELL_LIBMIXER_ERROR_NOT_INITIALIZED;
}
g_audio->ports[g_surmx.audio_port].state.compare_and_swap(audio_port_state::opened, audio_port_state::closed);
g_audio.ports[g_surmx.audio_port].state.compare_and_swap(audio_port_state::opened, audio_port_state::closed);
return CELL_OK;
}
@ -630,14 +630,14 @@ s32 cellSurMixerPause(u32 type)
{
libmixer.warning("cellSurMixerPause(type=%d)", type);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
if (g_surmx.audio_port >= AUDIO_PORT_COUNT)
{
return CELL_LIBMIXER_ERROR_NOT_INITIALIZED;
}
g_audio->ports[g_surmx.audio_port].state.compare_and_swap(audio_port_state::started, audio_port_state::opened);
g_audio.ports[g_surmx.audio_port].state.compare_and_swap(audio_port_state::started, audio_port_state::opened);
return CELL_OK;
}
@ -654,9 +654,9 @@ s32 cellSurMixerGetTimestamp(u64 tag, vm::ptr<u64> stamp)
{
libmixer.error("cellSurMixerGetTimestamp(tag=0x%llx, stamp=*0x%x)", tag, stamp);
const auto g_audio = g_fxo->get<cell_audio>();
auto& g_audio = g_fxo->get<cell_audio>();
*stamp = g_audio->m_start_time + tag * AUDIO_BUFFER_SAMPLES * 1'000'000 / g_audio->cfg.audio_sampling_rate;
*stamp = g_audio.m_start_time + tag * AUDIO_BUFFER_SAMPLES * 1'000'000 / g_audio.cfg.audio_sampling_rate;
return CELL_OK;
}

File diff suppressed because it is too large Load Diff

View File

@ -178,9 +178,9 @@ error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr<SceNpMatchin
error_code sceNpMatching2Term(ppu_thread& ppu);
error_code sceNpMatching2Term2();
error_code generic_match2_error_check(const named_thread<np_handler> *nph, SceNpMatching2ContextId ctxId, vm::cptr<void> reqParam, vm::ptr<SceNpMatching2RequestId> assignedReqId)
error_code generic_match2_error_check(const named_thread<np_handler>& nph, SceNpMatching2ContextId ctxId, vm::cptr<void> reqParam, vm::ptr<SceNpMatching2RequestId> assignedReqId)
{
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -207,11 +207,11 @@ error_code sceNp2Init(u32 poolsize, vm::ptr<void> poolptr)
{
sceNp2.warning("sceNp2Init(poolsize=0x%x, poolptr=*0x%x)", poolsize, poolptr);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
{
std::lock_guard lock(nph->mutex_status);
if (nph->is_NP2_init)
std::lock_guard lock(nph.mutex_status);
if (nph.is_NP2_init)
{
return SCE_NP_ERROR_ALREADY_INITIALIZED;
}
@ -224,7 +224,7 @@ error_code sceNp2Init(u32 poolsize, vm::ptr<void> poolptr)
return result;
}
nph->is_NP2_init = true;
nph.is_NP2_init = true;
return CELL_OK;
}
@ -239,14 +239,14 @@ error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr<SceNpMatchin
{
sceNp2.todo("sceNpMatching2Init2(stackSize=0x%x, priority=%d, param=*0x%x)", stackSize, priority, param);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_init)
if (!nph.is_NP2_init)
{
return SCE_NP_ERROR_NOT_INITIALIZED;
}
if (nph->is_NP2_Match2_init)
if (nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED;
}
@ -256,7 +256,7 @@ error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr<SceNpMatchin
// 2. Create heap area to be used by the NP matching 2 utility
// 3. Set maximum lengths for the event data queues in the system
nph->is_NP2_Match2_init = true;
nph.is_NP2_Match2_init = true;
return CELL_OK;
}
@ -265,11 +265,11 @@ error_code sceNp2Term(ppu_thread& ppu)
{
sceNp2.warning("sceNp2Term()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
{
std::lock_guard lock(nph->mutex_status);
if (!nph->is_NP2_init)
std::lock_guard lock(nph.mutex_status);
if (!nph.is_NP2_init)
{
return SCE_NP_ERROR_NOT_INITIALIZED;
}
@ -280,7 +280,7 @@ error_code sceNp2Term(ppu_thread& ppu)
// cellSysutilUnregisterCallbackDispatcher();
sceNpTerm();
nph->is_NP2_init = false;
nph.is_NP2_init = false;
return CELL_OK;
}
@ -295,21 +295,21 @@ error_code sceNpMatching2Term2()
{
sceNp2.warning("sceNpMatching2Term2()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
{
std::lock_guard lock(nph->mutex_status);
if (!nph->is_NP2_init)
std::lock_guard lock(nph.mutex_status);
if (!nph.is_NP2_init)
{
return SCE_NP_ERROR_NOT_INITIALIZED;
}
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
nph->is_NP2_Match2_init = false;
nph.is_NP2_Match2_init = false;
}
// TODO: for all contexts: sceNpMatching2DestroyContext
@ -321,9 +321,9 @@ error_code sceNpMatching2DestroyContext(SceNpMatching2ContextId ctxId)
{
sceNp2.todo("sceNpMatching2DestroyContext(ctxId=%d)", ctxId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -339,7 +339,7 @@ error_code sceNpMatching2LeaveLobby(
{
sceNp2.todo("sceNpMatching2LeaveLobby(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -352,9 +352,9 @@ error_code sceNpMatching2RegisterLobbyMessageCallback(SceNpMatching2ContextId ct
{
sceNp2.todo("sceNpMatching2RegisterLobbyMessageCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -367,7 +367,7 @@ error_code sceNpMatching2GetWorldInfoList(
{
sceNp2.warning("sceNpMatching2GetWorldInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -378,7 +378,7 @@ error_code sceNpMatching2GetWorldInfoList(
return SCE_NP_MATCHING2_ERROR_INVALID_SERVER_ID;
}
*assignedReqId = nph->get_world_list(ctxId, optParam, reqParam->serverId);
*assignedReqId = nph.get_world_list(ctxId, optParam, reqParam->serverId);
return CELL_OK;
}
@ -387,9 +387,9 @@ error_code sceNpMatching2RegisterLobbyEventCallback(SceNpMatching2ContextId ctxI
{
sceNp2.todo("sceNpMatching2RegisterLobbyEventCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -402,7 +402,7 @@ error_code sceNpMatching2GetLobbyMemberDataInternalList(SceNpMatching2ContextId
{
sceNp2.todo("sceNpMatching2GetLobbyMemberDataInternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -416,13 +416,13 @@ error_code sceNpMatching2SearchRoom(
{
sceNp2.warning("sceNpMatching2SearchRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->search_room(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.search_room(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -432,9 +432,9 @@ error_code sceNpMatching2SignalingGetConnectionStatus(
{
sceNp2.warning("sceNpMatching2SignalingGetConnectionStatus(ctxId=%d, roomId=%d, memberId=%d, connStatus=*0x%x, peerAddr=*0x%x, peerPort=*0x%x)", ctxId, roomId, memberId, connStatus, peerAddr, peerPort);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -444,8 +444,9 @@ error_code sceNpMatching2SignalingGetConnectionStatus(
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
}
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
const auto si = sigh->get_sig2_infos(roomId, memberId);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
const auto si = sigh.get_sig2_infos(roomId, memberId);
*connStatus = si.connStatus;
@ -467,7 +468,7 @@ error_code sceNpMatching2SetUserInfo(
{
sceNp2.todo("sceNpMatching2SetUserInfo(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -480,9 +481,9 @@ error_code sceNpMatching2GetClanLobbyId(SceNpMatching2ContextId ctxId, SceNpClan
{
sceNp2.todo("sceNpMatching2GetClanLobbyId(ctxId=%d, clanId=%d, lobbyId=*0x%x)", ctxId, clanId, lobbyId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -495,7 +496,7 @@ error_code sceNpMatching2GetLobbyMemberDataInternal(
{
sceNp2.todo("sceNpMatching2GetLobbyMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -508,9 +509,9 @@ error_code sceNpMatching2ContextStart(SceNpMatching2ContextId ctxId)
{
sceNp2.warning("sceNpMatching2ContextStart(ctxId=%d)", ctxId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -521,7 +522,8 @@ error_code sceNpMatching2ContextStart(SceNpMatching2ContextId ctxId)
if (ctx->context_callback)
{
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
ctx->context_callback(cb_ppu, ctxId, SCE_NP_MATCHING2_CONTEXT_EVENT_Start, SCE_NP_MATCHING2_EVENT_CAUSE_CONTEXT_ACTION, 0, ctx->context_callback_param);
return 0;
});
@ -535,7 +537,7 @@ error_code sceNpMatching2CreateServerContext(
{
sceNp2.warning("sceNpMatching2CreateServerContext(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -546,7 +548,7 @@ error_code sceNpMatching2CreateServerContext(
return SCE_NP_MATCHING2_ERROR_INVALID_SERVER_ID;
}
*assignedReqId = nph->create_server_context(ctxId, optParam, reqParam->serverId);
*assignedReqId = nph.create_server_context(ctxId, optParam, reqParam->serverId);
return CELL_OK;
}
@ -555,9 +557,9 @@ error_code sceNpMatching2GetMemoryInfo(vm::ptr<SceNpMatching2MemoryInfo> memInfo
{
sceNp2.todo("sceNpMatching2GetMemoryInfo(memInfo=*0x%x)", memInfo);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -570,13 +572,13 @@ error_code sceNpMatching2LeaveRoom(
{
sceNp2.warning("sceNpMatching2LeaveRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->leave_room(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.leave_room(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -586,13 +588,13 @@ error_code sceNpMatching2SetRoomDataExternal(
{
sceNp2.warning("sceNpMatching2SetRoomDataExternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->set_roomdata_external(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.set_roomdata_external(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -602,9 +604,9 @@ error_code sceNpMatching2SignalingGetConnectionInfo(
{
sceNp2.todo("sceNpMatching2SignalingGetConnectionInfo(ctxId=%d, roomId=%d, memberId=%d, code=%d, connInfo=*0x%x)", ctxId, roomId, memberId, code, connInfo);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -623,8 +625,8 @@ error_code sceNpMatching2SignalingGetConnectionInfo(
}
case 5:
{
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
const auto si = sigh->get_sig2_infos(roomId, memberId);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
const auto si = sigh.get_sig2_infos(roomId, memberId);
connInfo->address.port = std::bit_cast<u16, be_t<u16>>(si.port);
connInfo->address.addr.np_s_addr = si.addr;
break;
@ -649,13 +651,13 @@ error_code sceNpMatching2SendRoomMessage(
{
sceNp2.todo("sceNpMatching2SendRoomMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->send_room_message(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.send_room_message(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -665,7 +667,7 @@ error_code sceNpMatching2JoinLobby(
{
sceNp2.todo("sceNpMatching2JoinLobby(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -679,7 +681,7 @@ error_code sceNpMatching2GetRoomMemberDataExternalList(SceNpMatching2ContextId c
{
sceNp2.todo("sceNpMatching2GetRoomMemberDataExternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -692,9 +694,9 @@ error_code sceNpMatching2AbortRequest(SceNpMatching2ContextId ctxId, SceNpMatchi
{
sceNp2.todo("sceNpMatching2AbortRequest(ctxId=%d, reqId=%d)", ctxId, reqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -707,13 +709,13 @@ error_code sceNpMatching2GetServerInfo(
{
sceNp2.warning("sceNpMatching2GetServerInfo(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->get_server_status(ctxId, optParam, reqParam->serverId);
*assignedReqId = nph.get_server_status(ctxId, optParam, reqParam->serverId);
return CELL_OK;
}
@ -722,9 +724,9 @@ error_code sceNpMatching2GetEventData(SceNpMatching2ContextId ctxId, SceNpMatchi
{
sceNp2.notice("sceNpMatching2GetEventData(ctxId=%d, eventKey=%d, buf=*0x%x, bufLen=%d)", ctxId, eventKey, buf, bufLen);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -734,16 +736,16 @@ error_code sceNpMatching2GetEventData(SceNpMatching2ContextId ctxId, SceNpMatchi
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
}
return not_an_error(nph->get_match2_event(eventKey, static_cast<u8 *>(buf.get_ptr()), bufLen));
return not_an_error(nph.get_match2_event(eventKey, static_cast<u8 *>(buf.get_ptr()), bufLen));
}
error_code sceNpMatching2GetRoomSlotInfoLocal(SceNpMatching2ContextId ctxId, const SceNpMatching2RoomId roomId, vm::ptr<SceNpMatching2RoomSlotInfo> roomSlotInfo)
{
sceNp2.todo("sceNpMatching2GetRoomSlotInfoLocal(ctxId=%d, roomId=%d, roomSlotInfo=*0x%x)", ctxId, roomId, roomSlotInfo);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -756,7 +758,7 @@ error_code sceNpMatching2SendLobbyChatMessage(
{
sceNp2.todo("sceNpMatching2SendLobbyChatMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -769,9 +771,9 @@ error_code sceNpMatching2AbortContextStart(SceNpMatching2ContextId ctxId)
{
sceNp2.todo("sceNpMatching2AbortContextStart(ctxId=%d)", ctxId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -783,9 +785,9 @@ error_code sceNpMatching2GetRoomMemberIdListLocal(SceNpMatching2ContextId ctxId,
{
sceNp2.todo("sceNpMatching2GetRoomMemberIdListLocal(ctxId=%d, roomId=%d, sortMethod=%d, memberId=*0x%x, memberIdNum=%d)", ctxId, roomId, sortMethod, memberId, memberIdNum);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -798,13 +800,13 @@ error_code sceNpMatching2JoinRoom(
{
sceNp2.warning("sceNpMatching2JoinRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->join_room(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.join_room(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -815,9 +817,9 @@ error_code sceNpMatching2GetRoomMemberDataInternalLocal(SceNpMatching2ContextId
sceNp2.todo("sceNpMatching2GetRoomMemberDataInternalLocal(ctxId=%d, roomId=%d, memberId=%d, attrId=*0x%x, attrIdNum=%d, member=*0x%x, buf=*0x%x, bufLen=%d)", ctxId, roomId, memberId, attrId,
attrIdNum, member, buf, bufLen);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -829,9 +831,9 @@ error_code sceNpMatching2GetCbQueueInfo(SceNpMatching2ContextId ctxId, vm::ptr<S
{
sceNp2.todo("sceNpMatching2GetCbQueueInfo(ctxId=%d, queueInfo=*0x%x)", ctxId, queueInfo);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -844,7 +846,7 @@ error_code sceNpMatching2KickoutRoomMember(
{
sceNp2.todo("sceNpMatching2KickoutRoomMember(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -857,9 +859,9 @@ error_code sceNpMatching2ContextStartAsync(SceNpMatching2ContextId ctxId, u32 ti
{
sceNp2.warning("sceNpMatching2ContextStartAsync(ctxId=%d, timeout=%d)", ctxId, timeout);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -875,7 +877,8 @@ error_code sceNpMatching2ContextStartAsync(SceNpMatching2ContextId ctxId, u32 ti
if (ctx->context_callback)
{
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
ctx->context_callback(cb_ppu, ctxId, SCE_NP_MATCHING2_CONTEXT_EVENT_Start, SCE_NP_MATCHING2_EVENT_CAUSE_CONTEXT_ACTION, 0, ctx->context_callback_param);
return 0;
});
@ -889,7 +892,7 @@ error_code sceNpMatching2SetSignalingOptParam(
{
sceNp2.todo("sceNpMatching2SetSignalingOptParam(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -902,9 +905,9 @@ error_code sceNpMatching2RegisterContextCallback(SceNpMatching2ContextId ctxId,
{
sceNp2.warning("sceNpMatching2RegisterContextCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -929,7 +932,7 @@ error_code sceNpMatching2SendRoomChatMessage(
{
sceNp2.todo("sceNpMatching2SendRoomChatMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -943,13 +946,13 @@ error_code sceNpMatching2SetRoomDataInternal(
{
sceNp2.todo("sceNpMatching2SetRoomDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->set_roomdata_internal(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.set_roomdata_internal(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -959,13 +962,13 @@ error_code sceNpMatching2GetRoomDataInternal(
{
sceNp2.todo("sceNpMatching2GetRoomDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->get_roomdata_internal(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.get_roomdata_internal(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -975,13 +978,13 @@ error_code sceNpMatching2SignalingGetPingInfo(
{
sceNp2.warning("sceNpMatching2SignalingGetPingInfo(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->get_ping_info(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.get_ping_info(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -990,9 +993,9 @@ error_code sceNpMatching2GetServerIdListLocal(SceNpMatching2ContextId ctxId, vm:
{
sceNp2.todo("sceNpMatching2GetServerIdListLocal(ctxId=%d, serverId=*0x%x, serverIdNum=%d)", ctxId, serverId, serverIdNum);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1002,7 +1005,7 @@ error_code sceNpMatching2GetServerIdListLocal(SceNpMatching2ContextId ctxId, vm:
return SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND;
}
const auto slist = nph->get_match2_server_list(ctxId);
const auto slist = nph.get_match2_server_list(ctxId);
u32 num_servs = std::min(static_cast<u32>(slist.size()), serverIdNum);
@ -1040,7 +1043,7 @@ error_code sceNpMatching2GrantRoomOwner(
{
sceNp2.todo("sceNpMatching2GrantRoomOwner(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1054,9 +1057,9 @@ error_code sceNpMatching2CreateContext(
{
sceNp2.warning("sceNpMatching2CreateContext(npId=*0x%x, commId=*0x%x(%s), passPhrase=*0x%x, ctxId=*0x%x, option=%d)", npId, commId, commId->data, ctxId, option);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1075,9 +1078,9 @@ error_code sceNpMatching2GetSignalingOptParamLocal(SceNpMatching2ContextId ctxId
{
sceNp2.todo("sceNpMatching2GetSignalingOptParamLocal(ctxId=%d, roomId=%d, signalingOptParam=*0x%x)", ctxId, roomId, signalingOptParam);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1089,15 +1092,15 @@ error_code sceNpMatching2RegisterSignalingCallback(SceNpMatching2ContextId ctxId
{
sceNp2.notice("sceNpMatching2RegisterSignalingCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->set_sig2_cb(ctxId, cbFunc, cbFuncArg);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.set_sig2_cb(ctxId, cbFunc, cbFuncArg);
return CELL_OK;
}
@ -1106,9 +1109,9 @@ error_code sceNpMatching2ClearEventData(SceNpMatching2ContextId ctxId, SceNpMatc
{
sceNp2.todo("sceNpMatching2ClearEventData(ctxId=%d, eventKey=%d)", ctxId, eventKey);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1121,7 +1124,7 @@ error_code sceNpMatching2GetUserInfoList(
{
sceNp2.todo("sceNpMatching2GetUserInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1135,7 +1138,7 @@ error_code sceNpMatching2GetRoomMemberDataInternal(
{
sceNp2.todo("sceNpMatching2GetRoomMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1149,7 +1152,7 @@ error_code sceNpMatching2SetRoomMemberDataInternal(
{
sceNp2.todo("sceNpMatching2SetRoomMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1163,14 +1166,14 @@ error_code sceNpMatching2JoinProhibitiveRoom(
{
sceNp2.warning("sceNpMatching2JoinProhibitiveRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
// TODO: add blocked users
*assignedReqId = nph->join_room(ctxId, optParam, &reqParam->joinParam);
*assignedReqId = nph.join_room(ctxId, optParam, &reqParam->joinParam);
return CELL_OK;
}
@ -1179,9 +1182,9 @@ error_code sceNpMatching2SignalingSetCtxOpt(SceNpMatching2ContextId ctxId, s32 o
{
sceNp2.todo("sceNpMatching2SignalingSetCtxOpt(ctxId=%d, optname=%d, optval=%d)", ctxId, optname, optval);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1194,7 +1197,7 @@ error_code sceNpMatching2DeleteServerContext(
{
sceNp2.todo("sceNpMatching2DeleteServerContext(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1207,9 +1210,9 @@ error_code sceNpMatching2SetDefaultRequestOptParam(SceNpMatching2ContextId ctxId
{
sceNp2.warning("sceNpMatching2SetDefaultRequestOptParam(ctxId=%d, optParam=*0x%x)", ctxId, optParam);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1232,16 +1235,16 @@ error_code sceNpMatching2RegisterRoomEventCallback(SceNpMatching2ContextId ctxId
{
sceNp2.todo("sceNpMatching2RegisterRoomEventCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
nph->room_event_cb = cbFunc;
nph->room_event_cb_ctx = ctxId;
nph->room_event_cb_arg = cbFuncArg;
nph.room_event_cb = cbFunc;
nph.room_event_cb_ctx = ctxId;
nph.room_event_cb_arg = cbFuncArg;
return CELL_OK;
}
@ -1250,9 +1253,9 @@ error_code sceNpMatching2GetRoomPasswordLocal(SceNpMatching2ContextId ctxId, Sce
{
sceNp2.todo("sceNpMatching2GetRoomPasswordLocal(ctxId=%d, roomId=%d, withPassword=*0x%x, roomPassword=*0x%x)", ctxId, roomId, withPassword, roomPassword);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1265,7 +1268,7 @@ error_code sceNpMatching2GetRoomDataExternalList(
{
sceNp2.todo("sceNpMatching2GetRoomDataExternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1279,13 +1282,13 @@ error_code sceNpMatching2CreateJoinRoom(
{
sceNp2.warning("sceNpMatching2CreateJoinRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
}
*assignedReqId = nph->create_join_room(ctxId, optParam, reqParam.get_ptr());
*assignedReqId = nph.create_join_room(ctxId, optParam, reqParam.get_ptr());
return CELL_OK;
}
@ -1294,9 +1297,9 @@ error_code sceNpMatching2SignalingGetCtxOpt(SceNpMatching2ContextId ctxId, s32 o
{
sceNp2.todo("sceNpMatching2SignalingGetCtxOpt(ctxId=%d, optname=%d, optval=*0x%x)", ctxId, optname, optval);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1309,7 +1312,7 @@ error_code sceNpMatching2GetLobbyInfoList(
{
sceNp2.todo("sceNpMatching2GetLobbyInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1323,9 +1326,9 @@ error_code sceNpMatching2GetLobbyMemberIdListLocal(
{
sceNp2.todo("sceNpMatching2GetLobbyMemberIdListLocal(ctxId=%d, lobbyId=%d, memberId=*0x%x, memberIdNum=%d, me=*0x%x)", ctxId, lobbyId, memberId, memberIdNum, me);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1338,7 +1341,7 @@ error_code sceNpMatching2SendLobbyInvitation(
{
sceNp2.todo("sceNpMatching2SendLobbyInvitation(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1351,9 +1354,9 @@ error_code sceNpMatching2ContextStop(SceNpMatching2ContextId ctxId)
{
sceNp2.todo("sceNpMatching2ContextStop(ctxId=%d)", ctxId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1367,7 +1370,8 @@ error_code sceNpMatching2ContextStop(SceNpMatching2ContextId ctxId)
if (ctx->context_callback)
{
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
ctx->context_callback(cb_ppu, ctxId, SCE_NP_MATCHING2_CONTEXT_EVENT_Stop, SCE_NP_MATCHING2_EVENT_CAUSE_CONTEXT_ACTION, 0, ctx->context_callback_param);
return 0;
});
@ -1381,7 +1385,7 @@ error_code sceNpMatching2SetLobbyMemberDataInternal(
{
sceNp2.todo("sceNpMatching2SetLobbyMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
{
return res;
@ -1394,16 +1398,16 @@ error_code sceNpMatching2RegisterRoomMessageCallback(SceNpMatching2ContextId ctx
{
sceNp2.todo("sceNpMatching2RegisterRoomMessageCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
nph->room_msg_cb = cbFunc;
nph->room_msg_cb_ctx = ctxId;
nph->room_msg_cb_arg = cbFuncArg;
nph.room_msg_cb = cbFunc;
nph.room_msg_cb_ctx = ctxId;
nph.room_msg_cb_arg = cbFuncArg;
return CELL_OK;
}
@ -1412,9 +1416,9 @@ error_code sceNpMatching2SignalingCancelPeerNetInfo(SceNpMatching2ContextId ctxI
{
sceNp2.todo("sceNpMatching2SignalingCancelPeerNetInfo(ctxId=%d, reqId=%d)", ctxId, reqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1426,9 +1430,9 @@ error_code sceNpMatching2SignalingGetLocalNetInfo(vm::ptr<SceNpMatching2Signalin
{
sceNp2.todo("sceNpMatching2SignalingGetLocalNetInfo(netinfo=*0x%x)", netinfo);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1446,9 +1450,9 @@ error_code sceNpMatching2SignalingGetPeerNetInfo(SceNpMatching2ContextId ctxId,
{
sceNp2.todo("sceNpMatching2SignalingGetPeerNetInfo(ctxId=%d, roomId=%d, roomMemberId=%d, reqId=*0x%x)", ctxId, roomId, roomMemberId, reqId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1465,9 +1469,9 @@ error_code sceNpMatching2SignalingGetPeerNetInfoResult(SceNpMatching2ContextId c
{
sceNp2.todo("sceNpMatching2SignalingGetPeerNetInfoResult(ctxId=%d, reqId=%d, netinfo=*0x%x)", ctxId, reqId, netinfo);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP2_Match2_init)
if (!nph.is_NP2_Match2_init)
{
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
@ -1485,14 +1489,14 @@ error_code sceNpAuthOAuthInit()
{
sceNp2.todo("sceNpAuthOAuthInit()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (nph->is_NP_Auth_init)
if (nph.is_NP_Auth_init)
{
return SCE_NP_OAUTH_ERROR_ALREADY_INITIALIZED;
}
nph->is_NP_Auth_init = true;
nph.is_NP_Auth_init = true;
return CELL_OK;
}
@ -1501,10 +1505,10 @@ error_code sceNpAuthOAuthTerm()
{
sceNp2.todo("sceNpAuthOAuthTerm()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
// TODO: check if this might throw SCE_NP_OAUTH_ERROR_NOT_INITIALIZED
nph->is_NP_Auth_init = false;
nph.is_NP_Auth_init = false;
return CELL_OK;
}
@ -1513,9 +1517,9 @@ error_code sceNpAuthCreateOAuthRequest()
{
sceNp2.todo("sceNpAuthCreateOAuthRequest()");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP_Auth_init)
if (!nph.is_NP_Auth_init)
{
return SCE_NP_OAUTH_ERROR_NOT_INITIALIZED;
}
@ -1527,9 +1531,9 @@ error_code sceNpAuthDeleteOAuthRequest(SceNpAuthOAuthRequestId reqId)
{
sceNp2.todo("sceNpAuthDeleteOAuthRequest(reqId=%d)");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP_Auth_init)
if (!nph.is_NP_Auth_init)
{
return SCE_NP_OAUTH_ERROR_NOT_INITIALIZED;
}
@ -1541,9 +1545,9 @@ error_code sceNpAuthAbortOAuthRequest(SceNpAuthOAuthRequestId reqId)
{
sceNp2.todo("sceNpAuthAbortOAuthRequest(reqId=%d)");
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP_Auth_init)
if (!nph.is_NP_Auth_init)
{
return SCE_NP_OAUTH_ERROR_NOT_INITIALIZED;
}
@ -1555,9 +1559,9 @@ error_code sceNpAuthGetAuthorizationCode(SceNpAuthOAuthRequestId reqId, vm::cptr
{
sceNp2.todo("sceNpAuthGetAuthorizationCode(reqId=%d, param=*0x%x, authCode=*0x%x, issuerId=%d)", reqId, param, authCode, issuerId);
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (!nph->is_NP_Auth_init)
if (!nph.is_NP_Auth_init)
{
return SCE_NP_OAUTH_ERROR_NOT_INITIALIZED;
}

View File

@ -77,9 +77,9 @@ error_code sceNpClansInit(vm::cptr<SceNpCommunicationId> commId, vm::cptr<SceNpC
{
sceNpClans.warning("sceNpClansInit(commId=*0x%x, passphrase=*0x%x, pool=*0x%x, poolSize=*0x%x, flags=0x%x)", commId, passphrase, pool, poolSize, flags);
const auto clans_manager = g_fxo->get<sce_np_clans_manager>();
auto& clans_manager = g_fxo->get<sce_np_clans_manager>();
if (clans_manager->is_initialized)
if (clans_manager.is_initialized)
{
return SCE_NP_CLANS_ERROR_ALREADY_INITIALIZED;
}
@ -94,7 +94,7 @@ error_code sceNpClansInit(vm::cptr<SceNpCommunicationId> commId, vm::cptr<SceNpC
return SCE_NP_CLANS_ERROR_NOT_SUPPORTED;
}
clans_manager->is_initialized = true;
clans_manager.is_initialized = true;
return CELL_OK;
}
@ -103,14 +103,14 @@ error_code sceNpClansTerm()
{
sceNpClans.warning("sceNpClansTerm()");
const auto clans_manager = g_fxo->get<sce_np_clans_manager>();
auto& clans_manager = g_fxo->get<sce_np_clans_manager>();
if (!clans_manager->is_initialized)
if (!clans_manager.is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
clans_manager->is_initialized = false;
clans_manager.is_initialized = false;
return CELL_OK;
}
@ -119,7 +119,7 @@ error_code sceNpClansCreateRequest(vm::ptr<SceNpClansRequestHandle> handle, u64
{
sceNpClans.todo("sceNpClansCreateRequest(handle=*0x%x, flags=0x%llx)", handle, flags);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -141,7 +141,7 @@ error_code sceNpClansDestroyRequest(vm::ptr<SceNpClansRequestHandle> handle)
{
sceNpClans.todo("sceNpClansDestroyRequest(handle=*0x%x)", handle);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -153,7 +153,7 @@ error_code sceNpClansAbortRequest(vm::ptr<SceNpClansRequestHandle> handle)
{
sceNpClans.todo("sceNpClansAbortRequest(handle=*0x%x)", handle);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -165,7 +165,7 @@ error_code sceNpClansCreateClan(vm::ptr<SceNpClansRequestHandle> handle, vm::cpt
{
sceNpClans.todo("sceNpClansCreateClan(handle=*0x%x, name=%s, tag=%s, clanId=*0x%x)", handle, name, tag, clanId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -187,7 +187,7 @@ error_code sceNpClansDisbandClan(vm::ptr<SceNpClansRequestHandle> handle, SceNpC
{
sceNpClans.todo("sceNpClansDisbandClan(handle=*0x%x, clanId=*0x%x)", handle, clanId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -199,7 +199,7 @@ error_code sceNpClansGetClanList(vm::ptr<SceNpClansRequestHandle> handle, vm::cp
{
sceNpClans.todo("sceNpClansGetClanList(handle=*0x%x, paging=*0x%x, clanList=*0x%x, pageResult=*0x%x)", handle, paging, clanList, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -224,7 +224,7 @@ error_code sceNpClansGetClanListByNpId(vm::ptr<SceNpClansRequestHandle> handle,
{
sceNpClans.todo("sceNpClansGetClanListByNpId(handle=*0x%x, paging=*0x%x, npid=*0x%x, clanList=*0x%x, pageResult=*0x%x)", handle, paging, npid, clanList, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -249,7 +249,7 @@ error_code sceNpClansSearchByProfile(vm::ptr<SceNpClansRequestHandle> handle, vm
{
sceNpClans.todo("sceNpClansSearchByProfile(handle=*0x%x, paging=*0x%x, search=*0x%x, results=*0x%x, pageResult=*0x%x)", handle, paging, search, results, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -274,7 +274,7 @@ error_code sceNpClansSearchByName(vm::ptr<SceNpClansRequestHandle> handle, vm::c
{
sceNpClans.todo("sceNpClansSearchByName(handle=*0x%x, paging=*0x%x, search=*0x%x, results=*0x%x, pageResult=*0x%x)", handle, paging, search, results, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -299,7 +299,7 @@ error_code sceNpClansGetClanInfo(vm::ptr<SceNpClansRequestHandle> handle, SceNpC
{
sceNpClans.todo("sceNpClansGetClanInfo(handle=*0x%x, clanId=%d, info=*0x%x)", handle, clanId, info);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -317,7 +317,7 @@ error_code sceNpClansUpdateClanInfo(vm::ptr<SceNpClansRequestHandle> handle, Sce
{
sceNpClans.todo("sceNpClansUpdateClanInfo(handle=*0x%x, clanId=%d, info=*0x%x)", handle, clanId, info);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -340,7 +340,7 @@ error_code sceNpClansGetMemberList(vm::ptr<SceNpClansRequestHandle> handle, SceN
{
sceNpClans.todo("sceNpClansGetMemberList(handle=*0x%x, clanId=%d, paging=*0x%x, status=%d, memList=*0x%x, pageResult=*0x%x)", handle, clanId, paging, status, memList, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -365,7 +365,7 @@ error_code sceNpClansGetMemberInfo(vm::ptr<SceNpClansRequestHandle> handle, SceN
{
sceNpClans.todo("sceNpClansGetMemberInfo(handle=*0x%x, clanId=%d, npid=*0x%x, memInfo=*0x%x)", handle, clanId, npid, memInfo);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -382,7 +382,7 @@ error_code sceNpClansUpdateMemberInfo(vm::ptr<SceNpClansRequestHandle> handle, S
{
sceNpClans.todo("sceNpClansUpdateMemberInfo(handle=*0x%x, clanId=%d, memInfo=*0x%x)", handle, clanId, info);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -405,7 +405,7 @@ error_code sceNpClansChangeMemberRole(vm::ptr<SceNpClansRequestHandle> handle, S
{
sceNpClans.todo("sceNpClansChangeMemberRole(handle=*0x%x, clanId=%d, npid=*0x%x, role=%d)", handle, clanId, npid, role);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -422,7 +422,7 @@ error_code sceNpClansGetAutoAcceptStatus(vm::ptr<SceNpClansRequestHandle> handle
{
sceNpClans.todo("sceNpClansGetAutoAcceptStatus(handle=*0x%x, clanId=%d, enable=*0x%x)", handle, clanId, enable);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -439,7 +439,7 @@ error_code sceNpClansUpdateAutoAcceptStatus(vm::ptr<SceNpClansRequestHandle> han
{
sceNpClans.todo("sceNpClansUpdateAutoAcceptStatus(handle=*0x%x, clanId=%d, enable=%d)", handle, clanId, enable);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -451,7 +451,7 @@ error_code sceNpClansJoinClan(vm::ptr<SceNpClansRequestHandle> handle, SceNpClan
{
sceNpClans.todo("sceNpClansJoinClan(handle=*0x%x, clanId=%d)", handle, clanId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -463,7 +463,7 @@ error_code sceNpClansLeaveClan(vm::ptr<SceNpClansRequestHandle> handle, SceNpCla
{
sceNpClans.todo("sceNpClansLeaveClan(handle=*0x%x, clanId=%d)", handle, clanId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -475,7 +475,7 @@ error_code sceNpClansKickMember(vm::ptr<SceNpClansRequestHandle> handle, SceNpCl
{
sceNpClans.todo("sceNpClansKickMember(handle=*0x%x, clanId=%d, npid=*0x%x, message=*0x%x)", handle, clanId, npid, message);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -500,7 +500,7 @@ error_code sceNpClansSendInvitation(vm::ptr<SceNpClansRequestHandle> handle, Sce
{
sceNpClans.todo("sceNpClansSendInvitation(handle=*0x%x, clanId=%d, npid=*0x%x, message=*0x%x)", handle, clanId, npid, message);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -525,7 +525,7 @@ error_code sceNpClansCancelInvitation(vm::ptr<SceNpClansRequestHandle> handle, S
{
sceNpClans.todo("sceNpClansCancelInvitation(handle=*0x%x, clanId=%d, npid=*0x%x)", handle, clanId, npid);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -542,7 +542,7 @@ error_code sceNpClansSendInvitationResponse(vm::ptr<SceNpClansRequestHandle> han
{
sceNpClans.todo("sceNpClansSendInvitationResponse(handle=*0x%x, clanId=%d, message=*0x%x, accept=%d)", handle, clanId, message, accept);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -562,7 +562,7 @@ error_code sceNpClansSendMembershipRequest(vm::ptr<SceNpClansRequestHandle> hand
{
sceNpClans.todo("sceNpClansSendMembershipRequest(handle=*0x%x, clanId=%d, message=*0x%x)", handle, clanId, message);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -582,7 +582,7 @@ error_code sceNpClansCancelMembershipRequest(vm::ptr<SceNpClansRequestHandle> ha
{
sceNpClans.todo("sceNpClansCancelMembershipRequest(handle=*0x%x, clanId=%d)", handle, clanId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -594,7 +594,7 @@ error_code sceNpClansSendMembershipResponse(vm::ptr<SceNpClansRequestHandle> han
{
sceNpClans.todo("sceNpClansSendMembershipResponse(handle=*0x%x, clanId=%d, npid=*0x%x, message=*0x%x, allow=%d)", handle, clanId, npid, message, allow);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -619,7 +619,7 @@ error_code sceNpClansGetBlacklist(vm::ptr<SceNpClansRequestHandle> handle, SceNp
{
sceNpClans.todo("sceNpClansGetBlacklist(handle=*0x%x, clanId=%d, paging=*0x%x, bl=*0x%x, pageResult=*0x%x)", handle, clanId, paging, bl, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -644,7 +644,7 @@ error_code sceNpClansAddBlacklistEntry(vm::ptr<SceNpClansRequestHandle> handle,
{
sceNpClans.todo("sceNpClansAddBlacklistEntry(handle=*0x%x, clanId=%d, npid=*0x%x)", handle, clanId, npid);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -661,7 +661,7 @@ error_code sceNpClansRemoveBlacklistEntry(vm::ptr<SceNpClansRequestHandle> handl
{
sceNpClans.todo("sceNpClansRemoveBlacklistEntry(handle=*0x%x, clanId=%d, npid=*0x%x)", handle, clanId, npid);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -678,7 +678,7 @@ error_code sceNpClansRetrieveAnnouncements(vm::ptr<SceNpClansRequestHandle> hand
{
sceNpClans.todo("sceNpClansRetrieveAnnouncements(handle=*0x%x, clanId=%d, paging=*0x%x, mlist=*0x%x, pageResult=*0x%x)", handle, clanId, paging, mlist, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -703,7 +703,7 @@ error_code sceNpClansPostAnnouncement(vm::ptr<SceNpClansRequestHandle> handle, S
{
sceNpClans.todo("sceNpClansPostAnnouncement(handle=*0x%x, clanId=%d, message=*0x%x, data=*0x%x, duration=%d, mId=*0x%x)", handle, clanId, message, data, duration, mId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -730,7 +730,7 @@ error_code sceNpClansRemoveAnnouncement(vm::ptr<SceNpClansRequestHandle> handle,
{
sceNpClans.todo("sceNpClansPostAnnouncement(handle=*0x%x, clanId=%d, mId=%d)", handle, clanId, mId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -742,7 +742,7 @@ error_code sceNpClansPostChallenge(vm::ptr<SceNpClansRequestHandle> handle, SceN
{
sceNpClans.todo("sceNpClansPostChallenge(handle=*0x%x, clanId=%d, targetClan=%d, message=*0x%x, data=*0x%x, duration=%d, mId=*0x%x)", handle, clanId, targetClan, message, data, duration, mId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -769,7 +769,7 @@ error_code sceNpClansRetrievePostedChallenges(vm::ptr<SceNpClansRequestHandle> h
{
sceNpClans.todo("sceNpClansRetrievePostedChallenges(handle=*0x%x, clanId=%d, targetClan=%d, paging=*0x%x, mList=*0x%x, pageResult=*0x%x)", handle, clanId, targetClan, paging, mList, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -794,7 +794,7 @@ error_code sceNpClansRemovePostedChallenge(vm::ptr<SceNpClansRequestHandle> hand
{
sceNpClans.todo("sceNpClansRemovePostedChallenge(handle=*0x%x, clanId=%d, targetClan=%d, mId=%d)", handle, clanId, targetClan, mId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -806,7 +806,7 @@ error_code sceNpClansRetrieveChallenges(vm::ptr<SceNpClansRequestHandle> handle,
{
sceNpClans.todo("sceNpClansRetrieveChallenges(handle=*0x%x, clanId=%d, paging=*0x%x, mList=*0x%x, pageResult=*0x%x)", handle, clanId, paging, mList, pageResult);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
@ -831,7 +831,7 @@ error_code sceNpClansRemoveChallenge(SceNpClansRequestHandle handle, SceNpClanId
{
sceNpClans.todo("sceNpClansRemoveChallenge(handle=*0x%x, clanId=%d, mId=%d)", handle, clanId, mId);
if (!g_fxo->get<sce_np_clans_manager>()->is_initialized)
if (!g_fxo->get<sce_np_clans_manager>().is_initialized)
{
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}

View File

@ -43,9 +43,9 @@ error_code sceNpSnsFbInit(vm::cptr<SceNpSnsFbInitParams> params)
{
sceNpSns.todo("sceNpSnsFbInit(params=*0x%x)", params);
const auto manager = g_fxo->get<sce_np_sns_manager>();
auto& manager = g_fxo->get<sce_np_sns_manager>();
if (manager->is_initialized)
if (manager.is_initialized)
{
return SCE_NP_SNS_FB_ERROR_ALREADY_INITIALIZED;
}
@ -57,7 +57,7 @@ error_code sceNpSnsFbInit(vm::cptr<SceNpSnsFbInitParams> params)
// TODO: Use the initialization parameters somewhere
manager->is_initialized = true;
manager.is_initialized = true;
return CELL_OK;
}
@ -66,14 +66,14 @@ error_code sceNpSnsFbTerm()
{
sceNpSns.warning("sceNpSnsFbTerm()");
const auto manager = g_fxo->get<sce_np_sns_manager>();
auto& manager = g_fxo->get<sce_np_sns_manager>();
if (!manager->is_initialized)
if (!manager.is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
manager->is_initialized = false;
manager.is_initialized = false;
return CELL_OK;
}
@ -82,7 +82,7 @@ error_code sceNpSnsFbCreateHandle(vm::ptr<u32> handle)
{
sceNpSns.warning("sceNpSnsFbCreateHandle(handle=*0x%x)", handle);
if (!g_fxo->get<sce_np_sns_manager>()->is_initialized)
if (!g_fxo->get<sce_np_sns_manager>().is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
@ -107,7 +107,7 @@ error_code sceNpSnsFbDestroyHandle(u32 handle)
{
sceNpSns.warning("sceNpSnsFbDestroyHandle(handle=%d)", handle);
if (!g_fxo->get<sce_np_sns_manager>()->is_initialized)
if (!g_fxo->get<sce_np_sns_manager>().is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
@ -129,7 +129,7 @@ error_code sceNpSnsFbAbortHandle(u32 handle)
{
sceNpSns.todo("sceNpSnsFbAbortHandle(handle=%d)", handle);
if (!g_fxo->get<sce_np_sns_manager>()->is_initialized)
if (!g_fxo->get<sce_np_sns_manager>().is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
@ -160,7 +160,7 @@ error_code sceNpSnsFbGetAccessToken(u32 handle, vm::cptr<SceNpSnsFbAccessTokenPa
return SCE_NP_SNS_ERROR_INVALID_ARGUMENT;
}
if (!g_fxo->get<sce_np_sns_manager>()->is_initialized)
if (!g_fxo->get<sce_np_sns_manager>().is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
@ -179,9 +179,9 @@ error_code sceNpSnsFbGetAccessToken(u32 handle, vm::cptr<SceNpSnsFbAccessTokenPa
return SCE_NP_SNS_FB_ERROR_UNKNOWN_HANDLE;
}
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (nph->get_psn_status() == SCE_NP_MANAGER_STATUS_OFFLINE)
if (nph.get_psn_status() == SCE_NP_MANAGER_STATUS_OFFLINE)
{
return not_an_error(SCE_NP_SNS_ERROR_NOT_SIGN_IN);
}
@ -229,7 +229,7 @@ s32 sceNpSnsFbCheckThrottle(vm::ptr<void> arg0)
return SCE_NP_SNS_ERROR_INVALID_ARGUMENT;
}
if (!g_fxo->get<sce_np_sns_manager>()->is_initialized)
if (!g_fxo->get<sce_np_sns_manager>().is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
@ -241,7 +241,7 @@ s32 sceNpSnsFbCheckConfig(vm::ptr<void> arg0)
{
sceNpSns.todo("sceNpSnsFbCheckConfig(arg0=*0x%x)", arg0);
if (!g_fxo->get<sce_np_sns_manager>()->is_initialized)
if (!g_fxo->get<sce_np_sns_manager>().is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
@ -287,7 +287,7 @@ error_code sceNpSnsFbGetLongAccessToken(u32 handle, vm::cptr<SceNpSnsFbAccessTok
return SCE_NP_SNS_ERROR_INVALID_ARGUMENT;
}
if (!g_fxo->get<sce_np_sns_manager>()->is_initialized)
if (!g_fxo->get<sce_np_sns_manager>().is_initialized)
{
return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED;
}
@ -306,9 +306,9 @@ error_code sceNpSnsFbGetLongAccessToken(u32 handle, vm::cptr<SceNpSnsFbAccessTok
return SCE_NP_SNS_FB_ERROR_UNKNOWN_HANDLE;
}
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (nph->get_psn_status() == SCE_NP_MANAGER_STATUS_OFFLINE)
if (nph.get_psn_status() == SCE_NP_MANAGER_STATUS_OFFLINE)
{
return not_an_error(SCE_NP_SNS_ERROR_NOT_SIGN_IN);
}

View File

@ -209,11 +209,11 @@ error_code sceNpTrophyInit(vm::ptr<void> pool, u32 poolSize, u32 containerId, u6
{
sceNpTrophy.warning("sceNpTrophyInit(pool=*0x%x, poolSize=0x%x, containerId=0x%x, options=0x%llx)", pool, poolSize, containerId, options);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::scoped_lock lock(trophy_manager->mtx);
std::scoped_lock lock(trophy_manager.mtx);
if (trophy_manager->is_initialized)
if (trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_ALREADY_INITIALIZED;
}
@ -223,7 +223,7 @@ error_code sceNpTrophyInit(vm::ptr<void> pool, u32 poolSize, u32 containerId, u6
return SCE_NP_TROPHY_ERROR_NOT_SUPPORTED;
}
trophy_manager->is_initialized = true;
trophy_manager.is_initialized = true;
return CELL_OK;
}
@ -232,11 +232,11 @@ error_code sceNpTrophyTerm()
{
sceNpTrophy.warning("sceNpTrophyTerm()");
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::scoped_lock lock(trophy_manager->mtx);
std::scoped_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
@ -244,7 +244,7 @@ error_code sceNpTrophyTerm()
idm::clear<trophy_context_t>();
idm::clear<trophy_handle_t>();
trophy_manager->is_initialized = false;
trophy_manager.is_initialized = false;
return CELL_OK;
}
@ -253,11 +253,11 @@ error_code sceNpTrophyCreateHandle(vm::ptr<u32> handle)
{
sceNpTrophy.warning("sceNpTrophyCreateHandle(handle=*0x%x)", handle);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::scoped_lock lock(trophy_manager->mtx);
std::scoped_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
@ -282,12 +282,12 @@ error_code sceNpTrophyDestroyHandle(u32 handle)
{
sceNpTrophy.warning("sceNpTrophyDestroyHandle(handle=0x%x)", handle);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::scoped_lock lock(trophy_manager->mtx);
std::scoped_lock lock(trophy_manager.mtx);
// TODO: find out if this is checked
//if (!trophy_manager->is_initialized)
//if (!trophy_manager.is_initialized)
//{
// return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
//}
@ -316,12 +316,12 @@ error_code sceNpTrophyAbortHandle(u32 handle)
{
sceNpTrophy.todo("sceNpTrophyAbortHandle(handle=0x%x)", handle);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::scoped_lock lock(trophy_manager->mtx);
std::scoped_lock lock(trophy_manager.mtx);
// TODO: find out if this is checked
//if (!trophy_manager->is_initialized)
//if (!trophy_manager.is_initialized)
//{
// return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
//}
@ -356,11 +356,11 @@ error_code sceNpTrophyCreateContext(vm::ptr<u32> context, vm::cptr<SceNpCommunic
sceNpTrophy.notice("sceNpTrophyCreateContext(): commSign = %s", *commSign);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::scoped_lock lock(trophy_manager->mtx);
std::scoped_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
@ -434,11 +434,11 @@ error_code sceNpTrophyDestroyContext(u32 context)
{
sceNpTrophy.warning("sceNpTrophyDestroyContext(context=0x%x)", context);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::scoped_lock lock(trophy_manager->mtx);
std::scoped_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
@ -461,16 +461,16 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
{
sceNpTrophy.error("sceNpTrophyRegisterContext(context=0x%x, handle=0x%x, statusCb=*0x%x, arg=*0x%x, options=0x%llx)", context, handle, statusCb, arg, options);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
std::shared_lock lock(trophy_manager->mtx);
std::shared_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
const auto handle_ptr = idm::get<trophy_handle_t>(handle);
if (error)
@ -543,16 +543,16 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
return SCE_NP_TROPHY_ERROR_PROCESSING_ABORTED;
}
std::unique_lock lock2(trophy_manager->mtx);
std::unique_lock lock2(trophy_manager.mtx);
// Rerun error checks, the callback could have changed stuff by calling sceNpTrophy functions internally
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt2, error2] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt2, error2] = trophy_manager.get_context_ex(context, handle);
if (error2)
{
@ -654,16 +654,16 @@ error_code sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, vm::ptr<u64>
return SCE_NP_TROPHY_ERROR_NOT_SUPPORTED;
}
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -710,16 +710,16 @@ error_code sceNpTrophySetSoundLevel(u32 context, u32 handle, u32 level, u64 opti
return SCE_NP_TROPHY_ERROR_NOT_SUPPORTED;
}
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -733,16 +733,16 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGa
{
sceNpTrophy.error("sceNpTrophyGetGameInfo(context=0x%x, handle=0x%x, details=*0x%x, data=*0x%x)", context, handle, details, data);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -845,16 +845,16 @@ error_code sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::pt
{
sceNpTrophy.error("sceNpTrophyUnlockTrophy(context=0x%x, handle=0x%x, trophyId=%d, platinumId=*0x%x)", context, handle, trophyId, platinumId);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -931,16 +931,16 @@ error_code sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, vm::ptr<SceN
return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT;
}
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -1092,16 +1092,16 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p
return SCE_NP_TROPHY_ERROR_INVALID_TROPHY_ID;
}
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -1120,16 +1120,16 @@ error_code sceNpTrophyGetGameProgress(u32 context, u32 handle, vm::ptr<s32> perc
return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT;
}
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -1160,16 +1160,16 @@ error_code sceNpTrophyGetGameIcon(u32 context, u32 handle, vm::ptr<void> buffer,
{
sceNpTrophy.warning("sceNpTrophyGetGameIcon(context=0x%x, handle=0x%x, buffer=*0x%x, size=*0x%x)", context, handle, buffer, size);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{
@ -1210,16 +1210,16 @@ error_code sceNpTrophyGetTrophyIcon(u32 context, u32 handle, s32 trophyId, vm::p
{
sceNpTrophy.warning("sceNpTrophyGetTrophyIcon(context=0x%x, handle=0x%x, trophyId=%d, buffer=*0x%x, size=*0x%x)", context, handle, trophyId, buffer, size);
const auto trophy_manager = g_fxo->get<sce_np_trophy_manager>();
auto& trophy_manager = g_fxo->get<sce_np_trophy_manager>();
reader_lock lock(trophy_manager->mtx);
reader_lock lock(trophy_manager.mtx);
if (!trophy_manager->is_initialized)
if (!trophy_manager.is_initialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
const auto [ctxt, error] = trophy_manager->get_context_ex(context, handle);
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
if (error)
{

File diff suppressed because it is too large Load Diff

View File

@ -11,14 +11,14 @@ error_code sceNpUtilBandwidthTestInitStart(u32 prio, u64 stack)
{
sceNpUtil.todo("sceNpUtilBandwidthTestInitStart(prio=%d, stack=%d)", prio, stack);
const auto util_manager = g_fxo->get<sce_np_util_manager>();
auto& util_manager = g_fxo->get<sce_np_util_manager>();
if (util_manager->is_initialized)
if (util_manager.is_initialized)
{
return SCE_NP_ERROR_ALREADY_INITIALIZED;
}
util_manager->is_initialized = true;
util_manager.is_initialized = true;
return CELL_OK;
}
@ -27,7 +27,7 @@ error_code sceNpUtilBandwidthTestGetStatus()
{
sceNpUtil.todo("sceNpUtilBandwidthTestGetStatus()");
if (!g_fxo->get<sce_np_util_manager>()->is_initialized)
if (!g_fxo->get<sce_np_util_manager>().is_initialized)
{
return SCE_NP_ERROR_NOT_INITIALIZED;
}
@ -39,14 +39,14 @@ error_code sceNpUtilBandwidthTestShutdown(vm::ptr<SceNpUtilBandwidthTestResult>
{
sceNpUtil.todo("sceNpUtilBandwidthTestShutdown(result=*0x%x)", result);
const auto util_manager = g_fxo->get<sce_np_util_manager>();
auto& util_manager = g_fxo->get<sce_np_util_manager>();
if (!util_manager->is_initialized)
if (!util_manager.is_initialized)
{
return SCE_NP_ERROR_NOT_INITIALIZED;
}
util_manager->is_initialized = false;
util_manager.is_initialized = false;
return CELL_OK;
}
@ -55,7 +55,7 @@ error_code sceNpUtilBandwidthTestAbort()
{
sceNpUtil.todo("sceNpUtilBandwidthTestAbort()");
if (!g_fxo->get<sce_np_util_manager>()->is_initialized)
if (!g_fxo->get<sce_np_util_manager>().is_initialized)
{
return SCE_NP_ERROR_NOT_INITIALIZED;
}

View File

@ -27,26 +27,26 @@ struct libio_sys_config
// Only exists internally (has no name)
extern void libio_sys_config_init()
{
auto cfg = g_fxo->get<libio_sys_config>();
auto& cfg = g_fxo->get<libio_sys_config>();
std::lock_guard lock(cfg->mtx);
std::lock_guard lock(cfg.mtx);
if (cfg->init_ctr++ == 0)
if (cfg.init_ctr++ == 0)
{
// Belongs to "_cfg_evt_hndlr" thread (8k stack)
cfg->stack_addr = (ensure(vm::alloc(0x2000, vm::stack, 4096)));
cfg.stack_addr = ensure(vm::alloc(0x2000, vm::stack, 4096));
}
}
extern void libio_sys_config_end()
{
auto cfg = g_fxo->get<libio_sys_config>();
auto& cfg = g_fxo->get<libio_sys_config>();
std::lock_guard lock(cfg->mtx);
std::lock_guard lock(cfg.mtx);
if (cfg->init_ctr-- == 1)
if (cfg.init_ctr-- == 1)
{
ensure(vm::dealloc(std::exchange(cfg->stack_addr, 0), vm::stack));
ensure(vm::dealloc(std::exchange(cfg.stack_addr, 0), vm::stack));
}
}

View File

@ -777,12 +777,12 @@ static void ppu_check_patch_spu_images(const ppu_segment& seg)
for (const auto& prog : obj.progs)
{
// Apply the patch
applied += g_fxo->get<patch_engine>()->apply(hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
applied += g_fxo->get<patch_engine>().apply(hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
if (!Emu.GetTitleID().empty())
{
// Alternative patch
applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
applied += g_fxo->get<patch_engine>().apply(Emu.GetTitleID() + '-' + hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
}
}
@ -800,7 +800,7 @@ static void ppu_check_patch_spu_images(const ppu_segment& seg)
void try_spawn_ppu_if_exclusive_program(const ppu_module& m)
{
// If only PRX/OVL has been loaded at Emu.BootGame(), launch a single PPU thread so its memory can be viewed
if (Emu.IsReady() && g_fxo->get<ppu_module>()->segs.empty())
if (Emu.IsReady() && g_fxo->get<ppu_module>().segs.empty())
{
ppu_thread_params p
{
@ -829,10 +829,10 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
const auto prx = idm::make_ptr<lv2_obj, lv2_prx>();
// Access linkage information object
const auto link = g_fxo->get<ppu_linkage_info>();
auto& link = g_fxo->get<ppu_linkage_info>();
// Initialize HLE modules
ppu_initialize_modules(link);
ppu_initialize_modules(&link);
// Library hash
sha1_context sha;
@ -1079,8 +1079,8 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
ppu_loader.warning("Library %s (rtoc=0x%x):", lib_name, lib_info->toc);
prx->specials = ppu_load_exports(link, lib_info->exports_start, lib_info->exports_end);
prx->imports = ppu_load_imports(prx->relocs, link, lib_info->imports_start, lib_info->imports_end);
prx->specials = ppu_load_exports(&link, lib_info->exports_start, lib_info->exports_end);
prx->imports = ppu_load_imports(prx->relocs, &link, lib_info->imports_start, lib_info->imports_end);
std::stable_sort(prx->relocs.begin(), prx->relocs.end());
toc = lib_info->toc;
}
@ -1113,17 +1113,17 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
const std::string hash_seg = fmt::format("%s-%u", hash, i);
// Apply the patch
auto _applied = g_fxo->get<patch_engine>()->apply(hash_seg, vm::get_super_ptr(seg.addr), seg.size);
auto _applied = g_fxo->get<patch_engine>().apply(hash_seg, vm::get_super_ptr(seg.addr), seg.size);
if (!Emu.GetTitleID().empty())
{
// Alternative patch
_applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash_seg, vm::get_super_ptr(seg.addr), seg.size);
_applied += g_fxo->get<patch_engine>().apply(Emu.GetTitleID() + '-' + hash_seg, vm::get_super_ptr(seg.addr), seg.size);
}
// Rebase patch offsets
std::for_each(_applied.begin(), _applied.end(), [&](u32& res) { if (res != umax) res += seg.addr; });
applied += _applied;
if (_applied.empty())
@ -1205,11 +1205,13 @@ bool ppu_load_exec(const ppu_exec_object& elf)
}
}
g_fxo->need<ppu_linkage_info>();
// Set for delayed initialization in ppu_initialize()
const auto _main = g_fxo->get<ppu_module>();
auto& _main = g_fxo->get<ppu_module>();
// Access linkage information object
const auto link = g_fxo->init<ppu_linkage_info>();
auto& link = g_fxo->get<ppu_linkage_info>();
// TLS information
u32 tls_vaddr = 0;
@ -1232,7 +1234,7 @@ bool ppu_load_exec(const ppu_exec_object& elf)
struct on_fatal_error
{
ppu_module* _main;
ppu_module& _main;
bool errored = true;
~on_fatal_error()
@ -1243,7 +1245,7 @@ bool ppu_load_exec(const ppu_exec_object& elf)
}
// Revert previous allocations on an error
for (const auto& seg : _main->segs)
for (const auto& seg : _main.segs)
{
vm::dealloc(seg.addr);
}
@ -1300,7 +1302,7 @@ bool ppu_load_exec(const ppu_exec_object& elf)
}
// Store only LOAD segments (TODO)
_main->segs.emplace_back(_seg);
_main.segs.emplace_back(_seg);
}
}
@ -1321,33 +1323,33 @@ bool ppu_load_exec(const ppu_exec_object& elf)
if (addr && size)
{
_main->secs.emplace_back(_sec);
_main.secs.emplace_back(_sec);
if (_sec.flags & 0x4 && addr >= _main->segs[0].addr && addr + size <= _main->segs[0].addr + _main->segs[0].size)
if (_sec.flags & 0x4 && addr >= _main.segs[0].addr && addr + size <= _main.segs[0].addr + _main.segs[0].size)
{
end = std::max<u32>(end, addr + size);
}
}
}
sha1_finish(&sha, _main->sha1);
sha1_finish(&sha, _main.sha1);
// Format patch name
std::string hash("PPU-0000000000000000000000000000000000000000");
for (u32 i = 0; i < 20; i++)
{
constexpr auto pal = "0123456789abcdef";
hash[4 + i * 2] = pal[_main->sha1[i] >> 4];
hash[5 + i * 2] = pal[_main->sha1[i] & 15];
hash[4 + i * 2] = pal[_main.sha1[i] >> 4];
hash[5 + i * 2] = pal[_main.sha1[i] & 15];
}
// Apply the patch
auto applied = g_fxo->get<patch_engine>()->apply(hash, vm::g_base_addr);
auto applied = g_fxo->get<patch_engine>().apply(hash, vm::g_base_addr);
if (!Emu.GetTitleID().empty())
{
// Alternative patch
applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash, vm::g_base_addr);
applied += g_fxo->get<patch_engine>().apply(Emu.GetTitleID() + '-' + hash, vm::g_base_addr);
}
if (applied.empty())
@ -1360,10 +1362,10 @@ bool ppu_load_exec(const ppu_exec_object& elf)
}
// Initialize HLE modules
ppu_initialize_modules(link);
ppu_initialize_modules(&link);
// Embedded SPU elf patching
for (const auto& seg : _main->segs)
for (const auto& seg : _main.segs)
{
ppu_check_patch_spu_images(seg);
}
@ -1373,10 +1375,10 @@ bool ppu_load_exec(const ppu_exec_object& elf)
{
auto shle = g_fxo->init<statichle_handler>(0);
for (u32 i = _main->segs[0].addr; i < (_main->segs[0].addr + _main->segs[0].size); i += 4)
for (u32 i = _main.segs[0].addr; i < (_main.segs[0].addr + _main.segs[0].size); i += 4)
{
vm::cptr<u8> _ptr = vm::cast(i);
shle->check_against_patterns(_ptr, (_main->segs[0].addr + _main->segs[0].size) - i, i);
shle->check_against_patterns(_ptr, (_main.segs[0].addr + _main.segs[0].size) - i, i);
}
}
@ -1512,9 +1514,9 @@ bool ppu_load_exec(const ppu_exec_object& elf)
return false;
}
ppu_load_exports(link, proc_prx_param.libent_start, proc_prx_param.libent_end);
ppu_load_imports(_main->relocs, link, proc_prx_param.libstub_start, proc_prx_param.libstub_end);
std::stable_sort(_main->relocs.begin(), _main->relocs.end());
ppu_load_exports(&link, proc_prx_param.libent_start, proc_prx_param.libent_end);
ppu_load_imports(_main.relocs, &link, proc_prx_param.libstub_start, proc_prx_param.libstub_end);
std::stable_sort(_main.relocs.begin(), _main.relocs.end());
}
break;
}
@ -1594,14 +1596,14 @@ bool ppu_load_exec(const ppu_exec_object& elf)
}
// Set path (TODO)
_main->name.clear();
_main->path = vfs::get(Emu.argv[0]);
_main.name.clear();
_main.path = vfs::get(Emu.argv[0]);
// Analyse executable (TODO)
_main->analyse(0, static_cast<u32>(elf.header.e_entry), end, applied);
_main.analyse(0, static_cast<u32>(elf.header.e_entry), end, applied);
// Validate analyser results (not required)
_main->validate(0);
_main.validate(0);
// Set SDK version
g_ps3_process_info.sdk_ver = sdk_version;
@ -1781,7 +1783,7 @@ std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const ppu_ex
}
// Access linkage information object
const auto link = g_fxo->get<ppu_linkage_info>();
auto& link = g_fxo->get<ppu_linkage_info>();
// Executable hash
sha1_context sha;
@ -1903,12 +1905,12 @@ std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const ppu_ex
}
// Apply the patch
auto applied = g_fxo->get<patch_engine>()->apply(hash, vm::g_base_addr);
auto applied = g_fxo->get<patch_engine>().apply(hash, vm::g_base_addr);
if (!Emu.GetTitleID().empty())
{
// Alternative patch
applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash, vm::g_base_addr);
applied += g_fxo->get<patch_engine>().apply(Emu.GetTitleID() + '-' + hash, vm::g_base_addr);
}
// Embedded SPU elf patching
@ -1997,8 +1999,8 @@ std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const ppu_ex
fmt::throw_exception("Bad magic! (0x%x)", proc_prx_param.magic);
}
ppu_load_exports(link, proc_prx_param.libent_start, proc_prx_param.libent_end);
ppu_load_imports(ovlm->relocs, link, proc_prx_param.libstub_start, proc_prx_param.libstub_end);
ppu_load_exports(&link, proc_prx_param.libent_start, proc_prx_param.libent_end);
ppu_load_imports(ovlm->relocs, &link, proc_prx_param.libstub_start, proc_prx_param.libstub_end);
}
break;
}

View File

@ -456,7 +456,7 @@ static bool ppu_break(ppu_thread& ppu, ppu_opcode_t op)
{
// Pause
ppu.state.atomic_op([](bs_t<cpu_flag>& state) { if (!(state & cpu_flag::dbg_step)) state += cpu_flag::dbg_pause; });
if (ppu.check_state())
{
return false;
@ -2216,7 +2216,7 @@ extern void ppu_finalize(const ppu_module& info)
}
#ifdef LLVM_AVAILABLE
g_fxo->get<jit_module_manager>()->remove(cache_path + info.name);
g_fxo->get<jit_module_manager>().remove(cache_path + info.name);
#endif
}
@ -2515,9 +2515,9 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<lv2_
extern void ppu_initialize()
{
const auto _main = g_fxo->get<ppu_module>();
auto& _main = g_fxo->get<ppu_module>();
if (!_main)
if (!g_fxo->is_init<ppu_module>())
{
return;
}
@ -2530,9 +2530,9 @@ extern void ppu_initialize()
bool compile_main = false;
// Check main module cache
if (!_main->segs.empty())
if (!_main.segs.empty())
{
compile_main = ppu_initialize(*_main, true);
compile_main = ppu_initialize(_main, true);
}
std::vector<lv2_prx*> prx_list;
@ -2575,9 +2575,9 @@ extern void ppu_initialize()
}
// Initialize main module cache
if (!_main->segs.empty())
if (!_main.segs.empty())
{
ppu_initialize(*_main);
ppu_initialize(_main);
}
// Initialize preloaded libraries
@ -2602,7 +2602,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
}
// Temporarily
s_ppu_toc = g_fxo->get<std::unordered_map<u32, u32>>();
s_ppu_toc = &g_fxo->get<std::unordered_map<u32, u32>>();
for (const auto& func : info.funcs)
{
@ -2709,7 +2709,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
};
// Permanently loaded compiled PPU modules (name -> data)
jit_module& jit_mod = g_fxo->get<jit_module_manager>()->get(cache_path + info.name);
jit_module& jit_mod = g_fxo->get<jit_module_manager>().get(cache_path + info.name);
// Compiler instance (deferred initialization)
std::shared_ptr<jit_compiler>& jit = jit_mod.pjit;
@ -2976,7 +2976,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
// Prevent watchdog thread from terminating
g_watchdog_hold_ctr++;
named_thread_group threads(fmt::format("PPUW.%u.", ++g_fxo->get<thread_index_allocator>()->index), thread_count, [&]()
named_thread_group threads(fmt::format("PPUW.%u.", ++g_fxo->get<thread_index_allocator>().index), thread_count, [&]()
{
// Set low priority
thread_ctrl::scoped_priority low_prio(-1);
@ -2992,7 +2992,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
const auto [obj_name, part] = std::as_const(workload)[i];
// Allocate "core"
std::lock_guard jlock(g_fxo->get<jit_core_allocator>()->sem);
std::lock_guard jlock(g_fxo->get<jit_core_allocator>().sem);
ppu_log.warning("LLVM: Compiling module %s%s", cache_path, obj_name);

View File

@ -44,7 +44,7 @@ void spu_recompiler::init()
// Initialize if necessary
if (!m_spurt)
{
m_spurt = g_fxo->get<spu_runtime>();
m_spurt = &g_fxo->get<spu_runtime>();
}
}
@ -77,9 +77,9 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
return add_loc->compiled;
}
if (auto cache = g_fxo->get<spu_cache>(); *cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1))
if (auto& cache = g_fxo->get<spu_cache>(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1))
{
cache->add(func);
cache.add(func);
}
{

View File

@ -546,7 +546,7 @@ void spu_cache::initialize()
// Initialize global cache instance
if (g_cfg.core.spu_cache)
{
*g_fxo->get<spu_cache>() = std::move(cache);
g_fxo->get<spu_cache>() = std::move(cache);
}
}
@ -4208,7 +4208,7 @@ public:
// Initialize if necessary
if (!m_spurt)
{
m_spurt = g_fxo->get<spu_runtime>();
m_spurt = &g_fxo->get<spu_runtime>();
cpu_translator::initialize(m_jit.get_context(), m_jit.get_engine());
const auto md_name = llvm::MDString::get(m_context, "branch_weights");
@ -4252,9 +4252,9 @@ public:
std::string log;
if (auto cache = g_fxo->get<spu_cache>(); *cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1))
if (auto& cache = g_fxo->get<spu_cache>(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1))
{
cache->add(func);
cache.add(func);
}
{
@ -4849,7 +4849,7 @@ public:
fs::file(m_spurt->get_cache_path() + "spu-ir.log", fs::write + fs::append).write(log);
}
if (*g_fxo->get<spu_cache>())
if (g_fxo->get<spu_cache>().operator bool())
{
spu_log.success("New block compiled successfully");
}
@ -9124,7 +9124,7 @@ struct spu_fast : public spu_recompiler_base
{
if (!m_spurt)
{
m_spurt = g_fxo->get<spu_runtime>();
m_spurt = &g_fxo->get<spu_runtime>();
}
}
@ -9460,7 +9460,7 @@ struct spu_fast : public spu_recompiler_base
else if (added)
{
// Send work to LLVM compiler thread
g_fxo->get<spu_llvm_thread>()->registered.push(m_hash_start, add_loc);
g_fxo->get<spu_llvm_thread>().registered.push(m_hash_start, add_loc);
}
// Rebuild trampoline if necessary

View File

@ -1073,7 +1073,7 @@ extern void ppu_execute_syscall(ppu_thread& ppu, u64 code)
if (code < g_ppu_syscall_table.size())
{
g_fxo->get<named_thread<ppu_syscall_usage>>()->stat[code]++;
g_fxo->get<named_thread<ppu_syscall_usage>>().stat[code]++;
if (auto func = g_ppu_syscall_table[code].first)
{

View File

@ -263,10 +263,10 @@ error_code sys_config_open(u32 equeue_hdl, vm::ptr<u32> out_config_hdl)
}
// Initialize lv2_config global state
const auto global = g_fxo->get<lv2_config>();
auto& global = g_fxo->get<lv2_config>();
if (true)
{
global->initialize();
global.initialize();
}
// Create a lv2_config_handle object
@ -307,7 +307,7 @@ error_code sys_config_get_service_event(u32 config_hdl, u32 event_id, vm::ptr<sy
}
// Find service_event object
const auto event = g_fxo->get<lv2_config>()->find_event(event_id);
const auto event = g_fxo->get<lv2_config>().find_event(event_id);
if (!event)
{
return CELL_ESRCH;

View File

@ -352,7 +352,7 @@ class lv2_config_service_event
atomic_t<u32> next_id = 0;
};
return g_fxo->get<service_event_id>()->next_id++;
return g_fxo->get<service_event_id>().next_id++;
}
public:
@ -385,7 +385,7 @@ public:
{
auto ev = std::make_shared<lv2_config_service_event>(std::forward<Args>(args)...);
g_fxo->get<lv2_config>()->add_service_event(ev);
g_fxo->get<lv2_config>().add_service_event(ev);
return ev;
}
@ -393,9 +393,9 @@ public:
// Destructor
~lv2_config_service_event()
{
if (auto global = g_fxo->get<lv2_config>())
if (auto& global = g_fxo->get<lv2_config>(); !Emu.IsStopped())
{
global->remove_service_event(id);
global.remove_service_event(id);
}
}

View File

@ -465,8 +465,8 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s3
file.seek(0);
if (magic == "NPD\0"_u32)
{
auto edatkeys = g_fxo->get<loaded_npdrm_keys>();
auto sdata_file = std::make_unique<EDATADecrypter>(std::move(file), edatkeys->devKlic.load(), edatkeys->rifKey.load());
auto& edatkeys = g_fxo->get<loaded_npdrm_keys>();
auto sdata_file = std::make_unique<EDATADecrypter>(std::move(file), edatkeys.devKlic.load(), edatkeys.rifKey.load());
if (!sdata_file->ReadHeader())
{
return {CELL_EFSSPECIFIC};
@ -553,7 +553,7 @@ error_code sys_fs_open(ppu_thread& ppu, vm::cptr<char> path, s32 flags, vm::ptr<
if (const u32 id = idm::import<lv2_fs_object, lv2_file>([&ppath = ppath, &file = file, mode, flags, &real = real, &type = type]() -> std::shared_ptr<lv2_file>
{
if (!g_fxo->get<loaded_npdrm_keys>()->npdrm_fds.try_inc(16))
if (!g_fxo->get<loaded_npdrm_keys>().npdrm_fds.try_inc(16))
{
return nullptr;
}
@ -681,7 +681,7 @@ error_code sys_fs_close(ppu_thread& ppu, u32 fd)
{
if (file.type >= lv2_file_type::sdata)
{
g_fxo->get<loaded_npdrm_keys>()->npdrm_fds--;
g_fxo->get<loaded_npdrm_keys>().npdrm_fds--;
}
});
@ -1350,7 +1350,7 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
stream.reset(std::move(sdata_file));
if (const u32 id = idm::import<lv2_fs_object, lv2_file>([&file = *file, &stream = stream]() -> std::shared_ptr<lv2_file>
{
if (!g_fxo->get<loaded_npdrm_keys>()->npdrm_fds.try_inc(16))
if (!g_fxo->get<loaded_npdrm_keys>().npdrm_fds.try_inc(16))
{
return nullptr;
}

View File

@ -50,10 +50,10 @@ error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32
}
// Get "default" memory container
const auto dct = g_fxo->get<lv2_memory_container>();
auto& dct = g_fxo->get<lv2_memory_container>();
// Try to get "physical memory"
if (!dct->take(size))
if (!dct.take(size))
{
return CELL_ENOMEM;
}
@ -62,7 +62,7 @@ error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32
{
if (u32 addr = area->alloc(size, nullptr, align))
{
ensure(!g_fxo->get<sys_memory_address_table>()->addrs[addr >> 16].exchange(dct));
ensure(!g_fxo->get<sys_memory_address_table>().addrs[addr >> 16].exchange(&dct));
if (alloc_addr)
{
@ -77,7 +77,7 @@ error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32
}
}
dct->used -= size;
dct.used -= size;
return CELL_ENOMEM;
}
@ -133,7 +133,7 @@ error_code sys_memory_allocate_from_container(cpu_thread& cpu, u32 size, u32 cid
{
if (u32 addr = area->alloc(size))
{
ensure(!g_fxo->get<sys_memory_address_table>()->addrs[addr >> 16].exchange(ct.ptr.get()));
ensure(!g_fxo->get<sys_memory_address_table>().addrs[addr >> 16].exchange(ct.ptr.get()));
if (alloc_addr)
{
@ -158,7 +158,7 @@ error_code sys_memory_free(cpu_thread& cpu, u32 addr)
sys_memory.warning("sys_memory_free(addr=0x%x)", addr);
const auto ct = addr % 0x10000 ? nullptr : g_fxo->get<sys_memory_address_table>()->addrs[addr >> 16].exchange(nullptr);
const auto ct = addr % 0x10000 ? nullptr : g_fxo->get<sys_memory_address_table>().addrs[addr >> 16].exchange(nullptr);
if (!ct)
{
@ -215,12 +215,12 @@ error_code sys_memory_get_user_memory_size(cpu_thread& cpu, vm::ptr<sys_memory_i
sys_memory.warning("sys_memory_get_user_memory_size(mem_info=*0x%x)", mem_info);
// Get "default" memory container
const auto dct = g_fxo->get<lv2_memory_container>();
auto& dct = g_fxo->get<lv2_memory_container>();
::reader_lock lock(s_memstats_mtx);
mem_info->total_user_memory = dct->size;
mem_info->available_user_memory = dct->size - dct->used;
mem_info->total_user_memory = dct.size;
mem_info->available_user_memory = dct.size - dct.used;
// Scan other memory containers
idm::select<lv2_memory_container>([&](u32, lv2_memory_container& ct)
@ -254,12 +254,12 @@ error_code sys_memory_container_create(cpu_thread& cpu, vm::ptr<u32> cid, u32 si
return CELL_ENOMEM;
}
const auto dct = g_fxo->get<lv2_memory_container>();
auto& dct = g_fxo->get<lv2_memory_container>();
std::lock_guard lock(s_memstats_mtx);
// Try to obtain "physical memory" from the default container
if (!dct->take(size))
if (!dct.take(size))
{
return CELL_ENOMEM;
}
@ -271,7 +271,7 @@ error_code sys_memory_container_create(cpu_thread& cpu, vm::ptr<u32> cid, u32 si
return CELL_OK;
}
dct->used -= size;
dct.used -= size;
return CELL_EAGAIN;
}
@ -305,7 +305,7 @@ error_code sys_memory_container_destroy(cpu_thread& cpu, u32 cid)
}
// Return "physical memory" to the default container
g_fxo->get<lv2_memory_container>()->used -= ct->size;
g_fxo->get<lv2_memory_container>().used -= ct->size;
return CELL_OK;
}

View File

@ -143,16 +143,16 @@ error_code sys_mmapper_allocate_shared_memory(ppu_thread& ppu, u64 ipc_key, u64
}
// Get "default" memory container
const auto dct = g_fxo->get<lv2_memory_container>();
auto& dct = g_fxo->get<lv2_memory_container>();
if (!dct->take(size))
if (!dct.take(size))
{
return CELL_ENOMEM;
}
if (auto error = create_lv2_shm(ipc_key != SYS_MMAPPER_NO_SHM_KEY, ipc_key, size, flags & SYS_MEMORY_PAGE_SIZE_64K ? 0x10000 : 0x100000, flags, dct))
if (auto error = create_lv2_shm(ipc_key != SYS_MMAPPER_NO_SHM_KEY, ipc_key, size, flags & SYS_MEMORY_PAGE_SIZE_64K ? 0x10000 : 0x100000, flags, &dct))
{
dct->used -= size;
dct.used -= size;
return error;
}
@ -317,16 +317,16 @@ error_code sys_mmapper_allocate_shared_memory_ext(ppu_thread& ppu, u64 ipc_key,
}
// Get "default" memory container
const auto dct = g_fxo->get<lv2_memory_container>();
auto& dct = g_fxo->get<lv2_memory_container>();
if (!dct->take(size))
if (!dct.take(size))
{
return CELL_ENOMEM;
}
if (auto error = create_lv2_shm<true>(true, ipc_key, size, flags & SYS_MEMORY_PAGE_SIZE_64K ? 0x10000 : 0x100000, flags, dct))
if (auto error = create_lv2_shm<true>(true, ipc_key, size, flags & SYS_MEMORY_PAGE_SIZE_64K ? 0x10000 : 0x100000, flags, &dct))
{
dct->used -= size;
dct.used -= size;
return error;
}
@ -467,10 +467,10 @@ error_code sys_mmapper_free_address(ppu_thread& ppu, u32 addr)
}
// If page fault notify exists and an address in this area is faulted, we can't free the memory.
auto pf_events = g_fxo->get<page_fault_event_entries>();
std::lock_guard pf_lock(pf_events->pf_mutex);
auto& pf_events = g_fxo->get<page_fault_event_entries>();
std::lock_guard pf_lock(pf_events.pf_mutex);
for (const auto& ev : pf_events->events)
for (const auto& ev : pf_events.events)
{
auto mem = vm::get(vm::any, addr);
if (mem && addr <= ev.second && ev.second <= addr + mem->size - 1)
@ -493,20 +493,20 @@ error_code sys_mmapper_free_address(ppu_thread& ppu, u32 addr)
}
// If a memory block is freed, remove it from page notification table.
auto pf_entries = g_fxo->get<page_fault_notification_entries>();
std::lock_guard lock(pf_entries->mutex);
auto& pf_entries = g_fxo->get<page_fault_notification_entries>();
std::lock_guard lock(pf_entries.mutex);
auto ind_to_remove = pf_entries->entries.begin();
for (; ind_to_remove != pf_entries->entries.end(); ++ind_to_remove)
auto ind_to_remove = pf_entries.entries.begin();
for (; ind_to_remove != pf_entries.entries.end(); ++ind_to_remove)
{
if (addr == ind_to_remove->start_addr)
{
break;
}
}
if (ind_to_remove != pf_entries->entries.end())
if (ind_to_remove != pf_entries.entries.end())
{
pf_entries->entries.erase(ind_to_remove);
pf_entries.entries.erase(ind_to_remove);
}
return CELL_OK;
@ -725,11 +725,11 @@ error_code sys_mmapper_enable_page_fault_notification(ppu_thread& ppu, u32 start
return CELL_EAGAIN;
}
auto pf_entries = g_fxo->get<page_fault_notification_entries>();
std::unique_lock lock(pf_entries->mutex);
auto& pf_entries = g_fxo->get<page_fault_notification_entries>();
std::unique_lock lock(pf_entries.mutex);
// Return error code if page fault notifications are already enabled
for (const auto& entry : pf_entries->entries)
for (const auto& entry : pf_entries.entries)
{
if (entry.start_addr == start_addr)
{
@ -741,7 +741,7 @@ error_code sys_mmapper_enable_page_fault_notification(ppu_thread& ppu, u32 start
}
page_fault_notification_entry entry{ start_addr, event_queue_id, port_id->value() };
pf_entries->entries.emplace_back(entry);
pf_entries.entries.emplace_back(entry);
return CELL_OK;
}
@ -749,18 +749,18 @@ error_code sys_mmapper_enable_page_fault_notification(ppu_thread& ppu, u32 start
error_code mmapper_thread_recover_page_fault(cpu_thread* cpu)
{
// We can only wake a thread if it is being suspended for a page fault.
auto pf_events = g_fxo->get<page_fault_event_entries>();
auto& pf_events = g_fxo->get<page_fault_event_entries>();
{
std::lock_guard pf_lock(pf_events->pf_mutex);
const auto pf_event_ind = pf_events->events.find(cpu);
std::lock_guard pf_lock(pf_events.pf_mutex);
const auto pf_event_ind = pf_events.events.find(cpu);
if (pf_event_ind == pf_events->events.end())
if (pf_event_ind == pf_events.events.end())
{
// if not found...
return CELL_EINVAL;
}
pf_events->events.erase(pf_event_ind);
pf_events.events.erase(pf_event_ind);
}
if (cpu->id_type() == 1u)

View File

@ -566,8 +566,8 @@ struct nt_p2p_port
// Adds to tcp timeout monitor to resend the message until an ack is received
if (require_ack)
{
auto tcpm = g_fxo->get<named_thread<tcp_timeout_monitor>>();
tcpm->add_message(sock_id, dst, std::move(data), seq);
auto& tcpm = g_fxo->get<named_thread<tcp_timeout_monitor>>();
tcpm.add_message(sock_id, dst, std::move(data), seq);
}
}
@ -590,8 +590,8 @@ struct nt_p2p_port
if (tcp_header->flags == lv2_socket::p2ps_i::ACK)
{
auto tcpm = g_fxo->get<named_thread<tcp_timeout_monitor>>();
tcpm->confirm_data_received(sock_id, tcp_header->ack);
auto& tcpm = g_fxo->get<named_thread<tcp_timeout_monitor>>();
tcpm.confirm_data_received(sock_id, tcp_header->ack);
}
auto send_ack = [&]()
@ -831,8 +831,8 @@ struct nt_p2p_port
sign_msgs.push_back(std::move(msg));
}
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->wake_up();
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.wake_up();
return true;
}
@ -1142,11 +1142,11 @@ using network_context = named_thread<network_thread>;
// Used by RPCN to send signaling packets to RPCN server(for UDP hole punching)
s32 send_packet_from_p2p_port(const std::vector<u8>& data, const sockaddr_in& addr)
{
s32 res = 0;
const auto nc = g_fxo->get<network_context>();
s32 res{};
auto& nc = g_fxo->get<network_context>();
{
std::lock_guard list_lock(nc->list_p2p_ports_mutex);
auto& def_port = nc->list_p2p_ports.at(3658);
std::lock_guard list_lock(nc.list_p2p_ports_mutex);
auto& def_port = nc.list_p2p_ports.at(3658);
res = ::sendto(def_port.p2p_socket, reinterpret_cast<const char*>(data.data()), data.size(), 0, reinterpret_cast<const sockaddr*>(&addr), sizeof(sockaddr_in));
}
@ -1156,14 +1156,14 @@ s32 send_packet_from_p2p_port(const std::vector<u8>& data, const sockaddr_in& ad
std::vector<std::vector<u8>> get_rpcn_msgs()
{
auto msgs = std::vector<std::vector<u8>>();
const auto nc = g_fxo->get<network_context>();
std::vector<std::vector<u8>> msgs;
auto& nc = g_fxo->get<network_context>();
{
std::lock_guard list_lock(nc->list_p2p_ports_mutex);
auto& def_port = nc->list_p2p_ports.at(3658);
std::lock_guard list_lock(nc.list_p2p_ports_mutex);
auto& def_port = nc.list_p2p_ports.at(3658);
{
std::lock_guard lock(def_port.s_rpcn_mutex);
msgs = std::move(def_port.rpcn_msgs);
msgs = std::move(def_port.rpcn_msgs);
def_port.rpcn_msgs.clear();
}
}
@ -1173,11 +1173,11 @@ std::vector<std::vector<u8>> get_rpcn_msgs()
std::vector<std::pair<std::pair<u32, u16>, std::vector<u8>>> get_sign_msgs()
{
auto msgs = std::vector<std::pair<std::pair<u32, u16>, std::vector<u8>>>();
const auto nc = g_fxo->get<network_context>();
std::vector<std::pair<std::pair<u32, u16>, std::vector<u8>>> msgs;
auto& nc = g_fxo->get<network_context>();
{
std::lock_guard list_lock(nc->list_p2p_ports_mutex);
auto& def_port = nc->list_p2p_ports.at(3658);
std::lock_guard list_lock(nc.list_p2p_ports_mutex);
auto& def_port = nc.list_p2p_ports.at(3658);
{
std::lock_guard lock(def_port.s_sign_mutex);
msgs = std::move(def_port.sign_msgs);
@ -1479,15 +1479,15 @@ error_code sys_net_bnet_bind(ppu_thread& ppu, s32 s, vm::cptr<sys_net_sockaddr>
lv2_socket::socket_type real_socket{};
const auto nc = g_fxo->get<network_context>();
auto& nc = g_fxo->get<network_context>();
{
std::lock_guard list_lock(nc->list_p2p_ports_mutex);
if (nc->list_p2p_ports.count(p2p_port) == 0)
std::lock_guard list_lock(nc.list_p2p_ports_mutex);
if (nc.list_p2p_ports.count(p2p_port) == 0)
{
nc->list_p2p_ports.emplace(std::piecewise_construct, std::forward_as_tuple(p2p_port), std::forward_as_tuple(p2p_port));
nc.list_p2p_ports.emplace(std::piecewise_construct, std::forward_as_tuple(p2p_port), std::forward_as_tuple(p2p_port));
}
auto& pport = nc->list_p2p_ports.at(p2p_port);
auto& pport = nc.list_p2p_ports.at(p2p_port);
real_socket = pport.p2p_socket;
{
std::lock_guard lock(pport.bound_p2p_vports_mutex);
@ -1597,13 +1597,13 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
lv2_socket::socket_type real_socket{};
const auto nc = g_fxo->get<network_context>();
auto& nc = g_fxo->get<network_context>();
{
std::lock_guard list_lock(nc->list_p2p_ports_mutex);
if (!nc->list_p2p_ports.count(sock.p2p.port))
nc->list_p2p_ports.emplace(std::piecewise_construct, std::forward_as_tuple(sock.p2p.port), std::forward_as_tuple(sock.p2p.port));
std::lock_guard list_lock(nc.list_p2p_ports_mutex);
if (!nc.list_p2p_ports.count(sock.p2p.port))
nc.list_p2p_ports.emplace(std::piecewise_construct, std::forward_as_tuple(sock.p2p.port), std::forward_as_tuple(sock.p2p.port));
auto& pport = nc->list_p2p_ports.at(sock.p2p.port);
auto& pport = nc.list_p2p_ports.at(sock.p2p.port);
real_socket = pport.p2p_socket;
{
std::lock_guard lock(pport.bound_p2p_vports_mutex);
@ -1658,15 +1658,15 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
if (psa_in->sin_port == 53)
{
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
// Hack for DNS
name.sin_port = std::bit_cast<u16, be_t<u16>>(53);
name.sin_addr.s_addr = nph->get_dns_ip();
name.sin_addr.s_addr = nph.get_dns_ip();
sys_net.notice("sys_net_bnet_connect: using DNS...");
nph->add_dns_spy(s);
nph.add_dns_spy(s);
}
else if (_addr->sa_family != SYS_NET_AF_INET)
{
@ -2245,10 +2245,10 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr<void> buf, u32
//if (!(sock.events & lv2_socket::poll::read))
{
const auto nph = g_fxo->get<named_thread<np_handler>>();
if (nph->is_dns(s) && nph->is_dns_queue(s))
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (nph.is_dns(s) && nph.is_dns_queue(s))
{
const auto packet = nph->get_dns_packet(s);
const auto packet = nph.get_dns_packet(s);
ensure(packet.size() < len);
memcpy(buf.get_ptr(), packet.data(), packet.size());
@ -2256,7 +2256,7 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr<void> buf, u32
native_addr.ss_family = AF_INET;
(reinterpret_cast<::sockaddr_in*>(&native_addr))->sin_port = std::bit_cast<u16, be_t<u16>>(53); // htons(53)
(reinterpret_cast<::sockaddr_in*>(&native_addr))->sin_addr.s_addr = nph->get_dns_ip();
(reinterpret_cast<::sockaddr_in*>(&native_addr))->sin_addr.s_addr = nph.get_dns_ip();
return true;
}
@ -2655,18 +2655,18 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr<void> buf, u32 l
//if (!(sock.events & lv2_socket::poll::write))
{
const auto nph = g_fxo->get<named_thread<np_handler>>();
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (addr && type == SYS_NET_SOCK_DGRAM && psa_in->sin_port == 53)
{
nph->add_dns_spy(s);
nph.add_dns_spy(s);
}
if (nph->is_dns(s))
if (nph.is_dns(s))
{
const s32 ret_analyzer = nph->analyze_dns_packet(s, reinterpret_cast<const u8*>(_buf.data()), len);
const s32 ret_analyzer = nph.analyze_dns_packet(s, reinterpret_cast<const u8*>(_buf.data()), len);
// If we're not connected just never send the packet and pretend we did
if (!nph->get_net_status())
if (!nph.get_net_status())
{
native_result = data_len;
return true;
@ -3135,10 +3135,10 @@ error_code sys_net_bnet_close(ppu_thread& ppu, s32 s)
// If it's a bound socket we "close" the vport
if ((sock->type == SYS_NET_SOCK_DGRAM_P2P || sock->type == SYS_NET_SOCK_STREAM_P2P) && sock->p2p.port && sock->p2p.vport)
{
const auto nc = g_fxo->get<network_context>();
auto& nc = g_fxo->get<network_context>();
{
std::lock_guard lock(nc->list_p2p_ports_mutex);
auto& p2p_port = nc->list_p2p_ports.at(sock->p2p.port);
std::lock_guard lock(nc.list_p2p_ports_mutex);
auto& p2p_port = nc.list_p2p_ports.at(sock->p2p.port);
{
std::lock_guard lock(p2p_port.bound_p2p_vports_mutex);
if (sock->type == SYS_NET_SOCK_DGRAM_P2P)
@ -3162,8 +3162,8 @@ error_code sys_net_bnet_close(ppu_thread& ppu, s32 s)
}
}
const auto nph = g_fxo->get<named_thread<np_handler>>();
nph->remove_dns_spy(s);
auto& nph = g_fxo->get<named_thread<np_handler>>();
nph.remove_dns_spy(s);
return CELL_OK;
}
@ -3189,7 +3189,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
{
fds_buf.assign(fds.get_ptr(), fds.get_ptr() + nfds);
std::unique_lock nw_lock(g_fxo->get<network_context>()->s_nw_mutex);
std::unique_lock nw_lock(g_fxo->get<network_context>().s_nw_mutex);
std::shared_lock lock(id_manager::g_mutex);
@ -3254,8 +3254,8 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
else
{
// Check for fake packet for dns interceptions
const auto nph = g_fxo->get<named_thread<np_handler>>();
if (fds_buf[i].events & SYS_NET_POLLIN && nph->is_dns(fds_buf[i].fd) && nph->is_dns_queue(fds_buf[i].fd))
auto& nph = g_fxo->get<named_thread<np_handler>>();
if (fds_buf[i].events & SYS_NET_POLLIN && nph.is_dns(fds_buf[i].fd) && nph.is_dns_queue(fds_buf[i].fd))
fds_buf[i].revents |= SYS_NET_POLLIN;
if (fds_buf[i].events & ~(SYS_NET_POLLIN | SYS_NET_POLLOUT | SYS_NET_POLLERR))
@ -3342,7 +3342,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
fds_buf[i].revents |= SYS_NET_POLLERR;
signaled++;
g_fxo->get<network_context>()->s_to_awake.emplace_back(&ppu);
g_fxo->get<network_context>().s_to_awake.emplace_back(&ppu);
return true;
}
@ -3377,7 +3377,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
return {};
}
std::lock_guard nw_lock(g_fxo->get<network_context>()->s_nw_mutex);
std::lock_guard nw_lock(g_fxo->get<network_context>().s_nw_mutex);
if (signaled)
{
@ -3425,7 +3425,7 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptr<sys_net_fd_set
if (exceptfds)
_exceptfds = *exceptfds;
std::lock_guard nw_lock(g_fxo->get<network_context>()->s_nw_mutex);
std::lock_guard nw_lock(g_fxo->get<network_context>().s_nw_mutex);
reader_lock lock(id_manager::g_mutex);
@ -3558,7 +3558,7 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptr<sys_net_fd_set
// rexcept.set(i);
signaled++;
g_fxo->get<network_context>()->s_to_awake.emplace_back(&ppu);
g_fxo->get<network_context>().s_to_awake.emplace_back(&ppu);
return true;
}
@ -3601,7 +3601,7 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptr<sys_net_fd_set
return {};
}
std::lock_guard nw_lock(g_fxo->get<network_context>()->s_nw_mutex);
std::lock_guard nw_lock(g_fxo->get<network_context>().s_nw_mutex);
if (signaled)
{
@ -3691,8 +3691,8 @@ error_code sys_net_infoctl(ppu_thread& ppu, s32 cmd, vm::ptr<void> arg)
char buffer[nameserver.size() + 80]{};
std::memcpy(buffer, nameserver.data(), nameserver.size());
const auto nph = g_fxo->get<named_thread<np_handler>>();
const auto dns_str = np_handler::ip_to_string(nph->get_dns_ip());
auto& nph = g_fxo->get<named_thread<np_handler>>();
const auto dns_str = np_handler::ip_to_string(nph.get_dns_ip());
std::memcpy(buffer + nameserver.size() - 1, dns_str.data(), dns_str.size());
std::string_view name{buffer};

View File

@ -33,7 +33,7 @@ static error_code overlay_load_module(vm::ptr<u32> ovlmid, const std::string& vp
src = std::move(lv2_file);
}
u128 klic = g_fxo->get<loaded_npdrm_keys>()->devKlic.load();
u128 klic = g_fxo->get<loaded_npdrm_keys>().devKlic.load();
ppu_exec_object obj = decrypt_self(std::move(src), reinterpret_cast<u8*>(&klic));

View File

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "sys_ppu_thread.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/perf_meter.hpp"
@ -48,13 +49,13 @@ struct ppu_thread_cleaner
bool ppu_thread_exit(ppu_thread& ppu)
{
ppu.state += cpu_flag::exit + cpu_flag::wait;
// Deallocate Stack Area
ensure(vm::dealloc(ppu.stack_addr, vm::stack) == ppu.stack_size);
if (const auto dct = g_fxo->get<lv2_memory_container>())
if (auto& dct = g_fxo->get<lv2_memory_container>(); !Emu.IsStopped())
{
dct->used -= ppu.stack_size;
dct.used -= ppu.stack_size;
}
return false;
@ -99,7 +100,7 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode)
ppu.state -= cpu_flag::suspend;
}
g_fxo->get<ppu_thread_cleaner>()->clean(old_status == ppu_join_status::detached ? ppu.id : 0);
g_fxo->get<ppu_thread_cleaner>().clean(old_status == ppu_join_status::detached ? ppu.id : 0);
while (ppu.joiner == ppu_join_status::zombie && !ppu.is_stopped())
{
@ -127,7 +128,7 @@ error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr<u64> vptr
sys_ppu_thread.trace("sys_ppu_thread_join(thread_id=0x%x, vptr=*0x%x)", thread_id, vptr);
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
auto thread = idm::get<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread) -> CellError
{
@ -210,7 +211,7 @@ error_code sys_ppu_thread_detach(ppu_thread& ppu, u32 thread_id)
sys_ppu_thread.trace("sys_ppu_thread_detach(thread_id=0x%x)", thread_id);
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
const auto thread = idm::check<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread) -> CellError
{
@ -261,8 +262,8 @@ error_code sys_ppu_thread_detach(ppu_thread& ppu, u32 thread_id)
if (thread.ret == CELL_EAGAIN)
{
g_fxo->get<ppu_thread_cleaner>()->clean(thread_id);
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(thread_id);
g_fxo->get<ppu_thread_cleaner>().clean(0);
}
return CELL_OK;
@ -293,7 +294,7 @@ error_code sys_ppu_thread_set_priority(ppu_thread& ppu, u32 thread_id, s32 prio)
}
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
const auto thread = idm::check<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread)
{
@ -325,7 +326,7 @@ error_code sys_ppu_thread_get_priority(ppu_thread& ppu, u32 thread_id, vm::ptr<s
sys_ppu_thread.trace("sys_ppu_thread_get_priority(thread_id=0x%x, priop=*0x%x)", thread_id, priop);
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
u32 prio;
@ -426,15 +427,15 @@ error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr<u64> thread_id, vm::p
const u32 tls = param->tls;
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
// Compute actual stack size and allocate
const u32 stack_size = utils::align<u32>(std::max<u32>(_stacksz, 4096), 4096);
const auto dct = g_fxo->get<lv2_memory_container>();
auto& dct = g_fxo->get<lv2_memory_container>();
// Try to obtain "physical memory" from the default container
if (!dct->take(stack_size))
if (!dct.take(stack_size))
{
return CELL_ENOMEM;
}
@ -443,7 +444,7 @@ error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr<u64> thread_id, vm::p
if (!stack_base)
{
dct->used -= stack_size;
dct.used -= stack_size;
return CELL_ENOMEM;
}
@ -484,7 +485,7 @@ error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr<u64> thread_id, vm::p
if (!tid)
{
vm::dealloc(stack_base);
dct->used -= stack_size;
dct.used -= stack_size;
return CELL_EAGAIN;
}
@ -634,11 +635,11 @@ error_code sys_ppu_thread_get_page_fault_context(ppu_thread& ppu, u32 thread_id,
}
// We can only get a context if the thread is being suspended for a page fault.
auto pf_events = g_fxo->get<page_fault_event_entries>();
reader_lock lock(pf_events->pf_mutex);
auto& pf_events = g_fxo->get<page_fault_event_entries>();
reader_lock lock(pf_events.pf_mutex);
const auto evt = pf_events->events.find(thread.ptr.get());
if (evt == pf_events->events.end())
const auto evt = pf_events.events.find(thread.ptr.get());
if (evt == pf_events.events.end())
{
return CELL_EINVAL;
}

View File

@ -401,7 +401,7 @@ void _sys_process_exit2(ppu_thread& ppu, s32 status, vm::ptr<sys_exit2_param> ar
if (disc.empty() && !Emu.GetTitleID().empty())
disc = vfs::get(Emu.GetDir());
Emu.CallAfter([path = std::move(path), argv = std::move(argv), envp = std::move(envp), data = std::move(data), disc = std::move(disc), hdd1 = std::move(hdd1), klic = g_fxo->get<loaded_npdrm_keys>()->devKlic.load()]() mutable
Emu.CallAfter([path = std::move(path), argv = std::move(argv), envp = std::move(envp), data = std::move(data), disc = std::move(disc), hdd1 = std::move(hdd1), klic = g_fxo->get<loaded_npdrm_keys>().devKlic.load()]() mutable
{
sys_process.success("Process finished -> %s", argv[0]);
Emu.SetForceBoot(true);

View File

@ -264,7 +264,7 @@ static error_code prx_load_module(const std::string& vpath, u64 flags, vm::ptr<s
src = std::move(lv2_file);
}
u128 klic = g_fxo->get<loaded_npdrm_keys>()->devKlic.load();
u128 klic = g_fxo->get<loaded_npdrm_keys>().devKlic.load();
ppu_prx_object obj = decrypt_self(std::move(src), reinterpret_cast<u8*>(&klic));

View File

@ -118,7 +118,7 @@ error_code sys_rsx_memory_allocate(cpu_thread& cpu, vm::ptr<u32> mem_handle, vm:
if (u32 addr = vm::falloc(rsx::constants::local_mem_base, size, vm::video))
{
g_fxo->get<lv2_rsx_config>()->memory_size = size;
g_fxo->get<lv2_rsx_config>().memory_size = size;
*mem_addr = addr;
*mem_handle = 0x5a5a5a5b;
return CELL_OK;
@ -142,7 +142,7 @@ error_code sys_rsx_memory_free(cpu_thread& cpu, u32 mem_handle)
return CELL_ENOMEM;
}
if (g_fxo->get<lv2_rsx_config>()->context_base)
if (g_fxo->get<lv2_rsx_config>().context_base)
{
fmt::throw_exception("Attempting to dealloc rsx memory when the context is still being used");
}
@ -176,11 +176,11 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr<u32> context_id, vm
return CELL_EINVAL;
}
auto rsx_cfg = g_fxo->get<lv2_rsx_config>();
auto& rsx_cfg = g_fxo->get<lv2_rsx_config>();
std::lock_guard lock(rsx_cfg->mutex);
std::lock_guard lock(rsx_cfg.mutex);
if (rsx_cfg->context_base)
if (rsx_cfg.context_base)
{
// We currently do not support multiple contexts
fmt::throw_exception("sys_rsx_context_allocate was called twice");
@ -225,7 +225,7 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr<u32> context_id, vm
driverInfo.version_driver = 0x211;
driverInfo.version_gpu = 0x5c;
driverInfo.memory_size = rsx_cfg->memory_size;
driverInfo.memory_size = rsx_cfg.memory_size;
driverInfo.nvcore_frequency = 500000000; // 0x1DCD6500
driverInfo.memory_frequency = 650000000; // 0x26BE3680
driverInfo.reportsNotifyOffset = 0x1000;
@ -234,7 +234,7 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr<u32> context_id, vm
driverInfo.systemModeFlags = static_cast<u32>(system_mode);
driverInfo.hardware_channel = 1; // * i think* this 1 for games, 0 for vsh
rsx_cfg->driver_info = vm::cast(*lpar_driver_info);
rsx_cfg.driver_info = vm::cast(*lpar_driver_info);
auto &dmaControl = vm::_ref<RsxDmaControl>(vm::cast(*lpar_dma_control));
dmaControl.get = 0;
@ -253,21 +253,21 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr<u32> context_id, vm
attr->name_u64 = 0;
sys_event_port_create(cpu, vm::get_addr(&driverInfo.handler_queue), SYS_EVENT_PORT_LOCAL, 0);
rsx_cfg->rsx_event_port = driverInfo.handler_queue;
rsx_cfg.rsx_event_port = driverInfo.handler_queue;
sys_event_queue_create(cpu, vm::get_addr(&driverInfo.handler_queue), attr, 0, 0x20);
sys_event_port_connect_local(cpu, rsx_cfg->rsx_event_port, driverInfo.handler_queue);
sys_event_port_connect_local(cpu, rsx_cfg.rsx_event_port, driverInfo.handler_queue);
rsx_cfg->dma_address = vm::cast(*lpar_dma_control);
rsx_cfg.dma_address = vm::cast(*lpar_dma_control);
const auto render = rsx::get_current_renderer();
render->display_buffers_count = 0;
render->current_display_buffer = 0;
render->label_addr = vm::cast(*lpar_reports);
render->device_addr = rsx_cfg->device_addr;
render->local_mem_size = rsx_cfg->memory_size;
render->device_addr = rsx_cfg.device_addr;
render->local_mem_size = rsx_cfg.memory_size;
render->init(vm::cast(*lpar_dma_control));
rsx_cfg->context_base = context_base;
rsx_cfg.context_base = context_base;
*context_id = 0x55555555;
return CELL_OK;
@ -283,11 +283,11 @@ error_code sys_rsx_context_free(cpu_thread& cpu, u32 context_id)
sys_rsx.todo("sys_rsx_context_free(context_id=0x%x)", context_id);
auto rsx_cfg = g_fxo->get<lv2_rsx_config>();
auto& rsx_cfg = g_fxo->get<lv2_rsx_config>();
std::scoped_lock lock(rsx_cfg->mutex);
std::scoped_lock lock(rsx_cfg.mutex);
if (context_id != 0x55555555 || !rsx_cfg->context_base)
if (context_id != 0x55555555 || !rsx_cfg.context_base)
{
return CELL_EINVAL;
}
@ -338,7 +338,7 @@ error_code sys_rsx_context_iomap(cpu_thread& cpu, u32 context_id, u32 io, u32 ea
io >>= 20, ea >>= 20, size >>= 20;
render->pause();
std::scoped_lock lock(g_fxo->get<lv2_rsx_config>()->mutex);
std::scoped_lock lock(g_fxo->get<lv2_rsx_config>().mutex);
for (u32 i = 0; i < size; i++)
{
@ -382,7 +382,7 @@ error_code sys_rsx_context_iounmap(cpu_thread& cpu, u32 context_id, u32 io, u32
vm::reader_lock rlock;
std::scoped_lock lock(g_fxo->get<lv2_rsx_config>()->mutex);
std::scoped_lock lock(g_fxo->get<lv2_rsx_config>().mutex);
for (const u32 end = (io >>= 20) + (size >>= 20); io < end;)
{
@ -422,15 +422,15 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
const auto render = rsx::get_current_renderer();
auto rsx_cfg = g_fxo->get<lv2_rsx_config>();
auto& rsx_cfg = g_fxo->get<lv2_rsx_config>();
if (!rsx_cfg->context_base || context_id != 0x55555555)
if (!rsx_cfg.context_base || context_id != 0x55555555)
{
sys_rsx.error("sys_rsx_context_attribute(): invalid context failure (context_id=0x%x)", context_id);
return CELL_OK; // Actually returns CELL_OK, cellGCmSys seem to be relying on this as well
}
auto &driverInfo = vm::_ref<RsxDriverInfo>(rsx_cfg->driver_info);
auto &driverInfo = vm::_ref<RsxDriverInfo>(rsx_cfg.driver_info);
switch (package_id)
{
case 0x001: // FIFO
@ -438,7 +438,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
render->pause();
const u64 get = static_cast<u32>(a3);
const u64 put = static_cast<u32>(a4);
vm::_ref<atomic_be_t<u64>>(rsx_cfg->dma_address + ::offset32(&RsxDmaControl::put)).release(put << 32 | get);
vm::_ref<atomic_be_t<u64>>(rsx_cfg.dma_address + ::offset32(&RsxDmaControl::put)).release(put << 32 | get);
render->sync_point_request.release(true);
render->unpause();
break;
@ -505,7 +505,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
driverInfo.head[a3].lastQueuedBufferId = static_cast<u32>(a4);
driverInfo.head[a3].flipFlags |= 0x40000000 | (1 << a4);
rsx_cfg->send_event(0, SYS_RSX_EVENT_QUEUE_BASE << a3, 0);
rsx_cfg.send_event(0, SYS_RSX_EVENT_QUEUE_BASE << a3, 0);
render->on_frame_end(static_cast<u32>(a4));
}
@ -519,7 +519,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
return SYS_RSX_CONTEXT_ATTRIBUTE_ERROR;
}
std::lock_guard lock(rsx_cfg->mutex);
std::lock_guard lock(rsx_cfg.mutex);
// Note: no error checking is being done
@ -623,7 +623,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
ensure(a5 & (1 << 30));
}
std::lock_guard lock(rsx_cfg->mutex);
std::lock_guard lock(rsx_cfg.mutex);
// When tile is going to be unbound, we can use it as a hint that the address will no longer be used as a surface and can be removed/invalidated
// Todo: There may be more checks such as format/size/width can could be done
@ -697,7 +697,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
ensure((a6 & 0xFFFFFFFF) == 0u + ((0x2000 << 0) | (0x20 << 16)));
}
std::lock_guard lock(rsx_cfg->mutex);
std::lock_guard lock(rsx_cfg.mutex);
auto &zcull = render->zculls[a3];
@ -741,7 +741,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
// seems gcmSysWaitLabel uses this offset, so lets set it to 0 every flip
vm::_ref<u32>(render->label_addr + 0x10) = 0;
rsx_cfg->send_event(0, SYS_RSX_EVENT_FLIP_BASE << 1, 0);
rsx_cfg.send_event(0, SYS_RSX_EVENT_FLIP_BASE << 1, 0);
break;
case 0xFED: // hack: vblank command
@ -767,7 +767,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
if (render->enable_second_vhandler)
event_flags |= SYS_RSX_EVENT_SECOND_VBLANK_BASE << a3; // second vhandler
rsx_cfg->send_event(0, event_flags, 0);
rsx_cfg.send_event(0, event_flags, 0);
break;
}
@ -776,7 +776,7 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64
// as i think we need custom lv1 interrupts to handle this accurately
// this also should probly be set by rsxthread
driverInfo.userCmdParam = static_cast<u32>(a4);
rsx_cfg->send_event(0, SYS_RSX_EVENT_USER_CMD, 0);
rsx_cfg.send_event(0, SYS_RSX_EVENT_USER_CMD, 0);
break;
default:
@ -803,12 +803,12 @@ error_code sys_rsx_device_map(cpu_thread& cpu, vm::ptr<u64> dev_addr, vm::ptr<u6
fmt::throw_exception("sys_rsx_device_map: Invalid dev_id %d", dev_id);
}
auto rsx_cfg = g_fxo->get<lv2_rsx_config>();
auto& rsx_cfg = g_fxo->get<lv2_rsx_config>();
static shared_mutex device_map_mtx;
std::scoped_lock lock(device_map_mtx);
if (!rsx_cfg->device_addr)
if (!rsx_cfg.device_addr)
{
const auto area = vm::reserve_map(vm::rsx_context, 0, 0x10000000, 0x403);
const u32 addr = area ? area->alloc(0x100000) : 0;
@ -819,11 +819,11 @@ error_code sys_rsx_device_map(cpu_thread& cpu, vm::ptr<u64> dev_addr, vm::ptr<u6
}
*dev_addr = addr;
rsx_cfg->device_addr = addr;
rsx_cfg.device_addr = addr;
return CELL_OK;
}
*dev_addr = rsx_cfg->device_addr;
*dev_addr = rsx_cfg.device_addr;
return CELL_OK;
}

View File

@ -168,12 +168,12 @@ void sys_spu_image::deploy(u8* loc, sys_spu_segment* segs, u32 nsegs)
}
// Apply the patch
auto applied = g_fxo->get<patch_engine>()->apply(hash, loc);
auto applied = g_fxo->get<patch_engine>().apply(hash, loc);
if (!Emu.GetTitleID().empty())
{
// Alternative patch
applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash, loc);
applied += g_fxo->get<patch_engine>().apply(Emu.GetTitleID() + '-' + hash, loc);
}
spu_log.notice("Loaded SPU image: %s (<- %u)%s", hash, applied.size(), dump);
@ -252,7 +252,7 @@ error_code sys_spu_image_open(ppu_thread& ppu, vm::ptr<sys_spu_image> img, vm::c
return {fs_error, path};
}
u128 klic = g_fxo->get<loaded_npdrm_keys>()->devKlic.load();
u128 klic = g_fxo->get<loaded_npdrm_keys>().devKlic.load();
const fs::file elf_file = decrypt_self(std::move(file), reinterpret_cast<u8*>(&klic));
@ -623,7 +623,7 @@ error_code sys_spu_thread_group_create(ppu_thread& ppu, vm::ptr<u32> id, u32 num
}
else
{
ct = g_fxo->get<lv2_memory_container>();
ct = &g_fxo->get<lv2_memory_container>();
if (ct->take(mem_size) != mem_size)
{
@ -1771,7 +1771,7 @@ error_code sys_spu_thread_group_log(ppu_thread& ppu, s32 command, vm::ptr<s32> s
atomic_t<s32> state = SYS_SPU_THREAD_GROUP_LOG_ON;
};
const auto state = g_fxo->get<spu_group_log_state_t>();
auto& state = g_fxo->get<spu_group_log_state_t>();
switch (command)
{
@ -1782,13 +1782,13 @@ error_code sys_spu_thread_group_log(ppu_thread& ppu, s32 command, vm::ptr<s32> s
return CELL_EFAULT;
}
*stat = state->state;
*stat = state.state;
break;
}
case SYS_SPU_THREAD_GROUP_LOG_ON:
case SYS_SPU_THREAD_GROUP_LOG_OFF:
{
state->state.release(command);
state.state.release(command);
break;
}
default: return CELL_EINVAL;

View File

@ -125,13 +125,13 @@ private:
void LIBUSB_CALL callback_transfer(struct libusb_transfer* transfer)
{
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
if (!usbh->is_init)
std::lock_guard lock(usbh.mutex);
if (!usbh.is_init)
return;
usbh->transfer_complete(transfer);
usbh.transfer_complete(transfer);
}
usb_handler_thread::usb_handler_thread()
@ -481,12 +481,12 @@ error_code sys_usbd_initialize(ppu_thread& ppu, vm::ptr<u32> handle)
sys_usbd.warning("sys_usbd_initialize(handle=*0x%x)", handle);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
// Must not occur (lv2 allows multiple handles, cellUsbd does not)
ensure(!usbh->is_init.exchange(true));
ensure(!usbh.is_init.exchange(true));
*handle = 0x115B;
@ -500,13 +500,13 @@ error_code sys_usbd_finalize(ppu_thread& ppu, u32 handle)
sys_usbd.warning("sys_usbd_finalize(handle=0x%x)", handle);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
usbh->is_init = false;
std::lock_guard lock(usbh.mutex);
usbh.is_init = false;
// Forcefully awake all waiters
for (auto& cpu : ::as_rvalue(std::move(usbh->sq)))
for (auto& cpu : ::as_rvalue(std::move(usbh.sq)))
{
// Special ternimation signal value
cpu->gpr[4] = 4;
@ -525,18 +525,18 @@ error_code sys_usbd_get_device_list(ppu_thread& ppu, u32 handle, vm::ptr<UsbInte
sys_usbd.warning("sys_usbd_get_device_list(handle=0x%x, device_list=*0x%x, max_devices=0x%x)", handle, device_list, max_devices);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
if (!usbh->is_init)
std::lock_guard lock(usbh.mutex);
if (!usbh.is_init)
return CELL_EINVAL;
// TODO: was std::min<s32>
u32 i_tocopy = std::min<u32>(max_devices, ::size32(usbh->handled_devices));
u32 i_tocopy = std::min<u32>(max_devices, ::size32(usbh.handled_devices));
for (u32 index = 0; index < i_tocopy; index++)
{
device_list[index] = usbh->handled_devices[index].first;
device_list[index] = usbh.handled_devices[index].first;
}
return not_an_error(i_tocopy);
@ -549,14 +549,14 @@ error_code sys_usbd_register_extra_ldd(ppu_thread& ppu, u32 handle, vm::ptr<char
sys_usbd.warning("sys_usbd_register_extra_ldd(handle=0x%x, s_product=%s, slen_product=0x%x, id_vendor=0x%x, id_product_min=0x%x, id_product_max=0x%x)", handle, s_product, slen_product, id_vendor,
id_product_min, id_product_max);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
if (!usbh->is_init)
std::lock_guard lock(usbh.mutex);
if (!usbh.is_init)
return CELL_EINVAL;
s32 res = usbh->add_ldd(s_product, slen_product, id_vendor, id_product_min, id_product_max);
usbh->check_devices_vs_ldds();
s32 res = usbh.add_ldd(s_product, slen_product, id_vendor, id_product_min, id_product_max);
usbh.check_devices_vs_ldds();
return not_an_error(res); // To check
}
@ -567,16 +567,16 @@ error_code sys_usbd_get_descriptor_size(ppu_thread& ppu, u32 handle, u32 device_
sys_usbd.trace("sys_usbd_get_descriptor_size(handle=0x%x, deviceNumber=0x%x)", handle, device_handle);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init || !usbh->handled_devices.count(device_handle))
if (!usbh.is_init || !usbh.handled_devices.count(device_handle))
{
return CELL_EINVAL;
}
return not_an_error(usbh->handled_devices[device_handle].second->device.get_size());
return not_an_error(usbh.handled_devices[device_handle].second->device.get_size());
}
error_code sys_usbd_get_descriptor(ppu_thread& ppu, u32 handle, u32 device_handle, vm::ptr<void> descriptor, u32 desc_size)
@ -585,17 +585,17 @@ error_code sys_usbd_get_descriptor(ppu_thread& ppu, u32 handle, u32 device_handl
sys_usbd.trace("sys_usbd_get_descriptor(handle=0x%x, deviceNumber=0x%x, descriptor=0x%x, desc_size=0x%x)", handle, device_handle, descriptor, desc_size);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init || !usbh->handled_devices.count(device_handle))
if (!usbh.is_init || !usbh.handled_devices.count(device_handle))
{
return CELL_EINVAL;
}
u8* ptr = static_cast<u8*>(descriptor.get_ptr());
usbh->handled_devices[device_handle].second->device.write_data(ptr);
usbh.handled_devices[device_handle].second->device.write_data(ptr);
return CELL_OK;
}
@ -634,16 +634,16 @@ error_code sys_usbd_open_pipe(ppu_thread& ppu, u32 handle, u32 device_handle, u3
sys_usbd.warning("sys_usbd_open_pipe(handle=0x%x, device_handle=0x%x, unk1=0x%x, unk2=0x%x, unk3=0x%x, endpoint=0x%x, unk4=0x%x)", handle, device_handle, unk1, unk2, unk3, endpoint, unk4);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init || !usbh->handled_devices.count(device_handle))
if (!usbh.is_init || !usbh.handled_devices.count(device_handle))
{
return CELL_EINVAL;
}
return not_an_error(usbh->open_pipe(device_handle, static_cast<u8>(endpoint)));
return not_an_error(usbh.open_pipe(device_handle, static_cast<u8>(endpoint)));
}
error_code sys_usbd_open_default_pipe(ppu_thread& ppu, u32 handle, u32 device_handle)
@ -652,16 +652,16 @@ error_code sys_usbd_open_default_pipe(ppu_thread& ppu, u32 handle, u32 device_ha
sys_usbd.trace("sys_usbd_open_default_pipe(handle=0x%x, device_handle=0x%x)", handle, device_handle);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init || !usbh->handled_devices.count(device_handle))
if (!usbh.is_init || !usbh.handled_devices.count(device_handle))
{
return CELL_EINVAL;
}
return not_an_error(usbh->open_pipe(device_handle, 0));
return not_an_error(usbh.open_pipe(device_handle, 0));
}
error_code sys_usbd_close_pipe(ppu_thread& ppu, u32 handle, u32 pipe_handle)
@ -670,16 +670,16 @@ error_code sys_usbd_close_pipe(ppu_thread& ppu, u32 handle, u32 pipe_handle)
sys_usbd.todo("sys_usbd_close_pipe(handle=0x%x, pipe_handle=0x%x)", handle, pipe_handle);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init || !usbh->is_pipe(pipe_handle))
if (!usbh.is_init || !usbh.is_pipe(pipe_handle))
{
return CELL_EINVAL;
}
usbh->close_pipe(pipe_handle);
usbh.close_pipe(pipe_handle);
return CELL_OK;
}
@ -696,15 +696,15 @@ error_code sys_usbd_receive_event(ppu_thread& ppu, u32 handle, vm::ptr<u64> arg1
sys_usbd.trace("sys_usbd_receive_event(handle=%u, arg1=*0x%x, arg2=*0x%x, arg3=*0x%x)", handle, arg1, arg2, arg3);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
{
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init)
if (!usbh.is_init)
return CELL_EINVAL;
if (usbh->get_event(arg1, arg2, arg3))
if (usbh.get_event(arg1, arg2, arg3))
{
// hack for Guitar Hero Live
// Attaching the device too fast seems to result in a nullptr along the way
@ -715,7 +715,7 @@ error_code sys_usbd_receive_event(ppu_thread& ppu, u32 handle, vm::ptr<u64> arg1
}
lv2_obj::sleep(ppu);
usbh->sq.emplace_back(&ppu);
usbh.sq.emplace_back(&ppu);
}
while (auto state = ppu.state.fetch_sub(cpu_flag::signal))
@ -784,18 +784,18 @@ error_code sys_usbd_transfer_data(ppu_thread& ppu, u32 handle, u32 id_pipe, vm::
}
}
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init || !usbh->is_pipe(id_pipe))
if (!usbh.is_init || !usbh.is_pipe(id_pipe))
{
return CELL_EINVAL;
}
u32 id_transfer = usbh->get_free_transfer_id();
const auto& pipe = usbh->get_pipe(id_pipe);
auto& transfer = usbh->get_transfer(id_transfer);
u32 id_transfer = usbh.get_free_transfer_id();
const auto& pipe = usbh.get_pipe(id_pipe);
auto& transfer = usbh.get_transfer(id_transfer);
// Default endpoint is control endpoint
if (pipe.endpoint == 0)
@ -823,7 +823,7 @@ error_code sys_usbd_transfer_data(ppu_thread& ppu, u32 handle, u32 id_pipe, vm::
}
if (transfer.fake)
usbh->fake_transfers.push_back(&transfer);
usbh.fake_transfers.push_back(&transfer);
// returns an identifier specific to the transfer
return not_an_error(id_transfer);
@ -835,18 +835,18 @@ error_code sys_usbd_isochronous_transfer_data(ppu_thread& ppu, u32 handle, u32 i
sys_usbd.todo("sys_usbd_isochronous_transfer_data(handle=0x%x, id_pipe=0x%x, iso_request=*0x%x)", handle, id_pipe, iso_request);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init || !usbh->is_pipe(id_pipe))
if (!usbh.is_init || !usbh.is_pipe(id_pipe))
{
return CELL_EINVAL;
}
u32 id_transfer = usbh->get_free_transfer_id();
const auto& pipe = usbh->get_pipe(id_pipe);
auto& transfer = usbh->get_transfer(id_transfer);
u32 id_transfer = usbh.get_free_transfer_id();
const auto& pipe = usbh.get_pipe(id_pipe);
auto& transfer = usbh.get_transfer(id_transfer);
memcpy(&transfer.iso_request, iso_request.get_ptr(), sizeof(UsbDeviceIsoRequest));
pipe.device->isochronous_transfer(&transfer);
@ -861,14 +861,14 @@ error_code sys_usbd_get_transfer_status(ppu_thread& ppu, u32 handle, u32 id_tran
sys_usbd.trace("sys_usbd_get_transfer_status(handle=0x%x, id_transfer=0x%x, unk1=0x%x, result=*0x%x, count=*0x%x)", handle, id_transfer, unk1, result, count);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init)
if (!usbh.is_init)
return CELL_EINVAL;
auto& transfer = usbh->get_transfer(id_transfer);
auto& transfer = usbh.get_transfer(id_transfer);
*result = transfer.result;
*count = transfer.count;
@ -882,14 +882,14 @@ error_code sys_usbd_get_isochronous_transfer_status(ppu_thread& ppu, u32 handle,
sys_usbd.todo("sys_usbd_get_isochronous_transfer_status(handle=0x%x, id_transfer=0x%x, unk1=0x%x, request=*0x%x, result=*0x%x)", handle, id_transfer, unk1, request, result);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init)
if (!usbh.is_init)
return CELL_EINVAL;
auto& transfer = usbh->get_transfer(id_transfer);
auto& transfer = usbh.get_transfer(id_transfer);
*result = transfer.result;
memcpy(request.get_ptr(), &transfer.iso_request, sizeof(UsbDeviceIsoRequest));
@ -919,14 +919,14 @@ error_code sys_usbd_event_port_send(ppu_thread& ppu, u32 handle, u64 arg1, u64 a
sys_usbd.warning("sys_usbd_event_port_send(handle=0x%x, arg1=0x%x, arg2=0x%x, arg3=0x%x)", handle, arg1, arg2, arg3);
const auto usbh = g_fxo->get<named_thread<usb_handler_thread>>();
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
std::lock_guard lock(usbh->mutex);
std::lock_guard lock(usbh.mutex);
if (!usbh->is_init)
if (!usbh.is_init)
return CELL_EINVAL;
usbh->add_event(arg1, arg2, arg3);
usbh.add_event(arg1, arg2, arg3);
return CELL_OK;
}

View File

@ -44,14 +44,14 @@ error_code sys_vm_memory_map(ppu_thread& ppu, u32 vsize, u32 psize, u32 cid, u64
const auto idm_ct = idm::get<lv2_memory_container>(cid);
const auto ct = cid == SYS_MEMORY_CONTAINER_ID_INVALID ? g_fxo->get<lv2_memory_container>() : idm_ct.get();
const auto ct = cid == SYS_MEMORY_CONTAINER_ID_INVALID ? &g_fxo->get<lv2_memory_container>() : idm_ct.get();
if (!ct)
{
return CELL_ESRCH;
}
if (!g_fxo->get<sys_vm_global_t>()->total_vsize.fetch_op([vsize](u32& size)
if (!g_fxo->get<sys_vm_global_t>().total_vsize.fetch_op([vsize](u32& size)
{
// A single process can hold up to 256MB of virtual memory, even on DECR
if (0x10000000 - size < vsize)
@ -68,7 +68,7 @@ error_code sys_vm_memory_map(ppu_thread& ppu, u32 vsize, u32 psize, u32 cid, u64
if (!ct->take(psize))
{
g_fxo->get<sys_vm_global_t>()->total_vsize -= vsize;
g_fxo->get<sys_vm_global_t>().total_vsize -= vsize;
return CELL_ENOMEM;
}
@ -87,7 +87,7 @@ error_code sys_vm_memory_map(ppu_thread& ppu, u32 vsize, u32 psize, u32 cid, u64
}
ct->used -= psize;
g_fxo->get<sys_vm_global_t>()->total_vsize -= vsize;
g_fxo->get<sys_vm_global_t>().total_vsize -= vsize;
return CELL_ENOMEM;
}
@ -121,7 +121,7 @@ error_code sys_vm_unmap(ppu_thread& ppu, u32 addr)
// Return memory
vmo.ct->used -= vmo.psize;
g_fxo->get<sys_vm_global_t>()->total_vsize -= vmo.size;
g_fxo->get<sys_vm_global_t>().total_vsize -= vmo.size;
});
if (!vmo)

View File

@ -906,9 +906,9 @@ namespace vm
// Notify rsx to invalidate range
// Note: This must be done *before* memory gets unmapped while holding the vm lock, otherwise
// the RSX might try to call VirtualProtect on memory that is already unmapped
if (const auto rsxthr = g_fxo->get<rsx::thread>(); g_fxo->is_init<rsx::thread>())
if (auto& rsxthr = g_fxo->get<rsx::thread>(); g_fxo->is_init<rsx::thread>())
{
rsxthr->on_notify_memory_unmapped(addr, size);
rsxthr.on_notify_memory_unmapped(addr, size);
}
// Actually unmap memory

View File

@ -325,8 +325,8 @@ void np_handler::init_NP(u32 poolsize, vm::ptr<void> poolptr)
ensure(!s_npid.empty()); // It should have been generated before this
np_handler::string_to_npid(s_npid, &npid);
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->set_self_sig_info(npid);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.set_self_sig_info(npid);
}
switch (g_cfg.net.psn_status)
@ -462,7 +462,8 @@ u32 np_handler::get_server_status(SceNpMatching2ContextId ctx_id, vm::cptr<SceNp
const auto cb_info = std::move(pending_requests.at(req_id));
pending_requests.erase(req_id);
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_GetServerInfo, event_key, 0, sizeof(SceNpMatching2GetServerInfoResponse), cb_info.cb_arg);
return 0;
});
@ -478,7 +479,8 @@ u32 np_handler::create_server_context(SceNpMatching2ContextId ctx_id, vm::cptr<S
const auto cb_info = std::move(pending_requests.at(req_id));
pending_requests.erase(req_id);
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_CreateServerContext, event_key, 0, 0, cb_info.cb_arg);
return 0;
});
@ -759,7 +761,8 @@ bool np_handler::reply_get_world_list(u32 req_id, std::vector<u8>& reply_data)
}
}
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_GetWorldInfoList, event_key, 0, sizeof(SceNpMatching2GetWorldInfoListResponse), cb_info.cb_arg);
return 0;
});
@ -792,14 +795,15 @@ bool np_handler::reply_create_join_room(u32 req_id, std::vector<u8>& reply_data)
RoomDataInternal_to_SceNpMatching2RoomDataInternal(resp, room_info.get_ptr(), npid);
// Establish Matching2 self signaling info
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->set_self_sig2_info(room_info->roomId, 1);
sigh->set_sig2_infos(room_info->roomId, 1, SCE_NP_SIGNALING_CONN_STATUS_ACTIVE, rpcn.get_addr_sig(), rpcn.get_port_sig(), true);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.set_self_sig2_info(room_info->roomId, 1);
sigh.set_sig2_infos(room_info->roomId, 1, SCE_NP_SIGNALING_CONN_STATUS_ACTIVE, rpcn.get_addr_sig(), rpcn.get_port_sig(), true);
// TODO? Should this send a message to Signaling CB? Is this even necessary?
extra_nps::print_create_room_resp(room_resp);
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_CreateJoinRoom, event_key, 0, sizeof(SceNpMatching2CreateJoinRoomResponse), cb_info.cb_arg);
return 0;
});
@ -835,12 +839,13 @@ bool np_handler::reply_join_room(u32 req_id, std::vector<u8>& reply_data)
extra_nps::print_room_data_internal(room_resp->roomDataInternal.get_ptr());
// Establish Matching2 self signaling info
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->set_self_sig2_info(room_info->roomId, member_id);
sigh->set_sig2_infos(room_info->roomId, member_id, SCE_NP_SIGNALING_CONN_STATUS_ACTIVE, rpcn.get_addr_sig(), rpcn.get_port_sig(), true);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.set_self_sig2_info(room_info->roomId, member_id);
sigh.set_sig2_infos(room_info->roomId, member_id, SCE_NP_SIGNALING_CONN_STATUS_ACTIVE, rpcn.get_addr_sig(), rpcn.get_port_sig(), true);
// TODO? Should this send a message to Signaling CB? Is this even necessary?
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_JoinRoom, event_key, 0, sizeof(SceNpMatching2JoinRoomResponse), cb_info.cb_arg);
return 0;
});
@ -864,10 +869,11 @@ bool np_handler::reply_leave_room(u32 req_id, std::vector<u8>& reply_data)
u32 event_key = get_event_key(); // Unsure if necessary if there is no data
// Disconnect all users from that room
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->disconnect_sig2_users(room_id);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.disconnect_sig2_users(room_id);
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_LeaveRoom, event_key, 0, 0, cb_info.cb_arg);
return 0;
});
@ -895,7 +901,8 @@ bool np_handler::reply_search_room(u32 req_id, std::vector<u8>& reply_data)
SearchRoomReponse_to_SceNpMatching2SearchRoomResponse(resp, search_resp);
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SearchRoom, event_key, 0, sizeof(SceNpMatching2SearchRoomResponse), cb_info.cb_arg);
return 0;
});
@ -913,7 +920,8 @@ bool np_handler::reply_set_roomdata_external(u32 req_id, std::vector<u8>& reply_
u32 event_key = get_event_key(); // Unsure if necessary if there is no data
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SetRoomDataExternal, event_key, 0, 0, cb_info.cb_arg);
return 0;
});
@ -946,7 +954,8 @@ bool np_handler::reply_get_roomdata_internal(u32 req_id, std::vector<u8>& reply_
extra_nps::print_room_data_internal(room_resp->roomDataInternal.get_ptr());
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_GetRoomDataInternal, event_key, 0, sizeof(SceNpMatching2GetRoomDataInternalResponse), cb_info.cb_arg);
return 0;
});
@ -964,7 +973,8 @@ bool np_handler::reply_set_roomdata_internal(u32 req_id, std::vector<u8>& reply_
u32 event_key = get_event_key(); // Unsure if necessary if there is no data
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SetRoomDataInternal, event_key, 0, 0, cb_info.cb_arg);
return 0;
});
@ -993,7 +1003,8 @@ bool np_handler::reply_get_ping_info(u32 req_id, std::vector<u8>& reply_data)
SceNpMatching2SignalingGetPingInfoResponse* final_ping_resp = reinterpret_cast<SceNpMatching2SignalingGetPingInfoResponse*>(allocate_req_result(event_key, sizeof(SceNpMatching2SignalingGetPingInfoResponse)));
GetPingInfoResponse_to_SceNpMatching2SignalingGetPingInfoResponse(resp, final_ping_resp);
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SignalingGetPingInfo, event_key, 0, sizeof(SceNpMatching2SignalingGetPingInfoResponse), cb_info.cb_arg);
return 0;
});
@ -1009,7 +1020,8 @@ bool np_handler::reply_send_room_message(u32 req_id, std::vector<u8>& reply_data
const auto cb_info = std::move(pending_requests.at(req_id));
pending_requests.erase(req_id);
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SendRoomMessage, 0, 0, 0, cb_info.cb_arg);
return 0;
});
@ -1032,8 +1044,8 @@ bool np_handler::reply_req_sign_infos(u32 req_id, std::vector<u8>& reply_data)
if (reply.is_error())
return error_and_disconnect("Malformed reply to RequestSignalingInfos command");
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->start_sig(conn_id, addr, port);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.start_sig(conn_id, addr, port);
return true;
}
@ -1082,7 +1094,8 @@ void np_handler::notif_user_joined_room(std::vector<u8>& data)
rpcn_log.notice("Received notification that user %s(%d) joined the room(%d)", notif_data->roomMemberDataInternal->userInfo.npId.handle.data, notif_data->roomMemberDataInternal->memberId, room_id);
extra_nps::print_room_member_data_internal(notif_data->roomMemberDataInternal.get_ptr());
sysutil_register_cb([room_event_cb = this->room_event_cb, room_id, event_key, room_event_cb_ctx = this->room_event_cb_ctx, room_event_cb_arg = this->room_event_cb_arg](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([room_event_cb = this->room_event_cb, room_id, event_key, room_event_cb_ctx = this->room_event_cb_ctx, room_event_cb_arg = this->room_event_cb_arg](ppu_thread& cb_ppu) -> s32
{
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_MemberJoined, event_key, 0, sizeof(SceNpMatching2RoomMemberUpdateInfo), room_event_cb_arg);
return 0;
});
@ -1109,7 +1122,8 @@ void np_handler::notif_user_left_room(std::vector<u8>& data)
rpcn_log.notice("Received notification that user %s(%d) left the room(%d)", notif_data->roomMemberDataInternal->userInfo.npId.handle.data, notif_data->roomMemberDataInternal->memberId, room_id);
extra_nps::print_room_member_data_internal(notif_data->roomMemberDataInternal.get_ptr());
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg](ppu_thread& cb_ppu) -> s32
{
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_MemberLeft, event_key, 0, sizeof(SceNpMatching2RoomMemberUpdateInfo), room_event_cb_arg);
return 0;
});
@ -1135,10 +1149,11 @@ void np_handler::notif_room_destroyed(std::vector<u8>& data)
rpcn_log.notice("Received notification that room(%d) was destroyed", room_id);
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->disconnect_sig2_users(room_id);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.disconnect_sig2_users(room_id);
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg](ppu_thread& cb_ppu) -> s32
{
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_RoomDestroyed, event_key, 0, sizeof(SceNpMatching2RoomUpdateInfo), room_event_cb_arg);
return 0;
});
@ -1160,9 +1175,9 @@ void np_handler::notif_p2p_connect(std::vector<u8>& data)
rpcn_log.notice("Received notification to connect to member(%d) of room(%d): %s:%d", member_id, room_id, ip_to_string(addr_p2p), port_p2p);
// Attempt Signaling
const auto sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh->set_sig2_infos(room_id, member_id, SCE_NP_SIGNALING_CONN_STATUS_PENDING, addr_p2p, port_p2p);
sigh->start_sig2(room_id, member_id);
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
sigh.set_sig2_infos(room_id, member_id, SCE_NP_SIGNALING_CONN_STATUS_PENDING, addr_p2p, port_p2p);
sigh.start_sig2(room_id, member_id);
}
void np_handler::notif_room_message_received(std::vector<u8>& data)
@ -1363,7 +1378,8 @@ u32 np_handler::add_players_to_history(vm::cptr<SceNpId> npids, u32 count)
// if (basic_handler)
// {
// sysutil_register_cb([basic_handler = this->basic_handler, req_id, basic_handler_arg = this->basic_handler_arg](ppu_thread& cb_ppu) -> s32 {
// sysutil_register_cb([basic_handler = this->basic_handler, req_id, basic_handler_arg = this->basic_handler_arg](ppu_thread& cb_ppu) -> s32
// {
// basic_handler(cb_ppu, SCE_NP_BASIC_EVENT_ADD_PLAYERS_HISTORY_RESULT, 0, req_id, basic_handler_arg);
// return 0;
// });

View File

@ -70,7 +70,8 @@ void signaling_handler::signal_sig_callback(u32 conn_id, int event)
{
if (sig_cb)
{
sysutil_register_cb([sig_cb = this->sig_cb, sig_cb_ctx = this->sig_cb_ctx, conn_id, event, sig_cb_arg = this->sig_cb_arg](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([sig_cb = this->sig_cb, sig_cb_ctx = this->sig_cb_ctx, conn_id, event, sig_cb_arg = this->sig_cb_arg](ppu_thread& cb_ppu) -> s32
{
sig_cb(cb_ppu, sig_cb_ctx, conn_id, event, 0, sig_cb_arg);
return 0;
});
@ -85,7 +86,8 @@ void signaling_handler::signal_ext_sig_callback(u32 conn_id, int event)
{
if (sig_ext_cb)
{
sysutil_register_cb([sig_ext_cb = this->sig_ext_cb, sig_ext_cb_ctx = this->sig_ext_cb_ctx, conn_id, event, sig_ext_cb_arg = this->sig_ext_cb_arg](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([sig_ext_cb = this->sig_ext_cb, sig_ext_cb_ctx = this->sig_ext_cb_ctx, conn_id, event, sig_ext_cb_arg = this->sig_ext_cb_arg](ppu_thread& cb_ppu) -> s32
{
sig_ext_cb(cb_ppu, sig_ext_cb_ctx, conn_id, event, 0, sig_ext_cb_arg);
return 0;
});
@ -98,7 +100,8 @@ void signaling_handler::signal_sig2_callback(u64 room_id, u16 member_id, SceNpMa
// Signal the callback
if (sig2_cb)
{
sysutil_register_cb([sig2_cb = this->sig2_cb, sig2_cb_ctx = this->sig2_cb_ctx, room_id, member_id, event, sig2_cb_arg = this->sig2_cb_arg](ppu_thread& cb_ppu) -> s32 {
sysutil_register_cb([sig2_cb = this->sig2_cb, sig2_cb_ctx = this->sig2_cb_ctx, room_id, member_id, event, sig2_cb_arg = this->sig2_cb_arg](ppu_thread& cb_ppu) -> s32
{
sig2_cb(cb_ppu, sig2_cb_ctx, room_id, member_id, event, 0, sig2_cb_arg);
return 0;
});
@ -587,8 +590,8 @@ u32 signaling_handler::init_sig_infos(const SceNpId* npid)
// Request peer infos from RPCN
std::string npid_str(reinterpret_cast<const char*>(npid->handle.data));
const auto nph = g_fxo->get<named_thread<np_handler>>();
nph->req_sign_infos(npid_str, conn_id);
auto& nph = g_fxo->get<named_thread<np_handler>>();
nph.req_sign_infos(npid_str, conn_id);
}
else
{

View File

@ -187,7 +187,7 @@ namespace rsx
continue;
}
const u32 bpp = g_fxo->get<rsx::avconf>()->get_bpp();
const u32 bpp = g_fxo->get<rsx::avconf>().get_bpp();
const u32 pitch = buffer.pitch ? +buffer.pitch : bpp * buffer.width;
if (pitch != dst_pitch)

View File

@ -162,7 +162,7 @@ private:
void load_texture_env();
void bind_texture_env();
gl::texture* get_present_source(gl::present_surface_info* info, const rsx::avconf* avconfig);
gl::texture* get_present_source(gl::present_surface_info* info, const rsx::avconf& avconfig);
public:
void set_viewport();

View File

@ -4,7 +4,7 @@
LOG_CHANNEL(screenshot_log, "SCREENSHOT");
gl::texture* GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf* avconfig)
gl::texture* GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf& avconfig)
{
gl::texture* image = nullptr;
@ -79,10 +79,10 @@ gl::texture* GLGSRender::get_present_source(gl::present_surface_info* info, cons
m_gl_texture_cache.invalidate_range(cmd, range, rsx::invalidation_cause::read);
gl::texture::format fmt;
switch (avconfig->format)
switch (avconfig.format)
{
default:
rsx_log.error("Unhandled video output format 0x%x", avconfig->format);
rsx_log.error("Unhandled video output format 0x%x", avconfig.format);
[[fallthrough]];
case CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_X8R8G8B8:
fmt = gl::texture::format::bgra;
@ -113,16 +113,16 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
u32 buffer_pitch = display_buffers[info.buffer].pitch;
u32 av_format;
const auto avconfig = g_fxo->get<rsx::avconf>();
auto& avconfig = g_fxo->get<rsx::avconf>();
if (avconfig->state)
if (avconfig.state)
{
av_format = avconfig->get_compatible_gcm_format();
av_format = avconfig.get_compatible_gcm_format();
if (!buffer_pitch)
buffer_pitch = buffer_width * avconfig->get_bpp();
buffer_pitch = buffer_width * avconfig.get_bpp();
const u32 video_frame_height = (!avconfig->_3d? avconfig->resolution_y : (avconfig->resolution_y - 30) / 2);
buffer_width = std::min(buffer_width, avconfig->resolution_x);
const u32 video_frame_height = (!avconfig._3d? avconfig.resolution_y : (avconfig.resolution_y - 30) / 2);
buffer_width = std::min(buffer_width, avconfig.resolution_x);
buffer_height = std::min(buffer_height, video_frame_height);
}
else
@ -153,7 +153,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
const auto image_to_flip_ = get_present_source(&present_info, avconfig);
image_to_flip = image_to_flip_->id();
if (avconfig->_3d) [[unlikely]]
if (avconfig._3d) [[unlikely]]
{
const auto [unused, min_expected_height] = rsx::apply_resolution_scale<true>(RSX_SURFACE_DIMENSION_IGNORED, buffer_height + 30);
if (image_to_flip_->height() < min_expected_height)
@ -236,7 +236,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
const bool use_full_rgb_range_output = g_cfg.video.full_rgb_range_output.get();
if (use_full_rgb_range_output && rsx::fcmp(avconfig->gamma, 1.f) && !avconfig->_3d)
if (use_full_rgb_range_output && rsx::fcmp(avconfig.gamma, 1.f) && !avconfig._3d)
{
// Blit source image to the screen
m_flip_fbo.recreate();
@ -248,12 +248,12 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
}
else
{
const f32 gamma = avconfig->gamma;
const f32 gamma = avconfig.gamma;
const bool limited_range = !use_full_rgb_range_output;
const rsx::simple_array<GLuint> images{ image_to_flip, image_to_flip2 };
gl::screen.bind();
m_video_output_pass.run(areau(aspect_ratio), images, gamma, limited_range, avconfig->_3d);
m_video_output_pass.run(areau(aspect_ratio), images, gamma, limited_range, avconfig._3d);
}
}

View File

@ -17,7 +17,7 @@ namespace rsx
type.disable_cancel = true;
type.progress_bar_count = 2;
dlg = g_fxo->get<rsx::overlays::display_manager>()->create<rsx::overlays::message_dialog>(!!g_cfg.video.shader_preloading_dialog.use_custom_background);
dlg = g_fxo->get<rsx::overlays::display_manager>().create<rsx::overlays::message_dialog>(!!g_cfg.video.shader_preloading_dialog.use_custom_background);
dlg->progress_bar_set_taskbar_index(-1);
dlg->show(false, msg, type, [](s32 status)
{

View File

@ -251,13 +251,13 @@ namespace rsx
{
if (!exit)
{
g_fxo->get<named_thread<msg_dialog_thread>>()->operator()([&, tbit = alloc_thread_bit()]()
g_fxo->get<named_thread<msg_dialog_thread>>()([&, tbit = alloc_thread_bit()]()
{
g_thread_bit = tbit;
if (interactive)
{
auto ref = g_fxo->get<display_manager>()->get(uid);
auto ref = g_fxo->get<display_manager>().get(uid);
if (auto error = run_input_loop())
{

View File

@ -1017,7 +1017,7 @@ namespace rsx
update_panel();
g_fxo->get<named_thread<osk_dialog_thread>>()->operator()([this, tbit = alloc_thread_bit()]
g_fxo->get<named_thread<osk_dialog_thread>>()([this, tbit = alloc_thread_bit()]
{
g_thread_bit = tbit;

View File

@ -414,7 +414,7 @@ namespace rsx
{
m_update_timer.Start();
const auto rsx_thread = g_fxo->get<rsx::thread>();
auto& rsx_thread = g_fxo->get<rsx::thread>();
switch (m_detail)
{
@ -422,7 +422,7 @@ namespace rsx
{
m_frametime = std::max(0.f, static_cast<float>(elapsed_update / m_frames));
m_rsx_load = rsx_thread->get_load();
m_rsx_load = rsx_thread.get_load();
m_total_threads = utils::cpu_stats::get_thread_count();
@ -440,7 +440,7 @@ namespace rsx
m_spu_cycles += thread_ctrl::get_cycles(spu);
});
m_rsx_cycles += rsx_thread->get_cycles();
m_rsx_cycles += rsx_thread.get_cycles();
m_total_cycles = std::max<u64>(1, m_ppu_cycles + m_spu_cycles + m_rsx_cycles);
m_cpu_usage = static_cast<f32>(m_cpu_stats.get_usage());
@ -716,10 +716,10 @@ namespace rsx
if (!g_cfg.misc.use_native_interface)
return;
if (auto manager = g_fxo->get<rsx::overlays::display_manager>())
if (auto& manager = g_fxo->get<rsx::overlays::display_manager>(); g_fxo->is_init<rsx::overlays::display_manager>())
{
auto& perf_settings = g_cfg.video.perf_overlay;
auto perf_overlay = manager->get<rsx::overlays::perf_metrics_overlay>();
auto perf_overlay = manager.get<rsx::overlays::perf_metrics_overlay>();
if (perf_settings.perf_overlay_enabled)
{
@ -727,10 +727,10 @@ namespace rsx
if (!existed)
{
perf_overlay = manager->create<rsx::overlays::perf_metrics_overlay>();
perf_overlay = manager.create<rsx::overlays::perf_metrics_overlay>();
}
std::scoped_lock lock(*manager);
std::lock_guard lock(manager);
perf_overlay->set_detail_level(perf_settings.level);
perf_overlay->set_position(perf_settings.position);
@ -747,7 +747,7 @@ namespace rsx
}
else if (perf_overlay)
{
manager->remove<rsx::overlays::perf_metrics_overlay>();
manager.remove<rsx::overlays::perf_metrics_overlay>();
}
}
}

View File

@ -216,15 +216,15 @@ namespace rsx
}
// NOTE: Object removal should be the last step
if (auto manager = g_fxo->get<display_manager>())
if (auto& manager = g_fxo->get<display_manager>(); g_fxo->is_init<display_manager>())
{
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
if (auto dlg = manager.get<rsx::overlays::message_dialog>())
{
if (dlg->progress_bar_count())
Emu.GetCallbacks().handle_taskbar_progress(0, 1);
}
manager->remove(uid);
manager.remove(uid);
}
}

View File

@ -103,8 +103,8 @@ namespace rsx
}
else
{
g_fxo->get<dma_thread>()->m_enqueued_count++;
g_fxo->get<dma_thread>()->m_work_queue.push(dst, src, length);
g_fxo->get<dma_thread>().m_enqueued_count++;
g_fxo->get<dma_thread>().m_work_queue.push(dst, src, length);
}
}
@ -116,8 +116,8 @@ namespace rsx
}
else
{
g_fxo->get<dma_thread>()->m_enqueued_count++;
g_fxo->get<dma_thread>()->m_work_queue.push(dst, src, length);
g_fxo->get<dma_thread>().m_enqueued_count++;
g_fxo->get<dma_thread>().m_work_queue.push(dst, src, length);
}
}
@ -131,8 +131,8 @@ namespace rsx
}
else
{
g_fxo->get<dma_thread>()->m_enqueued_count++;
g_fxo->get<dma_thread>()->m_work_queue.push(dst, primitive, count);
g_fxo->get<dma_thread>().m_enqueued_count++;
g_fxo->get<dma_thread>().m_work_queue.push(dst, primitive, count);
}
}
@ -141,21 +141,21 @@ namespace rsx
{
ensure(g_cfg.video.multithreaded_rsx);
g_fxo->get<dma_thread>()->m_enqueued_count++;
g_fxo->get<dma_thread>()->m_work_queue.push(request_code, args);
g_fxo->get<dma_thread>().m_enqueued_count++;
g_fxo->get<dma_thread>().m_work_queue.push(request_code, args);
}
// Synchronization
bool dma_manager::is_current_thread() const
{
return std::this_thread::get_id() == g_fxo->get<dma_thread>()->m_thread_id;
return std::this_thread::get_id() == g_fxo->get<dma_thread>().m_thread_id;
}
bool dma_manager::sync()
{
const auto _thr = g_fxo->get<dma_thread>();
auto& _thr = g_fxo->get<dma_thread>();
if (_thr->m_enqueued_count.load() <= _thr->m_processed_count.load()) [[likely]]
if (_thr.m_enqueued_count.load() <= _thr.m_processed_count.load()) [[likely]]
{
// Nothing to do
return true;
@ -169,7 +169,7 @@ namespace rsx
return false;
}
while (_thr->m_enqueued_count.load() > _thr->m_processed_count.load())
while (_thr.m_enqueued_count.load() > _thr.m_processed_count.load())
{
rsxthr->on_semaphore_acquire_wait();
utils::pause();
@ -177,7 +177,7 @@ namespace rsx
}
else
{
while (_thr->m_enqueued_count.load() > _thr->m_processed_count.load())
while (_thr.m_enqueued_count.load() > _thr.m_processed_count.load())
utils::pause();
}
@ -186,7 +186,7 @@ namespace rsx
void dma_manager::join()
{
*g_fxo->get<dma_thread>() = thread_state::aborting;
g_fxo->get<dma_thread>() = thread_state::aborting;
sync();
}
@ -205,7 +205,7 @@ namespace rsx
// Fault recovery
utils::address_range dma_manager::get_fault_range(bool writing) const
{
const auto m_current_job = (ensure(g_fxo->get<dma_thread>()->m_current_job));
const auto m_current_job = ensure(g_fxo->get<dma_thread>().m_current_job);
void *address = nullptr;
u32 range = m_current_job->length;

View File

@ -555,7 +555,7 @@ namespace rsx
rsx::overlays::reset_performance_overlay();
g_fxo->get<rsx::dma_manager>()->init();
g_fxo->get<rsx::dma_manager>().init();
on_init_thread();
if (!zcull_ctrl)
@ -684,7 +684,7 @@ namespace rsx
do_local_task(rsx::FIFO_state::lock_wait);
m_rsx_thread_exiting = true;
g_fxo->get<rsx::dma_manager>()->join();
g_fxo->get<rsx::dma_manager>().join();
state += cpu_flag::exit;
}
@ -2357,7 +2357,7 @@ namespace rsx
const u32 data_size = range.second * block.attribute_stride;
const u32 vertex_base = range.first * block.attribute_stride;
g_fxo->get<rsx::dma_manager>()->copy(persistent, vm::_ptr<char>(block.real_offset_address) + vertex_base, data_size);
g_fxo->get<rsx::dma_manager>().copy(persistent, vm::_ptr<char>(block.real_offset_address) + vertex_base, data_size);
persistent += data_size;
}
}
@ -2510,7 +2510,7 @@ namespace rsx
m_graphics_state |= rsx::pipeline_state::fragment_constants_dirty;
// DMA sync; if you need this, don't use MTRSX
// g_fxo->get<rsx::dma_manager>()->sync();
// g_fxo->get<rsx::dma_manager>().sync();
//TODO: On sync every sub-unit should finish any pending tasks
//Might cause zcull lockup due to zombie 'unclaimed reports' which are not forcefully removed currently
@ -2744,7 +2744,7 @@ namespace rsx
{
// Each 64 entries are grouped by a bit
const u64 io_event = SYS_RSX_EVENT_UNMAPPED_BASE << i;
g_fxo->get<lv2_rsx_config>()->send_event(0, io_event, to_unmap);
g_fxo->get<lv2_rsx_config>().send_event(0, io_event, to_unmap);
}
}
}
@ -2757,13 +2757,13 @@ namespace rsx
{
io >>= 20;
const auto cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg->gcmio_mutex);
auto& cfg = g_fxo->get<gcm_config>();
std::lock_guard lock(cfg.gcmio_mutex);
for (const u32 end = ea + (size >> 20); ea < end;)
{
cfg->offsetTable.ioAddress[ea++] = 0xFFFF;
cfg->offsetTable.eaAddress[io++] = 0xFFFF;
cfg.offsetTable.ioAddress[ea++] = 0xFFFF;
cfg.offsetTable.eaAddress[io++] = 0xFFFF;
}
}
}
@ -2828,7 +2828,7 @@ namespace rsx
{
if (g_cfg.video.multithreaded_rsx)
{
g_fxo->get<rsx::dma_manager>()->sync();
g_fxo->get<rsx::dma_manager>().sync();
}
external_interrupt_ack.store(true);

View File

@ -25,7 +25,7 @@ namespace vk
if (!flush && g_cfg.video.multithreaded_rsx)
{
auto packet = new submit_packet(queue, pfence, info);
g_fxo->get<rsx::dma_manager>()->backend_ctrl(rctrl_queue_submit, packet);
g_fxo->get<rsx::dma_manager>().backend_ctrl(rctrl_queue_submit, packet);
}
else
{

View File

@ -673,15 +673,15 @@ bool VKGSRender::on_access_violation(u32 address, bool is_writing)
if (result.num_flushable > 0)
{
if (g_fxo->get<rsx::dma_manager>()->is_current_thread())
if (g_fxo->get<rsx::dma_manager>().is_current_thread())
{
// The offloader thread cannot handle flush requests
ensure(!(m_queue_status & flush_queue_state::deadlock));
m_offloader_fault_range = g_fxo->get<rsx::dma_manager>()->get_fault_range(is_writing);
m_offloader_fault_range = g_fxo->get<rsx::dma_manager>().get_fault_range(is_writing);
m_offloader_fault_cause = (is_writing) ? rsx::invalidation_cause::write : rsx::invalidation_cause::read;
g_fxo->get<rsx::dma_manager>()->set_mem_fault_flag();
g_fxo->get<rsx::dma_manager>().set_mem_fault_flag();
m_queue_status |= flush_queue_state::deadlock;
// Wait for deadlock to clear
@ -690,7 +690,7 @@ bool VKGSRender::on_access_violation(u32 address, bool is_writing)
utils::pause();
}
g_fxo->get<rsx::dma_manager>()->clear_mem_fault_flag();
g_fxo->get<rsx::dma_manager>().clear_mem_fault_flag();
return true;
}
@ -1928,7 +1928,7 @@ void VKGSRender::close_and_submit_command_buffer(vk::fence* pFence, VkSemaphore
// Workaround for deadlock occuring during RSX offloader fault
// TODO: Restructure command submission infrastructure to avoid this condition
const bool sync_success = g_fxo->get<rsx::dma_manager>()->sync();
const bool sync_success = g_fxo->get<rsx::dma_manager>().sync();
const VkBool32 force_flush = !sync_success;
if (vk::test_status_interrupt(vk::heap_dirty))

View File

@ -516,7 +516,7 @@ private:
void present(vk::frame_context_t *ctx);
void reinitialize_swapchain();
vk::image* get_present_source(vk::present_surface_info* info, const rsx::avconf* avconfig);
vk::image* get_present_source(vk::present_surface_info* info, const rsx::avconf& avconfig);
void begin_render_pass();
void close_render_pass();

View File

@ -273,7 +273,7 @@ void VKGSRender::frame_context_cleanup(vk::frame_context_t *ctx, bool free_resou
vk::advance_completed_frame_counter();
}
vk::image* VKGSRender::get_present_source(vk::present_surface_info* info, const rsx::avconf* avconfig)
vk::image* VKGSRender::get_present_source(vk::present_surface_info* info, const rsx::avconf& avconfig)
{
vk::image* image_to_flip = nullptr;
@ -352,10 +352,10 @@ vk::image* VKGSRender::get_present_source(vk::present_surface_info* info, const
}
VkFormat format;
switch (avconfig->format)
switch (avconfig.format)
{
default:
rsx_log.error("Unhandled video output format 0x%x", avconfig->format);
rsx_log.error("Unhandled video output format 0x%x", avconfig.format);
[[fallthrough]];
case CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_X8R8G8B8:
format = VK_FORMAT_B8G8R8A8_UNORM;
@ -439,16 +439,16 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
u32 buffer_pitch = display_buffers[info.buffer].pitch;
u32 av_format;
const auto avconfig = g_fxo->get<rsx::avconf>();
auto& avconfig = g_fxo->get<rsx::avconf>();
if (avconfig->state)
if (avconfig.state)
{
av_format = avconfig->get_compatible_gcm_format();
av_format = avconfig.get_compatible_gcm_format();
if (!buffer_pitch)
buffer_pitch = buffer_width * avconfig->get_bpp();
buffer_pitch = buffer_width * avconfig.get_bpp();
const u32 video_frame_height = (!avconfig->_3d? avconfig->resolution_y : (avconfig->resolution_y - 30) / 2);
buffer_width = std::min(buffer_width, avconfig->resolution_x);
const u32 video_frame_height = (!avconfig._3d? avconfig.resolution_y : (avconfig.resolution_y - 30) / 2);
buffer_width = std::min(buffer_width, avconfig.resolution_x);
buffer_height = std::min(buffer_height, video_frame_height);
}
else
@ -471,7 +471,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
image_to_flip = get_present_source(&present_info, avconfig);
if (avconfig->_3d) [[unlikely]]
if (avconfig._3d) [[unlikely]]
{
const auto [unused, min_expected_height] = rsx::apply_resolution_scale<true>(RSX_SURFACE_DIMENSION_IGNORED, buffer_height + 30);
if (image_to_flip->height() < min_expected_height)
@ -592,7 +592,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
{
const bool use_full_rgb_range_output = g_cfg.video.full_rgb_range_output.get();
if (!use_full_rgb_range_output || !rsx::fcmp(avconfig->gamma, 1.f) || avconfig->_3d) [[unlikely]]
if (!use_full_rgb_range_output || !rsx::fcmp(avconfig.gamma, 1.f) || avconfig._3d) [[unlikely]]
{
calibration_src.push_back(dynamic_cast<vk::viewable_image*>(image_to_flip));
ensure(calibration_src.front());
@ -642,7 +642,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
vk::get_overlay_pass<vk::video_out_calibration_pass>()->run(
*m_current_command_buffer, areau(aspect_ratio), direct_fbo, calibration_src,
avconfig->gamma, !use_full_rgb_range_output, avconfig->_3d, single_target_pass);
avconfig.gamma, !use_full_rgb_range_output, avconfig._3d, single_target_pass);
image_to_flip->pop_layout(*m_current_command_buffer);
direct_fbo->release();

View File

@ -32,10 +32,10 @@ namespace vk
{
if (!flush && g_cfg.video.multithreaded_rsx)
{
auto offloader_thread = g_fxo->get<rsx::dma_manager>();
ensure(!offloader_thread->is_current_thread());
auto& offloader_thread = g_fxo->get<rsx::dma_manager>();
ensure(!offloader_thread.is_current_thread());
offloader_thread->backend_ctrl(rctrl_run_gc, reinterpret_cast<void*>(event_id));
offloader_thread.backend_ctrl(rctrl_run_gc, reinterpret_cast<void*>(event_id));
return;
}

View File

@ -69,7 +69,7 @@ namespace
VkDeviceSize offset_in_index_buffer = m_index_buffer_ring_info.alloc<256>(upload_size);
void* buf = m_index_buffer_ring_info.map(offset_in_index_buffer, upload_size);
g_fxo->get<rsx::dma_manager>()->emulate_as_indexed(buf, clause.primitive, vertex_count);
g_fxo->get<rsx::dma_manager>().emulate_as_indexed(buf, clause.primitive, vertex_count);
m_index_buffer_ring_info.unmap();
return std::make_tuple(

View File

@ -68,7 +68,7 @@ namespace vk
}
// Wait for DMA activity to end
g_fxo->get<rsx::dma_manager>()->sync();
g_fxo->get<rsx::dma_manager>().sync();
if (mapped)
{

View File

@ -207,7 +207,7 @@ namespace rsx
void texture_read_semaphore_release(thread* rsx, u32 _reg, u32 arg)
{
// Pipeline barrier seems to be equivalent to a SHADER_READ stage barrier
g_fxo->get<rsx::dma_manager>()->sync();
g_fxo->get<rsx::dma_manager>().sync();
if (g_cfg.video.strict_rendering_mode)
{
rsx->sync();
@ -230,7 +230,7 @@ namespace rsx
void back_end_write_semaphore_release(thread* rsx, u32 _reg, u32 arg)
{
// Full pipeline barrier
g_fxo->get<rsx::dma_manager>()->sync();
g_fxo->get<rsx::dma_manager>().sync();
rsx->sync();
const u32 offset = method_registers.semaphore_offset_4097();

View File

@ -530,15 +530,15 @@ const std::string Emulator::GetBackgroundPicturePath() const
std::string Emulator::PPUCache() const
{
const auto _main = g_fxo->get<ppu_module>();
auto& _main = g_fxo->get<ppu_module>();
if (!_main || _main->cache.empty())
if (!g_fxo->is_init<ppu_module>() || _main.cache.empty())
{
ppu_log.warning("PPU Cache location not initialized.");
return {};
}
return _main->cache;
return _main.cache;
}
bool Emulator::BootRsxCapture(const std::string& path)
@ -1070,7 +1070,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
}
// Load patches from different locations
g_fxo->get<patch_engine>()->append_title_patches(m_title_id);
g_fxo->get<patch_engine>().append_title_patches(m_title_id);
// Mount all devices
const std::string emu_dir = GetEmuDir();
@ -1157,15 +1157,15 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
if (obj == elf_error::ok)
{
const auto _main = g_fxo->get<ppu_module>();
auto& _main = g_fxo->get<ppu_module>();
ppu_load_exec(obj);
_main->path = path;
_main.path = path;
ConfigurePPUCache();
ppu_initialize(*_main);
ppu_initialize(_main);
}
else
{
@ -2074,25 +2074,25 @@ void Emulator::ConfigureLogs()
void Emulator::ConfigurePPUCache()
{
const auto _main = g_fxo->get<ppu_module>();
auto& _main = g_fxo->get<ppu_module>();
_main->cache = GetCacheDir();
_main.cache = GetCacheDir();
if (!m_title_id.empty() && m_cat != "1P")
{
_main->cache += Emu.GetTitleID();
_main->cache += '/';
_main.cache += Emu.GetTitleID();
_main.cache += '/';
}
fmt::append(_main->cache, "ppu-%s-%s/", fmt::base57(_main->sha1), _main->path.substr(_main->path.find_last_of('/') + 1));
fmt::append(_main.cache, "ppu-%s-%s/", fmt::base57(_main.sha1), _main.path.substr(_main.path.find_last_of('/') + 1));
if (!fs::create_path(_main->cache))
if (!fs::create_path(_main.cache))
{
sys_log.error("Failed to create cache directory: %s (%s)", _main->cache, fs::g_tls_error);
sys_log.error("Failed to create cache directory: %s (%s)", _main.cache, fs::g_tls_error);
}
else
{
sys_log.notice("Cache: %s", _main->cache);
sys_log.notice("Cache: %s", _main.cache);
}
}

View File

@ -36,11 +36,11 @@ bool vfs::mount(std::string_view vpath, std::string_view path)
// Workaround
g_fxo->need<vfs_manager>();
const auto table = g_fxo->get<vfs_manager>();
auto& table = g_fxo->get<vfs_manager>();
// TODO: scan roots of mounted devices for undeleted vfs::host::unlink remnants, and try to delete them (_WIN32 only)
std::lock_guard lock(table->mutex);
std::lock_guard lock(table.mutex);
if (vpath.empty())
{
@ -48,7 +48,7 @@ bool vfs::mount(std::string_view vpath, std::string_view path)
return false;
}
for (std::vector<vfs_directory*> list{&table->root};;)
for (std::vector<vfs_directory*> list{&table.root};;)
{
// Skip one or more '/'
const auto pos = vpath.find_first_not_of('/');
@ -111,9 +111,9 @@ bool vfs::mount(std::string_view vpath, std::string_view path)
std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir, std::string* out_path)
{
const auto table = g_fxo->get<vfs_manager>();
auto& table = g_fxo->get<vfs_manager>();
reader_lock lock(table->mutex);
reader_lock lock(table.mutex);
// Resulting path fragments: decoded ones
std::vector<std::string_view> result;
@ -136,7 +136,7 @@ std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir,
name_list.reserve(vpath.size() / 2);
}
for (std::vector<const vfs_directory*> list{&table->root};;)
for (std::vector<const vfs_directory*> list{&table.root};;)
{
// Skip one or more '/'
const auto pos = vpath.find_first_not_of('/');

View File

@ -578,7 +578,7 @@ void debugger_frame::UpdateUnitList()
idm::select<named_thread<ppu_thread>>(on_select);
idm::select<named_thread<spu_thread>>(on_select);
if (auto render = g_fxo->get<rsx::thread>(); emu_state != system_state::stopped && render && render->ctrl)
if (auto render = g_fxo->try_get<rsx::thread>(); emu_state != system_state::stopped && render && render->ctrl)
{
on_select(render->id, *render);
}

View File

@ -483,9 +483,9 @@ void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot
screenshot_manager manager;
{
const auto fxo = g_fxo->get<screenshot_manager>();
auto& fxo = g_fxo->get<screenshot_manager>();
std::lock_guard lock(screenshot_mtx);
manager = *fxo;
manager = fxo;
}
struct scoped_png_ptrs
@ -579,10 +579,10 @@ void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot
// Games choose the overlay file and the offset based on the current video resolution.
// We need to scale the overlay if our resolution scaling causes the image to have a different size.
const auto avconf = g_fxo->get<rsx::avconf>();
auto& avconf = g_fxo->get<rsx::avconf>();
// TODO: handle wacky PS3 resolutions (without resolution scaling)
if (avconf->resolution_x != sshot_width || avconf->resolution_y != sshot_height)
if (avconf.resolution_x != sshot_width || avconf.resolution_y != sshot_height)
{
const int scale = rsx::get_resolution_scale_percent();
const int x = (scale * manager.overlay_offset_x) / 100;

View File

@ -183,7 +183,7 @@ kernel_explorer::kernel_explorer(QWidget* parent)
void kernel_explorer::Update()
{
const auto dct = g_fxo->get<lv2_memory_container>();
const auto dct = g_fxo->try_get<lv2_memory_container>();
if (!dct)
{
@ -606,7 +606,7 @@ void kernel_explorer::Update()
{
// Currently a single context is supported at a time
const auto rsx = rsx::get_current_renderer();
const auto context_info = g_fxo->get<lv2_rsx_config>();
const auto context_info = g_fxo->try_get<lv2_rsx_config>();
if (!rsx || !context_info)
{

View File

@ -256,15 +256,15 @@ namespace stx
// Obtain object pointer (may be uninitialized memory)
template <typename T>
T* get() const noexcept
T& get() const noexcept
{
if constexpr (Size != 0)
{
return std::launder(reinterpret_cast<T*>(m_data + stx::typeoffset<typeinfo, std::decay_t<T>>()));
return *std::launder(reinterpret_cast<T*>(m_data + stx::typeoffset<typeinfo, std::decay_t<T>>()));
}
else
{
return std::launder(reinterpret_cast<T*>(m_list + stx::typeoffset<typeinfo, std::decay_t<T>>()));
return *std::launder(reinterpret_cast<T*>(m_list + stx::typeoffset<typeinfo, std::decay_t<T>>()));
}
}
@ -274,7 +274,7 @@ namespace stx
{
if (is_init<T>())
{
[[likely]] return get<T>();
[[likely]] return &get<T>();
}
[[unlikely]] return nullptr;