File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1
- /// Stream sample rate (samples per second per channel).
1
+ /// Stream sample rate (a frame rate or samples per second per channel).
2
2
pub type SampleRate = u32 ;
3
3
4
4
/// Number of channels in a stream.
Original file line number Diff line number Diff line change @@ -317,10 +317,19 @@ impl error::Error for StreamError {
317
317
}
318
318
319
319
impl OutputStream {
320
+ fn validate_config ( config : & OutputStreamConfig ) {
321
+ if let BufferSize :: Fixed ( sz) = config. buffer_size {
322
+ assert ! ( sz > 0 , "fixed buffer size is greater than zero" ) ;
323
+ }
324
+ assert ! ( config. sample_rate > 0 , "sample rate is greater than zero" ) ;
325
+ assert ! ( config. channel_count > 0 , "channel number is greater than zero" ) ;
326
+ }
327
+
320
328
fn open (
321
329
device : & cpal:: Device ,
322
330
config : & OutputStreamConfig ,
323
331
) -> Result < OutputStream , StreamError > {
332
+ Self :: validate_config ( config) ;
324
333
let ( controller, source) = mixer ( config. channel_count , config. sample_rate ) ;
325
334
Self :: init_stream ( device, config, source)
326
335
. map_err ( StreamError :: BuildStreamError )
You can’t perform that action at this time.
0 commit comments