Skip to content

Commit

Permalink
add TimeSpecDebug(timespec)
Browse files Browse the repository at this point in the history
  • Loading branch information
ameknite committed Feb 28, 2024
1 parent f1c9af7 commit ff945a8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/host/alsa/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
extern crate alsa;
extern crate libc;

use libc::timespec;

use self::alsa::poll::Descriptors;
use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
use crate::{
Expand All @@ -12,6 +14,8 @@ use crate::{
};
use std::cmp;
use std::convert::TryInto;
use std::fmt::Debug;
use std::path::Display;
use std::sync::{Arc, Mutex};
use std::thread::{self, JoinHandle};
use std::time::Duration;
Expand Down Expand Up @@ -873,8 +877,9 @@ 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 `{:?}`",
TimeSpecDebug(ts),
TimeSpecDebug(trigger_ts)
);
}
Ok(crate::StreamInstant::from_nanos(nanos))
Expand All @@ -889,6 +894,9 @@ fn stream_timestamp(
}
}

#[derive(Debug)]
struct TimeSpecDebug(timespec);

// Adapted from `timestamp2ns` here:
// https://fossies.org/linux/alsa-lib/test/audio_time.c
fn timespec_to_nanos(ts: libc::timespec) -> i64 {
Expand Down

0 comments on commit ff945a8

Please sign in to comment.