Skip to content

Commit 1997728

Browse files
committed
fix: clamp cubeb stream to MAX_CHANNELS
1 parent 5e6df5c commit 1997728

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/io/cubeb.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::context::AudioContextOptions;
77
use crate::io::microphone::MicrophoneRender;
88
use crate::media_devices::{MediaDeviceInfo, MediaDeviceInfoKind};
99
use crate::render::RenderThread;
10-
use crate::RENDER_QUANTUM_SIZE;
10+
use crate::{MAX_CHANNELS, RENDER_QUANTUM_SIZE};
1111

1212
use cubeb::{Context, DeviceId, DeviceType, StereoFrame, Stream, StreamParams};
1313

@@ -166,7 +166,10 @@ impl AudioBackendManager for CubebBackend {
166166
.map(|v| v as usize)
167167
.ok()
168168
.unwrap_or(2);
169-
crate::assert_valid_number_of_channels(number_of_channels);
169+
170+
// clamp the requested stream number of channels to MAX_CHANNELS even if
171+
// the soundcard can provide more channels
172+
let number_of_channels = number_of_channels.min(MAX_CHANNELS);
170173

171174
let layout = match number_of_channels {
172175
1 => cubeb::ChannelLayout::MONO,

0 commit comments

Comments
 (0)