Skip to content

Commit

Permalink
Add pcm::io_s24
Browse files Browse the repository at this point in the history
Closes #125
  • Loading branch information
diwic committed Oct 24, 2024
1 parent 0107524 commit 604dd3c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/pcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ impl PCM {
pub fn io_u8(&self) -> Result<IO<u8>> { self.io_checked() }
pub fn io_i16(&self) -> Result<IO<i16>> { self.io_checked() }
pub fn io_u16(&self) -> Result<IO<u16>> { self.io_checked() }
pub fn io_s24(&self) -> Result<IO<i32>> { self.verify_format(Format::s24()).map(|_| IO::new(self)) }
pub fn io_i32(&self) -> Result<IO<i32>> { self.io_checked() }
pub fn io_u32(&self) -> Result<IO<u32>> { self.io_checked() }
pub fn io_f32(&self) -> Result<IO<f32>> { self.io_checked() }
Expand Down Expand Up @@ -1226,6 +1227,19 @@ fn record_from_default() {
assert_eq!(pcm.io_i16().unwrap().readi(&mut buf).unwrap(), 1024/2);
}

#[test]
fn open_s24() {
let pcm = PCM::open(c"default", Direction::Playback, false).unwrap();
let hwp = HwParams::any(&pcm).unwrap();
hwp.set_channels(1).unwrap();
hwp.set_rate(44100, ValueOr::Nearest).unwrap();
hwp.set_format(Format::s24()).unwrap();
hwp.set_access(Access::RWInterleaved).unwrap();
pcm.hw_params(&hwp).unwrap();
assert_eq!(Format::s24().physical_width(), Ok(32));
let _io = pcm.io_s24().unwrap();
}

#[test]
fn playback_to_default() {
use std::ffi::CString;
Expand Down

0 comments on commit 604dd3c

Please sign in to comment.