From a5f9256ac6e5983500f7ee710ce5b718e8861c3f Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 8 Aug 2024 00:56:56 +0200 Subject: [PATCH] cellMic: skip alcCaptureSamples loop if num_samples is 0 Also use early out instead of ensure in get_data --- rpcs3/Emu/Cell/Modules/cellMic.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMic.cpp b/rpcs3/Emu/Cell/Modules/cellMic.cpp index 50ecdefb4b..a1ffd914f5 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMic.cpp @@ -561,14 +561,21 @@ u32 microphone_device::capture_audio() { ALCint samples_in = 0; alcGetIntegerv(micdevice.device, ALC_CAPTURE_SAMPLES, 1, &samples_in); + if (ALCenum err = alcGetError(micdevice.device); err != ALC_NO_ERROR) { cellMic.error("Error getting number of captured samples of device %s (error=0x%x)", micdevice.name, err); return CELL_MICIN_ERROR_FATAL; } + num_samples = std::min(num_samples, samples_in); } + if (num_samples == 0) + { + return 0; + } + for (mic_device& micdevice : devices) { alcCaptureSamples(micdevice.device, micdevice.buf.data(), num_samples); @@ -586,7 +593,10 @@ u32 microphone_device::capture_audio() void microphone_device::get_data(const u32 num_samples) { - ensure(num_samples > 0); + if (num_samples == 0) + { + return; + } switch (device_type) {