@@ -863,12 +863,13 @@ def get_portaudio_version():
863863class _StreamBase (object ):
864864 """Direct or indirect base class for all stream classes."""
865865
866- def __init__ (self , kind = None , samplerate = None , blocksize = None , device = None ,
866+ def __init__ (self , kind , samplerate = None , blocksize = None , device = None ,
867867 channels = None , dtype = None , latency = None , extra_settings = None ,
868868 callback = None , finished_callback = None , clip_off = None ,
869869 dither_off = None , never_drop_input = None ,
870870 prime_output_buffers_using_stream_callback = None ,
871871 userdata = None , wrap_callback = None ):
872+ assert kind in ('input' , 'output' , 'duplex' )
872873 assert wrap_callback in ('array' , 'buffer' , None )
873874 if blocksize is None :
874875 blocksize = default .blocksize
@@ -892,7 +893,7 @@ def __init__(self, kind=None, samplerate=None, blocksize=None, device=None,
892893 if prime_output_buffers_using_stream_callback :
893894 stream_flags |= _lib .paPrimeOutputBuffersUsingStreamCallback
894895
895- if kind is None :
896+ if kind == 'duplex' :
896897 idevice , odevice = _split (device )
897898 ichannels , ochannels = _split (channels )
898899 idtype , odtype = _split (dtype )
@@ -962,7 +963,7 @@ def callback_ptr(iptr, optr, frames, time, status, _):
962963 self ._channels , self ._dtype )
963964 return _wrap_callback (callback , data , frames , time , status )
964965
965- elif kind is None and wrap_callback == 'buffer' :
966+ elif kind == 'duplex' and wrap_callback == 'buffer' :
966967
967968 @ffi_callback
968969 def callback_ptr (iptr , optr , frames , time , status , _ ):
@@ -973,7 +974,7 @@ def callback_ptr(iptr, optr, frames, time, status, _):
973974 return _wrap_callback (
974975 callback , idata , odata , frames , time , status )
975976
976- elif kind is None and wrap_callback == 'array' :
977+ elif kind == 'duplex' and wrap_callback == 'array' :
977978
978979 @ffi_callback
979980 def callback_ptr (iptr , optr , frames , time , status , _ ):
@@ -1476,7 +1477,7 @@ def __init__(self, samplerate=None, blocksize=None,
14761477 RawInputStream, RawOutputStream, Stream
14771478
14781479 """
1479- _StreamBase .__init__ (self , kind = None , wrap_callback = 'buffer' ,
1480+ _StreamBase .__init__ (self , kind = 'duplex' , wrap_callback = 'buffer' ,
14801481 ** _remove_self (locals ()))
14811482
14821483
@@ -1874,7 +1875,7 @@ def __init__(self, samplerate=None, blocksize=None,
18741875 See `default.prime_output_buffers_using_stream_callback`.
18751876
18761877 """
1877- _StreamBase .__init__ (self , kind = None , wrap_callback = 'array' ,
1878+ _StreamBase .__init__ (self , kind = 'duplex' , wrap_callback = 'array' ,
18781879 ** _remove_self (locals ()))
18791880
18801881
@@ -2549,6 +2550,7 @@ def _check_dtype(dtype):
25492550def _get_stream_parameters (kind , device , channels , dtype , latency ,
25502551 extra_settings , samplerate ):
25512552 """Get parameters for one direction (input or output) of a stream."""
2553+ assert kind in ('input' , 'output' )
25522554 if device is None :
25532555 device = default .device [kind ]
25542556 if channels is None :
0 commit comments