Some nullability fixes in gstreamer-audio

This commit is contained in:
Sebastian Dröge 2017-12-16 10:56:59 +02:00
parent 5fb6ce77ee
commit 0eb32f0483
3 changed files with 7 additions and 8 deletions

View file

@ -40,6 +40,10 @@ impl ::AudioFormat {
} }
pub fn to_string<'a>(&self) -> &'a str { pub fn to_string<'a>(&self) -> &'a str {
if *self == ::AudioFormat::Unknown {
return "UNKNOWN";
}
unsafe { unsafe {
CStr::from_ptr(ffi::gst_audio_format_to_string(self.to_glib())) CStr::from_ptr(ffi::gst_audio_format_to_string(self.to_glib()))
.to_str() .to_str()

View file

@ -130,7 +130,7 @@ impl AudioInfo {
} }
} }
pub fn from_caps(caps: &gst::Caps) -> Option<Self> { pub fn from_caps(caps: &gst::CapsRef) -> Option<Self> {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
@ -146,12 +146,7 @@ impl AudioInfo {
pub fn to_caps(&self) -> Option<gst::Caps> { pub fn to_caps(&self) -> Option<gst::Caps> {
unsafe { unsafe {
let caps = ffi::gst_audio_info_to_caps(&self.0); from_glib_full(ffi::gst_audio_info_to_caps(&self.0))
if caps.is_null() {
None
} else {
Some(from_glib_full(caps))
}
} }
} }

View file

@ -61,7 +61,7 @@ pub fn audio_buffer_clip(
segment: &gst::Segment, segment: &gst::Segment,
rate: u32, rate: u32,
channels: u32, channels: u32,
) -> gst::Buffer { ) -> Option<gst::Buffer> {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {