[Scummvm-git-logs] scummvm master -> a7f2688944cb55ef1b1fb3fb1c9ffe46a63f5fdd
bluegr
noreply at scummvm.org
Sat Mar 14 17:38:49 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
a7f2688944 NANCY: Fix HIS Vorbis rewind-to-zero
Commit: a7f2688944cb55ef1b1fb3fb1c9ffe46a63f5fdd
https://github.com/scummvm/scummvm/commit/a7f2688944cb55ef1b1fb3fb1c9ffe46a63f5fdd
Author: flipkick (167208+flipkick at users.noreply.github.com)
Date: 2026-03-14T19:38:44+02:00
Commit Message:
NANCY: Fix HIS Vorbis rewind-to-zero
The original engine rewinds HIS Vorbis sounds to raw byte 0. Match that
behavior in the Nancy-specific Vorbis stream so affected assets do not
lose their leading audio when playback starts or rewinds.
Changed paths:
A audio/decoders/vorbis_intern.h
A engines/nancy/sound_vorbis.cpp
A engines/nancy/sound_vorbis.h
audio/decoders/vorbis.cpp
engines/nancy/module.mk
engines/nancy/sound.cpp
diff --git a/audio/decoders/vorbis.cpp b/audio/decoders/vorbis.cpp
index 2a69ff549b6..3edcf90d52f 100644
--- a/audio/decoders/vorbis.cpp
+++ b/audio/decoders/vorbis.cpp
@@ -25,24 +25,13 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_fseek
#include "audio/decoders/vorbis.h"
+#include "audio/decoders/vorbis_intern.h"
#ifdef USE_VORBIS
-#include "common/ptr.h"
-#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
-#include "audio/audiostream.h"
-
-#ifdef USE_TREMOR
-#include <tremor/ivorbisfile.h>
-#else
-#define OV_EXCLUDE_STATIC_CALLBACKS
-#include <vorbis/vorbisfile.h>
-#endif
-
-
namespace Audio {
// These are wrapper functions to allow using a SeekableReadStream object to
@@ -82,38 +71,6 @@ static const ov_callbacks g_stream_wrap = {
#pragma mark -
-class VorbisStream : public SeekableAudioStream {
-protected:
- Common::DisposablePtr<Common::SeekableReadStream> _inStream;
-
- bool _isStereo;
- int _rate;
-
- Timestamp _length;
-
- OggVorbis_File _ovFile;
-
- int16 _buffer[4096];
- const int16 *_bufferEnd;
- const int16 *_pos;
-
-public:
- // startTime / duration are in milliseconds
- VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose);
- ~VorbisStream();
-
- int readBuffer(int16 *buffer, const int numSamples) override;
-
- bool endOfData() const override { return _pos >= _bufferEnd; }
- bool isStereo() const override { return _isStereo; }
- int getRate() const override { return _rate; }
-
- bool seek(const Timestamp &where) override;
- Timestamp getLength() const override { return _length; }
-protected:
- bool refill();
-};
-
VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
_inStream(inStream, dispose),
_length(0, 1000),
diff --git a/audio/decoders/vorbis_intern.h b/audio/decoders/vorbis_intern.h
new file mode 100644
index 00000000000..fd9b2d83862
--- /dev/null
+++ b/audio/decoders/vorbis_intern.h
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * Internal interfaces to the Ogg Vorbis decoder.
+ *
+ * These can be used to make custom Vorbis decoder subclasses.
+ * Each .cpp that includes this header must define
+ * FORBIDDEN_SYMBOL_EXCEPTION_FILE and FORBIDDEN_SYMBOL_EXCEPTION_fseek
+ * before any #include, because vorbisfile.h uses FILE and fseek.
+ */
+
+#ifndef AUDIO_VORBIS_INTERN_H
+#define AUDIO_VORBIS_INTERN_H
+
+#include "common/scummsys.h"
+
+#ifdef USE_VORBIS
+
+#include "common/ptr.h"
+#include "common/stream.h"
+
+#include "audio/audiostream.h"
+#include "audio/timestamp.h"
+
+#ifdef USE_TREMOR
+#include <tremor/ivorbisfile.h>
+#else
+#define OV_EXCLUDE_STATIC_CALLBACKS
+#include <vorbis/vorbisfile.h>
+#endif
+
+namespace Audio {
+
+class VorbisStream : public SeekableAudioStream {
+protected:
+ Common::DisposablePtr<Common::SeekableReadStream> _inStream;
+
+ bool _isStereo;
+ int _rate;
+
+ Timestamp _length;
+
+ OggVorbis_File _ovFile;
+
+ int16 _buffer[4096];
+ const int16 *_bufferEnd;
+ const int16 *_pos;
+
+public:
+ VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose);
+ ~VorbisStream();
+
+ int readBuffer(int16 *buffer, const int numSamples) override;
+
+ bool endOfData() const override { return _pos >= _bufferEnd; }
+ bool isStereo() const override { return _isStereo; }
+ int getRate() const override { return _rate; }
+
+ bool seek(const Timestamp &where) override;
+ Timestamp getLength() const override { return _length; }
+
+protected:
+ bool refill();
+};
+
+} // End of namespace Audio
+
+#endif // USE_VORBIS
+#endif // AUDIO_VORBIS_INTERN_H
diff --git a/engines/nancy/module.mk b/engines/nancy/module.mk
index 15749e87eba..5449fadc7c5 100644
--- a/engines/nancy/module.mk
+++ b/engines/nancy/module.mk
@@ -91,6 +91,7 @@ MODULE_OBJS = \
renderobject.o \
resource.o \
sound.o \
+ sound_vorbis.o \
util.o \
video.o
diff --git a/engines/nancy/sound.cpp b/engines/nancy/sound.cpp
index c23f0c04935..da2f5fc13ff 100644
--- a/engines/nancy/sound.cpp
+++ b/engines/nancy/sound.cpp
@@ -27,7 +27,7 @@
#include "audio/audiostream.h"
#include "audio/decoders/raw.h"
-#include "audio/decoders/vorbis.h"
+#include "engines/nancy/sound_vorbis.h"
#include "engines/nancy/nancy.h"
#include "engines/nancy/sound.h"
@@ -222,7 +222,7 @@ Audio::SeekableAudioStream *SoundManager::makeHISStream(Common::SeekableReadStre
if (type == kSoundTypeRaw || type == kSoundTypeDiamondware)
return Audio::makeRawStream(subStream, overrideSamplesPerSec == 0 ? samplesPerSec : overrideSamplesPerSec, flags, DisposeAfterUse::YES);
else
- return Audio::makeVorbisStream(subStream, DisposeAfterUse::YES);
+ return makeHISVorbisStream(subStream, DisposeAfterUse::YES);
}
SoundManager::SoundManager() : _shouldRecalculate(false), _mixer(g_system->getMixer()) {}
diff --git a/engines/nancy/sound_vorbis.cpp b/engines/nancy/sound_vorbis.cpp
new file mode 100644
index 00000000000..6325831bf3e
--- /dev/null
+++ b/engines/nancy/sound_vorbis.cpp
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// Disable symbol overrides for FILE and fseek as those are used in the
+// Vorbis headers.
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+#define FORBIDDEN_SYMBOL_EXCEPTION_fseek
+
+#include "engines/nancy/sound_vorbis.h"
+#include "audio/decoders/vorbis_intern.h"
+#include "common/textconsole.h"
+
+namespace Nancy {
+
+class HISVorbisStream : public Audio::VorbisStream {
+public:
+ HISVorbisStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag dispose);
+
+ bool seek(const Audio::Timestamp &where) override;
+};
+
+HISVorbisStream::HISVorbisStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag dispose)
+ : Audio::VorbisStream(stream, dispose) {
+ // Start from the true beginning of the stream.
+ if (!endOfData()) {
+ if (ov_raw_seek(&_ovFile, 0) != 0) {
+ warning("HISVorbisStream: initial raw seek to 0 failed");
+ _pos = _bufferEnd;
+ } else {
+ refill();
+ }
+ }
+}
+
+bool HISVorbisStream::seek(const Audio::Timestamp &where) {
+ // Zero-time rewinds use raw seeking to match the original engine.
+ if (Audio::convertTimeToStreamPos(where, getRate(), false).totalNumberOfFrames() == 0) {
+ int res = ov_raw_seek(&_ovFile, 0);
+ if (res) {
+ warning("HISVorbisStream: raw seek to 0 failed (%d)", res);
+ _pos = _bufferEnd;
+ return false;
+ }
+ return refill();
+ }
+ return Audio::VorbisStream::seek(where);
+}
+
+Audio::SeekableAudioStream *makeHISVorbisStream(
+ Common::SeekableReadStream *stream,
+ DisposeAfterUse::Flag disposeAfterUse) {
+ Audio::SeekableAudioStream *s = new HISVorbisStream(stream, disposeAfterUse);
+ if (s && s->endOfData()) {
+ delete s;
+ return nullptr;
+ }
+ return s;
+}
+
+} // End of namespace Nancy
diff --git a/engines/nancy/sound_vorbis.h b/engines/nancy/sound_vorbis.h
new file mode 100644
index 00000000000..d5ef4c1566e
--- /dev/null
+++ b/engines/nancy/sound_vorbis.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NANCY_SOUND_VORBIS_H
+#define NANCY_SOUND_VORBIS_H
+
+#include "common/types.h"
+
+namespace Common {
+class SeekableReadStream;
+}
+
+namespace Audio {
+class SeekableAudioStream;
+}
+
+namespace Nancy {
+
+Audio::SeekableAudioStream *makeHISVorbisStream(
+ Common::SeekableReadStream *stream,
+ DisposeAfterUse::Flag disposeAfterUse);
+
+} // End of namespace Nancy
+
+#endif // NANCY_SOUND_VORBIS_H
More information about the Scummvm-git-logs
mailing list