aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2015-06-06 22:50:36 +0200
committerMartin Kiewitz2015-06-06 22:50:36 +0200
commit97813f89ecd2a06c74f776708a3d1852c96811a7 (patch)
tree8a9d4bc96dcad8b2cc87bb116199cbdd1465f337 /engines
parent2ac05321aab74a4fced53f402f1b0cd16a33cc23 (diff)
downloadscummvm-rg350-97813f89ecd2a06c74f776708a3d1852c96811a7.tar.gz
scummvm-rg350-97813f89ecd2a06c74f776708a3d1852c96811a7.tar.bz2
scummvm-rg350-97813f89ecd2a06c74f776708a3d1852c96811a7.zip
SHERLOCK: rework 3DO audio, add AIFC file support
- rework 3DO audio decoders to decode into buffer only - 3DO audio decoders also use streams without separate size arg now - add support for ADP4 + SDX2 inside AIFC files - add debug command "3do_playaudio" to play AIFC files - remove audio flags and replace with stereo bool
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/debugger.cpp43
-rw-r--r--engines/sherlock/debugger.h5
-rw-r--r--engines/sherlock/scalpel/3do/movie_decoder.cpp36
-rw-r--r--engines/sherlock/scalpel/3do/movie_decoder.h2
4 files changed, 72 insertions, 14 deletions
diff --git a/engines/sherlock/debugger.cpp b/engines/sherlock/debugger.cpp
index aaf24646e4..a627d7c494 100644
--- a/engines/sherlock/debugger.cpp
+++ b/engines/sherlock/debugger.cpp
@@ -26,12 +26,18 @@
#include "sherlock/scalpel/3do/movie_decoder.h"
+#include "audio/mixer.h"
+#include "audio/decoders/aiff.h"
+#include "audio/decoders/wave.h"
+#include "audio/decoders/3do.h"
+
namespace Sherlock {
Debugger::Debugger(SherlockEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
registerCmd("scene", WRAP_METHOD(Debugger, cmdScene));
registerCmd("3do_playmovie", WRAP_METHOD(Debugger, cmd3DO_PlayMovie));
+ registerCmd("3do_playaudio", WRAP_METHOD(Debugger, cmd3DO_PlayAudio));
registerCmd("song", WRAP_METHOD(Debugger, cmdSong));
}
@@ -84,6 +90,43 @@ bool Debugger::cmd3DO_PlayMovie(int argc, const char **argv) {
return cmdExit(0, 0);
}
+bool Debugger::cmd3DO_PlayAudio(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Format: 3do_playaudio <3do-audio-file>\n");
+ return true;
+ }
+
+ Common::File *file = new Common::File();
+ if (!file->open(argv[1])) {
+ debugPrintf("can not open specified audio file\n");
+ return true;
+ }
+
+ Audio::AudioStream *testStream;
+ Audio::SoundHandle testHandle;
+
+ // Try to load the given file as AIFF/AIFC
+ testStream = Audio::makeAIFFAudioStream(file, DisposeAfterUse::YES);
+
+ if (testStream) {
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &testHandle, testStream);
+ _vm->_events->clearEvents();
+
+ while ((!_vm->shouldQuit()) && g_system->getMixer()->isSoundHandleActive(testHandle)) {
+ _vm->_events->pollEvents();
+ g_system->delayMillis(10);
+ if (_vm->_events->kbHit()) {
+ break;
+ }
+ }
+
+ debugPrintf("playing completed\n");
+ g_system->getMixer()->stopHandle(testHandle);
+ }
+
+ return true;
+}
+
bool Debugger::cmdSong(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Format: song <room>\n");
diff --git a/engines/sherlock/debugger.h b/engines/sherlock/debugger.h
index 39866d0cd3..9b12668679 100644
--- a/engines/sherlock/debugger.h
+++ b/engines/sherlock/debugger.h
@@ -56,6 +56,11 @@ private:
bool cmd3DO_PlayMovie(int argc, const char **argv);
/**
+ * Plays a 3DO audio
+ */
+ bool cmd3DO_PlayAudio(int argc, const char **argv);
+
+ /**
* Plays a song
*/
bool cmdSong(int argc, const char **argv);
diff --git a/engines/sherlock/scalpel/3do/movie_decoder.cpp b/engines/sherlock/scalpel/3do/movie_decoder.cpp
index bd3d483e2f..9280bbab13 100644
--- a/engines/sherlock/scalpel/3do/movie_decoder.cpp
+++ b/engines/sherlock/scalpel/3do/movie_decoder.cpp
@@ -409,40 +409,50 @@ Scalpel3DOMovieDecoder::StreamAudioTrack::StreamAudioTrack(uint32 codecTag, uint
_codecTag = codecTag;
_sampleRate = sampleRate;
- _audioFlags = Audio::FLAG_16BITS;
- if (channels > 1)
- _audioFlags |= Audio::FLAG_STEREO;
-
- if (_audioFlags & Audio::FLAG_STEREO) {
- _audioStream = Audio::makeQueuingAudioStream(sampleRate, true);
- } else {
- _audioStream = Audio::makeQueuingAudioStream(sampleRate, false);
+ switch (channels) {
+ case 1:
+ _stereo = false;
+ break;
+ case 2:
+ _stereo = true;
+ break;
+ default:
+ error("Unsupported Sherlock 3DO movie audio channels %d", channels);
}
- // reset audio decoder persistant spaces
+ _audioStream = Audio::makeQueuingAudioStream(sampleRate, _stereo);
+
+ // reset audio decoder persistent spaces
memset(&_ADP4_PersistentSpace, 0, sizeof(_ADP4_PersistentSpace));
memset(&_SDX2_PersistentSpace, 0, sizeof(_SDX2_PersistentSpace));
}
Scalpel3DOMovieDecoder::StreamAudioTrack::~StreamAudioTrack() {
delete _audioStream;
+// free(_ADP4_PersistentSpace);
+// free(_SDX2_PersistentSpace);
}
void Scalpel3DOMovieDecoder::StreamAudioTrack::queueAudio(Common::SeekableReadStream *stream, uint32 size) {
- Audio::SeekableAudioStream *audioStream = 0;
+ Common::SeekableReadStream *compressedAudioStream = 0;
+ Audio::RewindableAudioStream *audioStream = 0;
+ uint32 audioLengthMSecs = 0;
+
+ // Read the specified chunk into memory
+ compressedAudioStream = stream->readStream(size);
switch(_codecTag) {
case MKTAG('A','D','P','4'):
- audioStream = Audio::make3DO_ADP4Stream(stream, size, _sampleRate, _audioFlags, DisposeAfterUse::NO, &_ADP4_PersistentSpace);
+ audioStream = Audio::make3DO_ADP4AudioStream(compressedAudioStream, _sampleRate, _stereo, &audioLengthMSecs, DisposeAfterUse::YES, &_ADP4_PersistentSpace);
break;
case MKTAG('S','D','X','2'):
- audioStream = Audio::make3DO_SDX2Stream(stream, size, _sampleRate, _audioFlags, DisposeAfterUse::NO, &_SDX2_PersistentSpace);
+ audioStream = Audio::make3DO_SDX2AudioStream(compressedAudioStream, _sampleRate, _stereo, &audioLengthMSecs, DisposeAfterUse::YES, &_SDX2_PersistentSpace);
break;
default:
break;
}
if (audioStream) {
- _totalAudioQueued += audioStream->getLength().msecs();
+ _totalAudioQueued += audioLengthMSecs;
_audioStream->queueAudioStream(audioStream, DisposeAfterUse::YES);
}
}
diff --git a/engines/sherlock/scalpel/3do/movie_decoder.h b/engines/sherlock/scalpel/3do/movie_decoder.h
index 60e79fa238..52d30cd9e2 100644
--- a/engines/sherlock/scalpel/3do/movie_decoder.h
+++ b/engines/sherlock/scalpel/3do/movie_decoder.h
@@ -107,7 +107,7 @@ private:
uint32 _codecTag;
uint16 _sampleRate;
- byte _audioFlags;
+ bool _stereo;
Audio::audio_3DO_ADP4_PersistentSpace _ADP4_PersistentSpace;
Audio::audio_3DO_SDX2_PersistentSpace _SDX2_PersistentSpace;