util/error: refactor error handling

This commit is contained in:
meh
2015-05-24 18:51:34 +02:00
parent 2716893612
commit 5b80b10949
13 changed files with 205 additions and 101 deletions

View File

@ -15,7 +15,7 @@ impl Audio {
let mut got: c_int = 0;
match avcodec_encode_audio2(self.ptr, &mut out.val, frame.ptr, &mut got) {
e if e < 0 => Err(Error::new(e)),
e if e < 0 => Err(Error::from(e)),
_ => Ok(got != 0)
}
}

View File

@ -38,7 +38,7 @@ impl Encoder {
Ok(Video(self))
}
else {
Err(Error::from(AVERROR_INVALIDDATA))
Err(Error::InvalidData)
}
}
@ -47,7 +47,7 @@ impl Encoder {
Ok(Audio(self))
}
else {
Err(Error::from(AVERROR_INVALIDDATA))
Err(Error::InvalidData)
}
}
@ -56,7 +56,7 @@ impl Encoder {
Ok(Subtitle(self))
}
else {
Err(Error::from(AVERROR_INVALIDDATA))
Err(Error::InvalidData)
}
}

View File

@ -12,7 +12,7 @@ impl Subtitle {
pub fn encode(&self, subtitle: &::Subtitle, out: &mut [u8]) -> Result<bool, Error> {
unsafe {
match avcodec_encode_subtitle(self.ptr, out.as_mut_ptr(), out.len() as c_int, &subtitle.val) {
e if e < 0 => Err(Error::new(e)),
e if e < 0 => Err(Error::from(e)),
_ => Ok(true)
}
}

View File

@ -16,7 +16,7 @@ impl Video {
let mut got: c_int = 0;
match avcodec_encode_video2(self.ptr, &mut out.val, frame.ptr, &mut got) {
e if e < 0 => Err(Error::new(e)),
e if e < 0 => Err(Error::from(e)),
_ => Ok(got != 0)
}
}