aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-05 20:14:28 +0000
committerJohannes Schickel2010-01-05 20:14:28 +0000
commit920dac2f9d271889ffdc6c05313c89a6077ec2d2 (patch)
tree5ca24942081a5171605aea463febd5a06860d5ac /sound
parente9a94ecb9b6eb20cb7cdc4f838df3f9b049d2de6 (diff)
downloadscummvm-rg350-920dac2f9d271889ffdc6c05313c89a6077ec2d2.tar.gz
scummvm-rg350-920dac2f9d271889ffdc6c05313c89a6077ec2d2.tar.bz2
scummvm-rg350-920dac2f9d271889ffdc6c05313c89a6077ec2d2.zip
Remove unsafe getTotalPlayTime from AudioStream.
svn-id: r47037
Diffstat (limited to 'sound')
-rw-r--r--sound/audiostream.cpp11
-rw-r--r--sound/audiostream.h14
-rw-r--r--sound/flac.cpp12
-rw-r--r--sound/mp3.cpp7
-rw-r--r--sound/vorbis.cpp11
5 files changed, 4 insertions, 51 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 4ecfbedada..d92c3b793c 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -168,12 +168,6 @@ public:
bool endOfData() const { return _ptr >= _end; }
int getRate() const { return _rate; }
- int32 getTotalPlayTime() const {
- if (!_numLoops)
- return kUnknownPlayTime;
- return _playtime * _numLoops;
- }
-
bool seek(const Timestamp &where);
// TODO: We can definitly increase the precision here, since we know the exact sample count
Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
@@ -331,11 +325,6 @@ public:
bool endOfData() const { return (_currentBlock == _audioBlockCount - 1) && (_diskLeft == 0) && (_bufferLeft == 0); }
int getRate() const { return _rate; }
- int32 getTotalPlayTime() const {
- if (!_numLoops)
- return kUnknownPlayTime;
- return _playtime * _numLoops;
- }
// TODO: We can definitly increase the precision here, since we know the exact sample count
Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
diff --git a/sound/audiostream.h b/sound/audiostream.h
index a3992ca94f..42bf93871b 100644
--- a/sound/audiostream.h
+++ b/sound/audiostream.h
@@ -117,20 +117,6 @@ public:
* @param numLoops number of loops to play, 0 - infinite
*/
virtual uint getNumPlayedLoops() { return 0; }
-
- enum {
- kUnknownPlayTime = -1
- };
-
- /**
- * Returns total playtime of the AudioStream object.
- * Note that this does not require to return any playtime, if the
- * playtime of the AudioStream is unknown it returns 'kUnknownPlayTime'.
- * @see kUnknownPlayTime
- *
- * @return playtime in milliseconds
- */
- virtual int32 getTotalPlayTime() const { return kUnknownPlayTime; }
};
/**
diff --git a/sound/flac.cpp b/sound/flac.cpp
index b99f8bb484..0310754374 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -143,12 +143,6 @@ public:
return _streaminfo.channels == 0 || (_lastSampleWritten && _sampleCache.bufFill == 0);
}
- int32 getTotalPlayTime() const {
- if (!_numLoops)
- return kUnknownPlayTime;
- return _totalPlayTime * _numLoops;
- }
-
bool seek(const Timestamp &where);
// TODO: We can definitly increase the precision here, since FLAC allows us to catch the sample count
Timestamp getLength() const { return Timestamp(_totalPlayTime, getRate()); }
@@ -256,7 +250,7 @@ FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool disp
_lastSample = (FLAC__uint64)(endTime * (_streaminfo.sample_rate / 1000.0));
if (_firstSample == 0 || seekAbsolute(_firstSample)) {
- int32 samples = kUnknownPlayTime;
+ int32 samples = -1;
if (!_lastSample) {
if (_streaminfo.total_samples)
@@ -265,7 +259,7 @@ FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool disp
samples = _lastSample - _firstSample - 1;
}
- if (samples != kUnknownPlayTime && samples >= 0 && numLoops) {
+ if (samples != -1 && samples >= 0 && numLoops) {
const int32 rate = _streaminfo.sample_rate;
int32 seconds = samples / rate;
@@ -273,7 +267,7 @@ FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool disp
_totalPlayTime = (seconds * 1000 + milliseconds);
} else {
- _totalPlayTime = kUnknownPlayTime;
+ _totalPlayTime = 0;
}
return; // no error occured
diff --git a/sound/mp3.cpp b/sound/mp3.cpp
index 332fe20d59..faebf347e1 100644
--- a/sound/mp3.cpp
+++ b/sound/mp3.cpp
@@ -93,11 +93,6 @@ public:
bool endOfData() const { return _state == MP3_STATE_EOS; }
bool isStereo() const { return MAD_NCHANNELS(&_frame.header) == 2; }
int getRate() const { return _frame.header.samplerate; }
- int32 getTotalPlayTime() const {
- if (!_numLoops)
- return kUnknownPlayTime;
- return _totalPlayTime * _numLoops;
- }
bool seek(const Timestamp &where);
// TODO: Maybe we can have a more precise implementation of this
@@ -167,7 +162,7 @@ MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, bool dispos
_totalPlayTime = mad_timer_count(length, MAD_UNITS_MILLISECONDS);
if (mad_timer_sign(length) < 0)
- _totalPlayTime = kUnknownPlayTime;
+ _totalPlayTime = 0;
// Decode the first chunk of data. This is necessary so that _frame
// is setup and isStereo() and getRate() return correct results.
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp
index a130ecc5ec..629c36b3db 100644
--- a/sound/vorbis.cpp
+++ b/sound/vorbis.cpp
@@ -127,17 +127,6 @@ public:
}
uint getNumPlayedLoops() { return _numPlayedLoops; }
- int32 getTotalPlayTime() const {
- if (!_numLoops)
- return AudioStream::kUnknownPlayTime;
-
-#ifdef USE_TREMOR
- return (_endTime - _startTime) * _numLoops;
-#else
- return (int32)((_endTime - _startTime) * 1000.0) * _numLoops;
-#endif
- }
-
bool seek(const Timestamp &where);
// TODO: Maybe we can have a more precise implementation of this
Timestamp getLength() const {