--- allegro-4.4.1.1.old/src/unix/uossmidi.c +++ allegro-4.4.1.1/src/unix/uossmidi.c @@ -101,31 +101,32 @@ _dummy_noop2 /* TODO */ }; - +static int HaveNoSynth = 0; /* as required by the OSS API */ void seqbuf_dump(void) { - if (_seqbufptr) { - write(seq_fd, _seqbuf, _seqbufptr); - _seqbufptr = 0; - } + if (_seqbufptr) { + if (!HaveNoSynth) write (seq_fd, _seqbuf, _seqbufptr); + _seqbufptr = 0; + } } - - /* attempt to open sequencer device */ static int seq_attempt_open(void) { char tmp1[128], tmp2[128], tmp3[128]; int fd; + if (HaveNoSynth) return (-1); + ustrzcpy(seq_driver, sizeof(seq_driver), get_config_string(uconvert_ascii("sound", tmp1), uconvert_ascii("oss_midi_driver", tmp2), uconvert_ascii("/dev/sequencer", tmp3))); fd = open(uconvert_toascii(seq_driver, tmp1), O_WRONLY); - if (fd < 0) + + if (fd < 0) uszprintf(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("%s: %s"), seq_driver, ustrerror(errno)); return fd; @@ -142,6 +143,8 @@ char tmp1[64], tmp2[256]; int score = 0, best_score, best_device; + if (HaveNoSynth) return (0); + if (ioctl(fd, SNDCTL_SEQ_NRSYNTHS, &num_synths) == -1) return 0; @@ -253,6 +256,8 @@ struct sbi_instrument ins; int i; + if (HaveNoSynth) return; + ins.device = seq_device; ins.key = FM_PATCH; memset(ins.operators, 0, sizeof(ins.operators)); @@ -278,6 +283,7 @@ /* FM synth setup */ static void seq_setup_fm (void) { + if (HaveNoSynth) return; seq_set_fm_patches(seq_fd); seq_drum_start = midi_oss.voices - 5; } @@ -290,6 +296,7 @@ { int bits = 0, drums; + if (HaveNoSynth) return; seq_drum_start = midi_oss.voices; if (seq_drum_start > 32) seq_drum_start = 32; @@ -331,6 +338,8 @@ */ static int oss_midi_detect(int input) { + if (HaveNoSynth) return FALSE; + if (input) { ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Input is not supported")); return FALSE; @@ -354,6 +363,8 @@ char tmp1[128], tmp2[128], tmp3[128]; unsigned int i; + if (HaveNoSynth) return -1; + if (input) { ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Input is not supported")); return -1; @@ -365,8 +376,14 @@ if (!seq_find_synth(seq_fd)) { close(seq_fd); + +#ifdef NOTDEF ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("No supported synth type found")); return -1; +#else + HaveNoSynth = 1; + return (0); +#endif } ioctl(seq_fd, SNDCTL_SEQ_RESET); @@ -412,6 +429,7 @@ int fd, vol, ret; char tmp[128]; + if (HaveNoSynth) return 0; fd = open(uconvert_toascii(mixer_driver, tmp), O_WRONLY); if (fd < 0) return -1; @@ -434,6 +452,7 @@ int fd, vol; char tmp[128]; + if (HaveNoSynth) return (0); fd = open(uconvert_toascii(mixer_driver, tmp), O_RDONLY); if (fd < 0) return -1; @@ -468,6 +487,8 @@ static int get_hardware_voice (int voice) { int hwvoice = voice; + + if (HaveNoSynth) return (15); /* FIXME: is this OK/useful for other things than AWE32? */ if (seq_synth_type != SYNTH_TYPE_FM && seq_drum_start > 0) { @@ -496,6 +517,8 @@ int voice, hwvoice; int is_percussion = 0; + if (HaveNoSynth) return; + /* percussion? */ if (inst > 127) { voice = _midi_allocate_voice(seq_drum_start, midi_driver->voices-1); @@ -543,8 +566,12 @@ */ static void oss_midi_key_off(int voice) { + int hwvoice; + + if (HaveNoSynth) return; + /* Get the hardware voice corresponding to this virtual voice. */ - int hwvoice = get_hardware_voice (voice); + hwvoice = get_hardware_voice (voice); SEQ_STOP_NOTE(seq_device, hwvoice, seq_note[voice], 64); SEQ_DUMPBUF(); @@ -559,6 +586,7 @@ */ static void oss_midi_set_volume(int voice, int vol) { + if (HaveNoSynth) return; SEQ_CONTROL(seq_device, voice, CTL_MAIN_VOLUME, vol); } @@ -569,6 +597,7 @@ */ static void oss_midi_set_pitch(int voice, int note, int bend) { + if (HaveNoSynth) return; SEQ_CONTROL(seq_device, voice, CTRL_PITCH_BENDER, 8192 + bend); } @@ -583,7 +612,7 @@ return; if (seq_fd > 0) { - close(seq_fd); + if (!HaveNoSynth) close(seq_fd); seq_fd = -1; } }