Moved the AudioCDManager as well as class AudioStream and its (standard) subclasses to namespace Audio

svn-id: r22231
This commit is contained in:
Max Horn 2006-04-29 22:33:31 +00:00
parent ac0ae13bee
commit 27307acd7c
59 changed files with 203 additions and 134 deletions

View file

@ -79,7 +79,7 @@ struct AdlibSoundInstrument {
byte amDepth;
};
class AdlibSoundDriver : public SoundDriver, AudioStream {
class AdlibSoundDriver : public SoundDriver, Audio::AudioStream {
public:
AdlibSoundDriver(Audio::Mixer *mixer);
virtual ~AdlibSoundDriver();

View file

@ -33,7 +33,7 @@ namespace Gob {
class GobEngine;
class Music : public AudioStream {
class Music : public Audio::AudioStream {
public:
Music(GobEngine *vm);
~Music();

View file

@ -66,7 +66,7 @@ public:
protected:
// TODO: This is a very primitive square wave generator. The only thing is
// has in common with the PC speaker is that it sounds terrible.
class SquareWaveStream : public AudioStream {
class SquareWaveStream : public Audio::AudioStream {
private:
uint _rate;
bool _beepForever;

View file

@ -26,8 +26,6 @@
#include "base/engine.h"
#include "common/rect.h"
class AudioStream;
namespace Kyra {
class Movie;

View file

@ -71,7 +71,7 @@ void Sound::voicePlay(const char *file) {
Common::MemoryReadStream vocStream(fileData, fileSize);
_mixer->stopHandle(_vocHandle);
_currentVocFile = makeVOCStream(vocStream);
_currentVocFile = Audio::makeVOCStream(vocStream);
}
if (_currentVocFile)
@ -476,13 +476,13 @@ void KyraEngine::snd_voiceWaitForFinish(bool ingame) {
const Sound::SpeechCodecs Sound::_supportedCodes[] = {
#ifdef USE_MAD
{ ".VO3", makeMP3Stream },
{ ".VO3", Audio::makeMP3Stream },
#endif // USE_MAD
#ifdef USE_VORBIS
{ ".VOG", makeVorbisStream },
{ ".VOG", Audio::makeVorbisStream },
#endif // USE_VORBIS
#ifdef USE_FLAC
{ ".VOF", makeFlacStream },
{ ".VOF", Audio::makeFlacStream },
#endif // USE_FLAC
{ 0, 0 }
};

View file

@ -30,9 +30,8 @@
#include "sound/mixer.h"
#include "kyra/kyra.h"
class AudioStream;
namespace Audio {
class AudioStream;
class Mixer;
class SoundHandle;
} // end of namespace Audio
@ -68,13 +67,13 @@ protected:
Audio::Mixer *_mixer;
private:
AudioStream *_currentVocFile;
Audio::AudioStream *_currentVocFile;
Audio::SoundHandle _vocHandle;
Common::File _compressHandle;
struct SpeechCodecs {
const char *fileext;
AudioStream *(*streamFunc)(Common::File*, uint32);
Audio::AudioStream *(*streamFunc)(Common::File*, uint32);
};
static const SpeechCodecs _supportedCodes[];

View file

@ -38,7 +38,7 @@
namespace Kyra {
class AdlibDriver : public AudioStream {
class AdlibDriver : public Audio::AudioStream {
public:
AdlibDriver(Audio::Mixer *mixer);
~AdlibDriver();

View file

@ -207,7 +207,7 @@ bool MP3Sound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) {
uint32 size;
Common::File *f = _vm->resource()->giveCompressedSound(name, &size);
if (f) {
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, makeMP3Stream(f, size));
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeMP3Stream(f, size));
return true;
}
return false;
@ -219,7 +219,7 @@ bool OGGSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) {
uint32 size;
Common::File *f = _vm->resource()->giveCompressedSound(name, &size);
if (f) {
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, makeVorbisStream(f, size));
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeVorbisStream(f, size));
return true;
}
return false;
@ -231,7 +231,7 @@ bool FLACSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) {
uint32 size;
Common::File *f = _vm->resource()->giveCompressedSound(name, &size);
if (f) {
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, makeFlacStream(f, size));
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeFlacStream(f, size));
return true;
}
return false;

View file

@ -41,18 +41,18 @@ namespace Saga {
#define BUFFER_SIZE 4096
struct TrackFormat {
DigitalTrackInfo* (*openTrackFunction)(int);
Audio::DigitalTrackInfo* (*openTrackFunction)(int);
};
static const TrackFormat TRACK_FORMATS[] = {
#ifdef USE_FLAC
{ getFlacTrack },
{ Audio::getFlacTrack },
#endif
#ifdef USE_VORBIS
{ getVorbisTrack },
{ Audio::getVorbisTrack },
#endif
#ifdef USE_MAD
{ getMP3Track },
{ Audio::getMP3Track },
#endif
{ NULL } // Terminator
@ -63,7 +63,7 @@ static const TrackFormat TRACK_FORMATS[] = {
// Sword 2, to make it easier to add support for compressed music... but I'll
// worry about that later.
class RAWInputStream : public AudioStream {
class RAWInputStream : public Audio::AudioStream {
private:
ResourceContext *_context;
Common::File *_file;
@ -374,7 +374,7 @@ bool Music::isPlaying() {
}
void Music::play(uint32 resourceId, MusicFlags flags) {
AudioStream *audioStream = NULL;
Audio::AudioStream *audioStream = NULL;
MidiParser *parser;
ResourceContext *context;
byte *resourceData;

View file

@ -137,7 +137,7 @@ private:
MidiParser *xmidiParser;
MidiParser *smfParser;
DigitalTrackInfo *_track;
Audio::DigitalTrackInfo *_track;
byte *_midiMusicData;

View file

@ -137,7 +137,7 @@ void SndRes::playVoice(uint32 resourceId) {
bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buffer, bool onlyHeader) {
byte *soundResource;
AudioStream *voxStream;
Audio::AudioStream *voxStream;
size_t soundResourceLength;
bool result = false;
GameSoundTypes resourceType;
@ -217,7 +217,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
buffer.buffer = NULL;
free(soundResource);
} else {
voxStream = makeADPCMStream(&readS, soundResourceLength, kADPCMOki);
voxStream = Audio::makeADPCMStream(&readS, soundResourceLength, Audio::kADPCMOki);
buffer.buffer = (byte *)malloc(buffer.size);
voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
if (voxSize != soundResourceLength * 2) {
@ -228,7 +228,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
result = true;
break;
case kSoundVOC:
data = loadVOCFromStream(readS, size, rate);
data = Audio::loadVOCFromStream(readS, size, rate);
if (data) {
buffer.frequency = rate;
buffer.sampleBits = 8;
@ -246,7 +246,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
free(soundResource);
break;
case kSoundWAV:
if (loadWAVFromStream(readS, size, rate, flags)) {
if (Audio::loadWAVFromStream(readS, size, rate, flags)) {
buffer.frequency = rate;
buffer.sampleBits = 16;
buffer.stereo = ((flags & Audio::Mixer::FLAG_STEREO) != 0);

View file

@ -1777,7 +1777,7 @@ int ScummEngine_v72he::getSoundResourceSize(int id) {
size = READ_BE_UINT32(ptr + 4);
Common::MemoryReadStream stream(ptr, size);
if (!loadWAVFromStream(stream, size, rate, flags)) {
if (!Audio::loadWAVFromStream(stream, size, rate, flags)) {
error("getSoundResourceSize: Not a valid WAV file");
}
} else {

View file

@ -538,12 +538,12 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
size = READ_LE_UINT32(ptr + 4);
Common::MemoryReadStream stream(ptr, size);
if (!loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) {
if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) {
error("playHESound: Not a valid WAV file (%d)", soundID);
}
if (compType == 17) {
AudioStream *voxStream = makeADPCMStream(&stream, size, kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
Audio::AudioStream *voxStream = Audio::makeADPCMStream(&stream, size, Audio::kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
sound = (char *)malloc(size * 4);
size = voxStream->readBuffer((int16*)sound, size * 2);

View file

@ -80,7 +80,7 @@ private:
ImuseDigiSndMgr::soundStruct *soundHandle;
Audio::SoundHandle handle;
AppendableAudioStream *stream;
AudioStream *stream2;
Audio::AudioStream *stream2;
Track();
};
@ -106,7 +106,7 @@ private:
void callback();
void switchToNextRegion(Track *track);
int allocSlot(int priority);
void startSound(int soundId, const char *soundName, int soundType, int volGroupId, AudioStream *input, int hookId, int volume, int priority);
void startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority);
void selectVolumeGroup(int soundId, int volGroupId);
int32 getPosInMs(int soundId);
@ -135,7 +135,7 @@ public:
void setAudioNames(int32 num, char *names);
void startVoice(int soundId, AudioStream *input);
void startVoice(int soundId, Audio::AudioStream *input);
void startVoice(int soundId, const char *soundName);
void startMusic(int soundId, int volume);
void startMusic(const char *soundName, int soundId, int hookId, int volume);

View file

@ -208,7 +208,7 @@ void IMuseDigital::refreshScripts() {
}
}
void IMuseDigital::startVoice(int soundId, AudioStream *input) {
void IMuseDigital::startVoice(int soundId, Audio::AudioStream *input) {
debug(5, "startVoiceStream(%d)", soundId);
startSound(soundId, "", 0, IMUSE_VOLGRP_VOICE, input, 0, 127, 127);
}

View file

@ -163,7 +163,7 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) {
int time_constant = ptr[offset];
offset += 2;
len -= 2;
sound->freq = getSampleRateFromVOCRate(time_constant);
sound->freq = Audio::getSampleRateFromVOCRate(time_constant);
sound->region[sound->numRegions].offset = offset;
sound->region[sound->numRegions].length = len;
sound->numRegions++;
@ -614,11 +614,11 @@ int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, b
if (!soundHandle->compressedStream) {
#ifdef USE_VORBIS
if (oggMode)
soundHandle->compressedStream = makeVorbisStream(cmpFile, len);
soundHandle->compressedStream = Audio::makeVorbisStream(cmpFile, len);
#endif
#ifdef USE_MAD
if (!oggMode)
soundHandle->compressedStream = makeMP3Stream(cmpFile, len);
soundHandle->compressedStream = Audio::makeMP3Stream(cmpFile, len);
#endif
assert(soundHandle->compressedStream);
}

View file

@ -85,7 +85,7 @@ public:
int type;
int volGroupId;
int disk;
AudioStream *compressedStream;
Audio::AudioStream *compressedStream;
bool compressed;
char lastFileName[24];
};

View file

@ -67,7 +67,7 @@ int IMuseDigital::allocSlot(int priority) {
return trackId;
}
void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int volGroupId, AudioStream *input, int hookId, int volume, int priority) {
void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority) {
debug(5, "IMuseDigital::startSound(%d)", soundId);
int l = allocSlot(priority);

View file

@ -92,7 +92,7 @@ void Player_MOD::startChannel(int id, void *data, int size, int rate, uint8 vol,
_channels[i].vol = vol;
_channels[i].pan = pan;
_channels[i].freq = rate;
_channels[i].input = makeLinearInputStream(rate, Audio::Mixer::FLAG_AUTOFREE | (loopStart != loopEnd ? Audio::Mixer::FLAG_LOOP : 0), (const byte*)data, size, loopStart, loopEnd - loopStart);
_channels[i].input = Audio::makeLinearInputStream(rate, Audio::Mixer::FLAG_AUTOFREE | (loopStart != loopEnd ? Audio::Mixer::FLAG_LOOP : 0), (const byte*)data, size, loopStart, loopEnd - loopStart);
_channels[i].converter = Audio::makeRateConverter(rate, _mixer->getOutputRate(), false, false);
}

View file

@ -36,7 +36,7 @@ namespace Scumm {
/**
* Generic Amiga MOD mixer - provides a 60Hz 'update' routine.
*/
class Player_MOD : public AudioStream {
class Player_MOD : public Audio::AudioStream {
public:
Player_MOD(ScummEngine *scumm);
virtual ~Player_MOD();
@ -73,7 +73,7 @@ private:
int8 pan;
uint16 freq;
Audio::RateConverter *converter;
AudioStream *input;
Audio::AudioStream *input;
};
Audio::Mixer *_mixer;

View file

@ -43,7 +43,7 @@ static const int NUMCHANS = 4;
/**
* Scumm NES sound/music driver.
*/
class Player_NES : public AudioStream, public MusicEngine {
class Player_NES : public Audio::AudioStream, public MusicEngine {
public:
Player_NES(ScummEngine *scumm);
virtual ~Player_NES();

View file

@ -76,7 +76,7 @@ struct channel_data {
* This simulates the pc speaker sound, which is driven by the 8253 (square
* wave generator) and a low-band filter.
*/
class Player_V2 : public AudioStream, public MusicEngine {
class Player_V2 : public Audio::AudioStream, public MusicEngine {
public:
Player_V2(ScummEngine *scumm, bool pcjr);
virtual ~Player_V2();

View file

@ -871,7 +871,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// as AudioCDManager::Status::playing, and MSVC6 has
// a fit with that. This typedef simplifies the notation
// to something MSVC6 can grasp.
typedef AudioCDManager::Status AudioCDManager_Status;
typedef Audio::AudioCDManager::Status AudioCDManager_Status;
const SaveLoadEntry audioCDEntries[] = {
MKLINE(AudioCDManager_Status, playing, sleUint32, VER(24)),
MKLINE(AudioCDManager_Status, track, sleInt32, VER(24)),
@ -1140,7 +1140,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// Save/load the Audio CD status
//
if (s->getVersion() >= VER(24)) {
AudioCDManager::Status info;
Audio::AudioCDManager::Status info;
if (s->isSaving())
info = AudioCD.getStatus();
s->saveLoadArrayOf(&info, 1, sizeof(info), audioCDEntries);

View file

@ -1270,7 +1270,7 @@ void SmushPlayer::tryCmpFile(const char *filename) {
if (_compressedFile.isOpen()) {
int size = _compressedFile.size();
_compressedFileMode = true;
_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, makeMP3Stream(&_compressedFile, size));
_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeMP3Stream(&_compressedFile, size));
return;
}
#endif
@ -1281,7 +1281,7 @@ void SmushPlayer::tryCmpFile(const char *filename) {
if (_compressedFile.isOpen()) {
int size = _compressedFile.size();
_compressedFileMode = true;
_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, makeVorbisStream(&_compressedFile, size));
_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeVorbisStream(&_compressedFile, size));
return;
}
#endif

View file

@ -272,10 +272,10 @@ void Sound::playSound(int soundID) {
// We'd have to add the 'Creative Voice File' header for this, though,
// or make readVOCFromMemory() less strict.
VocBlockHeader &voc_block_hdr = *(VocBlockHeader *)ptr;
Audio::VocBlockHeader &voc_block_hdr = *(Audio::VocBlockHeader *)ptr;
assert(voc_block_hdr.blocktype == 1);
size = voc_block_hdr.size[0] + (voc_block_hdr.size[1] << 8) + (voc_block_hdr.size[2] << 16) - 2;
rate = getSampleRateFromVOCRate(voc_block_hdr.sr);
rate = Audio::getSampleRateFromVOCRate(voc_block_hdr.sr);
assert(voc_block_hdr.pack == 0);
// Allocate a sound buffer, copy the data into it, and play
@ -600,29 +600,29 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle
}
if (!_soundsPaused && _vm->_mixer->isReady()) {
AudioStream *input = NULL;
Audio::AudioStream *input = NULL;
switch (_soundMode) {
case kMP3Mode:
#ifdef USE_MAD
assert(size > 0);
input = makeMP3Stream(_sfxFile, size);
input = Audio::makeMP3Stream(_sfxFile, size);
#endif
break;
case kVorbisMode:
#ifdef USE_VORBIS
assert(size > 0);
input = makeVorbisStream(_sfxFile, size);
input = Audio::makeVorbisStream(_sfxFile, size);
#endif
break;
case kFlacMode:
#ifdef USE_FLAC
assert(size > 0);
input = makeFlacStream(_sfxFile, size);
input = Audio::makeFlacStream(_sfxFile, size);
#endif
break;
default:
input = makeVOCStream(*_sfxFile);
input = Audio::makeVOCStream(*_sfxFile);
}
if (!input) {

View file

@ -136,7 +136,7 @@ protected:
* An audio stream to which additional data can be appended on-the-fly.
* Used by SMUSH and iMuseDigital.
*/
class AppendableAudioStream : public AudioStream {
class AppendableAudioStream : public Audio::AudioStream {
public:
virtual void append(const byte *data, uint32 len) = 0;
virtual void finish() = 0;

View file

@ -187,7 +187,7 @@ void MoviePlayer::startSound() {
_fd.read(buffer, size);
Common::MemoryReadStream stream(buffer, size);
_bgSoundStream = makeWAVStream(stream);
_bgSoundStream = Audio::makeWAVStream(stream);
_mixer->stopHandle(_bgSound);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
free(buffer);

View file

@ -38,7 +38,7 @@ class MoviePlayer {
Audio::Mixer *_mixer;
Audio::SoundHandle _bgSound;
AudioStream *_bgSoundStream;
Audio::AudioStream *_bgSoundStream;
bool _omniTV;
bool _playing;

View file

@ -133,7 +133,7 @@ void WavSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags) {
byte wavFlags;
int size, rate;
if (!loadWAVFromStream(*_file, size, rate, wavFlags)) {
if (!Audio::loadWAVFromStream(*_file, size, rate, wavFlags)) {
error("playSound: Not a valid WAV file");
}
@ -151,7 +151,7 @@ void VocSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags) {
_file->seek(_offsets[sound], SEEK_SET);
int size, rate;
byte *buffer = loadVOCFromStream(*_file, size, rate);
byte *buffer = Audio::loadVOCFromStream(*_file, size, rate);
_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);
}
@ -187,7 +187,7 @@ void MP3Sound::playSound(uint sound, Audio::SoundHandle *handle, byte flags)
uint32 size = _offsets[sound + i] - _offsets[sound];
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, makeMP3Stream(_file, size));
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, Audio::makeMP3Stream(_file, size));
}
#endif
@ -211,7 +211,7 @@ void VorbisSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags)
uint32 size = _offsets[sound + i] - _offsets[sound];
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, makeVorbisStream(_file, size));
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, Audio::makeVorbisStream(_file, size));
}
#endif
@ -235,7 +235,7 @@ void FlacSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags)
uint32 size = _offsets[sound + i] - _offsets[sound];
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, makeFlacStream(_file, size));
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, Audio::makeFlacStream(_file, size));
}
#endif
@ -588,7 +588,7 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soun
int size = READ_LE_UINT32(soundData + 4);
Common::MemoryReadStream stream(soundData, size);
if (!loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) {
if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) {
error("playSoundData: Not a valid WAV data");
}
@ -628,7 +628,7 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soun
flags |= Audio::Mixer::FLAG_LOOP;
if (compType == 2) {
AudioStream *sndStream = makeADPCMStream(&stream, size, kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
Audio::AudioStream *sndStream = Audio::makeADPCMStream(&stream, size, Audio::kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
buffer = (byte *)malloc(size * 4);
size = sndStream->readBuffer((int16*)buffer, size * 2);
size *= 2; // 16bits.

View file

@ -33,7 +33,7 @@ namespace Audio {
namespace Sky {
class AdlibMusic : public AudioStream, public MusicBase {
class AdlibMusic : public Audio::AudioStream, public MusicBase {
public:
AdlibMusic(Audio::Mixer *pMixer, Disk *pDisk);
~AdlibMusic(void);

View file

@ -74,11 +74,11 @@ bool AnimationState::soundFinished(void) {
return !_snd->isSoundHandleActive(_bgSound);
}
AudioStream *AnimationState::createAudioStream(const char *name, void *arg) {
Audio::AudioStream *AnimationState::createAudioStream(const char *name, void *arg) {
if (arg)
return (AudioStream*)arg;
return (Audio::AudioStream*)arg;
else
return AudioStream::openStreamFile(name);
return Audio::AudioStream::openStreamFile(name);
}
MoviePlayer::MoviePlayer(Screen *scr, Audio::Mixer *snd, OSystem *sys)
@ -103,7 +103,7 @@ MoviePlayer::~MoviePlayer(void) {
void MoviePlayer::play(uint32 id) {
#if defined(USE_MPEG2) && defined(USE_VORBIS)
AnimationState *anim = new AnimationState(_scr, _snd, _sys);
AudioStream *stream = NULL;
Audio::AudioStream *stream = NULL;
if (SwordEngine::_systemVars.cutscenePackVersion == 1) {
if ((id == SEQ_INTRO) || (id == SEQ_FINALE) || (id == SEQ_HISTORY) || (id == SEQ_FERRARI)) {
// these sequences are language specific
@ -120,7 +120,7 @@ void MoviePlayer::play(uint32 id) {
for (uint32 segCnt = 0; segCnt < numSegs; segCnt++) {
oggSource->seek( header[SwordEngine::_systemVars.language * 2 + 0 + segCnt * 14]);
uint32 segSize = header[SwordEngine::_systemVars.language * 2 + 1 + segCnt * 14];
AudioStream *apStream = makeVorbisStream(oggSource, segSize);
Audio::AudioStream *apStream = Audio::makeVorbisStream(oggSource, segSize);
if (!apStream)
error("Can't create Vorbis Stream from file %s", sndName);
sStream->appendStream(apStream);
@ -240,7 +240,7 @@ int SplittedAudioStream::getRate(void) const {
return 22050;
}
void SplittedAudioStream::appendStream(AudioStream *stream) {
void SplittedAudioStream::appendStream(Audio::AudioStream *stream) {
FileQueue **que = &_queue;
while (*que)
que = &((*que)->next);

View file

@ -76,7 +76,7 @@ private:
#endif
protected:
virtual AudioStream *createAudioStream(const char *name, void *arg);
virtual Audio::AudioStream *createAudioStream(const char *name, void *arg);
};
class MoviePlayer {
@ -98,15 +98,15 @@ private:
};
struct FileQueue {
AudioStream *stream;
Audio::AudioStream *stream;
FileQueue *next;
};
class SplittedAudioStream : public AudioStream {
class SplittedAudioStream : public Audio::AudioStream {
public:
SplittedAudioStream(void);
~SplittedAudioStream(void);
void appendStream(AudioStream *stream);
void appendStream(Audio::AudioStream *stream);
virtual int readBuffer(int16 *buffer, const int numSamples);
virtual bool isStereo(void) const;
virtual bool endOfData(void) const;

View file

@ -86,7 +86,7 @@ bool spaceInBuf(uint16 blitSta, uint16 blitEnd, uint16 renderDest) {
}
void CreditsPlayer::play(void) {
AudioStream *bgSoundStream = AudioStream::openStreamFile("credits");
Audio::AudioStream *bgSoundStream = Audio::AudioStream::openStreamFile("credits");
if (bgSoundStream == NULL) {
warning("\"credits.ogg\" not found, skipping credits sequence");
return;

View file

@ -47,7 +47,7 @@ WaveAudioStream::WaveAudioStream(Common::File *source, uint32 pSize) {
_sourceFile = source;
_sampleBuf = (uint8*)malloc(SMP_BUFSIZE);
_sourceFile->incRef();
if (_sourceFile->isOpen() && loadWAVFromStream(*_sourceFile, size, rate, flags)) {
if (_sourceFile->isOpen() && Audio::loadWAVFromStream(*_sourceFile, size, rate, flags)) {
_isStereo = (flags & Audio::Mixer::FLAG_STEREO) != 0;
_rate = rate;
if (pSize && (int)pSize < size)
@ -107,16 +107,16 @@ bool WaveAudioStream::endOfData(void) const {
// These functions are only called from Music, so I'm just going to
// assume that if locking is needed it has already been taken care of.
AudioStream *MusicHandle::createAudioSource(void) {
Audio::AudioStream *MusicHandle::createAudioSource(void) {
_file.seek(0);
switch (_musicMode) {
#ifdef USE_MAD
case MusicMp3:
return makeMP3Stream(&_file, _file.size());
return Audio::makeMP3Stream(&_file, _file.size());
#endif
#ifdef USE_VORBIS
case MusicVorbis:
return makeVorbisStream(&_file, _file.size());
return Audio::makeVorbisStream(&_file, _file.size());
#endif
case MusicWave:
return makeWaveStream(&_file, 0);

View file

@ -44,7 +44,7 @@ enum MusicMode {
MusicVorbis
};
class WaveAudioStream : public AudioStream {
class WaveAudioStream : public Audio::AudioStream {
public:
WaveAudioStream(Common::File *source, uint32 pSize);
virtual ~WaveAudioStream();
@ -61,15 +61,15 @@ private:
uint16 _bitsPerSample;
};
class MusicHandle : public AudioStream {
class MusicHandle : public Audio::AudioStream {
private:
Common::File _file;
bool _looping;
int32 _fading;
int32 _fadeSamples;
MusicMode _musicMode;
AudioStream *_audioSource;
AudioStream *createAudioSource(void);
Audio::AudioStream *_audioSource;
Audio::AudioStream *createAudioSource(void);
public:
MusicHandle() : _looping(false), _fading(0), _audioSource(NULL) {}
virtual int readBuffer(int16 *buffer, const int numSamples);
@ -85,7 +85,7 @@ public:
int getRate() const;
};
class Music : public AudioStream {
class Music : public Audio::AudioStream {
public:
Music(Audio::Mixer *pMixer);
~Music();

View file

@ -201,7 +201,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
#ifdef USE_MAD
else if (_cowMode == CowMp3) {
_cowFile.seek(index);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_speechHandle, makeMP3Stream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_speechHandle, Audio::makeMP3Stream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan);
// with compressed audio, we can't calculate the wave volume.
// so default to talking.
for (int cnt = 0; cnt < 480; cnt++)
@ -212,7 +212,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
#ifdef USE_VORBIS
else if (_cowMode == CowVorbis) {
_cowFile.seek(index);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_speechHandle, makeVorbisStream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_speechHandle, Audio::makeVorbisStream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan);
for (int cnt = 0; cnt < 480; cnt++)
_waveVolume[cnt] = true;
_waveVolPos = 0;

View file

@ -43,9 +43,9 @@
namespace Sword2 {
static AudioStream *makeCLUStream(Common::File *fp, int size);
static Audio::AudioStream *makeCLUStream(Common::File *fp, int size);
static AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, int cd, uint32 id, uint32 *numSamples) {
static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, int cd, uint32 id, uint32 *numSamples) {
debug(3, "Playing %s from CD %d", base, cd);
if (!fh->file.isOpen()) {
@ -139,15 +139,15 @@ static AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, int cd
return makeCLUStream(&fh->file, enc_len);
#ifdef USE_MAD
case kMP3Mode:
return makeMP3Stream(&fh->file, enc_len);
return Audio::makeMP3Stream(&fh->file, enc_len);
#endif
#ifdef USE_VORBIS
case kVorbisMode:
return makeVorbisStream(&fh->file, enc_len);
return Audio::makeVorbisStream(&fh->file, enc_len);
#endif
#ifdef USE_FLAC
case kFlacMode:
return makeFlacStream(&fh->file, enc_len);
return Audio::makeFlacStream(&fh->file, enc_len);
#endif
default:
return NULL;
@ -232,7 +232,7 @@ void CLUInputStream::refill() {
_bufferEnd = out;
}
AudioStream *makeCLUStream(Common::File *file, int size) {
Audio::AudioStream *makeCLUStream(Common::File *file, int size) {
return new CLUInputStream(file, size);
}
@ -718,7 +718,7 @@ uint32 Sound::preFetchCompSpeech(uint32 speechId, uint16 **buf) {
SoundFileHandle *fh = (cd == 1) ? &_speechFile[0] : &_speechFile[1];
AudioStream *input = getAudioStream(fh, "speech", cd, speechId, &numSamples);
Audio::AudioStream *input = getAudioStream(fh, "speech", cd, speechId, &numSamples);
if (!input)
return 0;
@ -762,7 +762,7 @@ int32 Sound::playCompSpeech(uint32 speechId, uint8 vol, int8 pan) {
int cd = _vm->_resman->getCD();
SoundFileHandle *fh = (cd == 1) ? &_speechFile[0] : &_speechFile[1];
AudioStream *input = getAudioStream(fh, "speech", cd, speechId, NULL);
Audio::AudioStream *input = getAudioStream(fh, "speech", cd, speechId, NULL);
if (!input)
return RDERR_INVALIDID;

View file

@ -265,7 +265,7 @@ int32 Sound::playFx(Audio::SoundHandle *handle, byte *data, uint32 len, uint8 vo
int rate, size;
byte flags;
if (!loadWAVFromStream(stream, size, rate, flags)) {
if (!Audio::loadWAVFromStream(stream, size, rate, flags)) {
warning("playFX: Not a valid WAV file");
return RDERR_INVALIDWAV;
}

View file

@ -79,7 +79,7 @@ enum {
RDSE_SPEAKING = 0
};
class CLUInputStream : public AudioStream {
class CLUInputStream : public Audio::AudioStream {
private:
Common::File *_file;
bool _firstTime;
@ -118,12 +118,12 @@ struct SoundFileHandle {
volatile bool inUse;
};
class MusicInputStream : public AudioStream {
class MusicInputStream : public Audio::AudioStream {
private:
int _cd;
SoundFileHandle *_fh;
uint32 _musicId;
AudioStream *_decoder;
Audio::AudioStream *_decoder;
int16 _buffer[BUFFER_SIZE];
const int16 *_bufferEnd;
const int16 *_pos;
@ -165,7 +165,7 @@ public:
int32 getTimeRemaining();
};
class Sound : public AudioStream {
class Sound : public Audio::AudioStream {
private:
Sword2Engine *_vm;

View file

@ -155,8 +155,8 @@ bool BaseAnimationState::init(const char *name, void *audioArg) {
#endif
}
AudioStream *BaseAnimationState::createAudioStream(const char *name, void *arg) {
return AudioStream::openStreamFile(name);
Audio::AudioStream *BaseAnimationState::createAudioStream(const char *name, void *arg) {
return Audio::AudioStream::openStreamFile(name);
}
bool BaseAnimationState::decodeFrame() {

View file

@ -26,7 +26,9 @@
#include "common/scummsys.h"
#include "sound/mixer.h"
class AudioStream;
namespace Audio {
class AudioStream;
}
// Uncomment this if you are using libmpeg2 0.3.1.
// #define USE_MPEG2_0_3_1
@ -91,7 +93,7 @@ protected:
Common::File *_mpegFile;
Audio::SoundHandle _bgSound;
AudioStream *_bgSoundStream;
Audio::AudioStream *_bgSoundStream;
#ifdef BACKEND_8BIT
int _palNum;
@ -132,7 +134,7 @@ public:
protected:
bool checkPaletteSwitch();
virtual void drawYUV(int width, int height, byte *const *dat) = 0;
virtual AudioStream *createAudioStream(const char *name, void *arg);
virtual Audio::AudioStream *createAudioStream(const char *name, void *arg);
#ifdef BACKEND_8BIT
void buildLookup(int p, int lines);

View file

@ -28,6 +28,8 @@
#include "sound/audiostream.h"
namespace Audio {
// TODO: Switch from a SeekableReadStream to a plain ReadStream. This requires
// some internal refactoring but is definitely possible and will increase the
// flexibility of this code.
@ -353,3 +355,5 @@ int16 ADPCMInputStream::decodeMS(ADPCMChannelStatus *c, byte code) {
AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) {
return new ADPCMInputStream(stream, size, type, rate, channels, blockAlign);
}
} // End of namespace Audio

View file

@ -27,6 +27,9 @@
#include "common/scummsys.h"
#include "common/stream.h"
namespace Audio {
class AudioStream;
enum typesADPCM {
@ -37,5 +40,6 @@ enum typesADPCM {
AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int rate = 22050, int channels = 2, uint32 blockAlign = 0);
} // End of namespace Audio
#endif

View file

@ -31,6 +31,8 @@
#include "common/util.h"
#include "common/system.h"
namespace Audio {
struct TrackFormat {
/** Decodername */
const char* decoderName;
@ -165,3 +167,5 @@ int AudioCDManager::getCachedTrack(int track) {
debug(2, "Track %d not available in compressed format", track);
return -1;
}
} // End of namespace Audio

View file

@ -28,6 +28,9 @@
#include "common/singleton.h"
#include "sound/mixer.h"
namespace Audio {
class DigitalTrackInfo {
public:
virtual bool error() = 0;
@ -82,6 +85,8 @@ private:
};
/** Shortcut for accessing the audio CD manager. */
#define AudioCD AudioCDManager::instance()
#define AudioCD Audio::AudioCDManager::instance()
} // End of namespace Audio
#endif

View file

@ -31,6 +31,9 @@
#include "sound/vorbis.h"
#include "sound/flac.h"
namespace Audio {
struct StreamFileFormat {
/** Decodername */
const char* decoderName;
@ -209,3 +212,6 @@ AudioStream *makeLinearInputStream(int rate, byte flags, const byte *ptr, uint32
}
}
}
} // End of namespace Audio

View file

@ -28,6 +28,8 @@
#include "common/scummsys.h"
namespace Audio {
/**
* Generic input stream for the resampling code.
*/
@ -116,11 +118,10 @@ AudioStream *makeLinearInputStream(int rate, byte flags, const byte *ptr, uint32
// us to go with the macro approach. So far this is
// the only template function that MSVC6 seemed to
// compile incorrectly. Knock on wood.
#define READSAMPLE(is16Bit, isUnsigned, ptr) \
((is16Bit ? READ_BE_UINT16(ptr) : (*ptr << 8)) ^ (isUnsigned ? 0x8000 : 0))
#define READ_ENDIAN_SAMPLE(is16Bit, isUnsigned, ptr, isLE) \
((is16Bit ? (isLE ? READ_LE_UINT16(ptr) : READ_BE_UINT16(ptr)) : (*ptr << 8)) ^ (isUnsigned ? 0x8000 : 0))
} // End of namespace Audio
#endif

View file

@ -37,6 +37,8 @@
using Common::File;
namespace Audio {
#pragma mark -
#pragma mark --- Flac stream ---
#pragma mark -
@ -849,4 +851,6 @@ AudioStream *makeFlacStream(File *file, uint32 length)
}
} // End of namespace Audio
#endif // #ifdef USE_FLAC

View file

@ -28,12 +28,15 @@
#ifdef USE_FLAC
class AudioStream;
class DigitalTrackInfo;
namespace Common {
class File;
}
namespace Audio {
class AudioStream;
class DigitalTrackInfo;
DigitalTrackInfo *getFlacTrack(int track);
/**
@ -44,5 +47,7 @@ DigitalTrackInfo *getFlacTrack(int track);
*/
AudioStream *makeFlacStream(Common::File *file, uint32 size);
} // End of namespace Audio
#endif // #ifdef USE_FLAC
#endif // #ifndef SOUND_FLAC_H

View file

@ -29,12 +29,12 @@
#include "common/mutex.h"
class AudioStream;
class OSystem;
namespace Audio {
class AudioStream;
class Channel;
class Mixer;

View file

@ -36,6 +36,8 @@
using Common::File;
namespace Audio {
#pragma mark -
#pragma mark --- MP3 (MAD) stream ---
#pragma mark -
@ -487,4 +489,6 @@ DigitalTrackInfo *getMP3Track(int track) {
}
#endif
} // End of namespace Audio
#endif // #ifdef USE_MAD

View file

@ -28,12 +28,15 @@
#ifdef USE_MAD
class AudioStream;
class DigitalTrackInfo;
namespace Common {
class File;
}
namespace Audio {
class AudioStream;
class DigitalTrackInfo;
DigitalTrackInfo *getMP3Track(int track);
/**
@ -44,6 +47,7 @@ DigitalTrackInfo *getMP3Track(int track);
*/
AudioStream *makeMP3Stream(Common::File *file, uint32 size);
#endif
} // End of namespace Audio
#endif
#endif // #ifdef USE_MAD
#endif // #ifndef SOUND_MP3_H

View file

@ -26,7 +26,7 @@
#define FIXP_SHIFT 16
class MidiDriver_Emulated : public AudioStream, public MidiDriver {
class MidiDriver_Emulated : public Audio::AudioStream, public MidiDriver {
protected:
bool _isOpen;
Audio::Mixer *_mixer;

View file

@ -31,6 +31,8 @@
#include "sound/voc.h"
namespace Audio {
int getSampleRateFromVOCRate(int vocSR) {
if (vocSR == 0xa5 || vocSR == 0xa6) {
return 11025;
@ -140,3 +142,5 @@ AudioStream *makeVOCStream(Common::ReadStream &stream) {
return makeLinearInputStream(rate, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED, data, size, 0, 0);
}
} // End of namespace Audio

View file

@ -27,9 +27,13 @@
#include "common/stdafx.h"
#include "common/scummsys.h"
class AudioStream;
namespace Common { class ReadStream; }
namespace Audio {
class AudioStream;
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
@ -81,4 +85,6 @@ extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate)
*/
AudioStream *makeVOCStream(Common::ReadStream &stream);
} // End of namespace Audio
#endif

View file

@ -44,6 +44,8 @@
using Common::File;
namespace Audio {
static AudioStream *makeVorbisStream(OggVorbis_File *file, int duration);
#pragma mark -
@ -134,7 +136,7 @@ static int seek_wrap(void *datasource, ogg_int64_t offset, int whence) {
f->curr_pos = f->file->pos() - f->start;
#ifdef __SYMBIAN32__
// For symbian we now store the last read position and then close the file
// For symbian we now store the last read position and then close the file
if (f->file) {
f->file->close();
}
@ -208,7 +210,7 @@ bool VorbisTrackInfo::openTrack() {
#ifndef __SYMBIAN32__
_file->incRef();
#endif
}
}
return err;
}
@ -233,7 +235,7 @@ void VorbisTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int
ov_time_seek(&_ov_file, (ogg_int64_t)(startFrame / 75.0 * 1000));
#endif
#else
ov_time_seek(&_ov_file, startFrame / 75.0);
ov_time_seek(&_ov_file, startFrame / 75.0);
#endif
AudioStream *input = makeVorbisStream(&_ov_file, duration * ov_info(&_ov_file, -1)->rate / 75);
@ -392,7 +394,7 @@ AudioStream *makeVorbisStream(File *file, uint32 size) {
#else
f->file = file;
#endif
f->start = file->pos();
f->start = file->pos();
f->len = size;
f->curr_pos = 0;
@ -400,12 +402,16 @@ AudioStream *makeVorbisStream(File *file, uint32 size) {
warning("Invalid file format");
delete ov_file;
delete f;
return 0;
} else {
return 0;
} else {
#ifndef __SYMBIAN32__
file->incRef();
#endif
return new VorbisInputStream(ov_file, 0, true);
}
}
#endif
}
} // End of namespace Audio
#endif // #ifdef USE_VORBIS

View file

@ -28,12 +28,15 @@
#ifdef USE_VORBIS
class AudioStream;
class DigitalTrackInfo;
namespace Common {
class File;
}
namespace Audio {
class AudioStream;
class DigitalTrackInfo;
DigitalTrackInfo *getVorbisTrack(int track);
/**
@ -44,6 +47,7 @@ DigitalTrackInfo *getVorbisTrack(int track);
*/
AudioStream *makeVorbisStream(Common::File *file, uint32 size);
#endif
} // End of namespace Audio
#endif
#endif // #ifdef USE_VORBIS
#endif // #ifndef SOUND_VORBIS_H

View file

@ -29,6 +29,8 @@
#include "sound/wave.h"
#include "sound/adpcm.h"
namespace Audio {
bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate, byte &flags, uint16 *wavType, int *blockAlign_) {
const uint32 initialPos = stream.pos();
byte buf[4+1];
@ -181,3 +183,5 @@ AudioStream *makeWAVStream(Common::SeekableReadStream &stream) {
return makeLinearInputStream(rate, flags, data, size, 0, 0);
}
} // End of namespace Audio

View file

@ -26,9 +26,12 @@
#include "common/stdafx.h"
#include "common/scummsys.h"
class AudioStream;
namespace Common { class SeekableReadStream; }
namespace Audio {
class AudioStream;
/**
* Try to load a WAVE from the given seekable stream. Returns true if
* successful. In that case, the stream's seek position will be set to the
@ -47,4 +50,6 @@ extern bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int
*/
AudioStream *makeWAVStream(Common::SeekableReadStream &stream);
} // End of namespace Audio
#endif