Repository navigation
Closed
Description
Since the slice already stores its length, the nbr_frames parameter seems superfluous.
Lines 2127 to 2153 in 9b3564e
| pub fn write_to_device( | |
| &self, | |
| nbr_frames: usize, | |
| data: &[u8], | |
| buffer_flags: Option<BufferFlags>, | |
| ) -> WasapiRes<()> { | |
| if nbr_frames == 0 { | |
| return Ok(()); | |
| } | |
| let nbr_bytes = nbr_frames * self.bytes_per_frame; | |
| if nbr_bytes != data.len() { | |
| return Err(WasapiError::DataLengthMismatch { | |
| received: data.len(), | |
| expected: nbr_bytes, | |
| }); | |
| } | |
| let bufferptr = unsafe { self.client.GetBuffer(nbr_frames as u32)? }; | |
| let bufferslice = unsafe { slice::from_raw_parts_mut(bufferptr, nbr_bytes) }; | |
| bufferslice.copy_from_slice(data); | |
| let flags = match buffer_flags { | |
| Some(bflags) => bflags.to_u32(), | |
| None => 0, | |
| }; | |
| unsafe { self.client.ReleaseBuffer(nbr_frames as u32, flags)? }; | |
| trace!("wrote {nbr_frames} frames"); | |
| Ok(()) | |
| } |
Metadata
Metadata
Assignees
Labels
No labels
Activity
HEnquist commentedon Oct 27, 2026
Thanks, yes you are right, that argument can be removed. It's been there since the first version of the library (where I probably just copied it over from the dequeue write method) and it was never needed. I'll just remove it. While looking at that I found some other minor inconsistencies that would be nice to fix as well. PR incoming!