Skip to content

Commit

Permalink
refactor(playback): do not transform time manually
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesterday17 committed Sep 16, 2024
1 parent d84aec9 commit c5842a7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions anni-playback/src/decoder/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use std::{
sync::{atomic::AtomicBool, Arc},
thread::{self, JoinHandle},
time::Duration,
};

use anyhow::{anyhow, Context};
Expand Down Expand Up @@ -291,8 +292,8 @@ impl Decoder {
.context("Could not decode audio packet.")?;

let position = if let Some(timebase) = playback.timebase {
let time = timebase.calc_time(packet.ts());
time.seconds * 1000 + (time.frac * 1000.0) as u64
let duration: Duration = timebase.calc_time(packet.ts()).into();
duration.as_millis() as u64
} else {
0
};
Expand Down Expand Up @@ -391,8 +392,8 @@ impl Decoder {

let duration = match (timebase, ts) {
(Some(timebase), Some(ts)) => {
let time = timebase.calc_time(ts);
time.seconds * 1000 + (time.frac * 1000.0) as u64
let duration: Duration = timebase.calc_time(ts).into();
duration.as_millis() as u64
}
_ => duration_hint.map(|dur| dur * 1000).unwrap_or(0),
};
Expand Down

0 comments on commit c5842a7

Please sign in to comment.