Exemplo n.º 1
0
Arquivo: midi.c Projeto: huangjs/cl
char *mus_midi_describe(void) 
{
  int i, err;
  snd_rawmidi_t *line;
  snd_rawmidi_info_t *info;
  char *buf = NULL;
  char one[256];
  snd_rawmidi_info_malloc(&info);
  buf = (char *)CALLOC(1024, sizeof(char));
  for (i = 0; i < 8; i++)
    {
      /* presumably this should use the card|device from the info struct, not a blind loop */
      err = snd_rawmidi_open(&line, NULL, mus_midi_device_name(i << 16), SND_RAWMIDI_NONBLOCK); /* do the "devices" matter here? */
      if (err < 0) continue;
      err = snd_rawmidi_info(line, info);
      if (err < 0) break;
      sprintf(one, "%s: card: %d, device: %d, stream: %d, flags: %x, id: %s, name: %s[%s; %d]\n",
	      mus_midi_device_name(i << 16),
	      snd_rawmidi_info_get_card(info),    /* card number */
	      snd_rawmidi_info_get_device(info),  /* device number */
	      snd_rawmidi_info_get_stream(info),  /* snd_rawmidi_stream_t */
	      snd_rawmidi_info_get_flags(info),   /* 1=out 2=in 4=dupex */
	      snd_rawmidi_info_get_id(info),      /* hardware id (out in?) */
	      snd_rawmidi_info_get_name(info),
	      snd_rawmidi_info_get_subdevice_name(info),
	      snd_rawmidi_info_get_subdevices_count(info));
      strcat(buf, one);
    }
  snd_rawmidi_info_free(info);
  return(buf);
}
Exemplo n.º 2
0
static
void alsa_get_id(alsa_id_t *id, snd_rawmidi_info_t *info)
{
    id->id[0] = snd_rawmidi_info_get_card(info);
    id->id[1] = snd_rawmidi_info_get_device(info);
    id->id[2] = snd_rawmidi_info_get_stream(info) == SND_RAWMIDI_STREAM_OUTPUT ? 1 : 0;
    id->id[3] = snd_rawmidi_info_get_subdevice(info);
}