Skip to content

Commit 5843e12

Browse files
committed
audio: Re-add mutex for port open to prevent double open.
1 parent 9d91ded commit 5843e12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/core/libraries/audio/audioout.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
namespace Libraries::AudioOut {
1818

19+
std::mutex port_open_mutex{};
1920
std::array<PortOut, SCE_AUDIO_OUT_NUM_PORTS> ports_out{};
2021

2122
static std::unique_ptr<AudioOutBackend> audio;
@@ -331,14 +332,15 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
331332
return ORBIS_AUDIO_OUT_ERROR_INVALID_FORMAT;
332333
}
333334

335+
std::unique_lock open_lock{port_open_mutex};
334336
const auto port =
335337
std::ranges::find_if(ports_out, [&](const PortOut& p) { return p.impl == nullptr; });
336338
if (port == ports_out.end()) {
337339
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
338340
return ORBIS_AUDIO_OUT_ERROR_PORT_FULL;
339341
}
340342

341-
std::scoped_lock lock(port->mutex);
343+
std::unique_lock port_lock(port->mutex);
342344

343345
port->type = port_type;
344346
port->format_info = GetFormatInfo(format);

0 commit comments

Comments
 (0)