+ name = getenv("ALSA_NAME");
+ if (name != NULL)
+ alsa_name = name;
+
+ snd_ctl_card_info_alloca(&info);
+ if ((err = snd_ctl_open(&ctl_handle, alsa_name, 0)) < 0) {
+ printf("control open: %s\n", snd_strerror(err));
+ }
+ else if ((err = snd_ctl_card_info(ctl_handle, info)) < 0) {
+ printf("control info: %s\n", snd_strerror(err));
+ snd_ctl_card_info_clear(info);
+ }
+ if (ctl_handle != NULL)
+ snd_ctl_close(ctl_handle);
+
+ name = snd_ctl_card_info_get_name(info);
+ if (name != NULL) {
+ if (strcasecmp(name, "PulseAudio") == 0) {
+ // PulseAudio's ALSA emulation is known to be broken..
+ printf("alsa: refusing to run under PulseAudio's emulation\n");
+ return -1;
+ }
+ else {
+ printf("alsa: using '%s', set ALSA_NAME to change\n", name);
+ }
+ }
+