mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-06-01 07:08:17 +00:00
fix clippy warnings
This commit is contained in:
parent
8f8f5bdff7
commit
5439f14e57
|
@ -65,7 +65,7 @@ fn test_rnnoise(audio_info: &gst_audio::AudioInfo, buffer_size: usize) {
|
|||
let output = map.as_slice().as_slice_of::<f64>().unwrap();
|
||||
|
||||
// all samples in the output buffers must value 0
|
||||
assert_eq!(output.iter().any(|sample| *sample as u16 != 0u16), false);
|
||||
assert!(output.iter().all(|sample| *sample as u16 == 0u16));
|
||||
total_processed += output.len();
|
||||
}
|
||||
h.push_event(gst::event::Eos::new());
|
||||
|
|
|
@ -167,7 +167,7 @@ fn csound_filter_eos() {
|
|||
let output = map.as_slice().as_slice_of::<f64>().unwrap();
|
||||
|
||||
// all samples in the output buffers must value 1
|
||||
assert_eq!(output.iter().any(|sample| *sample as u16 != 1u16), false);
|
||||
assert!(output.iter().all(|sample| *sample as u16 == 1u16));
|
||||
|
||||
num_samples += output.len();
|
||||
num_buffers += 1;
|
||||
|
@ -190,7 +190,7 @@ fn csound_filter_eos() {
|
|||
num_buffers += 1;
|
||||
|
||||
assert_eq!(output.len(), samples_at_eos);
|
||||
assert_eq!(output.iter().any(|sample| *sample as u16 != 1u16), false);
|
||||
assert!(output.iter().all(|sample| *sample as u16 == 1u16));
|
||||
|
||||
// All the generated samples should have been processed at this point
|
||||
assert_eq!(num_samples, EOS_NUM_SAMPLES * EOS_NUM_BUFFERS);
|
||||
|
|
|
@ -166,7 +166,7 @@ impl SinkHandler {
|
|||
inner.ips_rtptime = None;
|
||||
inner.ips_pts = None;
|
||||
|
||||
mem::replace(&mut inner.gap_packets, BTreeSet::new())
|
||||
mem::take(&mut inner.gap_packets)
|
||||
}
|
||||
|
||||
fn parse_caps(
|
||||
|
|
|
@ -161,7 +161,7 @@ impl UdpSinkPadHandlerInner {
|
|||
gst_pad: &gst::Pad,
|
||||
clients_to_add: impl Iterator<Item = SocketAddr>,
|
||||
) {
|
||||
let old_clients = mem::replace(&mut *Arc::make_mut(&mut self.clients), vec![]);
|
||||
let old_clients = mem::take(&mut *Arc::make_mut(&mut self.clients));
|
||||
|
||||
self.clients_to_configure = vec![];
|
||||
self.clients_to_unconfigure = vec![];
|
||||
|
@ -419,8 +419,8 @@ impl UdpSinkPadHandler {
|
|||
});
|
||||
}
|
||||
|
||||
let clients_to_configure = mem::replace(&mut inner.clients_to_configure, vec![]);
|
||||
let clients_to_unconfigure = mem::replace(&mut inner.clients_to_unconfigure, vec![]);
|
||||
let clients_to_configure = mem::take(&mut inner.clients_to_configure);
|
||||
let clients_to_unconfigure = mem::take(&mut inner.clients_to_unconfigure);
|
||||
|
||||
let settings = inner.settings.lock().unwrap().clone();
|
||||
|
||||
|
|
|
@ -458,8 +458,8 @@ impl Transcriber {
|
|||
let mut result = transcript.transcript.results.remove(0);
|
||||
let use_partial_results = self.settings.lock().unwrap().use_partial_results;
|
||||
if !result.is_partial && !result.alternatives.is_empty() {
|
||||
let alternative = result.alternatives.remove(0);
|
||||
if !use_partial_results {
|
||||
let alternative = result.alternatives.remove(0);
|
||||
gst_info!(
|
||||
CAT,
|
||||
obj: element,
|
||||
|
@ -518,7 +518,6 @@ impl Transcriber {
|
|||
state.buffers.push_back(buf);
|
||||
}
|
||||
} else {
|
||||
let alternative = result.alternatives.remove(0);
|
||||
let mut state = self.state.lock().unwrap();
|
||||
self.enqueue(
|
||||
element,
|
||||
|
|
|
@ -178,10 +178,7 @@ impl S3Sink {
|
|||
.sort_by(|a, b| a.part_number.cmp(&b.part_number));
|
||||
|
||||
let completed_upload = CompletedMultipartUpload {
|
||||
parts: Some(std::mem::replace(
|
||||
&mut started_state.completed_parts,
|
||||
Vec::new(),
|
||||
)),
|
||||
parts: Some(std::mem::take(&mut started_state.completed_parts)),
|
||||
};
|
||||
|
||||
let url = self.url.lock().unwrap();
|
||||
|
|
|
@ -181,9 +181,8 @@ impl TextWrap {
|
|||
start_ts + accumulate_time < pts
|
||||
})
|
||||
{
|
||||
let mut buf = gst::Buffer::from_mut_slice(
|
||||
mem::replace(&mut state.current_text, String::new()).into_bytes(),
|
||||
);
|
||||
let mut buf =
|
||||
gst::Buffer::from_mut_slice(mem::take(&mut state.current_text).into_bytes());
|
||||
{
|
||||
let buf_mut = buf.get_mut().unwrap();
|
||||
buf_mut.set_pts(state.start_ts);
|
||||
|
@ -366,7 +365,7 @@ impl TextWrap {
|
|||
let mut state = self.state.lock().unwrap();
|
||||
if !state.current_text.is_empty() {
|
||||
let mut buf = gst::Buffer::from_mut_slice(
|
||||
mem::replace(&mut state.current_text, String::new()).into_bytes(),
|
||||
mem::take(&mut state.current_text).into_bytes(),
|
||||
);
|
||||
{
|
||||
let buf_mut = buf.get_mut().unwrap();
|
||||
|
|
|
@ -370,7 +370,7 @@ impl CustomSource {
|
|||
gst_debug!(CAT, obj: element, "Stopping");
|
||||
|
||||
let mut state = self.state.lock().unwrap();
|
||||
let pads = mem::replace(&mut state.pads, vec![]);
|
||||
let pads = mem::take(&mut state.pads);
|
||||
state.num_audio = 0;
|
||||
state.num_video = 0;
|
||||
drop(state);
|
||||
|
|
|
@ -2171,9 +2171,6 @@ impl FallbackSrc {
|
|||
if state.source_restart_timeout.is_none() {
|
||||
self.schedule_source_restart_timeout(element, state, gst::ClockTime::ZERO);
|
||||
}
|
||||
|
||||
drop(state_guard);
|
||||
element.notify("status");
|
||||
} else {
|
||||
gst_debug!(CAT, obj: element, "Switched to main stream");
|
||||
if let Some(timeout) = state.source_retry_timeout.take() {
|
||||
|
@ -2185,10 +2182,10 @@ impl FallbackSrc {
|
|||
gst_debug!(CAT, obj: element, "Unscheduling restart timeout");
|
||||
timeout.unschedule();
|
||||
}
|
||||
|
||||
drop(state_guard);
|
||||
element.notify("status");
|
||||
}
|
||||
|
||||
drop(state_guard);
|
||||
element.notify("status");
|
||||
}
|
||||
|
||||
fn stats(&self) -> gst::Structure {
|
||||
|
|
|
@ -205,6 +205,7 @@ fn setup_sender_receiver(
|
|||
(sender_input, receiver_input_done, receiver_output, thread)
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn recv_buffers(
|
||||
receiver_output: &mpsc::Receiver<Either<gst::Buffer, gst::Event>>,
|
||||
segment: &mut gst::FormattedSegment<gst::ClockTime>,
|
||||
|
@ -1238,7 +1239,7 @@ fn test_two_stream_main_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, true);
|
||||
assert!(recording);
|
||||
|
||||
// Send 2 buffers to secondary stream. At this moment, main stream got eos
|
||||
// already (after 10 buffers) and secondary stream got 2 buffers.
|
||||
|
@ -1257,7 +1258,7 @@ fn test_two_stream_main_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, false);
|
||||
assert!(!recording);
|
||||
|
||||
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
|
||||
|
@ -1268,7 +1269,7 @@ fn test_two_stream_main_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_1.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
// Last buffer should be dropped from second stream
|
||||
let mut segment_2 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
|
@ -1280,7 +1281,7 @@ fn test_two_stream_main_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_2.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
thread_1.join().unwrap();
|
||||
thread_2.join().unwrap();
|
||||
|
@ -1321,7 +1322,7 @@ fn test_two_stream_secondary_eos_first() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, true);
|
||||
assert!(recording);
|
||||
|
||||
// And send EOS to the main stream then it will update state to Stopped
|
||||
sender_input_1.send(SendData::Eos).unwrap();
|
||||
|
@ -1332,7 +1333,7 @@ fn test_two_stream_secondary_eos_first() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, false);
|
||||
assert!(!recording);
|
||||
|
||||
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
|
||||
|
@ -1343,7 +1344,7 @@ fn test_two_stream_secondary_eos_first() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_1.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
// We sent 9 buffers to the second stream, and there should be no dropped
|
||||
// buffer
|
||||
|
@ -1356,7 +1357,7 @@ fn test_two_stream_secondary_eos_first() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_2.len(), 9);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
thread_1.join().unwrap();
|
||||
thread_2.join().unwrap();
|
||||
|
@ -1400,7 +1401,7 @@ fn test_three_stream_main_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, true);
|
||||
assert!(recording);
|
||||
|
||||
// Send 2 buffers to non-main streams. At this moment, main stream got EOS
|
||||
// already (after 10 buffers) and the other streams got 9 buffers.
|
||||
|
@ -1419,7 +1420,7 @@ fn test_three_stream_main_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, true);
|
||||
assert!(recording);
|
||||
|
||||
// And terminate the third thread without EOS
|
||||
sender_input_3.send(SendData::Buffers(2)).unwrap();
|
||||
|
@ -1434,7 +1435,7 @@ fn test_three_stream_main_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, false);
|
||||
assert!(!recording);
|
||||
|
||||
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
|
||||
|
@ -1445,7 +1446,7 @@ fn test_three_stream_main_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_1.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
// Last buffer should be dropped from non-main streams
|
||||
let mut segment_2 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
|
@ -1457,7 +1458,7 @@ fn test_three_stream_main_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_2.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
let mut segment_3 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
let (buffers_3, saw_eos) = recv_buffers(&receiver_output_3, &mut segment_3, 0);
|
||||
|
@ -1468,7 +1469,7 @@ fn test_three_stream_main_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_3.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
thread_1.join().unwrap();
|
||||
thread_2.join().unwrap();
|
||||
|
@ -1513,7 +1514,7 @@ fn test_three_stream_main_and_second_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, true);
|
||||
assert!(recording);
|
||||
|
||||
// And send EOS to the second stream, but state shouldn't be affected by
|
||||
// this EOS. The third stream is still not in EOS state
|
||||
|
@ -1525,7 +1526,7 @@ fn test_three_stream_main_and_second_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, true);
|
||||
assert!(recording);
|
||||
|
||||
// Send 2 buffers to the third stream. At this moment, main stream and
|
||||
// the second stream got EOS already (after 10 buffers) and the third stream
|
||||
|
@ -1546,7 +1547,7 @@ fn test_three_stream_main_and_second_eos() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, false);
|
||||
assert!(!recording);
|
||||
|
||||
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
|
||||
|
@ -1557,7 +1558,7 @@ fn test_three_stream_main_and_second_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_1.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
// We sent 9 buffers to the second stream, and there must be no dropped one
|
||||
let mut segment_2 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
|
@ -1569,7 +1570,7 @@ fn test_three_stream_main_and_second_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_2.len(), 9);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
// Last buffer should be dropped from the third stream
|
||||
let mut segment_3 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
|
@ -1581,7 +1582,7 @@ fn test_three_stream_main_and_second_eos() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_3.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
thread_1.join().unwrap();
|
||||
thread_2.join().unwrap();
|
||||
|
@ -1629,7 +1630,7 @@ fn test_three_stream_secondary_eos_first() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, true);
|
||||
assert!(recording);
|
||||
|
||||
// And send EOS, Send EOS to the main stream then it will update state to
|
||||
// Stopped
|
||||
|
@ -1641,7 +1642,7 @@ fn test_three_stream_secondary_eos_first() {
|
|||
.unwrap()
|
||||
.get::<bool>()
|
||||
.unwrap();
|
||||
assert_eq!(recording, false);
|
||||
assert!(!recording);
|
||||
|
||||
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
|
||||
|
@ -1652,7 +1653,7 @@ fn test_three_stream_secondary_eos_first() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_1.len(), 10);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
// Last buffer should be dropped from non-main streams
|
||||
let mut segment_2 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
|
@ -1664,7 +1665,7 @@ fn test_three_stream_secondary_eos_first() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_2.len(), 9);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
let mut segment_3 = gst::FormattedSegment::<gst::ClockTime>::new();
|
||||
let (buffers_3, saw_eos) = recv_buffers(&receiver_output_3, &mut segment_3, 0);
|
||||
|
@ -1675,7 +1676,7 @@ fn test_three_stream_secondary_eos_first() {
|
|||
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
|
||||
}
|
||||
assert_eq!(buffers_3.len(), 9);
|
||||
assert_eq!(saw_eos, true);
|
||||
assert!(saw_eos);
|
||||
|
||||
thread_1.join().unwrap();
|
||||
thread_2.join().unwrap();
|
||||
|
|
|
@ -463,7 +463,7 @@ impl State {
|
|||
let mut lines: Vec<Line> = vec![];
|
||||
|
||||
// Wish BTreeMap had a drain() method
|
||||
for (_idx, row) in std::mem::replace(&mut self.rows, BTreeMap::new()).into_iter() {
|
||||
for (_idx, row) in std::mem::take(&mut self.rows).into_iter() {
|
||||
if !row.is_empty() {
|
||||
let mut line: Line = row.into();
|
||||
line.carriage_return = self.carriage_return.take();
|
||||
|
|
|
@ -44,7 +44,7 @@ impl CacheBuffer {
|
|||
}
|
||||
pub fn consume(&self) -> Vec<u8> {
|
||||
let mut buffer = self.buffer.borrow_mut();
|
||||
std::mem::replace(&mut *buffer, Vec::new())
|
||||
std::mem::take(&mut *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -435,22 +435,15 @@ impl BaseTransformImpl for HsvDetector {
|
|||
caps: &gst::Caps,
|
||||
filter: Option<&gst::Caps>,
|
||||
) -> Option<gst::Caps> {
|
||||
let other_caps = if direction == gst::PadDirection::Src {
|
||||
let mut caps = caps.clone();
|
||||
|
||||
for s in caps.make_mut().iter_mut() {
|
||||
let mut other_caps = caps.clone();
|
||||
if direction == gst::PadDirection::Src {
|
||||
for s in other_caps.make_mut().iter_mut() {
|
||||
s.set("format", &gst::List::from_owned(video_input_formats()));
|
||||
}
|
||||
|
||||
caps
|
||||
} else {
|
||||
let mut caps = caps.clone();
|
||||
|
||||
for s in caps.make_mut().iter_mut() {
|
||||
for s in other_caps.make_mut().iter_mut() {
|
||||
s.set("format", &gst::List::from_owned(video_output_formats()));
|
||||
}
|
||||
|
||||
caps
|
||||
};
|
||||
|
||||
gst_debug!(
|
||||
|
|
|
@ -57,7 +57,7 @@ impl CacheBuffer {
|
|||
|
||||
pub fn consume(&self) -> Vec<u8> {
|
||||
let mut buffer = self.buffer.borrow_mut();
|
||||
std::mem::replace(&mut *buffer, Vec::new())
|
||||
std::mem::take(&mut *buffer)
|
||||
}
|
||||
}
|
||||
// The Encoder requires a Writer, so we use here and intermediate structure
|
||||
|
|
Loading…
Reference in a new issue