mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
SCUMM: Further SMUSH audio channel cleanup; this time unified some code, and got rid of one set of memory buffers
svn-id: r24542
This commit is contained in:
parent
d90762c430
commit
48e5ec67ff
@ -56,13 +56,12 @@ public:
|
||||
virtual bool setParameters(int32, int32, int32, int32, int32) = 0;
|
||||
virtual bool checkParameters(int32, int32, int32, int32, int32) = 0;
|
||||
virtual bool isTerminated() const = 0;
|
||||
virtual int32 getAvailableSoundDataSize() const = 0;
|
||||
virtual void getSoundData(int16 *sound_buffer, int32 size) = 0;
|
||||
virtual void getSoundData(int8 *sound_buffer, int32 size) = 0;
|
||||
virtual byte *getSoundData() = 0;
|
||||
virtual int32 getRate() = 0;
|
||||
virtual bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) = 0;
|
||||
|
||||
int32 getTrackIdentifier() const { return _track; };
|
||||
int32 getAvailableSoundDataSize() const { return _sbufferSize; }
|
||||
int32 getTrackIdentifier() const { return _track; }
|
||||
};
|
||||
|
||||
class SaudChannel : public SmushChannel {
|
||||
@ -86,9 +85,7 @@ public:
|
||||
bool setParameters(int32 duration, int32 flags, int32 vol1, int32 vol2, int32 index);
|
||||
bool checkParameters(int32 index, int32 duration, int32 flags, int32 vol1, int32 vol2);
|
||||
bool appendData(Chunk &b, int32 size);
|
||||
int32 getAvailableSoundDataSize() const;
|
||||
void getSoundData(int16 *sound_buffer, int32 size) { error("16bit request for SAUD channel should never happen"); };
|
||||
void getSoundData(int8 *sound_buffer, int32 size);
|
||||
byte *getSoundData();
|
||||
int32 getRate() { return 22050; }
|
||||
bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) {
|
||||
stereo = false;
|
||||
@ -123,9 +120,7 @@ public:
|
||||
bool setParameters(int32 nbframes, int32 size, int32 track_flags, int32 unk1, int32);
|
||||
bool checkParameters(int32 index, int32 nbframes, int32 size, int32 track_flags, int32 unk1);
|
||||
bool appendData(Chunk &b, int32 size);
|
||||
int32 getAvailableSoundDataSize() const;
|
||||
void getSoundData(int16 *sound_buffer, int32 size);
|
||||
void getSoundData(int8 *sound_buffer, int32 size);
|
||||
byte *getSoundData();
|
||||
int32 getRate() { return _rate; }
|
||||
bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) {
|
||||
stereo = (_channels == 2);
|
||||
|
@ -246,36 +246,16 @@ bool ImuseChannel::handleSubTags(int32 &offset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 ImuseChannel::getAvailableSoundDataSize(void) const {
|
||||
int32 ret = _sbufferSize;
|
||||
if (_channels == 2) ret /= 2;
|
||||
if (_bitsize > 8) ret /= 2;
|
||||
return ret;
|
||||
}
|
||||
byte *ImuseChannel::getSoundData() {
|
||||
byte *tmp = _sbuffer;
|
||||
|
||||
void ImuseChannel::getSoundData(int16 *snd, int32 size) {
|
||||
if (_dataSize <= 0 || _bitsize <= 8) error("invalid call to imuse_channel::read_sound_data()");
|
||||
if (_channels == 2) size *= 2;
|
||||
assert(_dataSize > 0);
|
||||
_dataSize -= _srbufferSize;
|
||||
|
||||
memcpy(snd, _sbuffer, size * 2);
|
||||
|
||||
delete []_sbuffer;
|
||||
assert(_sbufferSize == 2 * size);
|
||||
_sbuffer = 0;
|
||||
_sbufferSize = 0;
|
||||
_dataSize -= _srbufferSize;
|
||||
}
|
||||
|
||||
void ImuseChannel::getSoundData(int8 *snd, int32 size) {
|
||||
if (_dataSize <= 0 || _bitsize > 8) error("invalid call to imuse_channel::read_sound_data()");
|
||||
if (_channels == 2) size *= 2;
|
||||
|
||||
memcpy(snd, _sbuffer, size);
|
||||
|
||||
delete []_sbuffer;
|
||||
_sbuffer = 0;
|
||||
_sbufferSize = 0;
|
||||
_dataSize -= _srbufferSize;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
} // End of namespace Scumm
|
||||
|
@ -180,17 +180,17 @@ bool SaudChannel::appendData(Chunk &b, int32 size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32 SaudChannel::getAvailableSoundDataSize(void) const {
|
||||
return _sbufferSize;
|
||||
}
|
||||
byte *SaudChannel::getSoundData() {
|
||||
byte *tmp = _sbuffer;
|
||||
|
||||
void SaudChannel::getSoundData(int8 *snd, int32 size) {
|
||||
memcpy(snd, _sbuffer, size);
|
||||
assert(_dataSize > 0);
|
||||
if (!_keepSize)
|
||||
_dataSize -= size;
|
||||
delete []_sbuffer;
|
||||
_dataSize -= _sbufferSize;
|
||||
|
||||
_sbuffer = 0;
|
||||
_sbufferSize = 0;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
} // End of namespace Scumm
|
||||
|
@ -106,24 +106,16 @@ bool SmushMixer::handleFrame() {
|
||||
} else {
|
||||
int32 vol, pan;
|
||||
bool stereo, is_16bit;
|
||||
void *data;
|
||||
|
||||
_channels[i].chan->getParameters(stereo, is_16bit, vol, pan);
|
||||
|
||||
int32 size = _channels[i].chan->getAvailableSoundDataSize();
|
||||
byte *data = _channels[i].chan->getSoundData();
|
||||
|
||||
byte flags = stereo ? Audio::Mixer::FLAG_STEREO : 0;
|
||||
|
||||
if (is_16bit) {
|
||||
data = malloc(size * (stereo ? 4 : 2));
|
||||
_channels[i].chan->getSoundData((int16 *)data, size);
|
||||
size *= stereo ? 4 : 2;
|
||||
|
||||
flags |= Audio::Mixer::FLAG_16BITS;
|
||||
|
||||
} else {
|
||||
data = malloc(size * (stereo ? 2 : 1));
|
||||
_channels[i].chan->getSoundData((int8 *)data, size);
|
||||
size *= stereo ? 2 : 1;
|
||||
|
||||
flags |= Audio::Mixer::FLAG_UNSIGNED;
|
||||
}
|
||||
|
||||
@ -134,9 +126,9 @@ bool SmushMixer::handleFrame() {
|
||||
}
|
||||
_mixer->setChannelVolume(_channels[i].handle, vol);
|
||||
_mixer->setChannelBalance(_channels[i].handle, pan);
|
||||
_channels[i].stream->append((byte *)data, size);
|
||||
_channels[i].stream->append(data, size);
|
||||
}
|
||||
free(data);
|
||||
delete[] data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user