(samples: &[i16], channels: u16)
| 279 | )); |
| 280 | } |
| 281 | let mut samples = Vec::with_capacity(expected_samples); |
| 282 | for chunk in payload.chunks_exact(2) { |
| 283 | samples.push(i16::from_le_bytes([chunk[0], chunk[1]])); |
| 284 | } |
| 285 | Ok(samples) |
| 286 | } |
| 287 | |
| 288 | fn checked_sample_len(frames: usize, channels: u16) -> Result<usize, String> { |
| 289 | let len = frames |
| 290 | .checked_mul(channels as usize) |
| 291 | .ok_or_else(|| "mic clip sample len overflow".to_string())?; |
| 292 | if len > PMIC_MAX_SAMPLES { |
| 293 | return Err(format!( |
| 294 | "mic clip sample len {len} exceeds limit {PMIC_MAX_SAMPLES}" |
| 295 | )); |
no test coverage detected