sceAudioOutGetPortState added (thanks to gmoralis)

This commit is contained in:
georgemoralis 2024-06-18 14:28:09 +03:00 committed by psucien
parent ab36a238bf
commit 7b89b7f5fd
4 changed files with 54 additions and 3 deletions

View File

@ -145,4 +145,13 @@ bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
return true; return true;
} }
bool SDLAudio::AudioOutGetStatus(s32 handle, int* type, int* channels_num) {
std::scoped_lock lock{m_mutex};
auto& port = portsOut[handle - 1];
*type = port.type;
*channels_num = port.channels_num;
return true;
}
} // namespace Audio } // namespace Audio

View File

@ -18,6 +18,7 @@ public:
Libraries::AudioOut::OrbisAudioOutParam format); Libraries::AudioOut::OrbisAudioOutParam format);
s32 AudioOutOutput(s32 handle, const void* ptr); s32 AudioOutOutput(s32 handle, const void* ptr);
bool AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume); bool AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume);
bool AudioOutGetStatus(s32 handle, int* type, int* channels_num);
private: private:
struct PortOut { struct PortOut {

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <memory> #include <memory>
#include <common/assert.h>
#include <magic_enum.hpp> #include <magic_enum.hpp>
#include "audio_core/sdl_audio.h" #include "audio_core/sdl_audio.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -160,8 +161,38 @@ int PS4_SYSV_ABI sceAudioOutGetLastOutputTime() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAudioOutGetPortState() { int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state) {
LOG_ERROR(Lib_AudioOut, "(STUBBED) called");
int type = 0;
int channels_num = 0;
if (!audio->AudioOutGetStatus(handle, &type, &channels_num)) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
state->rerouteCounter = 0;
state->volume = 127; // max volume
switch (type) {
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
state->output = 1;
state->channel = (channels_num > 2 ? 2 : channels_num);
break;
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
state->output = 4;
state->channel = 1;
break;
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
state->output = 0;
state->channel = 0;
break;
default:
UNREACHABLE();
}
return ORBIS_OK; return ORBIS_OK;
} }

View File

@ -34,6 +34,16 @@ struct OrbisAudioOutOutputParam {
const void* ptr; const void* ptr;
}; };
struct OrbisAudioOutPortState {
u16 output;
u8 channel;
u8 reserved8_1[1];
s16 volume;
u16 rerouteCounter;
u64 flag;
u64 reserved64[2];
};
int PS4_SYSV_ABI sceAudioOutDeviceIdOpen(); int PS4_SYSV_ABI sceAudioOutDeviceIdOpen();
int PS4_SYSV_ABI sceAudioDeviceControlGet(); int PS4_SYSV_ABI sceAudioDeviceControlGet();
int PS4_SYSV_ABI sceAudioDeviceControlSet(); int PS4_SYSV_ABI sceAudioDeviceControlSet();
@ -55,7 +65,7 @@ int PS4_SYSV_ABI sceAudioOutGetHandleStatusInfo();
int PS4_SYSV_ABI sceAudioOutGetInfo(); int PS4_SYSV_ABI sceAudioOutGetInfo();
int PS4_SYSV_ABI sceAudioOutGetInfoOpenNum(); int PS4_SYSV_ABI sceAudioOutGetInfoOpenNum();
int PS4_SYSV_ABI sceAudioOutGetLastOutputTime(); int PS4_SYSV_ABI sceAudioOutGetLastOutputTime();
int PS4_SYSV_ABI sceAudioOutGetPortState(); int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state);
int PS4_SYSV_ABI sceAudioOutGetSimulatedBusUsableStatusByBusType(); int PS4_SYSV_ABI sceAudioOutGetSimulatedBusUsableStatusByBusType();
int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo(); int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo();
int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo2(); int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo2();