diff options
-rw-r--r-- | sky/music/adlibmusic.cpp | 4 | ||||
-rw-r--r-- | sky/music/adlibmusic.h | 2 | ||||
-rw-r--r-- | sky/music/gmmusic.cpp | 4 | ||||
-rw-r--r-- | sky/music/gmmusic.h | 2 | ||||
-rw-r--r-- | sky/music/mt32music.cpp | 4 | ||||
-rw-r--r-- | sky/music/mt32music.h | 2 | ||||
-rw-r--r-- | sky/music/musicbase.cpp | 8 | ||||
-rw-r--r-- | sky/music/musicbase.h | 4 |
8 files changed, 19 insertions, 11 deletions
diff --git a/sky/music/adlibmusic.cpp b/sky/music/adlibmusic.cpp index 827ffa8743..df537e0e6d 100644 --- a/sky/music/adlibmusic.cpp +++ b/sky/music/adlibmusic.cpp @@ -27,8 +27,8 @@ void SkyAdlibMusic::passMixerFunc(void *param, int16 *buf, uint len) { ((SkyAdlibMusic*)param)->premixerCall(buf, len); } -SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk) - : SkyMusicBase(pSkyDisk) { +SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, OSystem *system) + : SkyMusicBase(pSkyDisk, system) { _driverFileBase = 60202; _mixer = pMixer; diff --git a/sky/music/adlibmusic.h b/sky/music/adlibmusic.h index 8a1bb2c169..dd7085b0cd 100644 --- a/sky/music/adlibmusic.h +++ b/sky/music/adlibmusic.h @@ -31,7 +31,7 @@ class SkyAdlibMusic : public SkyMusicBase { public: - SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk); + SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, OSystem *system); ~SkyAdlibMusic(void); virtual void setVolume(uint8 volume); private: diff --git a/sky/music/gmmusic.cpp b/sky/music/gmmusic.cpp index 78bf349a04..2aab0e7b0b 100644 --- a/sky/music/gmmusic.cpp +++ b/sky/music/gmmusic.cpp @@ -26,8 +26,8 @@ void SkyGmMusic::passTimerFunc(void *param) { ((SkyGmMusic*)param)->timerCall(); } -SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk) - : SkyMusicBase(pSkyDisk) { +SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, OSystem *system) + : SkyMusicBase(pSkyDisk, system) { _driverFileBase = 60200; _midiDrv = pMidiDrv; diff --git a/sky/music/gmmusic.h b/sky/music/gmmusic.h index 6c9cd0b25c..acd04e996c 100644 --- a/sky/music/gmmusic.h +++ b/sky/music/gmmusic.h @@ -30,7 +30,7 @@ class SkyGmMusic : public SkyMusicBase { public: - SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk); + SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, OSystem *system); ~SkyGmMusic(void); virtual void setVolume(uint8 volume); private: diff --git a/sky/music/mt32music.cpp b/sky/music/mt32music.cpp index 6640451961..482721af19 100644 --- a/sky/music/mt32music.cpp +++ b/sky/music/mt32music.cpp @@ -26,8 +26,8 @@ void SkyMT32Music::passTimerFunc(void *param) { ((SkyMT32Music*)param)->timerCall(); } -SkyMT32Music::SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk) - : SkyMusicBase(pSkyDisk) { +SkyMT32Music::SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, OSystem *system) + : SkyMusicBase(pSkyDisk, system) { _driverFileBase = 60200; _midiDrv = pMidiDrv; diff --git a/sky/music/mt32music.h b/sky/music/mt32music.h index e28d3d5373..c547c565fe 100644 --- a/sky/music/mt32music.h +++ b/sky/music/mt32music.h @@ -30,7 +30,7 @@ class SkyMT32Music : public SkyMusicBase { public: - SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk); + SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, OSystem *system); ~SkyMT32Music(void); private: static void passTimerFunc(void *param); diff --git a/sky/music/musicbase.cpp b/sky/music/musicbase.cpp index 4a8cccdd6f..733e948e50 100644 --- a/sky/music/musicbase.cpp +++ b/sky/music/musicbase.cpp @@ -21,13 +21,15 @@ #include "musicbase.h" -SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk) { +SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk, OSystem *system) { _musicData = NULL; _allowedCommands = 0; _skyDisk = pSkyDisk; _currentMusic = 0; _musicVolume = 127; + _system = system; + _mutex = _system->create_mutex(); } SkyMusicBase::~SkyMusicBase(void) @@ -37,6 +39,7 @@ SkyMusicBase::~SkyMusicBase(void) void SkyMusicBase::loadSection(uint8 pSection) { + _system->lock_mutex(_mutex); if (_currentMusic) stopMusic(); if (_musicData) free(_musicData); _currentSection = pSection; @@ -51,6 +54,7 @@ void SkyMusicBase::loadSection(uint8 pSection) _numberOfChannels = _currentMusic = 0; setupPointers(); startDriver(); + _system->unlock_mutex(_mutex); } void SkyMusicBase::musicCommand(uint16 command) @@ -145,6 +149,7 @@ void SkyMusicBase::loadNewMusic(void) void SkyMusicBase::pollMusic(void) { + _system->lock_mutex(_mutex); uint8 newTempo; if (_onNextPoll.doReInit) startDriver(); if (_onNextPoll.doStopMusic) stopMusic(); @@ -160,5 +165,6 @@ void SkyMusicBase::pollMusic(void) updateTempo(); } } + _system->unlock_mutex(_mutex); _aktTime &= 0xFFFF; } diff --git a/sky/music/musicbase.h b/sky/music/musicbase.h index eec14b4a5b..1c992e98cb 100644 --- a/sky/music/musicbase.h +++ b/sky/music/musicbase.h @@ -43,7 +43,7 @@ private: class SkyMusicBase { public: - SkyMusicBase(SkyDisk *pSkyDisk); + SkyMusicBase(SkyDisk *pSkyDisk, OSystem *system); virtual ~SkyMusicBase(void); void loadSection(uint8 pSection); void musicCommand(uint16 command); @@ -54,6 +54,7 @@ public: protected: + OSystem *_system; SkyDisk *_skyDisk; uint8 *_musicData; uint8 _allowedCommands; @@ -68,6 +69,7 @@ protected: uint32 _aktTime; Actions _onNextPoll; SkyChannelBase *_channels[10]; + void *_mutex; virtual void setupPointers(void) = 0; virtual void setupChannels(uint8 *channelData) = 0; |