diff --git a/CHANGELOG.md b/CHANGELOG.md index 375c7c7..947865f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [20230407] + - Fixes memory leak from PROPVARIANT, refs #72 (@KillerBOSS2019) + ## [20230322] - CI and testing improvements - Improve audioclient, audiopolicy and mmdeviceapi support, refs #70 (@dot-Eagle96) diff --git a/pycaw/api/mmdeviceapi/depend/structures.py b/pycaw/api/mmdeviceapi/depend/structures.py index b5410ab..afc8c54 100644 --- a/pycaw/api/mmdeviceapi/depend/structures.py +++ b/pycaw/api/mmdeviceapi/depend/structures.py @@ -1,4 +1,4 @@ -from ctypes import Structure, Union +from ctypes import Structure, Union, byref, windll from ctypes.wintypes import DWORD, LONG, LPWSTR, ULARGE_INTEGER, VARIANT_BOOL, WORD from comtypes import GUID @@ -40,6 +40,9 @@ def GetValue(self): else: return "%s:?" % (vt) + def clear(self): + windll.ole32.PropVariantClear(byref(self)) + class PROPERTYKEY(Structure): _fields_ = [ diff --git a/pycaw/utils.py b/pycaw/utils.py index 4e9de13..192f82e 100644 --- a/pycaw/utils.py +++ b/pycaw/utils.py @@ -244,8 +244,7 @@ def CreateDevice(dev): "from device %r: %r" % (j, dev, exc) ) continue - # TODO - # PropVariantClear(byref(value)) + value.clear() name = str(pk) properties[name] = v audioState = AudioDeviceState(state) diff --git a/setup.py b/setup.py index f7b36d6..b300801 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ def read(fname): install_requires = ["comtypes", "psutil"] setup( name="pycaw", - version="20230322", + version="20230407", description="Python Core Audio Windows Library", long_description=read("README.md"), long_description_content_type="text/markdown",