Hello Guest

How to enumerate available sound-renderers

  • 7 Replies
  • 17485 Views
How to enumerate available sound-renderers
« on: May 01, 2005, 10:04:54 »
OpenGL can enumerate DisplayModes,
OpenAL can't enumerate sound-renderers?

Hardcoding in AL.create(String, int, int, boolean) isn't really a
solution and usually ends up targeting the software-driver on
every system, except the dev's.

I might have missed something... maybe :wink:

How to enumerate available sound-renderers
« Reply #1 on: February 02, 2006, 12:54:10 »
Hej Skippy0,

the enumeration of available sound devices(renderers) is switched off by the current implementation on LWJGL. That is because the ALC.alcGetString(int i) always uses the current device. Here's line 167 from ALC.java:
Code: [Select]

String result = nalcGetString(AL.device.device, pname);


If one could pass 0 as the first parameter, the returned value would be the enumeration encoded in one string. Here's some C code from SDK (aldlist.cpp from the Framework sample):
Code: [Select]

char *devices;
devices = (char *)ALFunction.alcGetString(NULL,ALC_DEVICE_SPECIFIER);
// go through device list (each device terminated with a single NULL, list terminated with double NULL)
while (*devices != NULL) {
  ALCdevice *device = ALFunction.alcOpenDevice(devices);
  if (device) {
    ALFunction.alcMakeContextCurrent(context);
    // if new actual device name isn't already in the list, then add it...
    actualDeviceName = ALFunction.alcGetString(device, ALC_DEVICE_SPECIFIER);
    ...
  }
  ...
}


You didn't miss something, LWJGL is missing something. :)

Cheers,
Sormuras


Edit: Fixed typos and added more source details.

*

Offline Matzon

  • *****
  • 2242
How to enumerate available sound-renderers
« Reply #2 on: February 02, 2006, 13:25:35 »
the problem is that we can't support the function in an exact context, since they implemented it in a hack'ish way.

They seperate the different suppliers by using \0 as the seperator (usually the end of string seperator). So if you call the fucntion you will always only get the first supplier back.
The only way to fix this - which no one has needed before - is to create an entirely new lwjgl-specific OpenAL method that returns the implementers as an array of strings...

How to enumerate available sound-renderers
« Reply #3 on: February 02, 2006, 13:56:38 »
Hi Matzon!

Yes, the way "they" return the list is ... c-stylish. That's a good example why I prefer hacking in Java. :)

On topic. At least Skippy0 and me need that enumration. And to add another analogy next to the one with GLs display modes, take the java.io package that enumerates all NICs - because sometimes, you want the end-user of your application to choose the screen resolution, the NIC(IP address) to bind a service to and regarding OpenAL, you want to offer all available sound devices.

+1 for enumerating all sound device names in a clean String[] like you suggested.

How to enumerate available sound-renderers
« Reply #4 on: February 02, 2006, 18:01:47 »
That would be really cool to have that implemented.

I have a onBoard Sound additional to my SB Live! and like to have the possibility to change the device that is used for sound playback.

How to enumerate available sound-renderers
« Reply #5 on: February 02, 2006, 22:02:26 »
Counting all - non ever needed this - we have a +3... :)

*

Offline Matzon

  • *****
  • 2242
How to enumerate available sound-renderers
« Reply #6 on: February 02, 2006, 22:58:03 »
I am on it - already comitted to cvs - just looking into rewriting it a bit to use less native code.

new method is String[] AL.getImplementations()

How to enumerate available sound-renderers
« Reply #7 on: February 03, 2006, 04:32:00 »
Quote from: "Matzon"
new method is String[] AL.getImplementations()


Danke!  :D