rust-av / ffms2-rs

ffms2 bindings
MIT License
10 stars 5 forks source link

AudioSource::new DelayMode should be signed integer #4

Closed askoufis closed 3 years ago

askoufis commented 3 years ago

DelayMode is cast to an i32 here, but in the new method signature it's a usize. The enum you can use for this in the original library uses negative values though, so there is no way to set the delay mode to anything other than relative to a video track (specified here), so it wont work for a pure audio application.

An easy fix would be to just change the type of DelayMode to isize instead. Alternatively, you could add a 4th enum variant that holds a usize and then match on them:

enum AudioDelay {
    DELAY_NO_SHIFT,
    DELAY_TIME_ZERO,
    DELAY_FIRST_VIDEO_TRACK,
    DELAY_VIDEO_TRACK(usize),
}

let delayMode = match DelayMode {
    AudioDelay::DELAY_NO_SHIFT => -3,
    AudioDelay::DELAY_TIME_ZERO => -2,
    AudioDelay::DELAY_FIRST_VIDEO_TRACK => -1,
    AudioDelay::DELAY_VIDEO_TRACK(track) => track as isize,

Though that's not a valid cast so you'd need to use try_from or something, but you get the point.

Luni-4 commented 3 years ago

Thanks a lot for your report @askoufis! :)

Yep, I prefer to change the type of DelayMode to isize. I'm going to do that as soon as possible

Luni-4 commented 3 years ago

Fixed in 7aacb83