mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-10 01:05:28 +00:00
audio: Add AudioInfo::is_valid() and guard against finfo being NULL when retrieving the audio format
This commit is contained in:
parent
d6b5126c87
commit
1924d3b222
1 changed files with 8 additions and 0 deletions
|
@ -151,6 +151,10 @@ impl AudioInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_valid(&self) -> bool {
|
||||||
|
!self.0.finfo.is_null() && self.0.channels > 0 && self.0.rate > 0 && self.0.bpf > 0
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_caps(caps: &gst::CapsRef) -> Result<AudioInfo, glib::error::BoolError> {
|
pub fn from_caps(caps: &gst::CapsRef) -> Result<AudioInfo, glib::error::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
|
|
||||||
|
@ -230,6 +234,10 @@ impl AudioInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format(&self) -> ::AudioFormat {
|
pub fn format(&self) -> ::AudioFormat {
|
||||||
|
if self.0.finfo.is_null() {
|
||||||
|
return ::AudioFormat::Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe { from_glib((*self.0.finfo).format) }
|
unsafe { from_glib((*self.0.finfo).format) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue