Skip to content

Commit

Permalink
remove nix -> use libc
Browse files Browse the repository at this point in the history
  • Loading branch information
ameknite committed Feb 28, 2024
1 parent 02e4453 commit d4f57f2
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/host/alsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,8 @@ impl Device {
.map_err(|e| (e, e.errno()));

let handle = match handle_result {
Err((_, alsa::nix::errno::Errno::EBUSY)) => {
return Err(BuildStreamError::DeviceNotAvailable)
}
Err((_, alsa::nix::errno::Errno::EINVAL)) => {
return Err(BuildStreamError::InvalidArgument)
}
Err((_, libc::EBUSY)) => return Err(BuildStreamError::DeviceNotAvailable),
Err((_, libc::EINVAL)) => return Err(BuildStreamError::InvalidArgument),
Err((e, _)) => return Err(e.into()),
Ok(handle) => handle,
};
Expand Down Expand Up @@ -316,13 +312,10 @@ impl Device {
.map_err(|e| (e, e.errno()));

let handle = match handle_result {
Err((_, alsa::nix::errno::Errno::ENOENT))
| Err((_, alsa::nix::errno::Errno::EBUSY)) => {
Err((_, libc::ENOENT)) | Err((_, libc::EBUSY)) => {
return Err(SupportedStreamConfigsError::DeviceNotAvailable)
}
Err((_, alsa::nix::errno::Errno::EINVAL)) => {
return Err(SupportedStreamConfigsError::InvalidArgument)
}
Err((_, libc::EINVAL)) => return Err(SupportedStreamConfigsError::InvalidArgument),
Err((e, _)) => return Err(e.into()),
Ok(handle) => handle,
};
Expand Down Expand Up @@ -759,9 +752,7 @@ fn poll_descriptors_and_prepare_buffer(

let status = stream.channel.status()?;
let avail_frames = match stream.channel.avail() {
Err(err) if err.errno() == alsa::nix::errno::Errno::EPIPE => {
return Ok(PollDescriptorsFlow::XRun)
}
Err(err) if err.errno() == libc::EPIPE => return Ok(PollDescriptorsFlow::XRun),
res => res,
}? as usize;
let delay_frames = match status.get_delay() {
Expand Down Expand Up @@ -842,7 +833,7 @@ fn process_output(
}
loop {
match stream.channel.io_bytes().writei(buffer) {
Err(err) if err.errno() == alsa::nix::errno::Errno::EPIPE => {
Err(err) if err.errno() == libc::EPIPE => {
// buffer underrun
// TODO: Notify the user of this.
let _ = stream.channel.try_recover(err, false);
Expand Down

0 comments on commit d4f57f2

Please sign in to comment.