Description
Issue №2496 opened by Starbuck5 at 2021-02-21 10:39:48
Looking at issue #2493 was interesting for me, I didn't know pygame and SDL had that capability! It was cool to play audio out of my monitor speakers when listening to music on headphones, I didn't even know that was possible.
That being said, the interface to do it could be improved.
The current interface:
sdl2.get_num_audio_devices(int iscapture) -> int
sdl2.get_audio_device_name(int index, int iscapture) -> bytes #needs to be encoded into a string in python 3
You also have to initialize pygame to have those functions work, then quit mixer and reinitialize with the device_name you've gotten, since calling mixer.init()
with a new device does nothing.
Proposed Additions:
mixer.get_device_names(bool iscapture = False) -> [str...]
I think this is a good way to bring it more into being more 'pythonic,' also nobody should be getting bytes instead of strings in 2021. (Can we do an #if PY3 to return native strings on python 2 and 3?)
mixer.init(devicename = "different than last time")
Reinitializing mixer with a different device name should cause mixer to close the old device, and open the new one.
I'd like to work on this, but I also wanted to put it out there for feedback first.
Edit: Turns out I hadn't read the OG issue for this, #627. This enhancement would help smooth out illume's points in section 1, about selecting device names.