aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorNorbert Lange2009-08-24 17:51:47 +0000
committerNorbert Lange2009-08-24 17:51:47 +0000
commit917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5 (patch)
treee652563203a00f8acecfaafbf93c64dbfbd13f25 /sound
parent5f87d5090cfcb34cda3c1f5d430e0865344d7366 (diff)
parentdd7868acc2512c9761d892e67a4837f4dc38bdc0 (diff)
downloadscummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.gz
scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.bz2
scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.zip
Merge with trunk
svn-id: r43701
Diffstat (limited to 'sound')
-rw-r--r--sound/audiocd.h8
-rw-r--r--sound/audiostream.cpp29
-rw-r--r--sound/audiostream.h2
-rw-r--r--sound/mods/maxtrax.cpp2
-rw-r--r--sound/mods/tfmx.cpp2
-rw-r--r--sound/shorten.h21
-rw-r--r--sound/voc.cpp2
7 files changed, 41 insertions, 25 deletions
diff --git a/sound/audiocd.h b/sound/audiocd.h
index 4c4ff26147..3ef4a1ac09 100644
--- a/sound/audiocd.h
+++ b/sound/audiocd.h
@@ -67,6 +67,14 @@ private:
friend class Common::Singleton<SingletonBaseType>;
AudioCDManager();
+ // FIXME: It might make sense to stop CD playback, when the AudioCDManager singleton
+ // is destroyed. Currently we can not do this, since in worst case the OSystem and
+ // along with it the Mixer will be destroyed before the AudioCDManager, thus
+ // leading to invalid memory access. If we can fix up the code to destroy the
+ // AudioCDManager before OSystem in *all* cases, that is including calling
+ // OSystem::quit, we might be able to implement it via a simple "stop()"
+ // call in a custom destructor of AudioCDManager.
+
/* used for emulated CD music */
SoundHandle _handle;
bool _emulating;
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 57d2e097bf..783a5733b3 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -211,14 +211,14 @@ protected:
int _audioBlockCount; ///< Number of blocks in _audioBlock
int _currentBlock; ///< Current audio block number
- int _beginLoop; ///< Loop parameter, currently not implemented
- int _endLoop; ///< Loop parameter, currently not implemented
-
+ int _beginLoop; ///< Loop start parameter
+ int _endLoop; ///< Loop end parameter, currently not implemented
+ bool _loop; ///< Determines if the stream should be looped when it finishes
public:
- LinearDiskStream(int rate, uint beginLoop, uint endLoop, bool disposeStream, Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, uint numBlocks)
+ LinearDiskStream(int rate, uint beginLoop, uint endLoop, bool disposeStream, Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, uint numBlocks, bool loop)
: _rate(rate), _stream(stream), _beginLoop(beginLoop), _endLoop(endLoop), _disposeAfterUse(disposeStream),
- _audioBlockCount(numBlocks) {
+ _audioBlockCount(numBlocks), _loop(loop) {
// Allocate streaming buffer
if (is16Bit) {
@@ -296,7 +296,6 @@ int LinearDiskStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffe
_diskLeft = _audioBlock[_currentBlock].len;
}
-
// Now read more data from disk if there is more to be read
if ((_bufferLeft == 0) && (_diskLeft > 0)) {
int32 readAmount = MIN(_diskLeft, BUFFER_SIZE);
@@ -315,6 +314,14 @@ int LinearDiskStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffe
// original position.
restoreFilePosition = true;
}
+
+ // Looping
+ if (_diskLeft == 0 && _loop) {
+ // Reset the stream
+ _currentBlock = 0;
+ _filePos = _audioBlock[_currentBlock].pos + _beginLoop;
+ _diskLeft = _audioBlock[_currentBlock].len;
+ }
}
// In case calling code relies on the position of this stream staying
@@ -399,19 +406,19 @@ AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte f
#define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \
if (is16Bit) { \
if (isLE) \
- return new LinearDiskStream<STEREO, true, UNSIGNED, true>(rate, loopStart, loopEnd, takeOwnership, &stream, block, numBlocks); \
+ return new LinearDiskStream<STEREO, true, UNSIGNED, true>(rate, loopStart, loopEnd, takeOwnership, stream, block, numBlocks, loop); \
else \
- return new LinearDiskStream<STEREO, true, UNSIGNED, false>(rate, loopStart, loopEnd, takeOwnership, &stream, block, numBlocks); \
+ return new LinearDiskStream<STEREO, true, UNSIGNED, false>(rate, loopStart, loopEnd, takeOwnership, stream, block, numBlocks, loop); \
} else \
- return new LinearDiskStream<STEREO, false, UNSIGNED, false>(rate, loopStart, loopEnd, takeOwnership, &stream, block, numBlocks)
+ return new LinearDiskStream<STEREO, false, UNSIGNED, false>(rate, loopStart, loopEnd, takeOwnership, stream, block, numBlocks, loop)
-AudioStream *makeLinearDiskStream(Common::SeekableReadStream& stream, LinearDiskStreamAudioBlock* block, int numBlocks, int rate, byte flags, bool takeOwnership, uint loopStart, uint loopEnd) {
+AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, int numBlocks, int rate, byte flags, bool takeOwnership, uint loopStart, uint loopEnd) {
const bool isStereo = (flags & Audio::Mixer::FLAG_STEREO) != 0;
const bool is16Bit = (flags & Audio::Mixer::FLAG_16BITS) != 0;
const bool isUnsigned = (flags & Audio::Mixer::FLAG_UNSIGNED) != 0;
const bool isLE = (flags & Audio::Mixer::FLAG_LITTLE_ENDIAN) != 0;
-
+ const bool loop = (flags & Audio::Mixer::FLAG_LOOP) != 0;
if (isStereo) {
if (isUnsigned) {
diff --git a/sound/audiostream.h b/sound/audiostream.h
index 99e140608d..09b97374d5 100644
--- a/sound/audiostream.h
+++ b/sound/audiostream.h
@@ -133,7 +133,7 @@ struct LinearDiskStreamAudioBlock {
* start position and length of each block of uncompressed audio in the stream.
*/
-AudioStream *makeLinearDiskStream(Common::SeekableReadStream& stream, LinearDiskStreamAudioBlock* block, int
+AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, int
numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd);
/**
diff --git a/sound/mods/maxtrax.cpp b/sound/mods/maxtrax.cpp
index 1cdbdcc24c..90ac3d55ca 100644
--- a/sound/mods/maxtrax.cpp
+++ b/sound/mods/maxtrax.cpp
@@ -983,7 +983,7 @@ allocError:
if (!errorMsg)
errorMsg = "Maxtrax: Could not allocate Memory";
- warning(errorMsg);
+ warning("%s", errorMsg);
if (loadSamples)
freePatches();
if (loadScores)
diff --git a/sound/mods/tfmx.cpp b/sound/mods/tfmx.cpp
index a7490c3f86..2ef7d79b7a 100644
--- a/sound/mods/tfmx.cpp
+++ b/sound/mods/tfmx.cpp
@@ -1097,7 +1097,7 @@ int Tfmx::doSfx(uint16 sfxIndex, bool unlockChannel) {
// some debugging functions
namespace {
-#ifndef NDEBUG
+#if !defined(NDEBUG) && 0
void displayMacroStep(const void *const vptr) {
const char *tableMacros[] = {
"DMAoff+Resetxx/xx/xx flag/addset/vol ",
diff --git a/sound/shorten.h b/sound/shorten.h
index c2a40280d3..bc9f229687 100644
--- a/sound/shorten.h
+++ b/sound/shorten.h
@@ -23,13 +23,15 @@
*
*/
-// The code in this file is currently only used in SAGA2 (in the
-// SAGA engine), so if that engine isn't enabled, we will skip
-// compiling it. If you plan to use this code in another engine,
-// you will have to add the proper define check here.
-// Also please add the define check at the comment after the
-// matching #endif further down this file.
-#if defined(ENABLE_SAGA2)
+// The code in this file is currently only used in SAGA2.
+// So when it is disabled, we will skip compiling it.
+// We also enable this code for ScummVM builds including support
+// for dynamic engine plugins.
+// If you plan to use this code in another engine, you will have
+// to add the proper define check here.
+#if !(defined(ENABLE_SAGA2) || defined(DYNAMIC_MODULES))
+
+#else
#ifndef SOUND_SHORTEN_H
#define SOUND_SHORTEN_H
@@ -48,7 +50,7 @@ class AudioStream;
* start of the audio data, and size, rate and flags contain information
* necessary for playback.
*/
-extern byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, byte &flags);
+byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, byte &flags);
/**
* Try to load a Shorten file from the given stream and create an AudioStream
@@ -62,6 +64,5 @@ AudioStream *makeShortenStream(Common::ReadStream &stream);
#endif
-#endif // defined(ENABLE_SAGA2)
-
+#endif // engine and dynamic plugins guard
diff --git a/sound/voc.cpp b/sound/voc.cpp
index a332477f3c..a5bab0af29 100644
--- a/sound/voc.cpp
+++ b/sound/voc.cpp
@@ -292,7 +292,7 @@ AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, b
int numBlocks = parseVOCFormat(stream, block, rate, loops, begin_loop, end_loop);
- AudioStream* audioStream = makeLinearDiskStream(stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
+ AudioStream *audioStream = makeLinearDiskStream(&stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
delete[] block;