Skip to content

Commit

Permalink
Some systems include both "default:" and "hw:" for the same usb device
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Oct 7, 2016
1 parent 8e19946 commit 3b0c793
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/audio/alsa/SDL_alsa_audio.c
Expand Up @@ -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);
Expand Down

0 comments on commit 3b0c793

Please sign in to comment.