Change callback interface so that it takes a dedicated error callback

This commit is contained in:
Tatsuyuki Ishi 2019-07-15 22:37:03 +09:00 • committed by mitchmindtree
parent c97d1dd3fa
commit 3cce3e43d9
8 changed files with 50 additions and 71 deletions

View file

@ -10,7 +10,8 @@ use {
OutputDevices,
PauseStreamError,
PlayStreamError,
StreamDataResult,
StreamData,
StreamError,
SupportedFormat,
SupportedFormatsError,
};
@ -117,12 +118,12 @@ pub trait DeviceTrait {
fn default_output_format(&self) -> Result<Format, DefaultFormatError>;
/// Create an input stream.
fn build_input_stream<F>(&self, format: &Format, callback: F) -> Result<Self::Stream, BuildStreamError>
where F: FnMut(StreamDataResult) + Send + 'static;
fn build_input_stream<D, E>(&self, format: &Format, data_callback: D, error_callback: E) -> Result<Self::Stream, BuildStreamError>
where D: FnMut(StreamData) + Send + 'static, E: FnMut(StreamError) + Send + 'static;
/// Create an output stream.
fn build_output_stream<F>(&self, format: &Format, callback: F) -> Result<Self::Stream, BuildStreamError>
where F: FnMut(StreamDataResult) + Send + 'static;
fn build_output_stream<D, E>(&self, format: &Format, data_callback: D, error_callback: E) -> Result<Self::Stream, BuildStreamError>
where D: FnMut(StreamData) + Send + 'static, E: FnMut(StreamError) + Send + 'static;
}
/// A stream created from `Device`, with methods to control playback.