Skip to content

Commit 6996658

Browse files
authored
support sample rate auto convert using PortAudio paWinWasapiAutoConvert flag when in share mode (#492)
1 parent c573242 commit 6996658

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

sounddevice.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ def __init__(self, channel_map=None, change_device_parameters=False,
24132413

24142414
class WasapiSettings:
24152415

2416-
def __init__(self, exclusive=False):
2416+
def __init__(self, exclusive=False, auto_convert=False):
24172417
"""WASAPI-specific input/output settings.
24182418
24192419
Objects of this class can be used as *extra_settings* argument
@@ -2427,6 +2427,10 @@ def __init__(self, exclusive=False):
24272427
Exclusive mode allows to deliver audio data directly to
24282428
hardware bypassing software mixing.
24292429
2430+
auto_convert : bool
2431+
auto_convert allows to resample audio data to hardware
2432+
supported samplerate when in shared mode(None exclusive mode)
2433+
24302434
Examples
24312435
--------
24322436
Setting exclusive mode when calling `play()`:
@@ -2444,6 +2448,8 @@ def __init__(self, exclusive=False):
24442448
flags = 0x0
24452449
if exclusive:
24462450
flags |= _lib.paWinWasapiExclusive
2451+
elif auto_convert:
2452+
flags |= _lib.paWinWasapiAutoConvert
24472453
self._streaminfo = _ffi.new('PaWasapiStreamInfo*', dict(
24482454
size=_ffi.sizeof('PaWasapiStreamInfo'),
24492455
hostApiType=_lib.paWASAPI,

sounddevice_build.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@
254254
paWinWasapiRedirectHostProcessor = 2,
255255
paWinWasapiUseChannelMask = 4,
256256
paWinWasapiPolling = 8,
257-
paWinWasapiThreadPriority = 16
257+
paWinWasapiThreadPriority = 16,
258+
paWinWasapiAutoConvert = 64
258259
} PaWasapiFlags;
259260
260261
typedef void (*PaWasapiHostProcessorCallback) (

0 commit comments

Comments
 (0)