stream_callback
- Specifies a callback function for
non-blocking (callback) operation. Default is
None, which indicates blocking operation (i.e.,
Stream.read and Stream.write). To use non-blocking operation,
specify a callback that conforms to the following signature:
callback(in_data,
frame_count,
time_info,
status_flags)
time_info is a dictionary with the following keys:
input_buffer_adc_time, current_time, and
output_buffer_dac_time. See the PortAudio
documentation for their meanings.
The callback must return a tuple:
(out_data, flag)
out_data is a string whose length should be the
(frame_count * channels * bytes-per-channel) if
output=True or None if output=False. flag
must be either paContinue, paComplete or paAbort.
When output=True and out_data does not contain at
least frame_count frames, paComplete is assumed for
flag.
Note: stream_callback is called in a separate
thread (from the main thread). Exceptions that occur in
the stream_callback will:
- print a traceback on standard error to aid debugging,
- queue the exception to be thrown (at some point) in
the main thread, and
- return paAbort to PortAudio to stop the stream.
Note: Do not call Stream.read or Stream.write if using
non-blocking operation.
See: PortAudio's callback signature for additional details: http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a8a60fb2a5ec9cbade3f54a9c978e2710