Convert more engines from Mixer::playRaw to Mixer::playInputStream

svn-id: r47377
This commit is contained in:
Max Horn 2010-01-19 11:22:14 +00:00
parent d2dd5a569a
commit 5ee6c79b5d
6 changed files with 34 additions and 15 deletions

View File

@ -32,6 +32,7 @@
#include "sound/audiostream.h"
#include "sound/fmopl.h"
#include "sound/raw.h"
#include "sound/mods/soundfx.h"
namespace Cine {
@ -844,7 +845,8 @@ void PaulaSound::update() {
void PaulaSound::playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume) {
assert(frequency > 0);
frequency = PAULA_FREQ / frequency;
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], data, size, DisposeAfterUse::YES, frequency, 0);
Audio::AudioStream *stream = Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, frequency, 0);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], stream);
_mixer->setChannelVolume(_channelsTable[channel], volume * Audio::Mixer::kMaxChannelVolume / 63);
}

View File

@ -23,9 +23,12 @@
*
*/
#include "sound/mixer.h"
#include "sound/voc.h"
#include "sound/audiocd.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
#include "sound/raw.h"
#include "sound/voc.h"
#include "common/config-manager.h"
#include "drascula/drascula.h"
@ -182,8 +185,9 @@ void DrasculaEngine::playFile(const char *fname) {
if (ConfMan.getBool("speech_mute"))
memset(soundData, 0x80, soundSize); // Mute speech but keep the pause
_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_soundHandle, soundData, soundSize - 64, DisposeAfterUse::YES,
Audio::AudioStream *stream = Audio::makeRawMemoryStream(soundData, soundSize - 64, DisposeAfterUse::YES,
11025, Audio::Mixer::FLAG_UNSIGNED);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_soundHandle, stream);
} else
warning("playFile: Could not open %s", fname);
}

View File

@ -31,6 +31,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
#include "sound/adpcm.h"
#include "sound/raw.h"
namespace Saga {

View File

@ -260,7 +260,7 @@ void Sound::playSample(QueueElement *elem) {
if (SwordEngine::isPsx()) { ;
uint32 size = READ_LE_UINT32(sampleData);
Audio::AudioStream *audStream = Audio::makeLoopingAudioStream(new Audio::VagStream(new Common::MemoryReadStream(sampleData + 4, size-4)), (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan, DisposeAfterUse::NO, false, false);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan, DisposeAfterUse::NO);
} else {
uint32 size = READ_LE_UINT32(sampleData + 0x28);
uint8 flags;
@ -351,17 +351,24 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
debug(6, "startSpeech(%d, %d): locIndex %d, sampleSize %d, index %d", roomNo, localNo, locIndex, sampleSize, index);
Audio::AudioStream *stream = 0;
if (sampleSize) {
uint8 speechVol = (_speechVolR + _speechVolL) / 2;
int8 speechPan = (_speechVolR - _speechVolL) / 2;
if ((_cowMode == CowWave) || (_cowMode == CowDemo)) {
uint32 size;
int16 *data = uncompressSpeech(index + _cowHeaderSize, sampleSize, &size);
if (data)
_mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_speechHandle, data, size, DisposeAfterUse::YES, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan);
if (data) {
stream = Audio::makeRawMemoryStream((byte *)data, size, DisposeAfterUse::YES, 11025, SPEECH_FLAGS);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, stream, SOUND_SPEECH_ID, speechVol, speechPan);
}
} else if (_cowMode == CowPSX && sampleSize != 0xffffffff) {
_cowFile.seek(index * 2048);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, new Audio::VagStream(_cowFile.readStream(sampleSize)), SOUND_SPEECH_ID, speechVol, speechPan);
Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize);
assert(tmp);
stream = new Audio::VagStream(tmp);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, stream, 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++)
@ -373,7 +380,8 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
_cowFile.seek(index);
Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize);
assert(tmp);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeFlacStream(tmp, DisposeAfterUse::YES), SOUND_SPEECH_ID, speechVol, speechPan);
stream = Audio::makeFlacStream(tmp, DisposeAfterUse::YES);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, stream, 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++)
@ -386,7 +394,8 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
_cowFile.seek(index);
Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize);
assert(tmp);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeVorbisStream(tmp, DisposeAfterUse::YES), SOUND_SPEECH_ID, speechVol, speechPan);
stream = Audio::makeVorbisStream(tmp, DisposeAfterUse::YES);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, stream, 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++)
@ -399,7 +408,8 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
_cowFile.seek(index);
Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize);
assert(tmp);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(tmp, DisposeAfterUse::YES), SOUND_SPEECH_ID, speechVol, speechPan);
stream = Audio::makeMP3Stream(tmp, DisposeAfterUse::YES);
_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, stream, 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++)

View File

@ -29,6 +29,7 @@
#include "common/system.h"
#include "engines/advancedDetector.h"
#include "sound/mixer.h"
#include "sound/raw.h"
#include "graphics/cursorman.h"
#include "graphics/thumbnail.h"
#include "teenagent/console.h"
@ -893,11 +894,12 @@ void TeenAgentEngine::playSoundNow(byte id) {
}
uint size = in->size();
char *data = new char[size];
byte *data = (byte *)malloc(size);
in->read(data, size);
//debug(0, "playing %u samples...", size);
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, data, size, DisposeAfterUse::YES, 11025, 0);
Audio::AudioStream *stream = Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, 11025, 0);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream);
}

View File

@ -43,6 +43,7 @@
#include "sound/vag.h"
#include "sound/flac.h"
#include "sound/mp3.h"
#include "sound/raw.h"
#include "sound/vorbis.h"
#include "gui/message.h"
@ -153,8 +154,7 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
#endif
break;
default:
_vm->_mixer->playRaw(type, &curChan.handle, sampleBuf, sampleLen, DisposeAfterUse::YES, 22050,
Audio::Mixer::FLAG_UNSIGNED);
sampleStream = Audio::makeRawMemoryStream(sampleBuf, sampleLen, DisposeAfterUse::YES, 22050, Audio::Mixer::FLAG_UNSIGNED);
break;
}
if (sampleStream) {