PulseAudio: Try fixing a division by zero error.

Public issue https://github.com/mackron/miniaudio/issues/412
This commit is contained in:
David Reid
2022-01-20 17:56:24 +10:00
parent b89603dc4d
commit 4f43538cd6
+12 -3
View File
@@ -28951,9 +28951,13 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
attr = *pActualAttr;
}
pDescriptorCapture->periodCount = attr.maxlength / attr.fragsize;
pDescriptorCapture->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / pDescriptorCapture->periodCount;
if (attr.fragsize > 0) {
pDescriptorPlayback->periodCount = ma_max(attr.maxlength / attr.fragsize, 1);
} else {
pDescriptorPlayback->periodCount = 1;
}
pDescriptorCapture->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / pDescriptorCapture->periodCount;
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Capture actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames);
}
@@ -29058,7 +29062,12 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
attr = *pActualAttr;
}
pDescriptorPlayback->periodCount = ma_max(attr.maxlength / attr.tlength, 1);
if (attr.tlength > 0) {
pDescriptorPlayback->periodCount = ma_max(attr.maxlength / attr.tlength, 1);
} else {
pDescriptorPlayback->periodCount = 1;
}
pDescriptorPlayback->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) / pDescriptorPlayback->periodCount;
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Playback actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalPeriodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorPlayback->periodSizeInFrames);
}