diff options
| author | yin kaisheng <yinkaisheng@live.com> | 2023-10-07 16:57:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-07 10:57:50 +0200 |
| commit | 69966580147804e64f95f5d978843027d91e154c (patch) | |
| tree | 717ee5a417ed84f90a16706823a1b28a9b7f43ef | |
| parent | c5732425ba0d46a33d1a2534a4616847d6f536c9 (diff) | |
support sample rate auto convert using PortAudio paWinWasapiAutoConvert flag when in share mode (#492)
| -rw-r--r-- | sounddevice.py | 8 | ||||
| -rw-r--r-- | sounddevice_build.py | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/sounddevice.py b/sounddevice.py index 7fc7c10..1592609 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -2413,7 +2413,7 @@ class CoreAudioSettings: class WasapiSettings: - def __init__(self, exclusive=False): + def __init__(self, exclusive=False, auto_convert=False): """WASAPI-specific input/output settings. Objects of this class can be used as *extra_settings* argument @@ -2427,6 +2427,10 @@ class WasapiSettings: Exclusive mode allows to deliver audio data directly to hardware bypassing software mixing. + auto_convert : bool + auto_convert allows to resample audio data to hardware + supported samplerate when in shared mode(None exclusive mode) + Examples -------- Setting exclusive mode when calling `play()`: @@ -2444,6 +2448,8 @@ class WasapiSettings: flags = 0x0 if exclusive: flags |= _lib.paWinWasapiExclusive + elif auto_convert: + flags |= _lib.paWinWasapiAutoConvert self._streaminfo = _ffi.new('PaWasapiStreamInfo*', dict( size=_ffi.sizeof('PaWasapiStreamInfo'), hostApiType=_lib.paWASAPI, diff --git a/sounddevice_build.py b/sounddevice_build.py index 1037471..6b45b79 100644 --- a/sounddevice_build.py +++ b/sounddevice_build.py @@ -254,7 +254,8 @@ typedef enum PaWasapiFlags paWinWasapiRedirectHostProcessor = 2, paWinWasapiUseChannelMask = 4, paWinWasapiPolling = 8, - paWinWasapiThreadPriority = 16 + paWinWasapiThreadPriority = 16, + paWinWasapiAutoConvert = 64 } PaWasapiFlags; typedef void (*PaWasapiHostProcessorCallback) ( |
