[Scummvm-cvs-logs] SF.net SVN: scummvm: [24542] scummvm/trunk/engines/scumm/smush
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Oct 28 02:18:20 CEST 2006
Revision: 24542
http://svn.sourceforge.net/scummvm/?rev=24542&view=rev
Author: fingolfin
Date: 2006-10-27 17:18:13 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
SCUMM: Further SMUSH audio channel cleanup; this time unified some code, and got rid of one set of memory buffers
Modified Paths:
--------------
scummvm/trunk/engines/scumm/smush/channel.h
scummvm/trunk/engines/scumm/smush/imuse_channel.cpp
scummvm/trunk/engines/scumm/smush/saud_channel.cpp
scummvm/trunk/engines/scumm/smush/smush_mixer.cpp
Modified: scummvm/trunk/engines/scumm/smush/channel.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/channel.h 2006-10-28 00:04:50 UTC (rev 24541)
+++ scummvm/trunk/engines/scumm/smush/channel.h 2006-10-28 00:18:13 UTC (rev 24542)
@@ -56,13 +56,12 @@
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 @@
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 @@
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);
Modified: scummvm/trunk/engines/scumm/smush/imuse_channel.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/imuse_channel.cpp 2006-10-28 00:04:50 UTC (rev 24541)
+++ scummvm/trunk/engines/scumm/smush/imuse_channel.cpp 2006-10-28 00:18:13 UTC (rev 24542)
@@ -246,36 +246,16 @@
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;
-
- memcpy(snd, _sbuffer, size * 2);
-
- delete []_sbuffer;
- assert(_sbufferSize == 2 * size);
- _sbuffer = 0;
- _sbufferSize = 0;
+ assert(_dataSize > 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
Modified: scummvm/trunk/engines/scumm/smush/saud_channel.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/saud_channel.cpp 2006-10-28 00:04:50 UTC (rev 24541)
+++ scummvm/trunk/engines/scumm/smush/saud_channel.cpp 2006-10-28 00:18:13 UTC (rev 24542)
@@ -180,17 +180,17 @@
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
Modified: scummvm/trunk/engines/scumm/smush/smush_mixer.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_mixer.cpp 2006-10-28 00:04:50 UTC (rev 24541)
+++ scummvm/trunk/engines/scumm/smush/smush_mixer.cpp 2006-10-28 00:18:13 UTC (rev 24542)
@@ -106,24 +106,16 @@
} 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 flags = stereo ? Audio::Mixer::FLAG_STEREO : 0;
+ 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 @@
}
_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;
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list