diff --git a/source/nvwave.py b/source/nvwave.py index 438c3c4e5d5..168204e07d6 100644 --- a/source/nvwave.py +++ b/source/nvwave.py @@ -18,7 +18,8 @@ c_void_p, CFUNCTYPE, c_float, - string_at, + c_char_p, + cast, ) from comtypes import HRESULT from comtypes.hresult import E_INVALIDARG @@ -339,12 +340,13 @@ def feed( # turn off trimming temporarily. if self._purpose is AudioPurpose.SPEECH and self._isLeadingSilenceInserted: self.startTrimmingLeadingSilence(False) - if not isinstance(data, bytes): - data = string_at(data, size) + # wasPlay_feed requires c_char_p, so cast data to c_char_p before calling. + # Casting bytes to c_char_p is also fine, as long as the original data is not released. + dataptr = cast(data, c_char_p) try: wasapi.wasPlay_feed( self._player, - data, + dataptr, size if size is not None else len(data), byref(feedId) if onDone else None, )