From 4fdda4e51e1d548b1912dc46a2919efeaec4b54b Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 8 Aug 2007 08:04:53 +0000 Subject: [PATCH] Query port 17:0 as well as default port Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2953 --- src/gui/midi_alsa.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gui/midi_alsa.h b/src/gui/midi_alsa.h index 475a2082..f9aae8a2 100644 --- a/src/gui/midi_alsa.h +++ b/src/gui/midi_alsa.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: midi_alsa.h,v 1.16 2007-06-14 08:23:46 qbix79 Exp $ */ +/* $Id: midi_alsa.h,v 1.17 2007-08-08 08:04:53 qbix79 Exp $ */ #define ALSA_PCM_OLD_HW_PARAMS_API #define ALSA_PCM_OLD_SW_PARAMS_API @@ -125,7 +125,8 @@ public: bool Open(const char * conf) { char var[10]; unsigned int caps; - + bool defaultport = true; //try 17:0 as well. Seems to be default nowadays + // try to use port specified in config file if (conf && conf[0]) { safe_strncpy(var, conf, 10); @@ -133,6 +134,7 @@ public: LOG_MSG("ALSA:Invalid alsa port %s", var); return false; } + defaultport = false; } // default port if none specified else if (parse_addr("65:0", &seq_client, &seq_port) < 0) { @@ -153,8 +155,8 @@ public: if (seq_client == SND_SEQ_ADDRESS_SUBSCRIBERS) caps = ~SND_SEQ_PORT_CAP_SUBS_READ; my_port = - snd_seq_create_simple_port(seq_handle, "DOSBOX", caps, - SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION); + snd_seq_create_simple_port(seq_handle, "DOSBOX", caps, + SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION); if (my_port < 0) { snd_seq_close(seq_handle); LOG_MSG("ALSA:Can't create ALSA port"); @@ -164,9 +166,18 @@ public: if (seq_client != SND_SEQ_ADDRESS_SUBSCRIBERS) { /* subscribe to MIDI port */ if (snd_seq_connect_to(seq_handle, my_port, seq_client, seq_port) < 0) { - snd_seq_close(seq_handle); - LOG_MSG("ALSA:Can't subscribe to MIDI port (%d:%d)", seq_client, seq_port); - return false; + if (defaultport) { //if port "65:0" (default) try "17:0" as well + seq_client = 17; seq_port = 0; //Update reported values + if(snd_seq_connect_to(seq_handle,my_port,seq_client,seq_port) < 0) { + snd_seq_close(seq_handle); + LOG_MSG("ALSA:Can't subscribe to MIDI port (65:0) nor (17:0)"); + return false; + } + } else { + snd_seq_close(seq_handle); + LOG_MSG("ALSA:Can't subscribe to MIDI port (%d:%d)", seq_client, seq_port); + return false; + } } }