[Scummvm-cvs-logs] SF.net SVN: scummvm:[53297] scummvm/trunk/engines/sword25

sev at users.sourceforge.net sev at users.sourceforge.net
Wed Oct 13 01:22:01 CEST 2010


Revision: 53297
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53297&view=rev
Author:   sev
Date:     2010-10-12 23:22:01 +0000 (Tue, 12 Oct 2010)

Log Message:
-----------
SWORD25: Started to hook TheoraDecoder. Crashes at startup.

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/fmv/movieplayer.cpp
    scummvm/trunk/engines/sword25/fmv/movieplayer.h
    scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp
    scummvm/trunk/engines/sword25/fmv/theora_decoder.h
    scummvm/trunk/engines/sword25/module.mk
    scummvm/trunk/engines/sword25/package/packagemanager.h
    scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp
    scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h

Modified: scummvm/trunk/engines/sword25/fmv/movieplayer.cpp
===================================================================
--- scummvm/trunk/engines/sword25/fmv/movieplayer.cpp	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/fmv/movieplayer.cpp	2010-10-12 23:22:01 UTC (rev 53297)
@@ -33,6 +33,9 @@
  */
 
 #include "sword25/fmv/movieplayer.h"
+#include "sword25/fmv/theora_decoder.h"
+#include "sword25/kernel/kernel.h"
+#include "sword25/package/packagemanager.h"
 
 namespace Sword25 {
 
@@ -47,13 +50,29 @@
 		BS_LOG_ERRORLN("Script bindings could not be registered.");
 	else
 		BS_LOGLN("Script bindings registered.");
+
+	_decoder = new TheoraDecoder();
 }
 
-bool MoviePlayer::LoadMovie(const Common::String &Filename, unsigned int Z) {
+bool MoviePlayer::LoadMovie(const Common::String &filename, unsigned int Z) {
+	Common::SeekableReadStream *in = Kernel::GetInstance()->GetPackage()->GetStream(filename);
+
+	if (!in) {
+		BS_LOG_ERRORLN("Could not open movie file \"%s\".", filename.c_str());
+		return false;
+	}
+
+	if (!_decoder->load(in)) {
+		BS_LOG_ERRORLN("Could not load movie file \"%s\".", filename.c_str());
+		return false;
+	}
+
 	return true;
 }
 
 bool MoviePlayer::UnloadMovie() {
+	_decoder->close();
+
 	return true;
 }
 

Modified: scummvm/trunk/engines/sword25/fmv/movieplayer.h
===================================================================
--- scummvm/trunk/engines/sword25/fmv/movieplayer.h	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/fmv/movieplayer.h	2010-10-12 23:22:01 UTC (rev 53297)
@@ -44,9 +44,7 @@
 
 namespace Sword25 {
 
-// -----------------------------------------------------------------------------
-// Class definitions
-// -----------------------------------------------------------------------------
+class TheoraDecoder;
 
 class MoviePlayer : public Service {
 public:
@@ -140,6 +138,8 @@
 
 private:
 	bool _RegisterScriptBindings();
+
+	TheoraDecoder *_decoder;
 };
 
 } // End of namespace Sword25

Modified: scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp
===================================================================
--- scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp	2010-10-12 23:22:01 UTC (rev 53297)
@@ -84,10 +84,10 @@
 	return(bytes);
 }
 
