mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
PINK: Switch whole engine to MemoryReadStream
This commit is contained in:
parent
a2b1164fe9
commit
991b579fce
engines/pink
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user