Ticket #8898: alsa.diff

File alsa.diff, 4.8 KB (added by eriktorbjorn, 12 years ago)

Patch against current SVN (trunk)

  • README

     
    13221322
    132313237.6.1) Playing sound with ALSA sequencer:                        [UNIX ONLY]
    13241324------ ----------------------------------
    1325 If you have installed the ALSA driver with the sequencer support, then
    1326 set the environment variable SCUMMVM_PORT or the config file parameter
    1327 alsa_port to your sequencer port. The default is "65:0".
     1325If you have installed the ALSA driver with the sequencer support, then set the
     1326environment variable SCUMMVM_PORT or the config file parameter alsa_port to
     1327your sequencer port. The default is to try both "65:0" and "17:0".
    13281328
    13291329Here is a little howto on how to use the ALSA sequencer with your soundcard.
    13301330In all cases, to have a list of all the sequencer ports you have, try the
    13311331command "aconnect -o -l". This should give output similar to:
    1332 client 64: 'External MIDI 0' [type=kernel]
    1333     0 'MIDI 0-0        '
    1334 client 65: 'Emu10k1 WaveTable' [type=kernel]
     1332
     1333client 14: 'Midi Through' [type=kernel]
     1334    0 'Midi Through Port-0'
     1335client 16: 'SBLive! Value [CT4832]' [type=kernel]
     1336    0 'EMU10K1 MPU-401 (UART)'
     1337client 17: 'Emu10k1 WaveTable' [type=kernel]
    13351338    0 'Emu10k1 Port 0  '
    13361339    1 'Emu10k1 Port 1  '
    13371340    2 'Emu10k1 Port 2  '
    13381341    3 'Emu10k1 Port 3  '
    1339 client 128: 'Client-128' [type=user]
     1342client 128: 'TiMidity' [type=user]
    13401343    0 'TiMidity port 0 '
    13411344    1 'TiMidity port 1 '
     1345    2 'TiMidity port 2 '
     1346    3 'TiMidity port 3 '
    13421347
    13431348This means the external MIDI output of the sound card is located on the
    1344 port 64:0, four WaveTable MIDI outputs in 65:0, 65:1, 65:2
    1345 and 65:3, and two TiMidity ports, located at 128:0 and 128:1.
     1349port 16:0, four WaveTable MIDI outputs in 17:0, 17:1, 17:2
     1350and 17:3, and four TiMidity ports, located at 128:0, 128:1, 128:2 and 128:3.
    13461351
    13471352If you have a FM-chip on your card, like the SB16, then you have to load
    13481353the SoundFonts using the sbiload software. Example:
    1349   sbiload -p 65:0 /etc/std.o3 /etc/drums.o3
     1354  sbiload -p 17:0 /etc/std.o3 /etc/drums.o3
    13501355
    13511356If you have a WaveTable capable sound card, you have to load a sbk or sf2
    1352 SoundFont using the sfxload software. Example:
     1357SoundFont using the sfxload or asfxload software. Example:
    13531358  sfxload /path/to/8mbgmsfx.sf2
    13541359
    13551360If you don't have a MIDI capable soundcard, there are two options: FluidSynth
  • backends/midi/alsa.cpp

     
    7979}
    8080
    8181int MidiDriver_ALSA::open() {
    82         const char *var;
     82        const char *var = NULL;
    8383
    8484        if (_isOpen)
    8585                return MERR_ALREADY_OPEN;
    8686        _isOpen = true;
    8787
    88         if (!(var = getenv("SCUMMVM_PORT"))) {
    89                 // use config option if no var specified
     88        var = getenv("SCUMMVM_PORT");
     89        if (!var && ConfMan.hasKey("alsa_port")) {
    9090                var = ConfMan.get("alsa_port").c_str();
     91        }
     92
     93        if (var) {
    9194                if (parse_addr(var, &seq_client, &seq_port) < 0) {
    9295                        error("Invalid port %s", var);
    9396                        return -1;
    9497                }
    95         } else {
    96                 if (parse_addr(var, &seq_client, &seq_port) < 0) {
    97                         error("Invalid port %s", var);
    98                         return -1;
    99                 }
    10098        }
    10199
    102100        if (my_snd_seq_open(&seq_handle) < 0) {
     
    120118                return -1;
    121119        }
    122120
    123         if (seq_client != SND_SEQ_ADDRESS_SUBSCRIBERS) {
    124                 /* subscribe to MIDI port */
    125                 if (snd_seq_connect_to(seq_handle, my_port, seq_client, seq_port) < 0) {
    126                         error("Can't subscribe to MIDI port (%d:%d) see README for help", seq_client, seq_port);
     121        if (var) {
     122                if (seq_client != SND_SEQ_ADDRESS_SUBSCRIBERS) {
     123                        // subscribe to MIDI port
     124                        if (snd_seq_connect_to(seq_handle, my_port, seq_client, seq_port) < 0) {
     125                                error("Can't subscribe to MIDI port (%d:%d) see README for help", seq_client, seq_port);
     126                        }
    127127                }
    128                 else printf("Connected to Alsa sequencer client [%d:%d]\n", seq_client, seq_port);
     128        } else {
     129                int defaultPorts[] = {
     130                        65, 0,
     131                        17, 0
     132                };
     133                int i;
     134
     135                for (i = 0; i < ARRAYSIZE(defaultPorts); i += 2) {
     136                        seq_client = defaultPorts[i];
     137                        seq_port = defaultPorts[i + 1];
     138                        if (snd_seq_connect_to(seq_handle, my_port, seq_client, seq_port) >= 0)
     139                                break;
     140                }
     141
     142                if (i >= ARRAYSIZE(defaultPorts))
     143                        error("Can't subscribe to MIDI port (65:0) or (17:0)");
    129144        }
    130145
     146        printf("Connected to Alsa sequencer client [%d:%d]\n", seq_client, seq_port);
    131147        printf("ALSA client initialised [%d:0]\n", my_client);
    132148
    133149        return 0;
  • base/commandLine.cpp

     
    212212        ConfMan.registerDefault("joystick_num", -1);
    213213        ConfMan.registerDefault("confirm_exit", false);
    214214        ConfMan.registerDefault("disable_sdl_parachute", false);
    215 #ifdef USE_ALSA
    216         ConfMan.registerDefault("alsa_port", "65:0");
    217 #endif
    218215
    219216        // Register default savepath
    220217#ifdef DEFAULT_SAVE_PATH