@@ -2688,19 +2688,23 @@ def _get_stream_parameters(kind, device, channels, dtype, latency,
2688
2688
"""Get parameters for one direction (input or output) of a stream."""
2689
2689
assert kind in ('input' , 'output' )
2690
2690
if device is None :
2691
- device = default .device [kind ]
2691
+ device = default .device
2692
+ device = _get_device_id (device , kind , raise_on_error = True )
2692
2693
if channels is None :
2693
- channels = default .channels [kind ]
2694
+ channels = default .channels
2695
+ channels = _select_input_or_output (channels , kind )
2694
2696
if dtype is None :
2695
- dtype = default .dtype [kind ]
2697
+ dtype = default .dtype
2698
+ dtype = _select_input_or_output (dtype , kind )
2696
2699
if latency is None :
2697
- latency = default .latency [kind ]
2700
+ latency = default .latency
2701
+ latency = _select_input_or_output (latency , kind )
2698
2702
if extra_settings is None :
2699
- extra_settings = default .extra_settings [kind ]
2703
+ extra_settings = default .extra_settings
2704
+ extra_settings = _select_input_or_output (extra_settings , kind )
2700
2705
if samplerate is None :
2701
2706
samplerate = default .samplerate
2702
2707
2703
- device = _get_device_id (device , kind , raise_on_error = True )
2704
2708
info = query_devices (device )
2705
2709
if channels is None :
2706
2710
channels = info ['max_' + kind + '_channels' ]
@@ -2792,6 +2796,16 @@ def _check(err, msg=''):
2792
2796
raise PortAudioError (errormsg , err )
2793
2797
2794
2798
2799
+ def _select_input_or_output (value_or_pair , kind ):
2800
+ """Given a pair (or a single value for both), select input or output."""
2801
+ ivalue , ovalue = _split (value_or_pair )
2802
+ if kind == 'input' :
2803
+ return ivalue
2804
+ elif kind == 'output' :
2805
+ return ovalue
2806
+ assert False
2807
+
2808
+
2795
2809
def _get_device_id (id_or_query_string , kind , raise_on_error = False ):
2796
2810
"""Return device ID given space-separated substrings."""
2797
2811
assert kind in ('input' , 'output' , None )
0 commit comments