Skip to main content

DataCallback

Type Alias DataCallback 

Source
pub type DataCallback<F> = dyn FnMut(&[F], &mut [F]) -> isize + Send + Sync + 'static;
Expand description

User supplied data callback.

  • Calling other cubeb functions from this callback is unsafe.
  • The code in the callback should be non-blocking.
  • Returning less than the number of frames this callback asks for or provides puts the stream in drain mode. This callback will not be called again, and the state callback will be called with CUBEB_STATE_DRAINED when all the frames have been output.

§Arguments

  • input_buffer: A slice containing the input data, zero-len if this is an output-only stream.
  • output_buffer: A mutable slice to be filled with audio samples, zero-len if this is an input-only stream.

§Return value

If the stream has output, this is the number of frames written to the output buffer. In this case, if this number is less than the length of the output buffer, then the stream will start to drain.

If the stream is input only, then returning the length of the input buffer indicates data has been read. In this case, a value less than that will result in the stream being stopped.