Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **ALSA**: Bump `alsa` to 0.12 and `alsa-sys` to 0.6, pending the `time_t` segfault fix upstream.
- **CoreAudio**: Bump `objc2-core-foundation` dependency lower bound to 0.3.1.
- **iOS**: Timestamps now include hardware latency and update when the audio route changes.
- **JACK**: Timestamps now include port latency.
Expand All @@ -26,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Timestamps now stay monotonic across device and graph changes.
- **ALSA**: A nonzero but sub-millisecond stream timeout is no longer treated as a non-blocking poll.
- **ALSA**: Fix a remaining timestamp segfault on 32-bit platforms with a 64-bit kernel `time_t`.
- **AudioWorklet**: Fix `Stream` operations to work when called from any thread.
- **AudioWorklet**: Fix stale audio output when a data callback wrote a partial buffer.
- **CoreAudio**: Default-output streams now report xrun status.
Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ asio-sys = { version = "0.3.0", path = "asio-sys", optional = true }
num-traits = { version = "0.2", optional = true }
jack = { version = "0.13.5", optional = true }

[patch.crates-io]
alsa = { git = "https://github.com/roderickvd/alsa-rs", branch = "fix/timespec-time64-mismatch" }

[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))'.dependencies]
alsa = "0.11"
alsa-sys = { version = "0.4", optional = true }
alsa = "0.12"
alsa-sys = { version = "0.6", optional = true }
libc = "0.2"
audio_thread_priority = { version = "0.35", optional = true, default-features = false }
jack = { version = "0.13.5", optional = true }
Expand Down
8 changes: 4 additions & 4 deletions src/host/alsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ struct StreamInner {

// htstamp value from the status query at prepare() time.
// Used as the creation-time anchor for SystemClock and AudioLink calculations.
creation_ts: libc::timespec,
creation_ts: alsa::timespec,

// Monotonic instant captured at stream creation. Timestamp origin for CreationInstant
// mode and last-resort fallback if the status query in now() fails.
Expand Down Expand Up @@ -1269,21 +1269,21 @@ fn process_output(
// https://fossies.org/linux/alsa-lib/test/audio_time.c
#[inline]
#[allow(clippy::unnecessary_cast)]
fn timespec_to_nanos(ts: libc::timespec) -> i64 {
fn timespec_to_nanos(ts: alsa::timespec) -> i64 {
ts.tv_sec as i64 * 1_000_000_000 + ts.tv_nsec as i64
}

// Adapted from `timediff` here:
// https://fossies.org/linux/alsa-lib/test/audio_time.c
#[inline]
fn timespec_diff_nanos(a: libc::timespec, b: libc::timespec) -> i64 {
fn timespec_diff_nanos(a: alsa::timespec, b: alsa::timespec) -> i64 {
timespec_to_nanos(a) - timespec_to_nanos(b)
}

// StreamInstant representing how long htstamp is ahead of origin, clamped to zero.
// Used as the creation-relative timestamp source for SystemClock and AudioLink fallback paths.
#[inline]
fn htstamp_elapsed(status: &alsa::pcm::Status, origin: libc::timespec) -> StreamInstant {
fn htstamp_elapsed(status: &alsa::pcm::Status, origin: alsa::timespec) -> StreamInstant {
let nanos = timespec_diff_nanos(status.get_htstamp(), origin);
StreamInstant::from_nanos(nanos.max(0) as u64)
}
Expand Down
Loading