unsafe fn process_input_callback<A, B, D, F>(
                data_callback: &mut D,
                interleaved: &mut [u8],
                asio_stream: &sys::AsioStream,
                asio_info: &sys::CallbackInfo,
                sample_rate: crate::SampleRate,
                from_endianness: F,
            ) where
                A: AsioSample,
                B: Sample,
                D: FnMut(&Data, &InputCallbackInfo) + Send + 'static,
                F: Fn(A) -> A,
            {
                // 1. Write the ASIO channels to the CPAL buffer.
                let interleaved: &mut [B] = cast_slice_mut(interleaved);
                let n_frames = asio_stream.buffer_size as usize;
                let n_channels = interleaved.len() / n_frames;
                let buffer_index = asio_info.buffer_index as usize;
                for ch_ix in 0..n_channels {
                    let asio_channel = asio_channel_slice::<A>(asio_stream, buffer_index, ch_ix);
                    for (frame, s_asio) in interleaved.chunks_mut(n_channels).zip(asio_channel) {
                        frame[ch_ix] = from_endianness(*s_asio).to_cpal_sample();
                    }
                }

                // 2. Deliver the interleaved buffer to the callback.
                let data = interleaved.as_mut_ptr() as *mut ();
                let len = interleaved.len();
                let data = Data::from_parts(data, len, B::FORMAT);
                let callback = system_time_to_stream_instant(asio_info.system_time);
                let delay = frames_to_duration(n_frames, sample_rate);
                let capture = callback
                    .sub(delay)
                    .expect("`capture` occurs before origin of alsa `StreamInstant`");
                let timestamp = crate::InputStreamTimestamp { callback, capture };
                let info = InputCallbackInfo { timestamp };
                data_callback(&data, &info);
            }
/// 1. Write from the ASIO buffer to the interleaved CPAL buffer.
/// 2. Deliver the CPAL buffer to the user callback.
1. Write from the ASIO buffer to the interleaved CPAL buffer.
2. Deliver the CPAL buffer to the user callback.
1 . Write from the ASIO buffer to the interleaved CPAL buffer . 2 . Deliver the CPAL buffer to the user callback .
unsafe fn process_input_callback<A, B, D, F>(
                data_callback: &mut D,
                interleaved: &mut [u8],
                asio_stream: &sys::AsioStream,
                asio_info: &sys::CallbackInfo,
                sample_rate: crate::SampleRate,
                from_endianness: F,
            ) where
                A: AsioSample,
                B: Sample,
                D: FnMut(&Data, &InputCallbackInfo) + Send + 'static,
                F: Fn(A) -> A,
            {
                // 1. Write the ASIO channels to the CPAL buffer.
                let interleaved: &mut [B] = cast_slice_mut(interleaved);
                let n_frames = asio_stream.buffer_size as usize;
                let n_channels = interleaved.len() / n_frames;
                let buffer_index = asio_info.buffer_index as usize;
                for ch_ix in 0..n_channels {
                    let asio_channel = asio_channel_slice::<A>(asio_stream, buffer_index, ch_ix);
                    for (frame, s_asio) in interleaved.chunks_mut(n_channels).zip(asio_channel) {
                        frame[ch_ix] = from_endianness(*s_asio).to_cpal_sample();
                    }
                }
                // 2. Deliver the interleaved buffer to the callback.
                let data = interleaved.as_mut_ptr() as *mut ();
                let len = interleaved.len();
                let data = Data::from_parts(data, len, B::FORMAT);
                let callback = system_time_to_stream_instant(asio_info.system_time);
                let delay = frames_to_duration(n_frames, sample_rate);
                let capture = callback
                    .sub(delay)
                    .expect("`capture` occurs before origin of alsa `StreamInstant`");
                let timestamp = crate::InputStreamTimestamp { callback, capture };
                let info = InputCallbackInfo { timestamp };
                data_callback(&data, &info);
            }
unsafe fn process_input_callback < A , B , D , F > ( data_callback : & mut D , interleaved : & mut [ u8 ] , asio_stream : & sys :: AsioStream , asio_info : & sys :: CallbackInfo , sample_rate : crate :: SampleRate , from_endianness : F , ) where A : AsioSample , B : Sample , D : FnMut ( & Data , & InputCallbackInfo ) + Send + ' static , F : Fn ( A ) -> A , { // 1. Write the ASIO channels to the CPAL buffer. let interleaved : & mut [ B ] = cast_slice_mut ( interleaved ) ; let n_frames = asio_stream . buffer_size as usize ; let n_channels = interleaved . len ( ) / n_frames ; let buffer_index = asio_info . buffer_index as usize ; for ch_ix in 0 .. n_channels { let asio_channel = asio_channel_slice :: < A > ( asio_stream , buffer_index , ch_ix ) ; for ( frame , s_asio ) in interleaved . chunks_mut ( n_channels ) . zip ( asio_channel ) { frame [ ch_ix ] = from_endianness ( * s_asio ) . to_cpal_sample ( ) ; } } // 2. Deliver the interleaved buffer to the callback. let data = interleaved . as_mut_ptr ( ) as * mut ( ) ; let len = interleaved . len ( ) ; let data = Data :: from_parts ( data , len , B :: FORMAT ) ; let callback = system_time_to_stream_instant ( asio_info . system_time ) ; let delay = frames_to_duration ( n_frames , sample_rate ) ; let capture = callback . sub ( delay ) . expect ( " " ) ; let timestamp = crate :: InputStreamTimestamp { callback , capture } ; let info = InputCallbackInfo { timestamp } ; data_callback ( & data , & info ) ; }
1.
1 .
data_callback
&mut D
interleaved
&mut [u8]
asio_stream
&sys::AsioStream
asio_info
&sys::CallbackInfo
sample_rate
crate::SampleRate
from_endianness
F
data_callback
&mut D
interleaved
&mut [u8]
asio_stream
&sys::AsioStream
asio_info
&sys::CallbackInfo
sample_rate
crate::SampleRate
from_endianness
F