nix
nix copied to clipboard
Weird ioctl_readwrite! behaviour for values above 10
trafficstars
I'm trying to implement crate to make OSS (audio on FreeBSD) handling easier, and this is the part of code that is behaving strangely
const SNDCTL_DSP_MAGIC: u8 = b'P';
const SNDCTL_DSP_COOKEDMODE: u8 = 30;
nix::ioctl_readwrite!(oss_set_cooked, SNDCTL_DSP_MAGIC, SNDCTL_DSP_COOKEDMODE, i32);
Later I call it like this
let mut cooked: i32 = 0;
oss_set_cooked(fd, &mut cooked).expect("Failed to disable cooked mode");
When I use truss to look at the syscalls, I get this
# truss target/debug/deps/oss-10d0d16316d09bcd --ignored 2>&1 | grep -A1 dsp
openat(AT_FDCWD,"/dev/dsp4",O_WRONLY|O_CLOEXEC,00) = 4 (0x4)
ioctl(4,0xc004501e { IORW 0x50('P'), 30, 4 },0x2fa2c9fc85ec) ERR#22 'Invalid argument'
But if I change SNDCTL_DSP_COOKEDMODE to 9 for example, this is what I get
# truss target/debug/deps/oss-10d0d16316d09bcd --ignored 2>&1 | grep -A1 dsp
openat(AT_FDCWD,"/dev/dsp4",O_WRONLY|O_CLOEXEC,00) = 4 (0x4)
ioctl(4,SNDCTL_DSP_SUBDIVIDE,0x157e572ad5ec) ERR#22 'Invalid argument'
Can you help me debug this, please? I'm new to Rust, but not new to FreeBSD. Thank you!