Commit 8d0a0ee6 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Directly use byte-slice-cast on the mapped buffer

No need to first get a byte slice from it anymore due to the buffer map
implementing AsRef/AsMut for byte slices
parent 8ff9294f
......@@ -93,7 +93,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
return gst::FlowReturn::Error;
};
let samples = if let Ok(samples) = map.as_slice().as_slice_of::<i16>() {
let samples = if let Ok(samples) = map.as_slice_of::<i16>() {
samples
} else {
gst_element_error!(
......
......@@ -30,7 +30,7 @@ fn example_main() {
if let Some(gst::PadProbeData::Buffer(ref buffer)) = probe_info.data {
let map = buffer.map_readable().unwrap();
let samples = if let Ok(samples) = map.as_slice().as_slice_of::<i16>() {
let samples = if let Ok(samples) = map.as_slice_of::<i16>() {
samples
} else {
return gst::PadProbeReturn::Ok;
......
......@@ -167,7 +167,7 @@ fn main() {
let buffer = buffer.get_mut().unwrap();
{
let mut samples = buffer.map_writable().unwrap();
let samples = samples.as_mut_slice().as_mut_slice_of::<i16>().unwrap();
let samples = samples.as_mut_slice_of::<i16>().unwrap();
// Generate some psychodelic waveforms
data.c += data.d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment