API to list available audio devices
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Is your feature request related to a problem? Please describe.
Yes, I need to send audio data to other audio output devices from the game. And I can't find any API that list the devices in the documentation or the source code. So far the documentation that I've found is only setting the output device for VR device, which using return value from the VR API.
Describe the solution you'd like
There should be an API for programmers to list available audio devices, and since there is an API to create an audio device handle using only it's device name, it should be suffice that the method is only returning string list of audio device names that the programer can use, and if the platform does not support this, return empty list or there should be a support-check method for it. And maybe also an event for output device connection and reconnection?
for OpenAL platforms
- Audio device listing support can be checked by using the return value of
alcIsExtensionPresent(NULL, "ALC_enumerate_all_EXT")oralcIsExtensionPresent(NULL, "ALC_enumeration_EXT") - List of names (or specifiers) can be processed from the return value of
alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER)oralcGetString(nullptr, ALC_DEVICE_SPECIFIER).
for other platforms
I haven't practically use other audio backend other than OpenAL, but from what I've read from OpenSL ES 1.0.1 spec section C.2.2 Sample Code, this requested API should be possible to implement with OpenSL ES too.
Additional context
What are the usecases?
My intention is for DualSense haptic feedback, that uses it's rear stereo channel as it's vibration data. Another use case I can think of is letting player to choose which output device they want to hear the game audio from.
What would the (pseudo) code look like?
if(AudioLayer.SupportsOutputDeviceQuery){
List<string> devices = AudioLayer.GetOutputDevices();
foreach(string dev in devices){
if(dev.Contains("Wireless Controller")){
Audio.RequestedAudioDevice = new AudioDevice() { name = dev };
break;
}
}
}
What kind of documentation is needed or needs to be updated?
Documentation for this API
Should there be an example project?
Yes, the example project should demonstrate playing audio from selected audio devices presented in UI.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the AudioLayer and AudioDevice APIs referenced in the request, then compare the OpenAL and other audio-backend paths for existing device-selection support. Done means an agreed cross-platform device-listing design, implementation scope, documentation, and the requested example project are specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100