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
This commit is contained in:
Sebastian Dröge 2018-06-01 11:55:13 +03:00
parent 8ff9294f9d
commit 8d0a0ee6b1
3 changed files with 3 additions and 3 deletions

View file

@ -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!(

View file

@ -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;

View file

@ -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;