mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-10 11:15:33 +00:00
claxondec: Remove unused streaminfo variable from the state
And pass it by reference instead of value.
This commit is contained in:
parent
9349b86b27
commit
23bcfb8b1c
1 changed files with 5 additions and 15 deletions
|
@ -29,7 +29,6 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
||||||
});
|
});
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
streaminfo: Option<claxon::metadata::StreamInfo>,
|
|
||||||
audio_info: Option<gst_audio::AudioInfo>,
|
audio_info: Option<gst_audio::AudioInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,10 +111,7 @@ impl AudioDecoderImpl for ClaxonDec {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&self, _element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
fn start(&self, _element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
*self.state.borrow_mut() = Some(State {
|
*self.state.borrow_mut() = Some(State { audio_info: None });
|
||||||
streaminfo: None,
|
|
||||||
audio_info: None,
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -123,7 +119,6 @@ impl AudioDecoderImpl for ClaxonDec {
|
||||||
fn set_format(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
fn set_format(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||||
gst_debug!(CAT, obj: element, "Setting format {:?}", caps);
|
gst_debug!(CAT, obj: element, "Setting format {:?}", caps);
|
||||||
|
|
||||||
let mut streaminfo: Option<claxon::metadata::StreamInfo> = None;
|
|
||||||
let mut audio_info: Option<gst_audio::AudioInfo> = None;
|
let mut audio_info: Option<gst_audio::AudioInfo> = None;
|
||||||
|
|
||||||
let s = caps.structure(0).unwrap();
|
let s = caps.structure(0).unwrap();
|
||||||
|
@ -145,7 +140,7 @@ impl AudioDecoderImpl for ClaxonDec {
|
||||||
if inmap[0..7] != [0x7f, b'F', b'L', b'A', b'C', 0x01, 0x00] {
|
if inmap[0..7] != [0x7f, b'F', b'L', b'A', b'C', 0x01, 0x00] {
|
||||||
gst_debug!(CAT, obj: element, "Unknown streamheader format");
|
gst_debug!(CAT, obj: element, "Unknown streamheader format");
|
||||||
} else if let Ok(tstreaminfo) = claxon_streaminfo(&inmap[13..]) {
|
} else if let Ok(tstreaminfo) = claxon_streaminfo(&inmap[13..]) {
|
||||||
if let Ok(taudio_info) = gstaudioinfo(tstreaminfo) {
|
if let Ok(taudio_info) = gstaudioinfo(&tstreaminfo) {
|
||||||
// To speed up negotiation
|
// To speed up negotiation
|
||||||
if element.set_output_format(&taudio_info).is_err()
|
if element.set_output_format(&taudio_info).is_err()
|
||||||
|| element.negotiate().is_err()
|
|| element.negotiate().is_err()
|
||||||
|
@ -158,7 +153,6 @@ impl AudioDecoderImpl for ClaxonDec {
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_info = Some(taudio_info);
|
audio_info = Some(taudio_info);
|
||||||
streaminfo = Some(tstreaminfo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,10 +160,7 @@ impl AudioDecoderImpl for ClaxonDec {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut state_guard = self.state.borrow_mut();
|
let mut state_guard = self.state.borrow_mut();
|
||||||
*state_guard = Some(State {
|
*state_guard = Some(State { audio_info });
|
||||||
streaminfo,
|
|
||||||
audio_info,
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -229,7 +220,7 @@ impl ClaxonDec {
|
||||||
gst::FlowError::Error
|
gst::FlowError::Error
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let audio_info = gstaudioinfo(streaminfo).map_err(|e| {
|
let audio_info = gstaudioinfo(&streaminfo).map_err(|e| {
|
||||||
gst::element_error!(element, gst::StreamError::Decode, [&e]);
|
gst::element_error!(element, gst::StreamError::Decode, [&e]);
|
||||||
gst::FlowError::Error
|
gst::FlowError::Error
|
||||||
})?;
|
})?;
|
||||||
|
@ -244,7 +235,6 @@ impl ClaxonDec {
|
||||||
element.set_output_format(&audio_info)?;
|
element.set_output_format(&audio_info)?;
|
||||||
element.negotiate()?;
|
element.negotiate()?;
|
||||||
|
|
||||||
state.streaminfo = Some(streaminfo);
|
|
||||||
state.audio_info = Some(audio_info);
|
state.audio_info = Some(audio_info);
|
||||||
|
|
||||||
element.finish_frame(None, 1)
|
element.finish_frame(None, 1)
|
||||||
|
@ -388,7 +378,7 @@ fn claxon_streaminfo(indata: &[u8]) -> Result<claxon::metadata::StreamInfo, &'st
|
||||||
Ok(streaminfo)
|
Ok(streaminfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gstaudioinfo(streaminfo: claxon::metadata::StreamInfo) -> Result<gst_audio::AudioInfo, String> {
|
fn gstaudioinfo(streaminfo: &claxon::metadata::StreamInfo) -> Result<gst_audio::AudioInfo, String> {
|
||||||
let format = match streaminfo.bits_per_sample {
|
let format = match streaminfo.bits_per_sample {
|
||||||
8 => gst_audio::AudioFormat::S8,
|
8 => gst_audio::AudioFormat::S8,
|
||||||
16 => gst_audio::AUDIO_FORMAT_S16,
|
16 => gst_audio::AUDIO_FORMAT_S16,
|
||||||
|
|
Loading…
Reference in a new issue