diff --git a/Cargo.toml b/Cargo.toml index 0bc8c9b..a28d23d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/host/alsa/mod.rs b/src/host/alsa/mod.rs index 86a240b..4c79e39 100644 --- a/src/host/alsa/mod.rs +++ b/src/host/alsa/mod.rs @@ -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, }; @@ -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, }; @@ -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() { @@ -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); @@ -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))