Update cellVoiceCreatePort syntax

This commit is contained in:
Eladash 2019-12-31 16:02:41 +02:00 committed by Ivan
parent 9958a83d10
commit b30be0fbc1
2 changed files with 14 additions and 12 deletions

View file

@ -168,22 +168,24 @@ error_code cellVoiceCreatePort(vm::ptr<u32> portId, vm::cptr<CellVoicePortParam>
// Id: bits [8,15] seem to contain a "random" value // Id: bits [8,15] seem to contain a "random" value
// bits [0,7] are based on creation counter modulo 0xa0 // bits [0,7] are based on creation counter modulo 0xa0
// The rest are set to zero and ignored. // The rest are set to zero and ignored.
manager->id_ctr = (manager->id_ctr + 1) % 0xa0; manager->id_ctr++; manager->id_ctr %= 0xa0;
auto port = manager->ports.begin();
bool success = false;
// It isn't known whether bits[8,15] are guaranteed to be non-zero // It isn't known whether bits[8,15] are guaranteed to be non-zero
for (u8 ctr2 = 1; !success; ctr2++) constexpr u32 min_value = 1;
for (u32 ctr2 = min_value; ctr2 < CELLVOICE_MAX_PORT + min_value; ctr2++)
{ {
verify(HERE), ctr2 < CELLVOICE_MAX_PORT + 1; const auto [port, success] = manager->ports.try_emplace(static_cast<u16>((ctr2 << 8) | manager->id_ctr));
std::tie(port, success) = manager->ports.try_emplace(::narrow<u16>((ctr2 << 8) | manager->id_ctr));
}
if (success)
{
port->second.info = *pArg; port->second.info = *pArg;
*portId = port->first; *portId = port->first;
return CELL_OK; return CELL_OK;
}
}
fmt::throw_exception("Unreachable" HERE);
} }
error_code cellVoiceDeletePort(u32 portId) error_code cellVoiceDeletePort(u32 portId)

View file

@ -185,7 +185,7 @@ struct voice_manager
}; };
// See cellVoiceCreatePort // See cellVoiceCreatePort
u32 id_ctr = 0; u8 id_ctr = 0;
// For cellVoiceSetNotifyEventQueue // For cellVoiceSetNotifyEventQueue
u32 port_source = 0; u32 port_source = 0;