Skip to content
Permalink
Browse files

Some systems include both "default:" and "hw:" for the same usb device

  • Loading branch information
slouken committed Oct 7, 2016
1 parent 8e19946 commit 3b0c79363ddb16c88c0b9f4ec1a97f648f2c610c
Showing with 22 additions and 2 deletions.
  1. +22 −2 src/audio/alsa/SDL_alsa_audio.c
@@ -771,16 +771,36 @@ ALSA_HotplugThread(void *arg)
ALSA_Device *seen = NULL;
ALSA_Device *prev;
int i;
const char *match = "default:";
size_t match_len = strlen(match);

/* determine what kind of name to match. Use "hw:" devices if they
exist, otherwise use "default:" */
for (i = 0; hints[i]; i++) {
char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
if (!name) {
continue;
}

if (SDL_strncmp(name, "hw:", 3) == 0) {
match = "hw:";
match_len = strlen(match);
free(name);
break;
}

free(name);
}

/* look through the list of device names to find matches */
for (i = 0; hints[i]; i++) {
char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
if (!name) {
continue;
}

/* only want physical hardware interfaces */
if (SDL_strncmp(name, "hw:", 3) == 0 ||
SDL_strncmp(name, "default:", 8) == 0) {
if (SDL_strncmp(name, match, match_len) == 0) {
char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID");
const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0);
const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0);

0 comments on commit 3b0c793

Please sign in to comment.