-bool TheoraDecoder::load(Common::SeekableReadStream &stream) {
+bool TheoraDecoder::load(Common::SeekableReadStream *stream) {
 	close();
 
-	_fileStream = &stream;
+	_fileStream = stream;
 
 	// start up Ogg stream synchronization layer
 	ogg_sync_init(&_oggSync);
@@ -236,7 +236,7 @@
 	// open audio
 	if (_vorbisPacket) {
 		_audStream = createAudioStream();
-		if (_audStream)
+		if (_audStream && _mixer)
 			_mixer->playStream(_soundType, _audHandle, _audStream);
 	}
 
@@ -255,7 +255,8 @@
 		vorbis_comment_clear(&_vorbisComment);
 		vorbis_info_clear(&_vorbisInfo);
 
-		_mixer->stopHandle(*_audHandle);
+		if (_mixer)
+			_mixer->stopHandle(*_audHandle);
 		_audStream = 0;
 	}
 	if (_theoraPacket) {
@@ -264,11 +265,12 @@
 		th_comment_clear(&_theoraComment);
 		th_info_clear(&_theoraInfo);
 	}
-	ogg_sync_clear(&_oggSync);
 
 	if (!_fileStream)
 		return;
 
+	ogg_sync_clear(&_oggSync);
+
 	delete _fileStream;
 	_fileStream = 0;
 
@@ -417,7 +419,7 @@
 }
 
 uint32 TheoraDecoder::getElapsedTime() const {
-	if (_audStream)
+	if (_audStream && _mixer)
 		return _mixer->getSoundElapsedTime(*_audHandle);
 
 	return VideoDecoder::getElapsedTime();

Modified: scummvm/trunk/engines/sword25/fmv/theora_decoder.h
===================================================================
--- scummvm/trunk/engines/sword25/fmv/theora_decoder.h	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/fmv/theora_decoder.h	2010-10-12 23:22:01 UTC (rev 53297)
@@ -47,14 +47,14 @@
  */
 class TheoraDecoder : public Graphics::FixedRateVideoDecoder {
 public:
-	TheoraDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType);
+	TheoraDecoder(Audio::Mixer *mixer = 0, Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType);
 	virtual ~TheoraDecoder();
 
 	/**
 	 * Load a video file
 	 * @param stream  the stream to load
 	 */
-	bool load(Common::SeekableReadStream &stream);
+	bool load(Common::SeekableReadStream *stream);
 	void close();
 	void reset();
 

Modified: scummvm/trunk/engines/sword25/module.mk
===================================================================
--- scummvm/trunk/engines/sword25/module.mk	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/module.mk	2010-10-12 23:22:01 UTC (rev 53297)
@@ -109,7 +109,7 @@
 	$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
 	$(QUIET_CXX)gcc  $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
 
-LIBS += -lpng
+LIBS += -lpng -ltheoradec
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_SWORD25), DYNAMIC_PLUGIN)

Modified: scummvm/trunk/engines/sword25/package/packagemanager.h
===================================================================
--- scummvm/trunk/engines/sword25/package/packagemanager.h	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/package/packagemanager.h	2010-10-12 23:22:01 UTC (rev 53297)
@@ -101,7 +101,14 @@
 	 * @remark              The client must not forget to release the data of the file using BE_DELETE_A.
 	 */
 	virtual byte *GetFile(const Common::String &FileName, unsigned int *pFileSize = NULL) = 0;
+
 	/**
+	 * Returns a stream from file file from the virtual directory tree
+	 * @param FileName      The filename of the file to load
+	 * @return              Pointer to the stream object
+	 */
+	virtual Common::SeekableReadStream *GetStream(const Common::String &fileName) = 0;
+	/**
 	 * Downloads an XML file and prefixes it with an XML Version key, since the XML files don't contain it,
 	 * and it is required for ScummVM to correctly parse the XML.
 	 * @param FileName      The filename of the file to load

Modified: scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp
===================================================================
--- scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp	2010-10-12 23:22:01 UTC (rev 53297)
@@ -152,6 +152,17 @@
 	return buffer;
 }
 
+Common::SeekableReadStream *ScummVMPackageManager::GetStream(const Common::String &fileName) {
+	Common::SeekableReadStream *in;
+	Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+	if (!fileNode)
+		return 0;
+	if (!(in = fileNode->createReadStream()))
+		return 0;
+
+	return in;
+}
+
 Common::String ScummVMPackageManager::GetCurrentDirectory() {
 	return _currentDirectory;
 }

Modified: scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h
===================================================================
--- scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h	2010-10-12 23:21:28 UTC (rev 53296)
+++ scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h	2010-10-12 23:22:01 UTC (rev 53297)
@@ -73,6 +73,7 @@
 	virtual bool LoadPackage(const Common::String &fileName, const Common::String &mountPosition);
 	virtual bool LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition);
 	virtual byte *GetFile(const Common::String &fileName, unsigned int *fileSizePtr = 0);
+	virtual Common::SeekableReadStream *GetStream(const Common::String &fileName);
 	virtual Common::String GetCurrentDirectory();
 	virtual bool ChangeDirectory(const Common::String &directory);
 	virtual Common::String GetAbsolutePath(const Common::String &fileName);


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