Skip to content

Commit acb8d06

Browse files
Lib.Audio3d: sceAudio3dGetDefaultOpenParameters fix (shadps4-emu#3923)
* OrbisAudio3dOpenParameters struct fix Not sure why we have the extra filler, but decomp suggests it shouldn't exist. This fixes stack_chk_fail issues in audio3d using titles. * Bring back filler, only copy 0x20 bytes. The library accepts variations on struct size, with the maximum size being the 0x28 size our current struct has. This fixes the issue without potentially breaking the struct. * Fix memcpy Prevent OOB read
1 parent 108cefa commit acb8d06

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core/libraries/audio3d/audio3d.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,15 @@ s32 PS4_SYSV_ABI sceAudio3dDeleteSpeakerArray() {
189189
s32 PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* params) {
190190
LOG_DEBUG(Lib_Audio3d, "called");
191191
if (params) {
192-
*params = OrbisAudio3dOpenParameters{
192+
auto default_params = OrbisAudio3dOpenParameters{
193193
.size_this = 0x20,
194194
.granularity = 0x100,
195195
.rate = OrbisAudio3dRate::ORBIS_AUDIO3D_RATE_48000,
196196
.max_objects = 512,
197197
.queue_depth = 2,
198198
.buffer_mode = OrbisAudio3dBufferMode::ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH,
199199
};
200+
memcpy(params, &default_params, 0x20);
200201
}
201202
return ORBIS_OK;
202203
}
@@ -445,7 +446,7 @@ s32 PS4_SYSV_ABI sceAudio3dPortOpen(const OrbisUserServiceUserId user_id,
445446
}
446447

447448
*port_id = id;
448-
std::memcpy(&state->ports[id].parameters, parameters, sizeof(OrbisAudio3dOpenParameters));
449+
std::memcpy(&state->ports[id].parameters, parameters, parameters->size_this);
449450

450451
return ORBIS_OK;
451452
}

0 commit comments

Comments
 (0)