Skip to content

Commit 754d915

Browse files
authored
Merge pull request #120 from paulzzh/patch-1
fix utf-16 decode error AGAIN
2 parents 7457715 + 6f5bb8b commit 754d915

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

soundcard/mediafoundation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import os
44
import cffi
5-
import numpy
6-
import time
75
import re
6+
import time
7+
import struct
88
import collections
99
import platform
1010

11+
import numpy
12+
1113
_ffi = cffi.FFI()
1214
_package_dir, _ = os.path.split(__file__)
1315
with open(os.path.join(_package_dir, 'mediafoundation.py.h'), 'rt') as f:
@@ -369,7 +371,7 @@ def name(self):
369371
for idx in range(256):
370372
if data[idx] == 0:
371373
break
372-
devicename = ''.join(chr(c) for c in data[0:idx])
374+
devicename = struct.pack('h' * idx, *data[0:idx]).decode('utf-16')
373375
_com.release(ppPropertyStore)
374376
return devicename
375377

0 commit comments

Comments
 (0)