Skip to content

Commit

Permalink
audioout: Add error returns when not initialized. (shadps4-emu#2309)
Browse files Browse the repository at this point in the history
  • Loading branch information
squidbus authored Feb 1, 2025
1 parent 259d5ef commit e1550c9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/libraries/audio/audioout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ int PS4_SYSV_ABI sceAudioOutChangeAppModuleState() {

int PS4_SYSV_ABI sceAudioOutClose(s32 handle) {
LOG_INFO(Lib_AudioOut, "handle = {}", handle);
if (audio == nullptr) {
return ORBIS_AUDIO_OUT_ERROR_NOT_INIT;
}
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
Expand Down Expand Up @@ -171,6 +174,9 @@ int PS4_SYSV_ABI sceAudioOutGetLastOutputTime() {
}

int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state) {
if (audio == nullptr) {
return ORBIS_AUDIO_OUT_ERROR_NOT_INIT;
}
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
Expand Down Expand Up @@ -305,6 +311,10 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
user_id, magic_enum::enum_name(port_type), index, length, sample_rate,
magic_enum::enum_name(param_type.data_format.Value()),
magic_enum::enum_name(param_type.attributes.Value()));
if (audio == nullptr) {
LOG_ERROR(Lib_AudioOut, "Audio out not initialized");
return ORBIS_AUDIO_OUT_ERROR_NOT_INIT;
}
if ((port_type < OrbisAudioOutPort::Main || port_type > OrbisAudioOutPort::Padspk) &&
(port_type != OrbisAudioOutPort::Aux)) {
LOG_ERROR(Lib_AudioOut, "Invalid port type");
Expand Down Expand Up @@ -368,6 +378,9 @@ int PS4_SYSV_ABI sceAudioOutOpenEx() {
}

s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, void* ptr) {
if (audio == nullptr) {
return ORBIS_AUDIO_OUT_ERROR_NOT_INIT;
}
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
Expand Down Expand Up @@ -489,6 +502,9 @@ int PS4_SYSV_ABI sceAudioOutSetUsbVolume() {
}

s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) {
if (audio == nullptr) {
return ORBIS_AUDIO_OUT_ERROR_NOT_INIT;
}
if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
Expand Down

0 comments on commit e1550c9

Please sign in to comment.