fn process_data()

in src/backend/buffer_manager.rs [94:136]


fn process_data<T: DataType>(
    data: *mut c_void,
    frame_count: usize,
    input_channel_count: usize,
    input_channels_to_ignore: usize,
    output_channel_count: usize,
) -> &'static [T] {
    assert!(
        input_channels_to_ignore == 0
            || input_channel_count >= input_channels_to_ignore + output_channel_count
    );
    let input_slice = unsafe {
        slice::from_raw_parts_mut::<T>(data as *mut T, frame_count * input_channel_count)
    };
    match input_channel_count.cmp(&output_channel_count) {
        Ordering::Equal => {
            assert_eq!(input_channels_to_ignore, 0);
            input_slice
        }
        Ordering::Greater => {
            if input_channels_to_ignore > 0 {
                drop_first_n_channels_in_place(
                    input_channels_to_ignore,
                    input_slice,
                    frame_count,
                    input_channel_count,
                );
            }
            let new_count_remixed = remix_or_drop_channels(
                input_channel_count - input_channels_to_ignore,
                output_channel_count,
                input_slice,
                frame_count,
            );
            unsafe { slice::from_raw_parts_mut::<T>(data as *mut T, new_count_remixed) }
        }
        Ordering::Less => {
            assert!(input_channel_count < output_channel_count);
            // Upmix happens on pull.
            input_slice
        }
    }
}