Skip to content

Instantly share code, notes, and snippets.

@perexg
Created September 19, 2022 12:46
Show Gist options
  • Save perexg/4977fcb33101148e578c34bd25db8ce4 to your computer and use it in GitHub Desktop.
Save perexg/4977fcb33101148e578c34bd25db8ce4 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <alsa/asoundlib.h>
static void open_pcm(const char *card, const char *dev)
{
char name[128];
snd_pcm_t *handle;
int err;
snprintf(name, sizeof(name), "hw:%s,%s", card, dev);
err = snd_pcm_open(&handle, name, SND_PCM_STREAM_PLAYBACK, 0);
printf("PCM - %s - %d (%s)\n", name, err, snd_strerror(err));
}
int main(int argc, char *argv[])
{
const char *card;
if (argc > 1) {
const char *card = argv[1];
open_pcm(card, "10");
open_pcm(card, "9");
open_pcm(card, "8");
open_pcm(card, "7");
open_pcm(card, "3");
} else {
printf("Specify card...\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment