[Scummvm-cvs-logs] SF.net SVN: scummvm: [22504] scummvm/trunk/engines/kyra
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Wed May 17 14:15:07 CEST 2006
Revision: 22504
Author: eriktorbjorn
Date: 2006-05-17 14:14:19 -0700 (Wed, 17 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22504&view=rev
Log Message:
-----------
Added (optional) looping to the digital sound class.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/kyra3.cpp
scummvm/trunk/engines/kyra/sound.h
scummvm/trunk/engines/kyra/sound_digital.cpp
Modified: scummvm/trunk/engines/kyra/kyra3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.cpp 2006-05-17 20:54:51 UTC (rev 22503)
+++ scummvm/trunk/engines/kyra/kyra3.cpp 2006-05-17 21:14:19 UTC (rev 22504)
@@ -77,7 +77,6 @@
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
logo->displayFrame(i);
_screen->updateScreen();
- playMenuAudioFile();
delayUntil(nextRun);
}
@@ -86,7 +85,6 @@
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
logo->displayFrame(i);
_screen->updateScreen();
- playMenuAudioFile();
delayUntil(nextRun);
}
@@ -94,7 +92,6 @@
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
logo->displayFrame(i);
_screen->updateScreen();
- playMenuAudioFile();
delayUntil(nextRun);
}
}
@@ -105,13 +102,11 @@
}
void KyraEngine_v3::playMenuAudioFile() {
- if (!_soundDigital->isPlaying(_musicSoundChannel)) {
- Common::File *handle = new Common::File();
- uint32 temp = 0;
- _res->fileHandle(_menuAudioFile, &temp, *handle);
- if (handle->isOpen()) {
- _musicSoundChannel = _soundDigital->playSound(handle, -1);
- }
+ Common::File *handle = new Common::File();
+ uint32 temp = 0;
+ _res->fileHandle(_menuAudioFile, &temp, *handle);
+ if (handle->isOpen()) {
+ _musicSoundChannel = _soundDigital->playSound(handle, true, -1);
}
}
}
Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h 2006-05-17 20:54:51 UTC (rev 22503)
+++ scummvm/trunk/engines/kyra/sound.h 2006-05-17 21:14:19 UTC (rev 22504)
@@ -221,7 +221,7 @@
bool init();
- int playSound(Common::File *fileHandle, int channel = -1);
+ int playSound(Common::File *fileHandle, bool loop = false, int channel = -1);
bool isPlaying(int channel);
void stopSound(int channel);
private:
Modified: scummvm/trunk/engines/kyra/sound_digital.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_digital.cpp 2006-05-17 20:54:51 UTC (rev 22503)
+++ scummvm/trunk/engines/kyra/sound_digital.cpp 2006-05-17 21:14:19 UTC (rev 22504)
@@ -33,7 +33,7 @@
// FIXME: sound 'stutters' a bit, maybe a problem while converting int8 samples to int16?
class AUDStream : public Audio::AudioStream {
public:
- AUDStream(Common::File *file);
+ AUDStream(Common::File *file, bool loop = false);
~AUDStream();
int readBuffer(int16 *buffer, const int numSamples);
@@ -44,6 +44,8 @@
int getRate() const { return _rate; }
private:
Common::File *_file;
+ bool _loop;
+ uint32 _loopStart;
bool _endOfData;
int _rate;
uint _processedSize;
@@ -70,13 +72,14 @@
0, 1, 2, 3, 4, 5, 6, 8
};
-AUDStream::AUDStream(Common::File *file) : _file(0), _endOfData(true), _rate(0),
+AUDStream::AUDStream(Common::File *file, bool loop) : _file(0), _endOfData(true), _rate(0),
_processedSize(0), _totalSize(0), _bytesLeft(0), _outBuffer(0),
_outBufferOffset(0), _outBufferSize(0), _inBuffer(0), _inBufferSize(0) {
#if defined(__SYMBIAN32__)
// Symbian can't share filehandles between different threads.
- // So create a new file and seek that to the other filehandles position
- _file= new File;
+ // So create a new file and seek that to the other filehandle's
+ // position
+ _file = new File;
_file->open(file->name());
_file->seek(file->pos());
#else
@@ -86,9 +89,12 @@
_rate = _file->readUint16LE();
_totalSize = _file->readUint32LE();
+ _loop = loop;
// TODO?: add checks
int flags = _file->readByte(); // flags
int type = _file->readByte(); // type
+
+ _loopStart = file->pos();
if (type == 1 && !flags) {
_endOfData = false;
@@ -134,10 +140,13 @@
// if no bytes of the old chunk are left, read the next one
if (_bytesLeft <= 0) {
if (_processedSize >= _totalSize) {
- // TODO: Eventually, we're probably going to need the
- // ability to loop the sound. Add this here?
- _endOfData = true;
- return 0;
+ if (_loop) {
+ _file->seek(_loopStart);
+ _processedSize = 0;
+ } else {
+ _endOfData = true;
+ return 0;
+ }
}
uint16 size = _file->readUint16LE();
@@ -287,7 +296,7 @@
return true;
}
-int SoundDigital::playSound(Common::File *fileHandle, int channel) {
+int SoundDigital::playSound(Common::File *fileHandle, bool loop, int channel) {
Sound *use = 0;
if (channel != -1 && channel < SOUND_STREAMS) {
stopSound(channel);
@@ -306,7 +315,7 @@
}
}
- Audio::AudioStream *stream = new AUDStream(fileHandle);
+ Audio::AudioStream *stream = new AUDStream(fileHandle, loop);
if (stream->endOfData()) {
delete stream;
delete fileHandle;
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