Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update device list by reloading portaudio dll #516

Open
HaujetZhao opened this issue Dec 29, 2023 · 1 comment
Open

Update device list by reloading portaudio dll #516

HaujetZhao opened this issue Dec 29, 2023 · 1 comment

Comments

@HaujetZhao
Copy link

import sounddevice as sd

print(sd.query_device)

# some device info listed
# then plug some new device

sd._terminate()
sd._initialize()
print(sd.query_device)

# device info list unchanged

sd._terminate()
sd._ffi.dlclose(sd._lib)
sd._lib = sd._ffi.dlopen(sd._libname)
sd._initialize()
print(sd.query_device)

# device info list updated, it works fine


# is it possible to close the dll when sd._terminate()
# and reopen the dll when sd._initialize()
# so that the device_list can be updated by re initialize sounddevice
@mgeier
Copy link
Member

mgeier commented Dec 30, 2023

# is it possible to close the dll when sd._terminate()
# and reopen the dll when sd._initialize()

Yes, I guess it would be possible, but the idea is that those two functions wrap the PortAudio functions Pa_Terminate() and Pa_Initialize(), respectively.

If additional functionality is desired, additional functions should be created.

But if the sequence of statements you mentioned is working for you, feel free to just use them in your code.


Related: #125, #343, #382.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants