diff --git a/DOSBox-mt32-patch/singleThread/midi_mt32.h b/DOSBox-mt32-patch/singleThread/midi_mt32.h index 55bf032..2f3ac87 100644 --- a/DOSBox-mt32-patch/singleThread/midi_mt32.h +++ b/DOSBox-mt32-patch/singleThread/midi_mt32.h @@ -1,44 +1,12 @@ +#include #include #include "mixer.h" #include "control.h" -class RingBuffer { -private: - static const unsigned int bufferSize = 1024; - unsigned int startpos; - unsigned int endpos; - Bit32u ringBuffer[bufferSize]; - -public: - RingBuffer() { - startpos = 0; - endpos = 0; - } - - bool put(Bit32u data) { - unsigned int newEndpos = endpos; - newEndpos++; - if (newEndpos == bufferSize) newEndpos = 0; - if (startpos == newEndpos) return false; - ringBuffer[endpos] = data; - endpos = newEndpos; - return true; - } - - Bit32u get() { - if (startpos == endpos) return 0; - Bit32u data = ringBuffer[startpos]; - startpos++; - if (startpos == bufferSize) startpos = 0; - return data; - } -}; - static class MidiHandler_mt32 : public MidiHandler { private: MixerChannel *chan; MT32Emu::Synth *synth; - RingBuffer midiBuffer; bool open, noise, reverseStereo; class MT32ReportHandler : public MT32Emu::ReportHandler { @@ -133,7 +101,7 @@ public: } void PlayMsg(Bit8u *msg) { - if (!midiBuffer.put(*(Bit32u *)msg)) LOG_MSG("MT32: Playback buffer full!"); + synth->playMsg(SDL_SwapLE32(*(Bit32u *)msg)); } void PlaySysex(Bit8u *sysex, Bitu len) { @@ -144,8 +112,6 @@ private: static void mixerCallBack(Bitu len); void render(Bitu len, Bit16s *buf) { - Bit32u msg = midiBuffer.get(); - if (msg != 0) synth->playMsg(msg); synth->render(buf, len); if (reverseStereo) { Bit16s *revBuf = buf;