[Scummvm-git-logs] scummvm master -> 991b579fcec8d9e879f473d09d3ea022915ae5f6
sev-
sev at scummvm.org
Mon May 10 16:31:04 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
991b579fce PINK: Switch whole engine to MemoryReadStream
Commit: 991b579fcec8d9e879f473d09d3ea022915ae5f6
https://github.com/scummvm/scummvm/commit/991b579fcec8d9e879f473d09d3ea022915ae5f6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-10T18:30:33+02:00
Commit Message:
PINK: Switch whole engine to MemoryReadStream
Changed paths:
engines/pink/objects/actions/action_sound.cpp
engines/pink/objects/pages/page.h
engines/pink/resource_mgr.cpp
engines/pink/resource_mgr.h
engines/pink/sound.cpp
engines/pink/sound.h
diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp
index 5ca720e1dc..9be81b58fc 100644
--- a/engines/pink/objects/actions/action_sound.cpp
+++ b/engines/pink/objects/actions/action_sound.cpp
@@ -21,8 +21,6 @@
*/
#include "common/debug.h"
-#include "common/memstream.h"
-#include "common/substream.h"
#include "pink/archive.h"
#include "pink/pink.h"
@@ -62,16 +60,7 @@ void ActionSound::start() {
} else
_actor->endAction();
- Common::SafeSeekableSubReadStream *stream = page->getResourceStream(_fileName);
- byte *data = (byte *)malloc(stream->size());
- stream->read(data, stream->size());
-
- Common::MemoryReadStream *memstream = new Common::MemoryReadStream(data, stream->size(), DisposeAfterUse::YES);
- delete stream;
-
- Common::SafeSeekableSubReadStream *stream2 = new Common::SafeSeekableSubReadStream(memstream, 0, memstream->size(), DisposeAfterUse::YES);
-
- _sound.play(stream2, soundType, _volume, 0, _isLoop);
+ _sound.play(page->getResourceStream(_fileName), soundType, _volume, 0, _isLoop);
debugC(6, kPinkDebugActions, "Actor %s has now ActionSound %s", _actor->getName().c_str(), _name.c_str());
}
diff --git a/engines/pink/objects/pages/page.h b/engines/pink/objects/pages/page.h
index d541fa79c3..8cf7a8d612 100644
--- a/engines/pink/objects/pages/page.h
+++ b/engines/pink/objects/pages/page.h
@@ -46,7 +46,7 @@ public:
Actor *findActor(const Common::String &name);
LeadActor *getLeadActor() { return _leadActor; }
- Common::SafeSeekableSubReadStream *getResourceStream(const Common::String &fileName) { return _resMgr.getResourceStream(fileName); }
+ Common::SeekableReadStream *getResourceStream(const Common::String &fileName) { return _resMgr.getResourceStream(fileName); }
virtual void clear();
void pause(bool paused);
diff --git a/engines/pink/resource_mgr.cpp b/engines/pink/resource_mgr.cpp
index dbbfd01e63..42f7ee1297 100644
--- a/engines/pink/resource_mgr.cpp
+++ b/engines/pink/resource_mgr.cpp
@@ -20,8 +20,6 @@
*
*/
-#include "common/substream.h"
-
#include "pink/cel_decoder.h"
#include "pink/file.h"
#include "pink/pink.h"
@@ -59,7 +57,7 @@ static int resDescComp(const void *a, const void *b) {
return scumm_stricmp((const char *)a, (const char *)b);
}
-Common::SafeSeekableSubReadStream *ResourceMgr::getResourceStream(const Common::String &name) {
+Common::SeekableReadStream *ResourceMgr::getResourceStream(const Common::String &name) {
Common::SeekableReadStream *stream;
ResourceDescription *desc = (ResourceDescription *)bsearch(name.c_str(), _resDescTable, _resCount, sizeof(ResourceDescription), resDescComp);
@@ -71,9 +69,13 @@ Common::SafeSeekableSubReadStream *ResourceMgr::getResourceStream(const Common::
stream->seek(desc->offset);
+ byte *data = (byte *)malloc(desc->size);
+ stream->read(data, desc->size);
+
+ Common::MemoryReadStream *memstream = new Common::MemoryReadStream(data, desc->size, DisposeAfterUse::YES);
+
debugC(kPinkDebugLoadingResources, "Got stream of %s resource", name.c_str());
- return new Common::SafeSeekableSubReadStream(stream, desc->offset,
- desc->offset + desc->size);
+ return memstream;
}
} // End of namespace Pink
diff --git a/engines/pink/resource_mgr.h b/engines/pink/resource_mgr.h
index 6fc40aed0b..08e9eab0ef 100644
--- a/engines/pink/resource_mgr.h
+++ b/engines/pink/resource_mgr.h
@@ -46,7 +46,7 @@ public:
void clear();
- Common::SafeSeekableSubReadStream *getResourceStream(const Common::String &name);
+ Common::SeekableReadStream *getResourceStream(const Common::String &name);
PinkEngine *getGame() const { return _game; }
diff --git a/engines/pink/sound.cpp b/engines/pink/sound.cpp
index 7caba2472f..56e73026f6 100644
--- a/engines/pink/sound.cpp
+++ b/engines/pink/sound.cpp
@@ -29,7 +29,7 @@
namespace Pink {
-void Sound::play(Common::SafeSeekableSubReadStream *stream, Audio::Mixer::SoundType type, byte volume, int8 balance, bool isLoop) {
+void Sound::play(Common::SeekableReadStream *stream, Audio::Mixer::SoundType type, byte volume, int8 balance, bool isLoop) {
// Vox files in pink have wave format.
// RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 22050 Hz
diff --git a/engines/pink/sound.h b/engines/pink/sound.h
index 6287cb320a..b286ca294d 100644
--- a/engines/pink/sound.h
+++ b/engines/pink/sound.h
@@ -30,17 +30,13 @@
#include "pink/constants.h"
-namespace Common {
- class SafeSeekableSubReadStream;
-}
-
namespace Pink {
class Sound {
public:
~Sound() { stop(); }
- void play(Common::SafeSeekableSubReadStream *stream, Audio::Mixer::SoundType type, byte volume = 100, int8 balance = 0, bool isLoop = false);
+ void play(Common::SeekableReadStream *stream, Audio::Mixer::SoundType type, byte volume = 100, int8 balance = 0, bool isLoop = false);
bool isPlaying() const { return g_system->getMixer()->isSoundHandleActive(_handle); }
More information about the Scummvm-git-logs
mailing list