mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 14:31:24 +12:00
cellMic: skip alcCaptureSamples loop if num_samples is 0
Also use early out instead of ensure in get_data
This commit is contained in:
parent
9505f8116b
commit
a5f9256ac6
1 changed files with 11 additions and 1 deletions
|
@ -561,14 +561,21 @@ u32 microphone_device::capture_audio()
|
||||||
{
|
{
|
||||||
ALCint samples_in = 0;
|
ALCint samples_in = 0;
|
||||||
alcGetIntegerv(micdevice.device, ALC_CAPTURE_SAMPLES, 1, &samples_in);
|
alcGetIntegerv(micdevice.device, ALC_CAPTURE_SAMPLES, 1, &samples_in);
|
||||||
|
|
||||||
if (ALCenum err = alcGetError(micdevice.device); err != ALC_NO_ERROR)
|
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);
|
cellMic.error("Error getting number of captured samples of device %s (error=0x%x)", micdevice.name, err);
|
||||||
return CELL_MICIN_ERROR_FATAL;
|
return CELL_MICIN_ERROR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_samples = std::min<u32>(num_samples, samples_in);
|
num_samples = std::min<u32>(num_samples, samples_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (num_samples == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (mic_device& micdevice : devices)
|
for (mic_device& micdevice : devices)
|
||||||
{
|
{
|
||||||
alcCaptureSamples(micdevice.device, micdevice.buf.data(), num_samples);
|
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)
|
void microphone_device::get_data(const u32 num_samples)
|
||||||
{
|
{
|
||||||
ensure(num_samples > 0);
|
if (num_samples == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (device_type)
|
switch (device_type)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue