[Scummvm-git-logs] scummvm master -> 06dab62e2ee15d2c496c2561ac320183014fa67a

sev- noreply at scummvm.org
Mon Nov 28 23:12:23 UTC 2022


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
277861c240 SCUMM: Change Player_V2Base to not inherit from Audio::AudioStream
06dab62e2e SCUMM: Move Player_V2CMS to the new CMS API


Commit: 277861c2400a8ea608c3ed183bb240b9352de3ff
    https://github.com/scummvm/scummvm/commit/277861c2400a8ea608c3ed183bb240b9352de3ff
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-11-29T00:12:19+01:00

Commit Message:
SCUMM: Change Player_V2Base to not inherit from Audio::AudioStream

Changed paths:
    engines/scumm/players/player_v2.cpp
    engines/scumm/players/player_v2.h
    engines/scumm/players/player_v2base.cpp
    engines/scumm/players/player_v2base.h
    engines/scumm/players/player_v2cms.cpp
    engines/scumm/players/player_v2cms.h


diff --git a/engines/scumm/players/player_v2.cpp b/engines/scumm/players/player_v2.cpp
index 789cdbdbd51..29d4f66765d 100644
--- a/engines/scumm/players/player_v2.cpp
+++ b/engines/scumm/players/player_v2.cpp
@@ -22,6 +22,8 @@
 #include "scumm/players/player_v2.h"
 #include "scumm/scumm.h"
 
+#define FREQ_HZ 236 // Don't change!
+
 namespace Scumm {
 
 #define SPK_DECAY   0xa000              /* Depends on sample rate */
@@ -33,10 +35,15 @@ namespace Scumm {
 
 
 Player_V2::Player_V2(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr)
-	: Player_V2Base(scumm, mixer, pcjr) {
+	: Player_V2Base(scumm, pcjr),
+	  _mixer(mixer),
+	  _sampleRate(_mixer->getOutputRate()) {
 
 	int i;
 
+	_next_tick = 0;
+	_tick_len = (_sampleRate << FIXP_SHIFT) / FREQ_HZ;
+
 	// Initialize square generator
 	_level = 0;
 
diff --git a/engines/scumm/players/player_v2.h b/engines/scumm/players/player_v2.h
index f8b25e79bab..0e6e5d7ddc0 100644
--- a/engines/scumm/players/player_v2.h
+++ b/engines/scumm/players/player_v2.h
@@ -23,6 +23,8 @@
 #define SCUMM_PLAYERS_PLAYER_V2_H
 
 #include "scumm/players/player_v2base.h"
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
 
 namespace Scumm {
 
@@ -31,7 +33,7 @@ namespace Scumm {
  * This simulates the pc speaker sound, which is driven  by the 8253 (square
  * wave generator) and a low-band filter.
  */
-class Player_V2 : public Player_V2Base {
+class Player_V2 : public Audio::AudioStream, public Player_V2Base {
 public:
 	Player_V2(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr);
 	~Player_V2() override;
@@ -46,8 +48,15 @@ public:
 
 	// AudioStream API
 	int readBuffer(int16 *buffer, const int numSamples) override;
+	bool isStereo() const override { return true; }
+	bool endOfData() const override { return false; }
+	int getRate() const override { return _sampleRate; }
 
 protected:
+	enum {
+		FIXP_SHIFT = 16
+	};
+
 	unsigned int _update_step;
 	unsigned int _decay;
 	int _level;
@@ -57,6 +66,15 @@ protected:
 	int _timer_count[4];
 	int _timer_output;
 
+	Audio::Mixer *_mixer;
+	Audio::SoundHandle _soundHandle;
+	const uint32 _sampleRate;
+
+	Common::Mutex _mutex;
+
+	uint32 _next_tick;
+	uint32 _tick_len;
+
 protected:
 	virtual void generateSpkSamples(int16 *data, uint len);
 	virtual void generatePCjrSamples(int16 *data, uint len);
diff --git a/engines/scumm/players/player_v2base.cpp b/engines/scumm/players/player_v2base.cpp
index 25a89f770cc..e352e4d1e65 100644
--- a/engines/scumm/players/player_v2base.cpp
+++ b/engines/scumm/players/player_v2base.cpp
@@ -22,8 +22,6 @@
 #include "scumm/players/player_v2base.h"
 #include "scumm/scumm.h"
 
-#define FREQ_HZ 236 // Don't change!
-
 #define MAX_OUTPUT 0x7fff
 
 namespace Scumm {
@@ -316,11 +314,9 @@ static const uint16 pcjr_freq_table[12] = {
 };
 
 
-Player_V2Base::Player_V2Base(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr)
+Player_V2Base::Player_V2Base(ScummEngine *scumm, bool pcjr)
 	: _vm(scumm),
-	_mixer(mixer),
-	_pcjr(pcjr),
-	_sampleRate(_mixer->getOutputRate()) {
+	_pcjr(pcjr) {
 
 	_isV3Game = (scumm->_game.version >= 3);
 
@@ -336,9 +332,6 @@ Player_V2Base::Player_V2Base(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr)
 	for (int i = 0; i < 4; ++i)
 		clear_channel(i);
 
-	_next_tick = 0;
-	_tick_len = (_sampleRate << FIXP_SHIFT) / FREQ_HZ;
-
 	// Initialize V3 music timer
 	_music_timer_ctr = _music_timer = 0;
 	_ticks_per_music_timer = 65535;
diff --git a/engines/scumm/players/player_v2base.h b/engines/scumm/players/player_v2base.h
index e1d8f2434b3..fc36212820b 100644
--- a/engines/scumm/players/player_v2base.h
+++ b/engines/scumm/players/player_v2base.h
@@ -25,8 +25,6 @@
 #include "common/scummsys.h"
 #include "common/mutex.h"
 #include "scumm/music.h"
-#include "audio/audiostream.h"
-#include "audio/mixer.h"
 
 namespace Scumm {
 
@@ -65,9 +63,9 @@ struct channel_data {
 /**
  * Common base class for Player_V2 and Player_V2CMS.
  */
-class Player_V2Base : public Audio::AudioStream, public MusicEngine {
+class Player_V2Base : public MusicEngine {
 public:
-	Player_V2Base(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr);
+	Player_V2Base(ScummEngine *scumm, bool pcjr);
 	~Player_V2Base() override;
 
 	// MusicEngine API
@@ -78,42 +76,19 @@ public:
  	int  getMusicTimer() override;
 // 	virtual int  getSoundStatus(int sound) const;
 
-	// AudioStream API
-/*
-	int readBuffer(int16 *buffer, const int numSamples) {
-		do_mix(buffer, numSamples / 2);
-		return numSamples;
-	}
-*/
-	bool isStereo() const override { return true; }
-	bool endOfData() const override { return false; }
-	int getRate() const override { return _sampleRate; }
-
 protected:
-	enum {
-		FIXP_SHIFT = 16
-	};
-
 	bool _isV3Game;
-	Audio::Mixer *_mixer;
-	Audio::SoundHandle _soundHandle;
 	ScummEngine *_vm;
 
 	bool _pcjr;
 	int _header_len;
 
-	const uint32 _sampleRate;
-	uint32 _next_tick;
-	uint32 _tick_len;
-
 	int   _current_nr;
 	byte *_current_data;
 	int   _next_nr;
 	byte *_next_data;
 	byte *_retaddr;
 
-	Common::Mutex _mutex;
-
 	union ChannelInfo {
 		channel_data d;
 		uint16 array[sizeof(channel_data)/2];
diff --git a/engines/scumm/players/player_v2cms.cpp b/engines/scumm/players/player_v2cms.cpp
index 888af76fdbe..35a4de32bbb 100644
--- a/engines/scumm/players/player_v2cms.cpp
+++ b/engines/scumm/players/player_v2cms.cpp
@@ -24,17 +24,22 @@
 #include "audio/mixer.h"
 #include "audio/softsynth/cms.h"
 
+#define FREQ_HZ 236 // Don't change!
+
 namespace Scumm {
 
 Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer)
-	: Player_V2Base(scumm, mixer, true), _cmsVoicesBase(), _cmsVoices(),
+	: Player_V2Base(scumm, true), _mixer(mixer),_cmsVoicesBase(), _cmsVoices(),
 	  _cmsChips(), _midiDelay(0), _octaveMask(0), _looping(0), _tempo(0),
 	  _tempoSum(0), _midiData(nullptr), _midiSongBegin(nullptr), _musicTimer(0),
 	  _musicTimerTicks(0), _voiceTimer(0), _loadedMidiSong(0),
 	  _outputTableReady(0), _midiChannel(), _midiChannelUse(),
-	  _lastMidiCommand(0) {
+	  _lastMidiCommand(0), _sampleRate(_mixer->getOutputRate()) {
 	setMusicVolume(255);
 
+	_next_tick = 0;
+	_tick_len = (_sampleRate << FIXP_SHIFT) / FREQ_HZ;
+
 	memset(_sfxFreq, 0xFF, sizeof(_sfxFreq));
 	memset(_sfxAmpl, 0x00, sizeof(_sfxAmpl));
 	memset(_sfxOctave, 0x66, sizeof(_sfxOctave));
diff --git a/engines/scumm/players/player_v2cms.h b/engines/scumm/players/player_v2cms.h
index 84428017d8d..b047342d088 100644
--- a/engines/scumm/players/player_v2cms.h
+++ b/engines/scumm/players/player_v2cms.h
@@ -23,6 +23,8 @@
 #define SCUMM_PLAYERS_PLAYER_V2CMS_H
 
 #include "scumm/players/player_v2base.h"	// for channel_data
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
 
 class CMSEmulator;
 
@@ -31,7 +33,7 @@ namespace Scumm {
 /**
  * Scumm V2 CMS/Gameblaster MIDI driver.
  */
-class Player_V2CMS : public Player_V2Base {
+class Player_V2CMS : public Audio::AudioStream, public Player_V2Base {
 public:
 	Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer);
 	~Player_V2CMS() override;
@@ -47,8 +49,14 @@ public:
 	// AudioStream API
 	int readBuffer(int16 *buffer, const int numSamples) override;
 	bool isStereo() const override { return true; }
+	bool endOfData() const override { return false; }
+	int getRate() const override { return _sampleRate; }
 
 private:
+	enum {
+		FIXP_SHIFT = 16
+	};
+
 	struct Voice {
 		byte attack;
 		byte decay;
@@ -169,6 +177,15 @@ private:
 	static const byte _cmsInitData[26];
 
 	CMSEmulator *_cmsEmu;
+
+	Audio::Mixer *_mixer;
+	Audio::SoundHandle _soundHandle;
+	const uint32 _sampleRate;
+
+	Common::Mutex _mutex;
+
+	uint32 _next_tick;
+	uint32 _tick_len;
 };
 
 } // End of namespace Scumm


Commit: 06dab62e2ee15d2c496c2561ac320183014fa67a
    https://github.com/scummvm/scummvm/commit/06dab62e2ee15d2c496c2561ac320183014fa67a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-11-29T00:12:19+01:00

Commit Message:
SCUMM: Move Player_V2CMS to the new CMS API

Changed paths:
    engines/scumm/players/player_v2cms.cpp
    engines/scumm/players/player_v2cms.h
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/players/player_v2cms.cpp b/engines/scumm/players/player_v2cms.cpp
index 35a4de32bbb..9e1766f4843 100644
--- a/engines/scumm/players/player_v2cms.cpp
+++ b/engines/scumm/players/player_v2cms.cpp
@@ -21,25 +21,21 @@
 
 #include "scumm/players/player_v2cms.h"
 #include "scumm/scumm.h"
-#include "audio/mixer.h"
-#include "audio/softsynth/cms.h"
+#include "audio/cms.h"
 
 #define FREQ_HZ 236 // Don't change!
 
 namespace Scumm {
 
-Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer)
-	: Player_V2Base(scumm, true), _mixer(mixer),_cmsVoicesBase(), _cmsVoices(),
+Player_V2CMS::Player_V2CMS(ScummEngine *scumm)
+	: Player_V2Base(scumm, true), _cmsVoicesBase(), _cmsVoices(),
 	  _cmsChips(), _midiDelay(0), _octaveMask(0), _looping(0), _tempo(0),
 	  _tempoSum(0), _midiData(nullptr), _midiSongBegin(nullptr), _musicTimer(0),
 	  _musicTimerTicks(0), _voiceTimer(0), _loadedMidiSong(0),
 	  _outputTableReady(0), _midiChannel(), _midiChannelUse(),
-	  _lastMidiCommand(0), _sampleRate(_mixer->getOutputRate()) {
+	  _lastMidiCommand(0) {
 	setMusicVolume(255);
 
-	_next_tick = 0;
-	_tick_len = (_sampleRate << FIXP_SHIFT) / FREQ_HZ;
-
 	memset(_sfxFreq, 0xFF, sizeof(_sfxFreq));
 	memset(_sfxAmpl, 0x00, sizeof(_sfxAmpl));
 	memset(_sfxOctave, 0x66, sizeof(_sfxOctave));
@@ -70,21 +66,25 @@ Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer)
 	_cmsVoices[7].octaveOutput = &_cmsChips[1].octave[1];
 
 	// inits the CMS Emulator like in the original
-	_cmsEmu = new CMSEmulator(_sampleRate);
+	_cmsEmu = CMS::Config::create();
+	if (!_cmsEmu || !_cmsEmu->init())
+		error("Failed to initialise CMS emulator");
+
 	for (int i = 0, cmsPort = 0x220; i < 2; cmsPort += 2, ++i) {
 		for (int off = 0; off < 13; ++off) {
-			_cmsEmu->portWrite(cmsPort+1, _cmsInitData[off*2]);
-			_cmsEmu->portWrite(cmsPort, _cmsInitData[off*2+1]);
+			// TODO: Use _cmsEmu->writeReg instead?
+			_cmsEmu->write(cmsPort+1, _cmsInitData[off*2]);
+			_cmsEmu->write(cmsPort, _cmsInitData[off*2+1]);
 		}
 	}
 
-	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
+	_cmsEmu->start(new Common::Functor0Mem<void, Player_V2CMS>(this, &Player_V2CMS::onTimer), FREQ_HZ);
 }
 
 Player_V2CMS::~Player_V2CMS() {
 	Common::StackLock lock(_mutex);
 
-	_mixer->stopHandle(_soundHandle);
+	_cmsEmu->stop();
 	delete _cmsEmu;
 }
 
@@ -313,40 +313,22 @@ void Player_V2CMS::processMidiData() {
 	return;
 }
 
-int Player_V2CMS::readBuffer(int16 *buffer, const int numSamples) {
+void Player_V2CMS::onTimer() {
 	Common::StackLock lock(_mutex);
 
-	uint step = 1;
-	int len = numSamples / 2;
-
-	// maybe this needs a complete rewrite
-	do {
-		if (!(_next_tick >> FIXP_SHIFT)) {
-			if (_midiData) {
-				--_voiceTimer;
-				if (!(_voiceTimer & 0x01))
-					playVoice();
-
-				int newTempoSum = _tempo + _tempoSum;
-				_tempoSum = newTempoSum & 0xFF;
-				if (newTempoSum > 0xFF)
-					processMidiData();
-			} else {
-				nextTick();
-				play();
-			}
-			_next_tick += _tick_len;
-		}
-
-		step = len;
-		if (step > (_next_tick >> FIXP_SHIFT))
-			step = (_next_tick >> FIXP_SHIFT);
-		_cmsEmu->readBuffer(buffer, step);
-		buffer += 2 * step;
-		_next_tick -= step << FIXP_SHIFT;
-	} while (len -= step);
+	if (_midiData) {
+		--_voiceTimer;
+		if (!(_voiceTimer & 0x01))
+			playVoice();
 
-	return numSamples;
+		int newTempoSum = _tempo + _tempoSum;
+		_tempoSum = newTempoSum & 0xFF;
+		if (newTempoSum > 0xFF)
+			processMidiData();
+	} else {
+		nextTick();
+		play();
+	}
 }
 
 void Player_V2CMS::playVoice() {
@@ -478,8 +460,9 @@ void Player_V2CMS::processVibrato(Voice2 *channel) {
 void Player_V2CMS::offAllChannels() {
 	for (int cmsPort = 0x220, i = 0; i < 2; cmsPort += 2, ++i) {
 		for (int off = 1; off <= 10; ++off) {
-			_cmsEmu->portWrite(cmsPort+1, _cmsInitData[off*2]);
-			_cmsEmu->portWrite(cmsPort, _cmsInitData[off*2+1]);
+			// TODO: Use _cmsEmu->writeReg instead?
+			_cmsEmu->write(cmsPort+1, _cmsInitData[off*2]);
+			_cmsEmu->write(cmsPort, _cmsInitData[off*2+1]);
 		}
 	}
 }
@@ -665,32 +648,33 @@ void Player_V2CMS::play() {
 	// with the high nibble of the volumeReg value
 	// the right channels amplitude is set
 	// with the low value the left channels amplitude
-	_cmsEmu->portWrite(0x221, 0);
-	_cmsEmu->portWrite(0x220, _sfxAmpl[0]);
-	_cmsEmu->portWrite(0x221, 1);
-	_cmsEmu->portWrite(0x220, _sfxAmpl[1]);
-	_cmsEmu->portWrite(0x221, 2);
-	_cmsEmu->portWrite(0x220, _sfxAmpl[2]);
-	_cmsEmu->portWrite(0x221, 3);
-	_cmsEmu->portWrite(0x220, _sfxAmpl[3]);
-	_cmsEmu->portWrite(0x221, 8);
-	_cmsEmu->portWrite(0x220, _sfxFreq[0]);
-	_cmsEmu->portWrite(0x221, 9);
-	_cmsEmu->portWrite(0x220, _sfxFreq[1]);
-	_cmsEmu->portWrite(0x221, 10);
-	_cmsEmu->portWrite(0x220, _sfxFreq[2]);
-	_cmsEmu->portWrite(0x221, 11);
-	_cmsEmu->portWrite(0x220, _sfxFreq[3]);
-	_cmsEmu->portWrite(0x221, 0x10);
-	_cmsEmu->portWrite(0x220, _sfxOctave[0]);
-	_cmsEmu->portWrite(0x221, 0x11);
-	_cmsEmu->portWrite(0x220, _sfxOctave[1]);
-	_cmsEmu->portWrite(0x221, 0x14);
-	_cmsEmu->portWrite(0x220, 0x3E);
-	_cmsEmu->portWrite(0x221, 0x15);
-	_cmsEmu->portWrite(0x220, 0x01);
-	_cmsEmu->portWrite(0x221, 0x16);
-	_cmsEmu->portWrite(0x220, noiseGen);
+	// TODO: Use _cmsEmu->writeReg instead?
+	_cmsEmu->write(0x221, 0);
+	_cmsEmu->write(0x220, _sfxAmpl[0]);
+	_cmsEmu->write(0x221, 1);
+	_cmsEmu->write(0x220, _sfxAmpl[1]);
+	_cmsEmu->write(0x221, 2);
+	_cmsEmu->write(0x220, _sfxAmpl[2]);
+	_cmsEmu->write(0x221, 3);
+	_cmsEmu->write(0x220, _sfxAmpl[3]);
+	_cmsEmu->write(0x221, 8);
+	_cmsEmu->write(0x220, _sfxFreq[0]);
+	_cmsEmu->write(0x221, 9);
+	_cmsEmu->write(0x220, _sfxFreq[1]);
+	_cmsEmu->write(0x221, 10);
+	_cmsEmu->write(0x220, _sfxFreq[2]);
+	_cmsEmu->write(0x221, 11);
+	_cmsEmu->write(0x220, _sfxFreq[3]);
+	_cmsEmu->write(0x221, 0x10);
+	_cmsEmu->write(0x220, _sfxOctave[0]);
+	_cmsEmu->write(0x221, 0x11);
+	_cmsEmu->write(0x220, _sfxOctave[1]);
+	_cmsEmu->write(0x221, 0x14);
+	_cmsEmu->write(0x220, 0x3E);
+	_cmsEmu->write(0x221, 0x15);
+	_cmsEmu->write(0x220, 0x01);
+	_cmsEmu->write(0x221, 0x16);
+	_cmsEmu->write(0x220, noiseGen);
 }
 
 void Player_V2CMS::playMusicChips(const MusicChip *table) {
@@ -698,30 +682,31 @@ void Player_V2CMS::playMusicChips(const MusicChip *table) {
 
 	do {
 		cmsPort += 2;
-		_cmsEmu->portWrite(cmsPort+1, 0);
-		_cmsEmu->portWrite(cmsPort, table->ampl[0]);
-		_cmsEmu->portWrite(cmsPort+1, 1);
-		_cmsEmu->portWrite(cmsPort, table->ampl[1]);
-		_cmsEmu->portWrite(cmsPort+1, 2);
-		_cmsEmu->portWrite(cmsPort, table->ampl[2]);
-		_cmsEmu->portWrite(cmsPort+1, 3);
-		_cmsEmu->portWrite(cmsPort, table->ampl[3]);
-		_cmsEmu->portWrite(cmsPort+1, 8);
-		_cmsEmu->portWrite(cmsPort, table->freq[0]);
-		_cmsEmu->portWrite(cmsPort+1, 9);
-		_cmsEmu->portWrite(cmsPort, table->freq[1]);
-		_cmsEmu->portWrite(cmsPort+1, 10);
-		_cmsEmu->portWrite(cmsPort, table->freq[2]);
-		_cmsEmu->portWrite(cmsPort+1, 11);
-		_cmsEmu->portWrite(cmsPort, table->freq[3]);
-		_cmsEmu->portWrite(cmsPort+1, 0x10);
-		_cmsEmu->portWrite(cmsPort, table->octave[0]);
-		_cmsEmu->portWrite(cmsPort+1, 0x11);
-		_cmsEmu->portWrite(cmsPort, table->octave[1]);
-		_cmsEmu->portWrite(cmsPort+1, 0x14);
-		_cmsEmu->portWrite(cmsPort, 0x3F);
-		_cmsEmu->portWrite(cmsPort+1, 0x15);
-		_cmsEmu->portWrite(cmsPort, 0x00);
+		// TODO: Use _cmsEmu->writeReg instead?
+		_cmsEmu->write(cmsPort+1, 0);
+		_cmsEmu->write(cmsPort, table->ampl[0]);
+		_cmsEmu->write(cmsPort+1, 1);
+		_cmsEmu->write(cmsPort, table->ampl[1]);
+		_cmsEmu->write(cmsPort+1, 2);
+		_cmsEmu->write(cmsPort, table->ampl[2]);
+		_cmsEmu->write(cmsPort+1, 3);
+		_cmsEmu->write(cmsPort, table->ampl[3]);
+		_cmsEmu->write(cmsPort+1, 8);
+		_cmsEmu->write(cmsPort, table->freq[0]);
+		_cmsEmu->write(cmsPort+1, 9);
+		_cmsEmu->write(cmsPort, table->freq[1]);
+		_cmsEmu->write(cmsPort+1, 10);
+		_cmsEmu->write(cmsPort, table->freq[2]);
+		_cmsEmu->write(cmsPort+1, 11);
+		_cmsEmu->write(cmsPort, table->freq[3]);
+		_cmsEmu->write(cmsPort+1, 0x10);
+		_cmsEmu->write(cmsPort, table->octave[0]);
+		_cmsEmu->write(cmsPort+1, 0x11);
+		_cmsEmu->write(cmsPort, table->octave[1]);
+		_cmsEmu->write(cmsPort+1, 0x14);
+		_cmsEmu->write(cmsPort, 0x3F);
+		_cmsEmu->write(cmsPort+1, 0x15);
+		_cmsEmu->write(cmsPort, 0x00);
 		++table;
 	} while ((cmsPort & 2) == 0);
 }
diff --git a/engines/scumm/players/player_v2cms.h b/engines/scumm/players/player_v2cms.h
index b047342d088..17f2a4a6d10 100644
--- a/engines/scumm/players/player_v2cms.h
+++ b/engines/scumm/players/player_v2cms.h
@@ -23,19 +23,19 @@
 #define SCUMM_PLAYERS_PLAYER_V2CMS_H
 
 #include "scumm/players/player_v2base.h"	// for channel_data
-#include "audio/audiostream.h"
-#include "audio/mixer.h"
 
-class CMSEmulator;
+namespace CMS {
+class CMS;
+}
 
 namespace Scumm {
 
 /**
  * Scumm V2 CMS/Gameblaster MIDI driver.
  */
-class Player_V2CMS : public Audio::AudioStream, public Player_V2Base {
+class Player_V2CMS : public Player_V2Base {
 public:
-	Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer);
+	Player_V2CMS(ScummEngine *scumm);
 	~Player_V2CMS() override;
 
 	// MusicEngine API
@@ -46,17 +46,9 @@ public:
 	int  getMusicTimer() override;
 	int  getSoundStatus(int sound) const override;
 
-	// AudioStream API
-	int readBuffer(int16 *buffer, const int numSamples) override;
-	bool isStereo() const override { return true; }
-	bool endOfData() const override { return false; }
-	int getRate() const override { return _sampleRate; }
+	void onTimer();
 
 private:
-	enum {
-		FIXP_SHIFT = 16
-	};
-
 	struct Voice {
 		byte attack;
 		byte decay;
@@ -176,16 +168,9 @@ private:
 	static const byte _volumeTable[16];
 	static const byte _cmsInitData[26];
 
-	CMSEmulator *_cmsEmu;
-
-	Audio::Mixer *_mixer;
-	Audio::SoundHandle _soundHandle;
-	const uint32 _sampleRate;
+	CMS::CMS *_cmsEmu;
 
 	Common::Mutex _mutex;
-
-	uint32 _next_tick;
-	uint32 _tick_len;
 };
 
 } // End of namespace Scumm
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index cff5102c24f..e0671eb5f90 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2006,7 +2006,7 @@ void ScummEngine::setupMusic(int midi, const Common::String &macInstrumentFile)
 	} else if ((_sound->_musicType == MDT_PCSPK || _sound->_musicType == MDT_PCJR) && (_game.version > 2 && _game.version <= 4)) {
 		_musicEngine = new Player_V2(this, _mixer, MidiDriver::getMusicType(dev) != MT_PCSPK);
 	} else if (_sound->_musicType == MDT_CMS) {
-		_musicEngine = new Player_V2CMS(this, _mixer);
+		_musicEngine = new Player_V2CMS(this);
 	} else if (_game.platform == Common::kPlatform3DO && _game.heversion <= 62) {
 		// 3DO versions use digital music and sound samples.
 	} else if (_game.platform == Common::kPlatformFMTowns && (_game.version == 3 || _game.id == GID_MONKEY)) {




More information about the Scummvm-git-logs mailing list