From b14fbaa72b3218862a533dd7f7c0e97e1bed4df7 Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Sun, 10 Feb 2019 23:34:54 +0100 Subject: BLADERUNNER: Cleanup of audio code Separated audio cache. Fixed bug in the audio cache where still used sound might get freed. Fixes crashes when engine is unloading which were caused by a race condition between the timer code and engine teardown code. --- engines/bladerunner/audio_player.h | 39 -------------------------------------- 1 file changed, 39 deletions(-) (limited to 'engines/bladerunner/audio_player.h') diff --git a/engines/bladerunner/audio_player.h b/engines/bladerunner/audio_player.h index 34059e33f3..580bdbcb79 100644 --- a/engines/bladerunner/audio_player.h +++ b/engines/bladerunner/audio_player.h @@ -35,43 +35,6 @@ namespace BladeRunner { class BladeRunnerEngine; class AudioCache; -/* - * This is a poor imitation of Bladerunner's resource cache - */ -class AudioCache { - struct cacheItem { - int32 hash; - int refs; - uint lastAccess; - byte *data; - uint32 size; - }; - - Common::Mutex _mutex; - Common::Array _cacheItems; - - uint32 _totalSize; - uint32 _maxSize; - uint32 _accessCounter; - -public: - AudioCache() : - _totalSize(0), - _maxSize(2457600), - _accessCounter(0) { - } - ~AudioCache(); - - bool canAllocate(uint32 size) const; - bool dropOldest(); - byte *findByHash(int32 hash); - void storeByHash(int32 hash, Common::SeekableReadStream *stream); - - void incRef(int32 hash); - void decRef(int32 hash); -}; - - enum AudioPlayerFlags { kAudioPlayerLoop = 1, kAudioPlayerOverrideVolume = 2 @@ -84,7 +47,6 @@ class AudioPlayer { bool isActive; int channel; int priority; - int32 hash; int volume; int pan; Audio::AudioStream *stream; @@ -93,7 +55,6 @@ class AudioPlayer { BladeRunnerEngine *_vm; Common::Mutex _mutex; - AudioCache *_cache; Track _tracks[kTracks]; int _sfxVolume; -- cgit v1.2.3