0
0

The default sound card as defined by ~/.asoundrc.

My PC has a bog standard AC’97 sound card. I recently purchased a USB headset. The headset is represented (to ALSA) as card 1.

[code:2gv1nt8e]

.asoundrc

set defaults.pcm.card 1
[/code:2gv1nt8e]

This works for all the other apps I have (using OpenAL, SDL_Mixer compiled for ALSA, gstreamer, etc) but FMOD apps that initialise using system->setDriver(0) (or the equivalent, by not calling setDriver at all) still defaults to card 0 (the AC’97 onboard card).
Here is the smallest app I could write that reproduces this problem:

[code:2gv1nt8e]
// fmodplay.cpp: plays a sound file specified as an argument.

include <cstdlib>

include <cstdio>

include <fmod.hpp>

extern "C" {

include <unistd.h>

include <fmod_errors.h>

}

void errcheck(FMOD_RESULT result)
{
if (result != FMOD_OK) {
fprintf(stderr, "FMOD error %d: %s\n", result, FMOD_ErrorString(result));
exit(EXIT_FAILURE);
}
}

int main(int argc, char** argv)
{
if (argc < 2) {
fprintf(stderr, "Usage: fmodplay [filename]\n");
return EXIT_FAILURE;
}

FMOD::System* system = NULL;
FMOD_RESULT result = FMOD::System_Create(&amp;system);
errcheck(result);

result = system-&gt;setOutput(FMOD_OUTPUTTYPE_ALSA);
errcheck(result);

/* 
 * Docs say 0 should choose 'the default as chosen by the OS'.
 * This still chooses card 0, even though card 1 is set as default
 * in .asoundrc (defaults.pcm.card 1). 
 */
result = system-&gt;setDriver(0);
errcheck(result);

result = system-&gt;init(32, FMOD_INIT_NORMAL, 0);
errcheck(result);

FMOD::Sound* sound = NULL;
result = system-&gt;createSound(argv[1], FMOD_SOFTWARE, NULL, &amp;sound);
errcheck(result);
result = sound-&gt;setMode(FMOD_LOOP_OFF);
errcheck(result);

bool playing = true;
FMOD::Channel *channel = NULL;
result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound, false, &amp;channel);
errcheck(result);
do {
    result = channel-&gt;isPlaying(&amp;playing);
    system-&gt;update();
    sleep(10);
} while (playing);

result = sound-&gt;release();
errcheck(result);
result = system-&gt;close();
errcheck(result);
result = system-&gt;release();
errcheck(result);

return EXIT_SUCCESS;

}
[/code:2gv1nt8e]

Work arounds include using OSS and going through aoss, or disabling the on-board through the BIOS. Is this something I’ve setup wrong (with my code, or ALSA), or an oddity of my setup (the headset is a Microsoft LifeChat LX-3000 or something close to that).

Thanks for any help.

  • You must to post comments
0
0

Hmmm, I just took a look at the enumeration code for ALSA, I can see a potential problem. Could you use System::getNumDrivers and System::getDriverInfo to print out a list of all the devices on your machine and post it here on the forum. Hopefully the output will confirm my hunch.

  • You must to post comments
0
0

Certainly.

[code:3fhcwnnm]
0: default:CARD=I82801BAICH2
1: front:CARD=I82801BAICH2,DEV=0
2: surround40:CARD=I82801BAICH2,DEV=0
3: surround41:CARD=I82801BAICH2,DEV=0
4: surround50:CARD=I82801BAICH2,DEV=0
5: surround51:CARD=I82801BAICH2,DEV=0
6: iec958:CARD=I82801BAICH2,DEV=0
7: default:CARD=default
8: front:CARD=default,DEV=0
9: surround40:CARD=default,DEV=0
10: surround41:CARD=default,DEV=0
11: surround50:CARD=default,DEV=0
12: surround51:CARD=default,DEV=0
13: iec958:CARD=default,DEV=0
14: cards
15: rear
16: center_lfe
17: side
18: surround71
19: spdif
20: hdmi
21: dmix
22: dsnoop
23: modem
24: phoneline
25: hw
26: plughw
27: plug
28: shm
29: tee
30: file
31: null
[/code:3fhcwnnm]

Driver 7 is the default card.

  • You must to post comments
0
0

Okay cool, that is what I expected to see, thanks for the output.

There should be an entry at the top of the list called "default", but because you have two cards with default entries "default:CARD=I82801BAICH2" and "default:CARD=default" they are overriding that global default. It’s the difference between the default output for the system and the default output for each card.

I will have this fixed up for our next release, which should be towards the end of the week.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.