added sceAudioOutSetVolume

This commit is contained in:
georgemoralis 2024-04-05 09:59:28 +03:00
parent 81143b4a9e
commit fc5e133c44
4 changed files with 55 additions and 6 deletions

View File

@ -108,4 +108,42 @@ s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
return result; return result;
} }
bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
using Libraries::AudioOut::OrbisAudioOutParam;
std::scoped_lock lock{m_mutex};
auto& port = portsOut[handle - 1];
if (!port.isOpen) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
for (int i = 0; i < port.channels_num; i++, bitflag >>= 1u) {
auto bit = bitflag & 0x1u;
if (bit == 1) {
int src_index = i;
if (port.format == OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD ||
port.format == OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD) {
switch (i) {
case 4:
src_index = 6;
break;
case 5:
src_index = 7;
break;
case 6:
src_index = 4;
break;
case 7:
src_index = 5;
break;
default:
break;
}
}
port.volume[i] = volume[src_index];
}
}
return true;
}
} // namespace Audio } // namespace Audio

View File

@ -20,6 +20,7 @@ public:
int AudioOutOpen(int type, u32 samples_num, u32 freq, int AudioOutOpen(int type, u32 samples_num, u32 freq,
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);
private: private:
struct PortOut { struct PortOut {

View File

@ -272,8 +272,11 @@ s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, const void* ptr) {
return audio->AudioOutOutput(handle, ptr); return audio->AudioOutOutput(handle, ptr);
} }
int PS4_SYSV_ABI sceAudioOutOutputs() { int PS4_SYSV_ABI sceAudioOutOutputs(OrbisAudioOutOutputParam* param, u32 num) {
LOG_ERROR(Lib_AudioOut, "(STUBBED) called"); for (u32 i = 0; i < num; i++) {
if (auto err = audio->AudioOutOutput(param[i].handle, param[i].ptr); err != 0)
return err;
}
return ORBIS_OK; return ORBIS_OK;
} }
@ -367,8 +370,10 @@ int PS4_SYSV_ABI sceAudioOutSetUsbVolume() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAudioOutSetVolume() { s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) {
LOG_ERROR(Lib_AudioOut, "(STUBBED) called"); if (!audio->AudioOutSetVolume(handle, flag, vol)) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
}
return ORBIS_OK; return ORBIS_OK;
} }

View File

@ -30,6 +30,11 @@ enum OrbisAudioOutParam {
ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD = 7 ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD = 7
}; };
struct OrbisAudioOutOutputParam {
s32 handle;
const void* ptr;
};
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();
@ -69,7 +74,7 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
u32 sample_rate, OrbisAudioOutParam param_type); u32 sample_rate, OrbisAudioOutParam param_type);
int PS4_SYSV_ABI sceAudioOutOpenEx(); int PS4_SYSV_ABI sceAudioOutOpenEx();
s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, const void* ptr); s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, const void* ptr);
int PS4_SYSV_ABI sceAudioOutOutputs(); s32 PS4_SYSV_ABI sceAudioOutOutputs(OrbisAudioOutOutputParam* param, u32 num);
int PS4_SYSV_ABI sceAudioOutPtClose(); int PS4_SYSV_ABI sceAudioOutPtClose();
int PS4_SYSV_ABI sceAudioOutPtGetLastOutputTime(); int PS4_SYSV_ABI sceAudioOutPtGetLastOutputTime();
int PS4_SYSV_ABI sceAudioOutPtOpen(); int PS4_SYSV_ABI sceAudioOutPtOpen();
@ -88,7 +93,7 @@ int PS4_SYSV_ABI sceAudioOutSetPortStatuses();
int PS4_SYSV_ABI sceAudioOutSetRecMode(); int PS4_SYSV_ABI sceAudioOutSetRecMode();
int PS4_SYSV_ABI sceAudioOutSetSparkParam(); int PS4_SYSV_ABI sceAudioOutSetSparkParam();
int PS4_SYSV_ABI sceAudioOutSetUsbVolume(); int PS4_SYSV_ABI sceAudioOutSetUsbVolume();
int PS4_SYSV_ABI sceAudioOutSetVolume(); s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol);
int PS4_SYSV_ABI sceAudioOutSetVolumeDown(); int PS4_SYSV_ABI sceAudioOutSetVolumeDown();
int PS4_SYSV_ABI sceAudioOutStartAuxBroadcast(); int PS4_SYSV_ABI sceAudioOutStartAuxBroadcast();
int PS4_SYSV_ABI sceAudioOutStartSharePlay(); int PS4_SYSV_ABI sceAudioOutStartSharePlay();