Skip to content

Commit

Permalink
Update alsa from 0.8 to 0.9 (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall authored Mar 1, 2024
1 parent 403ffb5 commit 70d65b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ asio-sys = { version = "0.2", path = "asio-sys", optional = true }
num-traits = { version = "0.2.6", optional = true }

[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))'.dependencies]
alsa = "0.8"
alsa = "0.9"
libc = "0.2"
jack = { version = "0.11", optional = true }

Expand Down
25 changes: 8 additions & 17 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 Expand Up @@ -882,8 +873,8 @@ fn stream_timestamp(
let nanos = timespec_diff_nanos(ts, trigger_ts);
if nanos < 0 {
panic!(
"get_htstamp `{:?}` was earlier than get_trigger_htstamp `{:?}`",
ts, trigger_ts
"get_htstamp `{}.{}` was earlier than get_trigger_htstamp `{}.{}`",
ts.tv_sec, ts.tv_nsec, trigger_ts.tv_sec, ts.tv_nsec
);
}
Ok(crate::StreamInstant::from_nanos(nanos))
Expand Down

0 comments on commit 70d65b5

Please sign in to comment.