mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-05 00:36:57 +00:00
Remove loop start/end params from Mixer::playRaw; convert some code from Mixer::playRaw to Mixer::playInputStream
svn-id: r47375
This commit is contained in:
parent
f0a0ed8f9e
commit
b227c660c6
@ -35,6 +35,7 @@
|
||||
|
||||
#include "sound/audiostream.h"
|
||||
#include "sound/mixer.h"
|
||||
#include "sound/raw.h"
|
||||
|
||||
namespace Draci {
|
||||
|
||||
@ -203,8 +204,8 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffe
|
||||
Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
|
||||
|
||||
// Don't use DisposeAfterUse::YES, because our caching system deletes samples by itself.
|
||||
_mixer->playRaw(soundType, handle, buffer._data,
|
||||
buffer._length, DisposeAfterUse::NO, buffer._frequency, flags, -1, volume);
|
||||
Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer._data, buffer._length, DisposeAfterUse::NO, buffer._frequency, flags, 0, 0);
|
||||
_mixer->playInputStream(soundType, handle, stream, -1, volume);
|
||||
}
|
||||
|
||||
void Sound::playSound(const SoundSample *buffer, int volume, bool loop) {
|
||||
|
@ -27,9 +27,11 @@
|
||||
#include "m4/sound.h"
|
||||
#include "m4/compression.h"
|
||||
|
||||
#include "common/stream.h"
|
||||
|
||||
#include "sound/audiostream.h"
|
||||
#include "sound/mixer.h"
|
||||
#include "common/stream.h"
|
||||
#include "sound/raw.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
@ -96,7 +98,8 @@ void Sound::playSound(const char *soundName, int volume, bool loop, int channel)
|
||||
_vm->res()->toss(soundName);
|
||||
|
||||
// Sound format is 8bit mono, unsigned, 11025kHz
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, bufferSize, DisposeAfterUse::YES, 11025, flags, -1, volume);
|
||||
Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, bufferSize, DisposeAfterUse::YES, 11025, flags, 0, 0);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume);
|
||||
}
|
||||
|
||||
void Sound::pauseSound() {
|
||||
@ -139,7 +142,7 @@ void Sound::playVoice(const char *soundName, int volume) {
|
||||
SndHandle *handle = getHandle();
|
||||
byte *buffer;
|
||||
|
||||
buffer = new byte[soundStream->size()];
|
||||
buffer = (byte *)malloc(soundStream->size());
|
||||
soundStream->read(buffer, soundStream->size());
|
||||
|
||||
handle->type = kEffectHandle;
|
||||
@ -148,7 +151,8 @@ void Sound::playVoice(const char *soundName, int volume) {
|
||||
_vm->res()->toss(soundName);
|
||||
|
||||
// Voice format is 8bit mono, unsigned, 11025kHz
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, soundStream->size(), DisposeAfterUse::YES, 11025, flags, -1, volume);
|
||||
Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, soundStream->size(), DisposeAfterUse::YES, 11025, flags);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume);
|
||||
}
|
||||
|
||||
void Sound::pauseVoice() {
|
||||
@ -264,9 +268,10 @@ void Sound::playDSRSound(int soundIndex, int volume, bool loop) {
|
||||
buffer, _dsrFile.dsrEntries[soundIndex]->uncompSize);
|
||||
|
||||
// Play sound
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer,
|
||||
Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer,
|
||||
_dsrFile.dsrEntries[soundIndex]->uncompSize, DisposeAfterUse::YES,
|
||||
_dsrFile.dsrEntries[soundIndex]->frequency, flags, -1, volume);
|
||||
_dsrFile.dsrEntries[soundIndex]->frequency, flags, 0, 0);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume);
|
||||
|
||||
/*
|
||||
// Dump the sound file
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "sound/mididrv.h"
|
||||
#include "sound/mixer.h"
|
||||
#include "sound/mp3.h"
|
||||
#include "sound/raw.h"
|
||||
#include "sound/voc.h"
|
||||
#include "sound/vorbis.h"
|
||||
#include "sound/wave.h"
|
||||
@ -159,7 +160,8 @@ void Sound::processSoundQueues() {
|
||||
|
||||
void Sound::playSound(int soundID) {
|
||||
byte *ptr;
|
||||
char *sound;
|
||||
byte *sound;
|
||||
Audio::AudioStream *stream;
|
||||
int size = -1;
|
||||
int rate;
|
||||
byte flags = Audio::Mixer::FLAG_UNSIGNED;
|
||||
@ -199,7 +201,7 @@ void Sound::playSound(int soundID) {
|
||||
ptr += 0x72;
|
||||
|
||||
// Allocate a sound buffer, copy the data into it, and play
|
||||
sound = (char *)malloc(size);
|
||||
sound = (byte *)malloc(size);
|
||||
memcpy(sound, ptr, size);
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
|
||||
}
|
||||
@ -221,7 +223,7 @@ void Sound::playSound(int soundID) {
|
||||
ptr += 0x26;
|
||||
|
||||
// Allocate a sound buffer, copy the data into it, and play
|
||||
sound = (char *)malloc(size);
|
||||
sound = (byte *)malloc(size);
|
||||
memcpy(sound, ptr, size);
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
|
||||
}
|
||||
@ -292,7 +294,7 @@ void Sound::playSound(int soundID) {
|
||||
assert(voc_block_hdr.pack == 0);
|
||||
|
||||
// Allocate a sound buffer, copy the data into it, and play
|
||||
sound = (char *)malloc(size);
|
||||
sound = (byte *)malloc(size);
|
||||
memcpy(sound, ptr + 6, size);
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
|
||||
}
|
||||
@ -334,9 +336,9 @@ void Sound::playSound(int soundID) {
|
||||
warning("Wrong wave size in sound #%i: %i", soundID, waveSize);
|
||||
waveSize = size;
|
||||
}
|
||||
sound = (char *)malloc(waveSize);
|
||||
sound = (byte *)malloc(waveSize);
|
||||
for (int x = 0; x < waveSize; x++) {
|
||||
int b = *ptr++;
|
||||
byte b = *ptr++;
|
||||
if (b < 0x80)
|
||||
sound[x] = 0x7F - b;
|
||||
else
|
||||
@ -347,7 +349,8 @@ void Sound::playSound(int soundID) {
|
||||
if (loopEnd > 0)
|
||||
flags |= Audio::Mixer::FLAG_LOOP;
|
||||
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, waveSize, DisposeAfterUse::YES, rate, flags, soundID, 255, 0, loopStart, loopEnd);
|
||||
stream = Audio::makeRawMemoryStream(sound, waveSize, DisposeAfterUse::YES, rate, flags, loopStart, loopEnd);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, 255, 0);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
@ -424,7 +427,7 @@ void Sound::playSound(int soundID) {
|
||||
assert(size);
|
||||
|
||||
rate = 3579545 / READ_BE_UINT16(ptr + 20);
|
||||
sound = (char *)malloc(size);
|
||||
sound = (byte *)malloc(size);
|
||||
int vol = ptr[24] * 4;
|
||||
int loopStart = 0, loopEnd = 0;
|
||||
int loopcount = ptr[27];
|
||||
@ -439,8 +442,8 @@ void Sound::playSound(int soundID) {
|
||||
}
|
||||
|
||||
memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate,
|
||||
flags, soundID, vol, 0, loopStart, loopEnd);
|
||||
stream = Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, rate, flags, loopStart, loopEnd);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, vol, 0);
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "sky/sound.h"
|
||||
#include "sky/struc.h"
|
||||
|
||||
#include "sound/raw.h"
|
||||
|
||||
namespace Sky {
|
||||
|
||||
#define SOUND_FILE_BASE 60203
|
||||
@ -1115,10 +1117,13 @@ void Sound::playSound(uint16 sound, uint16 volume, uint8 channel) {
|
||||
flags |= Audio::Mixer::FLAG_LOOP;
|
||||
}
|
||||
|
||||
|
||||
Audio::AudioStream *stream = Audio::makeRawMemoryStream(_soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, loopSta, loopEnd);
|
||||
|
||||
if (channel == 0)
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound0, _soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, SOUND_CH0, volume, 0, loopSta, loopEnd);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_ingameSound0, stream, SOUND_CH0, volume, 0);
|
||||
else
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound1, _soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, SOUND_CH1, volume, 0, loopSta, loopEnd);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_ingameSound1, stream, SOUND_CH1, volume, 0);
|
||||
}
|
||||
|
||||
void Sound::fnStartFx(uint32 sound, uint8 channel) {
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
#include "sound/flac.h"
|
||||
#include "sound/mp3.h"
|
||||
#include "sound/raw.h"
|
||||
#include "sound/vorbis.h"
|
||||
#include "sound/wave.h"
|
||||
#include "sound/vag.h"
|
||||
@ -271,7 +272,8 @@ void Sound::playSample(QueueElement *elem) {
|
||||
flags |= Audio::Mixer::FLAG_STEREO;
|
||||
if (_fxList[elem->id].type == FX_LOOP)
|
||||
flags |= Audio::Mixer::FLAG_LOOP;
|
||||
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &elem->handle, sampleData + 0x2C, size, DisposeAfterUse::NO, 11025, flags, elem->id, volume, pan, 0, 0);
|
||||
Audio::AudioStream *stream = Audio::makeRawMemoryStream(sampleData + 0x2C, size, DisposeAfterUse::NO, 11025, flags, 0, 0);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &elem->handle, stream, elem->id, volume, pan);
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -224,14 +224,13 @@ void MixerImpl::playRaw(
|
||||
uint32 size,
|
||||
DisposeAfterUse::Flag autofreeBuffer,
|
||||
uint rate, byte flags,
|
||||
int id, byte volume, int8 balance,
|
||||
uint32 loopStart, uint32 loopEnd) {
|
||||
int id, byte volume, int8 balance) {
|
||||
|
||||
// Create the input stream
|
||||
AudioStream *input = makeRawMemoryStream((byte *)sound, size, autofreeBuffer, rate, flags, loopStart, loopEnd);
|
||||
// Create the audio stream
|
||||
AudioStream *stream = makeRawMemoryStream((byte *)sound, size, autofreeBuffer, rate, flags, 0, 0);
|
||||
|
||||
// Play it
|
||||
playInputStream(type, handle, input, id, volume, balance, DisposeAfterUse::YES, false, false);
|
||||
playInputStream(type, handle, stream, id, volume, balance, DisposeAfterUse::YES, false, false);
|
||||
}
|
||||
|
||||
void MixerImpl::playInputStream(
|
||||
|
@ -133,9 +133,11 @@ public:
|
||||
SoundHandle *handle,
|
||||
void *sound, uint32 size,
|
||||
DisposeAfterUse::Flag autofreeBuffer,
|
||||
uint rate, byte flags,
|
||||
int id = -1, byte volume = kMaxChannelVolume, int8 balance = 0,
|
||||
uint32 loopStart = 0, uint32 loopEnd = 0) = 0;
|
||||
uint rate,
|
||||
byte flags,
|
||||
int id = -1,
|
||||
byte volume = kMaxChannelVolume,
|
||||
int8 balance = 0) = 0;
|
||||
|
||||
/**
|
||||
* Start playing the given audio input stream.
|
||||
@ -161,7 +163,9 @@ public:
|
||||
SoundType type,
|
||||
SoundHandle *handle,
|
||||
AudioStream *input,
|
||||
int id = -1, byte volume = kMaxChannelVolume, int8 balance = 0,
|
||||
int id = -1,
|
||||
byte volume = kMaxChannelVolume,
|
||||
int8 balance = 0,
|
||||
DisposeAfterUse::Flag autofreeStream = DisposeAfterUse::YES,
|
||||
bool permanent = false,
|
||||
bool reverseStereo = false) = 0;
|
||||
|
@ -80,8 +80,7 @@ public:
|
||||
void *sound, uint32 size,
|
||||
DisposeAfterUse::Flag autofreeBuffer,
|
||||
uint rate, byte flags,
|
||||
int id, byte volume, int8 balance,
|
||||
uint32 loopStart, uint32 loopEnd);
|
||||
int id, byte volume, int8 balance);
|
||||
|
||||
virtual void playInputStream(
|
||||
SoundType type,
|
||||
|
Loading…
Reference in New Issue
Block a user