bastibe/PySoundCard

Implement reinitialization function

Opened this issue · 4 comments

A reinitialization function would help to refresh the device/api list if they changed during running pysoundcard.
My workaround until now:

pysoundcard._pa.Pa_Terminate()
pysoundcard._py.Pa_Initialize()
devlist = list(pysoundcard.devices())

Absolutely!

I also need this if I want to switch between ALSA and JACK.
In this case, re-initialization alone (in one step) isn't enough, I'd also need a way to call "terminate" first, then I would start the JACK daemon, and then I would call the (re-)initialization function.

Any ideas for function names?

Why not just:

pysoundcard.terminate_portaudio()
pysoundcard.initialize_portaudio()

so the user can handle both kinds of problems without digging into ._pa namespace.

A few more options for brainstorming:

pysoundcard.terminate()
pysoundcard.initialize()

... would be a little less verbose.

The names might suggest that a user has to manually initialize and terminate each session, which is of course not the case.

These two might avoid this problem:

pysoundcard.unload()
pysoundcard.reload()  # this should include unloading

Any more suggestions/comments?

The downside of reload is that it doesn't clearly say that it is closing all streams. Something like reset or terminate is a little clearer about that.