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

add al_set_audio_output_device for audio output device selection #1542

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

aldrik-ramaekers
Copy link
Contributor

Currently only implemented on dsound and aqueue backend. I also extended ex_audio_simple for easy testing.

@SiegeLord
Copy link
Member

Thanks!

It looks like for AQueue all the voices remain valid, but what about DirectSound? I see you re-create it for the default voice, but what about the others? Maybe we should maintain a vector of voices to update them. I'll take a look at what the other backends can handle (although I'm sure re-creating the voices works no matter what).

@aldrik-ramaekers
Copy link
Contributor Author

aldrik-ramaekers commented Mar 13, 2024

It would also be possible to let the user specify the voice to update e.g al_set_audio_output_device_for_voice(device, voice).
This would make sense because according to the docs a voice represents an audio device on the system.

@SiegeLord
Copy link
Member

That would certainly be ideal, if it's possible, but we'd need to investigate that it's an option for all backends.

@aldrik-ramaekers
Copy link
Contributor Author

Just glancing at the code dsound, aqueue and SDL2 backend will only require minor changes.

for PulseAudio & ALSA the buffer fill routine seems to not lock mutex while writing so might have to do something like stop voice -> block main thread untill routine stopped -> set new handle & params -> start voice

openal, opensl, oss do not have device iteration yet so not looking at it for now.

recreating the voice is probably the easiest way to go, but at that point you might as well just let the user call a function like al_create_voice_with_output_device and scrap al_set_audio_output_device_for_voice.

user code would then look something like:

voice = al_create_voice_with_output_device(device)
al_attach_mixer_to_voice(al_get_default_mixer(), voice)
al_set_default_voice(voice)

I'm fine with both methods

@aldrik-ramaekers aldrik-ramaekers marked this pull request as draft March 19, 2024 21:44
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

Successfully merging this pull request may close these issues.

2 participants