mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-30 07:13:18 +00:00
audio_core: Fix return value types and shift some error handling to library. (#1212)
This commit is contained in:
parent
7e533ccf50
commit
388d717205
4 changed files with 32 additions and 38 deletions
|
@ -176,11 +176,15 @@ int PS4_SYSV_ABI sceAudioOutGetLastOutputTime() {
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state) {
|
||||
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
|
||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||
}
|
||||
|
||||
int type = 0;
|
||||
int channels_num = 0;
|
||||
|
||||
if (!audio->AudioOutGetStatus(handle, &type, &channels_num)) {
|
||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||
if (const auto err = audio->AudioOutGetStatus(handle, &type, &channels_num); err != ORBIS_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
state->rerouteCounter = 0;
|
||||
|
@ -310,12 +314,7 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
|
|||
LOG_ERROR(Lib_AudioOut, "Invalid format attribute");
|
||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
|
||||
}
|
||||
int result = audio->AudioOutOpen(port_type, length, sample_rate, format);
|
||||
if (result == -1) {
|
||||
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
|
||||
return ORBIS_AUDIO_OUT_ERROR_PORT_FULL;
|
||||
}
|
||||
return result;
|
||||
return audio->AudioOutOpen(port_type, length, sample_rate, format);
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioOutOpenEx() {
|
||||
|
@ -324,12 +323,19 @@ int PS4_SYSV_ABI sceAudioOutOpenEx() {
|
|||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, const void* ptr) {
|
||||
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
|
||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||
}
|
||||
if (ptr == nullptr) {
|
||||
// Nothing to output
|
||||
return ORBIS_OK;
|
||||
}
|
||||
return audio->AudioOutOutput(handle, ptr);
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioOutOutputs(OrbisAudioOutOutputParam* param, u32 num) {
|
||||
for (u32 i = 0; i < num; i++) {
|
||||
if (auto err = audio->AudioOutOutput(param[i].handle, param[i].ptr); err != 0)
|
||||
if (const auto err = sceAudioOutOutput(param[i].handle, param[i].ptr); err != 0)
|
||||
return err;
|
||||
}
|
||||
return ORBIS_OK;
|
||||
|
@ -426,10 +432,10 @@ int PS4_SYSV_ABI sceAudioOutSetUsbVolume() {
|
|||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) {
|
||||
if (!audio->AudioOutSetVolume(handle, flag, vol)) {
|
||||
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
|
||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||
}
|
||||
return ORBIS_OK;
|
||||
return audio->AudioOutSetVolume(handle, flag, vol);
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
|
||||
|
|
|
@ -11,6 +11,10 @@ namespace Libraries::AudioOut {
|
|||
|
||||
constexpr int SCE_AUDIO_OUT_VOLUME_0DB = 32768; // max volume value
|
||||
|
||||
// main up to 8 ports, BGM 1 port, voice up to 4 ports,
|
||||
// personal up to 4 ports, padspk up to 5 ports, aux 1 port
|
||||
constexpr int SCE_AUDIO_OUT_NUM_PORTS = 22;
|
||||
|
||||
enum OrbisAudioOutPort {
|
||||
ORBIS_AUDIO_OUT_PORT_TYPE_MAIN = 0,
|
||||
ORBIS_AUDIO_OUT_PORT_TYPE_BGM = 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue