Skip to content

Commit 76b18c5

Browse files
committed
fix: incorrect conversion of ALSA frames to FrameCount on 32-bit platforms
Fixes #1053
1 parent 7a6e10d commit 76b18c5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/host/alsa/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,9 +1193,10 @@ impl StreamTrait for Stream {
11931193
}
11941194
}
11951195

1196-
// Overly safe clamp because alsa Frames are i64 (64-bit) or i32 (32-bit)
1196+
// Convert ALSA frames to FrameCount, clamping to valid range.
1197+
// ALSA Frames are i64 (64-bit) or i32 (32-bit).
11971198
fn clamp_frame_count(buffer_size: alsa::pcm::Frames) -> FrameCount {
1198-
buffer_size.clamp(1, FrameCount::MAX as alsa::pcm::Frames) as FrameCount
1199+
buffer_size.max(1).try_into().unwrap_or(FrameCount::MAX)
11991200
}
12001201

12011202
fn hw_params_buffer_size_min_max(hw_params: &alsa::pcm::HwParams) -> (FrameCount, FrameCount) {

0 commit comments

Comments
 (0)