#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <alsa/asoundlib.h> #define NL "\r\n" void get_alsa_midi_cards(void) { int card, status, cnt; int code; char *card_name; int i; card = -1; // use -1 to prime the pump of iterating through card list status = snd_card_next(&card); if (status < 0 || card < 0) {printf ("Content-Type: text/html; charset=utf-8" NL "Cache-Control: no-cache" NL NL);
printf("{\"alsa_midi_card\":[]}"); //printf("Status: %i Card: %i", status, card); //printf("Status: 404 Not Found" NL NL); return; }printf ("Content-Type: text/html; charset=utf-8" NL "Cache-Control: no-cache" NL NL);
printf("{\"alsa_midi_card\":["); for (i = 0, cnt = 0; card >= 0; i++) { if ((code = snd_card_get_longname (card, &card_name)) < 0) continue; if (cnt++ > 0) printf(","); printf("{\"longname\":\""); printf(card_name); printf("\"}"); if ((status = snd_card_next (&card)) < 0) break; } printf("]}"); } int main (int argc, char *argv[]) { get_alsa_midi_cards(); return 0; } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx