mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
truth nuke
This commit is contained in:
@@ -123,24 +123,7 @@ class AudioEngine:
|
|||||||
def __init__(self, device_type: int, sample_rate: float, buffer_size: int, volume_presets: VolumeConfig):
|
def __init__(self, device_type: int, sample_rate: float, buffer_size: int, volume_presets: VolumeConfig):
|
||||||
if device_type == -1:
|
if device_type == -1:
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
ffi = cffi.FFI()
|
device_type = next((i for i in range(5) if "WDM" in self.get_host_api_name(i)), 0)
|
||||||
ffi.cdef("""
|
|
||||||
typedef int PaHostApiIndex;
|
|
||||||
const char* get_host_api_name(PaHostApiIndex hostApi);
|
|
||||||
""")
|
|
||||||
lib = ffi.dlopen("libaudio.dll")
|
|
||||||
for i in range(5):
|
|
||||||
result = lib.get_host_api_name(i) # type: ignore
|
|
||||||
if result == ffi.NULL:
|
|
||||||
continue
|
|
||||||
result = ffi.string(result)
|
|
||||||
if isinstance(result, bytes):
|
|
||||||
result = result.decode('utf-8')
|
|
||||||
if "WDM" in result:
|
|
||||||
device_type = i
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
device_type = 0
|
|
||||||
else:
|
else:
|
||||||
device_type = 0
|
device_type = 0
|
||||||
self.device_type = device_type
|
self.device_type = device_type
|
||||||
@@ -165,8 +148,14 @@ class AudioEngine:
|
|||||||
|
|
||||||
def get_host_api_name(self, api_id: int) -> str:
|
def get_host_api_name(self, api_id: int) -> str:
|
||||||
"""Returns the name of the host API with the given ID"""
|
"""Returns the name of the host API with the given ID"""
|
||||||
result = lib.get_host_api_name(api_id) # type: ignore
|
if api_id == -1:
|
||||||
|
id = self.device_type
|
||||||
|
else:
|
||||||
|
id = api_id
|
||||||
|
result = lib.get_host_api_name(id) # type: ignore
|
||||||
result = ffi.string(result)
|
result = ffi.string(result)
|
||||||
|
if result == ffi.NULL:
|
||||||
|
return ""
|
||||||
if isinstance(result, bytes):
|
if isinstance(result, bytes):
|
||||||
result = result.decode('utf-8')
|
result = result.decode('utf-8')
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user