aboutsummaryrefslogtreecommitdiff
path: root/sound/flac.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2010-01-01 16:28:22 +0000
committerEugene Sandulenko2010-01-01 16:28:22 +0000
commit622dd0d16dbf735323a6fae985f0231a4ef5d393 (patch)
tree6b14067f8c501153e9b378a104ffcc91ff29647c /sound/flac.cpp
parentd1b844d3c36b9011442d3a6538bc35878b3b694e (diff)
downloadscummvm-rg350-622dd0d16dbf735323a6fae985f0231a4ef5d393.tar.gz
scummvm-rg350-622dd0d16dbf735323a6fae985f0231a4ef5d393.tar.bz2
scummvm-rg350-622dd0d16dbf735323a6fae985f0231a4ef5d393.zip
Implemented setNumLoops() for common audio streams.
Implemented getNumPlayedLoops() for common audio streams. Requested by m_kriewitz. svn-id: r46836
Diffstat (limited to 'sound/flac.cpp')
-rw-r--r--sound/flac.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/sound/flac.cpp b/sound/flac.cpp
index bb633b8352..8fc7440ff5 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -87,8 +87,6 @@ protected:
Common::SeekableReadStream *_inStream;
bool _disposeAfterUse;
- uint _numLoops;
-
::FLAC__SeekableStreamDecoder *_decoder;
/** Header of the stream */
@@ -103,6 +101,9 @@ protected:
/** total play time */
int32 _totalPlayTime;
+ uint _numLoops; ///< Number of loops to play
+ uint _numPlayedLoops; ///< Number of loops which have been played
+
/** true if the last sample was decoded from the FLAC-API - there might still be data in the buffer */
bool _lastSampleWritten;
@@ -146,6 +147,9 @@ public:
bool isStreamDecoderReady() const { return getStreamDecoderState() == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC ; }
+ void setNumLoops(uint numLoops = 1) { _numLoops = numLoops; }
+ uint getNumPlayedLoops() { return _numPlayedLoops; }
+
protected:
uint getChannels() const { return MIN<uint>(_streaminfo.channels, MAX_OUTPUT_CHANNELS); }
@@ -193,6 +197,7 @@ FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool disp
_inStream(inStream),
_disposeAfterUse(dispose),
_numLoops(numLoops),
+ _numPlayedLoops(0),
_firstSample(0), _lastSample(0),
_outBuffer(NULL), _requestedSamples(0), _lastSampleWritten(false),
_methodConvertBuffers(&FlacInputStream::convertBuffersGeneric)
@@ -373,6 +378,7 @@ int FlacInputStream::readBuffer(int16 *buffer, const int numSamples) {
if (_lastSampleWritten && _numLoops != 1) {
if (_numLoops != 0)
_numLoops--;
+ _numPlayedLoops++;
seekAbsolute(_firstSample);
state = getStreamDecoderState();
}