unsafe fn process_output_callback<A, B, D, F>(
                data_callback: &mut D,
                interleaved: &mut [u8],
                silence_asio_buffer: bool,
                asio_stream: &sys::AsioStream,
                asio_info: &sys::CallbackInfo,
                sample_rate: crate::SampleRate,
                to_endianness: F,
            ) where
                A: Sample,
                B: AsioSample,
                D: FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static,
                F: Fn(B) -> B,
            {
                // 1. Render interleaved buffer from callback.
                let interleaved: &mut [A] = cast_slice_mut(interleaved);
                let data = interleaved.as_mut_ptr() as *mut ();
                let len = interleaved.len();
                let mut data = Data::from_parts(data, len, A::FORMAT);
                let callback = system_time_to_stream_instant(asio_info.system_time);
                let n_frames = asio_stream.buffer_size as usize;
                let delay = frames_to_duration(n_frames, sample_rate);
                let playback = callback
                    .add(delay)
                    .expect("`playback` occurs beyond representation supported by `StreamInstant`");
                let timestamp = crate::OutputStreamTimestamp { callback, playback };
                let info = OutputCallbackInfo { timestamp };
                data_callback(&mut data, &info);

                // 2. Silence ASIO channels if necessary.
                let n_channels = interleaved.len() / n_frames;
                let buffer_index = asio_info.buffer_index as usize;
                if silence_asio_buffer {
                    for ch_ix in 0..n_channels {
                        let asio_channel =
                            asio_channel_slice_mut::<B>(asio_stream, buffer_index, ch_ix);
                        asio_channel
                            .iter_mut()
                            .for_each(|s| *s = to_endianness(B::SILENCE));
                    }
                }

                // 3. Write interleaved samples to ASIO channels, one channel at a time.
                for ch_ix in 0..n_channels {
                    let asio_channel =
                        asio_channel_slice_mut::<B>(asio_stream, buffer_index, ch_ix);
                    for (frame, s_asio) in interleaved.chunks(n_channels).zip(asio_channel) {
                        *s_asio = *s_asio + to_endianness(B::from_cpal_sample(&frame[ch_ix]));
                    }
                }
            }
/// 1. Render the given callback to the given buffer of interleaved samples.
/// 2. If required, silence the ASIO buffer.
/// 3. Finally, write the interleaved data to the non-interleaved ASIO buffer,
///    performing endianness conversions as necessary.
1. Render the given callback to the given buffer of interleaved samples.
2. If required, silence the ASIO buffer.
3. Finally, write the interleaved data to the non-interleaved ASIO buffer,
performing endianness conversions as necessary.
1 . Render the given callback to the given buffer of interleaved samples . 2 . If required silence the ASIO buffer . 3 . Finally write the interleaved data to the non - interleaved ASIO buffer performing endianness conversions as necessary .
unsafe fn process_output_callback<A, B, D, F>(
                data_callback: &mut D,
                interleaved: &mut [u8],
                silence_asio_buffer: bool,
                asio_stream: &sys::AsioStream,
                asio_info: &sys::CallbackInfo,
                sample_rate: crate::SampleRate,
                to_endianness: F,
            ) where
                A: Sample,
                B: AsioSample,
                D: FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static,
                F: Fn(B) -> B,
            {
                // 1. Render interleaved buffer from callback.
                let interleaved: &mut [A] = cast_slice_mut(interleaved);
                let data = interleaved.as_mut_ptr() as *mut ();
                let len = interleaved.len();
                let mut data = Data::from_parts(data, len, A::FORMAT);
                let callback = system_time_to_stream_instant(asio_info.system_time);
                let n_frames = asio_stream.buffer_size as usize;
                let delay = frames_to_duration(n_frames, sample_rate);
                let playback = callback
                    .add(delay)
                    .expect("`playback` occurs beyond representation supported by `StreamInstant`");
                let timestamp = crate::OutputStreamTimestamp { callback, playback };
                let info = OutputCallbackInfo { timestamp };
                data_callback(&mut data, &info);
                // 2. Silence ASIO channels if necessary.
                let n_channels = interleaved.len() / n_frames;
                let buffer_index = asio_info.buffer_index as usize;
                if silence_asio_buffer {
                    for ch_ix in 0..n_channels {
                        let asio_channel =
                            asio_channel_slice_mut::<B>(asio_stream, buffer_index, ch_ix);
                        asio_channel
                            .iter_mut()
                            .for_each(|s| *s = to_endianness(B::SILENCE));
                    }
                }
                // 3. Write interleaved samples to ASIO channels, one channel at a time.
                for ch_ix in 0..n_channels {
                    let asio_channel =
                        asio_channel_slice_mut::<B>(asio_stream, buffer_index, ch_ix);
                    for (frame, s_asio) in interleaved.chunks(n_channels).zip(asio_channel) {
                        *s_asio = *s_asio + to_endianness(B::from_cpal_sample(&frame[ch_ix]));
                    }
                }
            }
unsafe fn process_output_callback < A , B , D , F > ( data_callback : & mut D , interleaved : & mut [ u8 ] , silence_asio_buffer : bool , asio_stream : & sys :: AsioStream , asio_info : & sys :: CallbackInfo , sample_rate : crate :: SampleRate , to_endianness : F , ) where A : Sample , B : AsioSample , D : FnMut ( & mut Data , & OutputCallbackInfo ) + Send + ' static , F : Fn ( B ) -> B , { // 1. Render interleaved buffer from callback. let interleaved : & mut [ A ] = cast_slice_mut ( interleaved ) ; let data = interleaved . as_mut_ptr ( ) as * mut ( ) ; let len = interleaved . len ( ) ; let mut data = Data :: from_parts ( data , len , A :: FORMAT ) ; let callback = system_time_to_stream_instant ( asio_info . system_time ) ; let n_frames = asio_stream . buffer_size as usize ; let delay = frames_to_duration ( n_frames , sample_rate ) ; let playback = callback . add ( delay ) . expect ( " " ) ; let timestamp = crate :: OutputStreamTimestamp { callback , playback } ; let info = OutputCallbackInfo { timestamp } ; data_callback ( & mut data , & info ) ; // 2. Silence ASIO channels if necessary. let n_channels = interleaved . len ( ) / n_frames ; let buffer_index = asio_info . buffer_index as usize ; if silence_asio_buffer { for ch_ix in 0 .. n_channels { let asio_channel = asio_channel_slice_mut :: < B > ( asio_stream , buffer_index , ch_ix ) ; asio_channel . iter_mut ( ) . for_each ( | s | * s = to_endianness ( B :: SILENCE ) ) ; } } // 3. Write interleaved samples to ASIO channels, one channel at a time. for ch_ix in 0 .. n_channels { let asio_channel = asio_channel_slice_mut :: < B > ( asio_stream , buffer_index , ch_ix ) ; for ( frame , s_asio ) in interleaved . chunks ( n_channels ) . zip ( asio_channel ) { * s_asio = * s_asio + to_endianness ( B :: from_cpal_sample ( & frame [ ch_ix ] ) ) ; } } }
1.
1 .
data_callback
&mut D
interleaved
&mut [u8]
silence_asio_buffer
bool
asio_stream
&sys::AsioStream
asio_info
&sys::CallbackInfo
sample_rate
crate::SampleRate
to_endianness
F
data_callback
&mut D
interleaved
&mut [u8]
silence_asio_buffer
bool
asio_stream
&sys::AsioStream
asio_info
&sys::CallbackInfo
sample_rate
crate::SampleRate
to_endianness
F