1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef BLADERUNNER_AUD_STREAM_H 24 #define BLADERUNNER_AUD_STREAM_H 25 26 #include "bladerunner/adpcm_decoder.h" 27 28 #include "audio/audiostream.h" 29 #include "common/endian.h" 30 #include "common/types.h" 31 32 namespace BladeRunner { 33 34 class AudioCache; 35 36 class AudStream : public Audio::RewindableAudioStream { 37 byte *_data; 38 byte *_p; 39 byte *_end; 40 AudioCache *_cache; 41 int32 _hash; 42 uint16 _deafBlockRemain; 43 uint16 _frequency; 44 uint32 _size; 45 uint32 _sizeDecompressed; 46 byte _flags; 47 byte _compressionType; 48 int _overrideFrequency; 49 50 ADPCMWestwoodDecoder _decoder; 51 52 void init(byte *data); 53 54 public: 55 AudStream(byte *data, int overrideFrequency = -1); 56 AudStream(AudioCache *cache, int32 hash, int overrideFrequency = -1); 57 ~AudStream() override; 58 59 int readBuffer(int16 *buffer, const int numSamples) override; isStereo()60 bool isStereo() const override { return false; } getRate()61 int getRate() const override { return _overrideFrequency > 0 ? _overrideFrequency : _frequency; }; endOfData()62 bool endOfData() const override { return _p == _end; } 63 bool rewind() override; 64 uint32 getLength() const; 65 bool startAtSecond(uint32 startSecond); 66 int getBytesPerSecond() const; 67 }; 68 69 } // End of namespace BladeRunner 70 71 #endif 72