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

Crash at startup on Linux when searching for an ALSA device #127

Open
iamgreaser opened this issue Jan 3, 2018 · 3 comments
Open

Crash at startup on Linux when searching for an ALSA device #127

iamgreaser opened this issue Jan 3, 2018 · 3 comments
Labels

Comments

@iamgreaser
Copy link

@iamgreaser iamgreaser commented Jan 3, 2018

I have a setup which works fine as long as whatever you're using uses the default device and makes no attempt whatsoever to try to steal the sound card.

Regardless, it seems to be doing exactly what it should not be doing.

ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave

My setup's a bit odd. I have a 5.1 JACK setup and two methods for getting stereo ALSA routed to JACK (loopback bridge + raw JACK plugin). I have tried both approaches and both break.

Are you able to force the audio system to use default on ALSA?

@PleasingFungus

This comment has been minimized.

Copy link
Owner

@PleasingFungus PleasingFungus commented Jan 3, 2018

Hm, that sounds like a Linux crash bug, all right! I've reached out to my local Linux expert - hopefully he'll have some advice.

@amonakov

This comment has been minimized.

Copy link

@amonakov amonakov commented Jan 5, 2018

See also #114 (FMOD Studio ALSA backend bug). It seems it doesn't properly choose the default device.

@amonakov

This comment has been minimized.

Copy link

@amonakov amonakov commented Jan 6, 2018

... although judging from the (lack of meaningful) response to the previous bug, we might as well take it in our own hands.

The following LD_PRELOAD hack can be used to override FMOD's default device selection. Normally it just dumps the list of output devices found by FMOD to stdout, but when FMODSUX_SETDRIVER environment variable is set, it will use its value to set FMOD output device.

It works for me as a workaround for #114 — please try if it helps in your case as well.

// gcc -shared -fpic -Os -o /tmp/Si0s.so this.c -ldl
#define _GNU_SOURCE 1
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>

int FMOD_System_GetNumDrivers(void *, int *);
int FMOD_System_GetDriverInfo(void *, int, char *, int, void *, int *, int *, int *);
int FMOD_System_SetDriver(void *, int);

int FMOD_System_Create(void** sys)
{
  __typeof(FMOD_System_Create) *real_create = dlsym(RTLD_NEXT, "FMOD_System_Create");
  if (!real_create) {
    fprintf(stderr, "dlsym: %s\n", dlerror());
    abort();
  }
  int ret, drv, numdrv;
  if ((ret = real_create(sys)))
    return ret;
  const char *drvstr = getenv("FMODSUX_SETDRIVER");
  if (drvstr && sscanf(drvstr, "%d", &drv) == 1)
    FMOD_System_SetDriver(*sys, drv);
  else if (!FMOD_System_GetNumDrivers(*sys, &numdrv))
    for (drv = 0; drv < numdrv; drv++) {
      char namebuf[50];
      int rate, mode, nch;
      if (!FMOD_System_GetDriverInfo(*sys, drv, namebuf, sizeof namebuf, 0, &rate, &mode, &nch))
	printf("%2d: mode %d, %d/%dch: %s\n", drv, mode, rate, nch, namebuf);
    }
  return 0;
}

Edited to add: credit goes to @SolraBizna for posting a similar hack for Don't Starve back in 2013. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.