- singleThread version of DOSBox patch cleaned up and relies on synth's internal MIDI queue

This commit is contained in:
sergm
2013-08-03 21:02:21 +03:00
parent ac008a6c3f
commit f95c3f9852

View File

@@ -1,44 +1,12 @@
#include <SDL_endian.h>
#include <mt32emu/mt32emu.h>
#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;