0
101 Mar 19, 2004 at 06:54

I don’t know how I can choose an other output sound card than the primary sound device.
Is it possible to choose the secondary sound card with the function alcOpenDevice()
or is it an other function which could allow to play a sound on the sound card of my choice either the primary sound card either the secondary sound card.

#### 6 Replies

0
101 Mar 20, 2004 at 16:11

To be honest, from my experience, I dont think you can. I had a good look at the OpenAL spec’s, and as far as I can tell, using alcOpenDevice(…) selects the device that is most suited to the method you have choosen. It doesnt specifiy wether multiple calls to alcOpenDevice(…) selects another sound device, or just uses the same one.

It might be worth looking at OpenGL (this is a total shot in the dark, so I may be totally wrong here) and seeing if you can select different display devices. If you can, you might be able to use a similar method in AL. But as I said, thats a shot in the dark…

Sorry I couldnt be more help
Spree

0
101 Mar 20, 2004 at 19:00

you can’t do that with opengl

0
101 Mar 22, 2004 at 11:16

I did say it was a shot in the dark, oh well ;)

Just reading the OpenAL mailing lists, and the same question came up. So I guess it can be done! :)

Here is one of the responses

“altest” in openal/demos/altest/common/altest.cpp.  During
initialization, you’ll see a reference to enumeration – that section
will show you how to use the context enumeration extension to enumerate
the various “devices” on your system.

These “devices” do not necessarily correspond with sound cards,
however.  For instance, I have a computer at work with an NVIDIA
nForce2 and a Creative Audigy 2 in it.  The devices enumerate and will
play back as follows:

Device Name / playback device
MMSYSTEM / whatever is the “preferred audio device” selected for Windows
DirectSound / “preferred audio device” as with MMSYSTEM
DirectSound3D / “preferred audio device” as with MMSYSTEM
NVIDIA nForce2 / always will play back on the nForce 2
Creative Audigy 2 / always will play back on the Audigy 2

On your system, if you have an nForce2 and a Creative card, then you’ll
see explicit entries for those two cards on your device list.  Any card
that doesn’t have its own accelerated OpenAL implementation will have
to be selected by using one of the generic devices, which will follow
the “preferred audio device” selection in Windows.

Bare in mind that the DirectSound3D enumeration has a few bugs associated with it, so at the moment, out of the 3 standard devices, DirectSound is probably the best bet

Hope that helps some
Spree

0
101 Mar 23, 2004 at 04:14

I have tried what the guy has tell but it seems only working
with nForce2 and Creative audigy sound card….
and I don’t have any of these sound card….
If anyone has a solution with other type of soundcard

0
101 Mar 23, 2004 at 09:35

Haha thought it might have been, but thought I’d post it anyway ;)

Spree

0
101 Sep 03, 2004 at 14:32

Sth like this to detect all devices

const alDeviceList* sound::getDeviceList (bool refresh)
{
if (devList.numDevices==0 || refresh)
{
char deviceName[256] = {0};
char *defaultDevice=NULL;
char *deviceList=NULL;

if (alcIsExtensionPresent(NULL, (ALubyte*)"ALC_ENUMERATION_EXT") == AL_TRUE)
{ // try out enumeration extension
deviceList = (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER);

devList.numDevices = 0;
if (strlen(deviceList))
{
devList.numDevices=1;
defaultDevice = (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
devList.numDefaultDevice = 0;

for (U16 numDevices = 0; numDevices < 16; numDevices++)
{
devList.devices[numDevices] = deviceList;
if (defaultDevice && strcmp(devList.devices[numDevices], defaultDevice) == 0)
{
devList.numDefaultDevice = numDevices;
}

deviceList += strlen(deviceList);

if (deviceList[0] == 0)
{
if (deviceList[1] == 0)
{
break;
}
else
{
devList.numDevices++;
deviceList++;
}
}
}
}
}
}
return &devList;
}


and then sth like this - mind you, only tested on sb-audigy,
switching sound without exiting the game also works (although
old sound will be stopped so you will only hear new sounds):

bool sound::useDevice    (U16 id)
{
bool result = false;
const char* devname = getDeviceName (id);

// terminate old device + context
destroyBuffers();

alcMakeContextCurrent(NULL);
if (pDevice)
alcCloseDevice(pDevice);
if (pContext)
alcDestroyContext(pContext);

// open
if (id<SOUND_AL_MAXDEVICE)
{
// open specified device
pDevice  = alcOpenDevice((unsigned char*)devList.devices[id]);
devList.curDevice = id;
pContext = alcCreateContext(pDevice, NULL);
alcMakeContextCurrent(pContext);
initBuffers();
result=true;
}
else
{
// open default device
pDevice  = alcOpenDevice(NULL);
devList.curDevice = devList.numDefaultDevice;
pContext = alcCreateContext(pDevice, NULL);
alcMakeContextCurrent(pContext);
initBuffers();
result=true;
}

alDistanceModel (AL_NONE); // or whatever distanceModel you like

return result;
}


Note that you’ll probably need some locks to avoid threading problems