experimental seek in compressed streams in dimuse in time ms resolution

svn-id: r30521
This commit is contained in:
Paweł Kołodziejski 2008-01-16 22:20:34 +00:00
parent 6b33041172
commit bd32e7a6b0
2 changed files with 8 additions and 6 deletions

View File

@ -177,13 +177,13 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
continue;
}
if (track->sndDataExtComp) {
/* if (track->sndDataExtComp) {
track->regionOffset = 0;
}
track->sndDataExtComp = _sound->isSndDataExtComp(track->soundDesc);
if (track->sndDataExtComp) {
track->regionOffset = 0;
}
}*/
track->dataOffset = _sound->getRegionOffset(track->soundDesc, track->curRegion);
int bits = _sound->getBits(track->soundDesc);
int channels = _sound->getChannels(track->soundDesc);

View File

@ -654,6 +654,7 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte
*buf = new byte[size];
assert(*buf);
char fileName[24];
int offsetMs = ((offset * 8 * 1000) / soundDesc->bits) / (soundDesc->channels * soundDesc->freq);
sprintf(fileName, "%s_reg%03d", soundDesc->name, region);
if (scumm_stricmp(fileName, soundDesc->lastFileName) != 0) {
int32 offs = 0, len = 0;
@ -695,25 +696,26 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte
assert(tmp);
#ifdef USE_FLAC
if (soundMode == 3)
soundDesc->compressedStream = Audio::makeFlacStream(tmp, true);
soundDesc->compressedStream = Audio::makeFlacStream(tmp, true, offsetMs);
#endif
#ifdef USE_VORBIS
if (soundMode == 2)
soundDesc->compressedStream = Audio::makeVorbisStream(tmp, true);
soundDesc->compressedStream = Audio::makeVorbisStream(tmp, true, offsetMs);
#endif
#ifdef USE_MAD
if (soundMode == 1)
soundDesc->compressedStream = Audio::makeMP3Stream(tmp, true);
soundDesc->compressedStream = Audio::makeMP3Stream(tmp, true, offsetMs);
#endif
assert(soundDesc->compressedStream);
}
strcpy(soundDesc->lastFileName, fileName);
}
size = soundDesc->compressedStream->readBuffer((int16 *)*buf, size / 2) * 2;
if (soundDesc->compressedStream->endOfData()) {
if (soundDesc->compressedStream->endOfData() || soundDesc->endFlag) {
delete soundDesc->compressedStream;
soundDesc->compressedStream = NULL;
soundDesc->lastFileName[0] = 0;
soundDesc->endFlag = true;
}
}