add timeout paramter to DeviceTrait stream builders (#696)
* add timeout paramter to DeviceTrait stream builders This makes it possible for the library client to handle situations where the host takes too long to respond or even blocks forever, eg. a retry can be applied. if the timeout passed is "None" the current behaviour is applied, eg. blocking forever. if the timeout passed is a Duration then it will be applied to the Device Streams. This is only implemented for ALSA, the other hosts will ignore the parameter for now. Signed-off-by: Marc Bodmer <marc.bodmer@securiton.ch>
This commit is contained in:
parent
def424809b
commit
0a3e8c2208
21 changed files with 148 additions and 21 deletions
|
|
@ -1,5 +1,7 @@
|
|||
//! The suite of traits allowing CPAL to abstract over hosts, devices, event loops and stream IDs.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::{
|
||||
BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, DevicesError,
|
||||
InputCallbackInfo, InputDevices, OutputCallbackInfo, OutputDevices, PauseStreamError,
|
||||
|
|
@ -120,6 +122,7 @@ pub trait DeviceTrait {
|
|||
config: &StreamConfig,
|
||||
mut data_callback: D,
|
||||
error_callback: E,
|
||||
timeout: Option<Duration>,
|
||||
) -> Result<Self::Stream, BuildStreamError>
|
||||
where
|
||||
T: SizedSample,
|
||||
|
|
@ -137,6 +140,7 @@ pub trait DeviceTrait {
|
|||
)
|
||||
},
|
||||
error_callback,
|
||||
timeout,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -146,6 +150,7 @@ pub trait DeviceTrait {
|
|||
config: &StreamConfig,
|
||||
mut data_callback: D,
|
||||
error_callback: E,
|
||||
timeout: Option<Duration>,
|
||||
) -> Result<Self::Stream, BuildStreamError>
|
||||
where
|
||||
T: SizedSample,
|
||||
|
|
@ -163,6 +168,7 @@ pub trait DeviceTrait {
|
|||
)
|
||||
},
|
||||
error_callback,
|
||||
timeout,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -173,6 +179,7 @@ pub trait DeviceTrait {
|
|||
sample_format: SampleFormat,
|
||||
data_callback: D,
|
||||
error_callback: E,
|
||||
timeout: Option<Duration>,
|
||||
) -> Result<Self::Stream, BuildStreamError>
|
||||
where
|
||||
D: FnMut(&Data, &InputCallbackInfo) + Send + 'static,
|
||||
|
|
@ -185,6 +192,7 @@ pub trait DeviceTrait {
|
|||
sample_format: SampleFormat,
|
||||
data_callback: D,
|
||||
error_callback: E,
|
||||
timeout: Option<Duration>,
|
||||
) -> Result<Self::Stream, BuildStreamError>
|
||||
where
|
||||
D: FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue