diff options
author | Max Horn | 2004-10-11 22:19:22 +0000 |
---|---|---|
committer | Max Horn | 2004-10-11 22:19:22 +0000 |
commit | bdf66b1a072b93bfb128f7a6368b500b81d0036f (patch) | |
tree | 31e6bf3fe6c0d4791163e3c69dd5647ee81138ad /backends/midi/ym2612.cpp | |
parent | 1036e88aa63adfe503a8d22d3b2df207d8e235c2 (diff) | |
download | scummvm-rg350-bdf66b1a072b93bfb128f7a6368b500b81d0036f.tar.gz scummvm-rg350-bdf66b1a072b93bfb128f7a6368b500b81d0036f.tar.bz2 scummvm-rg350-bdf66b1a072b93bfb128f7a6368b500b81d0036f.zip |
Make use of the new setupPremix variant (i.e. use an AudioStream subclass instead of a premix proc)
svn-id: r15523
Diffstat (limited to 'backends/midi/ym2612.cpp')
-rw-r--r-- | backends/midi/ym2612.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/backends/midi/ym2612.cpp b/backends/midi/ym2612.cpp index 3a5b1e1cab..f701a1541e 100644 --- a/backends/midi/ym2612.cpp +++ b/backends/midi/ym2612.cpp @@ -24,6 +24,7 @@ #include "stdafx.h" #include "common/util.h" +#include "sound/audiostream.h" #include "sound/mididrv.h" #include "sound/mixer.h" @@ -157,7 +158,7 @@ public: void sysEx_customInstrument(uint32 type, byte *instr); }; -class MidiDriver_YM2612 : public MidiDriver { +class MidiDriver_YM2612 : public AudioStream, public MidiDriver { protected: MidiChannel_YM2612 *_channel[16]; @@ -178,7 +179,6 @@ protected: void rate(uint16 r); void generate_samples(int16 *buf, int len); - static void premix_proc(void *param, int16 *buf, uint len); public: MidiDriver_YM2612(SoundMixer *mixer); @@ -198,6 +198,21 @@ public: MidiChannel *allocateChannel() { return 0; } MidiChannel *getPercussionChannel() { return 0; } + + + // AudioStream API + int readBuffer(int16 *buffer, const int numSamples) { + memset(buffer, 0, 2 * numSamples); // FIXME + generate_samples(buffer, numSamples / 2); + return numSamples; + } + int16 read() { + error("ProcInputStream::read not supported"); + } + bool isStereo() const { return true; } + bool endOfData() const { return false; } + + int getRate() const { return _mixer->getOutputRate(); } }; //////////////////////////////////////// @@ -754,7 +769,7 @@ MidiDriver_YM2612::~MidiDriver_YM2612() { int MidiDriver_YM2612::open() { if (_isOpen) return MERR_ALREADY_OPEN; - _mixer->setupPremix(premix_proc, this); + _mixer->setupPremix(this); _isOpen = true; return 0; } @@ -765,7 +780,7 @@ void MidiDriver_YM2612::close() { _isOpen = false; // Detach the premix callback handler - _mixer->setupPremix(0, 0); + _mixer->setupPremix(0); } void MidiDriver_YM2612::setTimerCallback(void *timer_param, Timer::TimerProc timer_proc) { @@ -822,10 +837,6 @@ void MidiDriver_YM2612::sysEx(byte *msg, uint16 length) { _channel[msg[1]]->sysEx_customInstrument('EUP ', &msg[2]); } -void MidiDriver_YM2612::premix_proc(void *param, int16 *buf, uint len) { - ((MidiDriver_YM2612 *) param)->generate_samples(buf, len); -} - void MidiDriver_YM2612::generate_samples(int16 *data, int len) { int step; |