raymanfx / libv4l-rs

Video4Linux2 bindings for Rust
MIT License
145 stars 62 forks source link

`From<Timestamp> for time::Duration` faulty #27

Closed EtomicBomb closed 3 years ago

EtomicBomb commented 3 years ago

I know this should be a pull request but in

impl From<Timestamp> for time::Duration {
    fn from(ts: Timestamp) -> Self {
        time::Duration::new(ts.sec as u64, (ts.usec / 1000) as u32)
    }
}

ts.usec should be multiplied by 1000 and not divided

EtomicBomb commented 3 years ago

And now that I'm looking at that part of the code, From<time::Duration> for Timestamp looks incorrect too - I think in the line

Timestamp::new(duration.as_secs() as time_t, duration.as_micros() as time_t)

duration.as_micros() should be duration.subsec_micros()