[Scummvm-cvs-logs] CVS: scummvm/sword2/driver animation.cpp,1.49,1.50 animation.h,1.30,1.31 d_sound.cpp,1.135,1.136 d_sound.h,1.59,1.60
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Tue Jan 11 00:32:21 CET 2005
Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30512/driver
Modified Files:
animation.cpp animation.h d_sound.cpp d_sound.h
Log Message:
Use Fingolfin's new WAV code.
Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- animation.cpp 10 Jan 2005 22:06:47 -0000 1.49
+++ animation.cpp 11 Jan 2005 08:31:14 -0000 1.50
@@ -168,7 +168,7 @@
* @param musicOut lead-out music
*/
-int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], byte *musicOut) {
+int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], byte *musicOut, uint32 musicOutLen) {
// This happens if the user quits during the "eye" smacker
if (_vm->_quit)
return RD_OK;
@@ -188,7 +188,7 @@
if (!anim->init(filename)) {
delete anim;
// Missing Files? Use the old 'Narration Only' hack
- playDummy(filename, text, musicOut);
+ playDummy(filename, text, musicOut, musicOutLen);
return RD_OK;
}
@@ -253,7 +253,7 @@
frameCounter++;
if (frameCounter == leadOutFrame && musicOut)
- _vm->_sound->playFx(0, musicOut, 0, 0, RDSE_FXLEADOUT);
+ _vm->_sound->playFx(0, musicOutLen, musicOut, 0, 0, RDSE_FXLEADOUT);
OSystem::Event event;
while (_sys->pollEvent(event)) {
@@ -334,7 +334,7 @@
return RD_OK;
#else
// No MPEG2? Use the old 'Narration Only' hack
- playDummy(filename, text, musicOut);
+ playDummy(filename, text, musicOut, musicOutLen);
return RD_OK;
#endif
}
@@ -344,7 +344,7 @@
* are missing.
*/
-int32 MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte *musicOut) {
+int32 MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte *musicOut, uint32 musicOutLen) {
int frameCounter = 0, textCounter = 0;
if (text) {
byte oldPal[256 * 4];
@@ -484,7 +484,7 @@
// that have subtitles.
if (!skipCutscene && musicOut) {
- _vm->_sound->playFx(0, musicOut, 0, 0, RDSE_FXLEADOUT);
+ _vm->_sound->playFx(0, musicOutLen, musicOut, 0, 0, RDSE_FXLEADOUT);
_vm->_sound->waitForLeadOut();
}
Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- animation.h 1 Jan 2005 15:10:22 -0000 1.30
+++ animation.h 11 Jan 2005 08:31:15 -0000 1.31
@@ -71,11 +71,11 @@
void closeTextObject(MovieTextObject *obj);
void drawTextObject(AnimationState *anim, MovieTextObject *obj);
- int32 playDummy(const char *filename, MovieTextObject *text[], byte *musicOut);
+ int32 playDummy(const char *filename, MovieTextObject *text[], byte *musicOut, uint32 musicOutLen);
public:
MoviePlayer(Sword2Engine *vm);
- int32 play(const char *filename, MovieTextObject *text[], byte *musicOut);
+ int32 play(const char *filename, MovieTextObject *text[], byte *musicOut, uint32 musicOutLen);
};
} // End of namespace Sword2
Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- d_sound.cpp 10 Jan 2005 22:06:47 -0000 1.135
+++ d_sound.cpp 11 Jan 2005 08:31:16 -0000 1.136
@@ -896,55 +896,6 @@
// ----------------------------------------------------------------------------
/**
- * Retrieve information about an in-memory WAV file.
- * @param data The WAV data
- * @param wavInfo Pointer to the WavInfo structure to fill with information.
- * @return True if the data appears to be a WAV file, otherwise false.
- */
-
-bool Sound::getWavInfo(byte *data, WavInfo *wavInfo) {
- uint32 wavLength;
- uint32 offset;
-
- if (READ_UINT32(data) != MKID('RIFF')) {
- warning("getWavInfo: No 'RIFF' header");
- return false;
- }
-
- wavLength = READ_LE_UINT32(data + 4) + 8;
-
- if (READ_UINT32(data + 8) != MKID('WAVE')) {
- warning("getWavInfo: No 'WAVE' header");
- return false;
- }
-
- if (READ_UINT32(data + 12) != MKID('fmt ')) {
- warning("getWavInfo: No 'fmt' header");
- return false;
- }
-
- wavInfo->channels = READ_LE_UINT16(data + 22);
- wavInfo->rate = READ_LE_UINT16(data + 24);
-
- offset = READ_LE_UINT32(data + 16) + 20;
-
- // It's almost certainly a WAV file, but we still need to find its
- // 'data' chunk.
-
- while (READ_UINT32(data + offset) != MKID('data')) {
- if (offset >= wavLength) {
- warning("getWavInfo: Can't find 'data' chunk");
- return false;
- }
- offset += (READ_LE_UINT32(data + offset + 4) + 8);
- }
-
- wavInfo->samples = READ_LE_UINT32(data + offset + 4);
- wavInfo->data = data + offset + 8;
- return true;
-}
-
-/**
* @return the index of the sound effect with the ID passed in.
*/
@@ -1112,7 +1063,7 @@
* @warning Zero is not a valid id
*/
-int32 Sound::playFx(int32 id, byte *data, uint8 vol, int8 pan, uint8 type) {
+int32 Sound::playFx(int32 id, uint32 len, byte *data, uint8 vol, int8 pan, uint8 type) {
if (!_soundOn)
return RD_OK;
@@ -1128,19 +1079,11 @@
soundType = SoundMixer::kMusicAudioDataType;
}
- WavInfo wavInfo;
-
- // TODO: use loadWAVFromStream to load the WAVE data!
- /*
+ Common::MemoryReadStream stream(data, len);
int rate, size;
- bye flags;
- // FIXME: Instead of passing an arbitrary large size for the memory stream
- // here, we should instead determine the real size of the memory area.
- Common::MemoryReadStream stream(data, 10000000);
- isValidWAV = loadWAVFromStream(stream, size, rate, flags);
- */
+ byte flags;
- if (!getWavInfo(data, &wavInfo)) {
+ if (!loadWAVFromStream(stream, size, rate, flags)) {
warning("playFx: Not a valid WAV file");
return RDERR_INVALIDWAV;
}
@@ -1176,12 +1119,6 @@
if (_fx[fxi]._handle.isActive())
return RDERR_FXALREADYOPEN;
- uint32 flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_LITTLE_ENDIAN;
-
- if (wavInfo.channels == 2)
- flags |= SoundMixer::FLAG_STEREO;
-
-
if (type == RDSE_FXLOOP)
flags |= SoundMixer::FLAG_LOOP;
else
@@ -1191,7 +1128,7 @@
int8 p = _panTable[pan + 16];
- _vm->_mixer->playRaw(&_fx[fxi]._handle, wavInfo.data, wavInfo.samples, wavInfo.rate, flags, -1, volume, p, 0, 0, soundType);
+ _vm->_mixer->playRaw(&_fx[fxi]._handle, data + stream.pos(), size, rate, flags, -1, volume, p, 0, 0, soundType);
return RD_OK;
}
Index: d_sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- d_sound.h 10 Jan 2005 22:06:48 -0000 1.59
+++ d_sound.h 11 Jan 2005 08:31:16 -0000 1.60
@@ -41,13 +41,6 @@
extern void sword2_sound_handler(void *refCon);
-struct WavInfo {
- uint8 channels;
- uint16 rate;
- uint32 samples;
- uint8 *data;
-};
-
struct FxHandle {
int32 _id;
bool _paused;
@@ -97,8 +90,6 @@
void buildPanTable(bool reverse);
- bool getWavInfo(uint8 *data, WavInfo *wavInfo);
-
void muteMusic(bool mute);
bool isMusicMute(void);
void pauseMusic(void);
@@ -126,7 +117,7 @@
void pauseFxForSequence(void);
void unpauseFx(void);
bool isFxPlaying(int32 id);
- int32 playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type);
+ int32 playFx(int32 id, uint32 len, uint8 *data, uint8 vol, int8 pan, uint8 type);
int32 stopFx(int32 id);
void clearAllFx(void);
};
More information about the Scummvm-git-logs
mailing list