mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-02-13 03:15:25 +00:00
livesync: Extract audio_info_from_caps
And adjust it slightly so it never panics. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1086>
This commit is contained in:
parent
1e67259462
commit
35552dc73c
1 changed files with 11 additions and 12 deletions
|
@ -27,6 +27,15 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fn audio_info_from_caps(
|
||||||
|
caps: &gst::CapsRef,
|
||||||
|
) -> Result<Option<gst_audio::AudioInfo>, glib::BoolError> {
|
||||||
|
caps.structure(0)
|
||||||
|
.map_or(false, |s| s.has_name("audio/x-raw"))
|
||||||
|
.then(|| gst_audio::AudioInfo::from_caps(caps))
|
||||||
|
.transpose()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
enum BufferLateness {
|
enum BufferLateness {
|
||||||
OnTime,
|
OnTime,
|
||||||
|
@ -631,13 +640,7 @@ impl LiveSync {
|
||||||
gst::EventView::Caps(c) => {
|
gst::EventView::Caps(c) => {
|
||||||
let caps = c.caps_owned();
|
let caps = c.caps_owned();
|
||||||
|
|
||||||
let audio_info = match caps
|
let audio_info = match audio_info_from_caps(&caps) {
|
||||||
.structure(0)
|
|
||||||
.unwrap()
|
|
||||||
.has_name("audio/x-raw")
|
|
||||||
.then(|| gst_audio::AudioInfo::from_caps(&caps))
|
|
||||||
.transpose()
|
|
||||||
{
|
|
||||||
Ok(ai) => ai,
|
Ok(ai) => ai,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
gst::error!(CAT, imp: self, "Failed to parse audio caps: {}", e);
|
gst::error!(CAT, imp: self, "Failed to parse audio caps: {}", e);
|
||||||
|
@ -1092,11 +1095,7 @@ impl LiveSync {
|
||||||
MutexGuard::unlocked(&mut state, || self.srcpad.push_event(event));
|
MutexGuard::unlocked(&mut state, || self.srcpad.push_event(event));
|
||||||
state.srcresult?;
|
state.srcresult?;
|
||||||
|
|
||||||
state.out_audio_info = caps
|
state.out_audio_info = audio_info_from_caps(&caps).unwrap();
|
||||||
.structure(0)
|
|
||||||
.unwrap()
|
|
||||||
.has_name("audio/x-raw")
|
|
||||||
.then(|| gst_audio::AudioInfo::from_caps(&caps).unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(segment) = segment {
|
if let Some(segment) = segment {
|
||||||
|
|
Loading…
Reference in a new issue