First enumerate all internal devices and then external midi ports.

This commit is contained in:
Christian Costa 2003-12-08 21:46:50 +00:00 committed by Alexandre Julliard
parent 3114368152
commit 1469cf58f3
1 changed files with 120 additions and 96 deletions

View File

@ -957,51 +957,14 @@ static DWORD modReset(WORD wDevID)
return MMSYSERR_NOERROR;
}
#endif /* defined(HAVE_ALSA) && ((SND_LIB_MAJOR == 0 && SND_LIB_MINOR >= 9) || SND_LIB_MAJOR >= 1) */
/*======================================================================*
* MIDI entry points *
*======================================================================*/
/**************************************************************************
* ALSA_MidiInit [internal]
* ALSA_AddMidiPort [internal]
*
* Initializes the MIDI devices information variables
* Helper for ALSA_MidiInit
*/
LONG ALSA_MidiInit(void)
void ALSA_AddMidiPort(snd_seq_client_info_t* cinfo, snd_seq_port_info_t* pinfo, int cap, int type)
{
#if defined(HAVE_ALSA) && ((SND_LIB_MAJOR == 0 && SND_LIB_MINOR >= 9) || SND_LIB_MAJOR >= 1)
static BOOL bInitDone = FALSE;
snd_seq_client_info_t *cinfo;
snd_seq_port_info_t *pinfo;
int count;
if (bInitDone)
return TRUE;
TRACE("Initializing the MIDI variables.\n");
bInitDone = TRUE;
/* try to open device */
if (midiOpenSeq(0) == -1) {
return TRUE;
}
#if 0 /* Debug purpose */
snd_lib_error_set_handler(error_handler);
#endif
snd_seq_client_info_alloca(&cinfo);
snd_seq_port_info_alloca(&pinfo);
snd_seq_client_info_set_client(cinfo, -1);
while(snd_seq_query_next_client(midiSeq, cinfo) >= 0) {
snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
snd_seq_port_info_set_port(pinfo, -1);
count = 0;
while (snd_seq_query_next_port(midiSeq, pinfo) >= 0) {
int cap = snd_seq_port_info_get_capability(pinfo);
int type = snd_seq_port_info_get_type(pinfo);
if (cap & SND_SEQ_PORT_CAP_WRITE) {
TRACE("OUT (%d:%s:%s:%d:%s:%x)\n",snd_seq_client_info_get_client(cinfo),
snd_seq_client_info_get_name(cinfo),
@ -1011,9 +974,9 @@ LONG ALSA_MidiInit(void)
type);
if (MODM_NumDevs >= MAX_MIDIOUTDRV)
continue;
return;
if (!type)
continue;
return;
memcpy(&MidiOutDev[MODM_NumDevs].addr, snd_seq_port_info_get_addr(pinfo), sizeof(snd_seq_addr_t));
@ -1053,7 +1016,6 @@ LONG ALSA_MidiInit(void)
MidiOutDev[MODM_NumDevs].caps.wChannelMask, MidiOutDev[MODM_NumDevs].caps.dwSupport,
(long)type, (long)0);
MODM_NumDevs++;
}
if (cap & SND_SEQ_PORT_CAP_READ) {
@ -1065,9 +1027,9 @@ LONG ALSA_MidiInit(void)
type);
if (MIDM_NumDevs >= MAX_MIDIINDRV)
continue;
return;
if (!type)
continue;
return;
memcpy(&MidiInDev[MIDM_NumDevs].addr, snd_seq_port_info_get_addr(pinfo), sizeof(snd_seq_addr_t));
@ -1097,6 +1059,68 @@ LONG ALSA_MidiInit(void)
MIDM_NumDevs++;
}
}
#endif /* defined(HAVE_ALSA) && ((SND_LIB_MAJOR == 0 && SND_LIB_MINOR >= 9) || SND_LIB_MAJOR >= 1) */
/*======================================================================*
* MIDI entry points *
*======================================================================*/
/**************************************************************************
* ALSA_MidiInit [internal]
*
* Initializes the MIDI devices information variables
*/
LONG ALSA_MidiInit(void)
{
#if defined(HAVE_ALSA) && ((SND_LIB_MAJOR == 0 && SND_LIB_MINOR >= 9) || SND_LIB_MAJOR >= 1)
static BOOL bInitDone = FALSE;
snd_seq_client_info_t *cinfo;
snd_seq_port_info_t *pinfo;
if (bInitDone)
return TRUE;
TRACE("Initializing the MIDI variables.\n");
bInitDone = TRUE;
/* try to open device */
if (midiOpenSeq(0) == -1) {
return TRUE;
}
#if 0 /* Debug purpose */
snd_lib_error_set_handler(error_handler);
#endif
snd_seq_client_info_alloca(&cinfo);
snd_seq_port_info_alloca(&pinfo);
/* First, search for all internal midi devices */
snd_seq_client_info_set_client(cinfo, -1);
while(snd_seq_query_next_client(midiSeq, cinfo) >= 0) {
snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
snd_seq_port_info_set_port(pinfo, -1);
while (snd_seq_query_next_port(midiSeq, pinfo) >= 0) {
int cap = snd_seq_port_info_get_capability(pinfo);
int type = snd_seq_port_info_get_type(pinfo);
if (type != SND_SEQ_PORT_TYPE_MIDI_GENERIC)
ALSA_AddMidiPort(cinfo, pinfo, cap, type);
}
}
/* Second, search for all external ports */
snd_seq_client_info_set_client(cinfo, -1);
while(snd_seq_query_next_client(midiSeq, cinfo) >= 0) {
snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
snd_seq_port_info_set_port(pinfo, -1);
while (snd_seq_query_next_port(midiSeq, pinfo) >= 0) {
int cap = snd_seq_port_info_get_capability(pinfo);
int type = snd_seq_port_info_get_type(pinfo);
if (type == SND_SEQ_PORT_TYPE_MIDI_GENERIC)
ALSA_AddMidiPort(cinfo, pinfo, cap, type);
}
}