Fix audio plugins build after gstreamer-rs!376

AudioInfo::from_caps() now returns a Result.
This commit is contained in:
Philippe Normand 2019-12-14 15:26:20 +00:00
parent 23ed11e52f
commit 0f99994d9e
4 changed files with 9 additions and 10 deletions

View file

@ -295,11 +295,8 @@ impl BaseTransformImpl for AudioEcho {
));
}
let info = match gst_audio::AudioInfo::from_caps(incaps) {
None => return Err(gst_loggable_error!(CAT, "Failed to parse input caps")),
Some(info) => info,
};
let info = gst_audio::AudioInfo::from_caps(incaps)
.or(Err(gst_loggable_error!(CAT, "Failed to parse input caps")))?;
let max_delay = self.settings.lock().unwrap().max_delay;
let size = max_delay * (info.rate() as u64) / gst::SECOND_VAL;
let buffer_size = size * (info.channels() as u64);

View file

@ -573,7 +573,7 @@ impl AggregatorImpl for FallbackSwitch {
let audio_info;
let video_info;
if caps.get_structure(0).unwrap().get_name() == "audio/x-raw" {
audio_info = gst_audio::AudioInfo::from_caps(&caps);
audio_info = gst_audio::AudioInfo::from_caps(&caps).ok();
video_info = None;
} else if caps.get_structure(0).unwrap().get_name() == "video/x-raw" {
audio_info = None;

View file

@ -1161,7 +1161,7 @@ impl ToggleRecord {
let caps = c.get_caps();
let s = caps.get_structure(0).unwrap();
if s.get_name().starts_with("audio/") {
state.audio_info = gst_audio::AudioInfo::from_caps(caps);
state.audio_info = gst_audio::AudioInfo::from_caps(caps).ok();
gst_log!(CAT, obj: pad, "Got audio caps {:?}", state.audio_info);
state.video_info = None;
} else if s.get_name().starts_with("video/") {

View file

@ -443,9 +443,11 @@ impl BaseSrcImpl for SineSrc {
) -> Result<(), gst::LoggableError> {
use std::f64::consts::PI;
let info = gst_audio::AudioInfo::from_caps(caps).ok_or_else(|| {
gst_loggable_error!(CAT, "Failed to build `AudioInfo` from caps {}", caps)
})?;
let info = gst_audio::AudioInfo::from_caps(caps).or(Err(gst_loggable_error!(
CAT,
"Failed to build `AudioInfo` from caps {}",
caps
)))?;
gst_debug!(CAT, obj: element, "Configuring for caps {}", caps);