aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2010-03-11 23:39:51 +0000
committerMax Horn2010-03-11 23:39:51 +0000
commit9b837d66d4647a7642a761cefe5798d30a21504a (patch)
treee5e96cd1a48850a699f0e77a748d415921f7b18e /sound
parent5886a0cc7715c874919a7056dfb6b65d3be19dce (diff)
downloadscummvm-rg350-9b837d66d4647a7642a761cefe5798d30a21504a.tar.gz
scummvm-rg350-9b837d66d4647a7642a761cefe5798d30a21504a.tar.bz2
scummvm-rg350-9b837d66d4647a7642a761cefe5798d30a21504a.zip
Replace Audio::MixerImpl::setOutputRate with a new 'sampleRate' param to the MixerImpl constructor
svn-id: r48238
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp18
-rw-r--r--sound/mixer_intern.h19
2 files changed, 9 insertions, 28 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index eae370e12b..93a18d51b0 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -160,8 +160,10 @@ private:
#pragma mark -
-MixerImpl::MixerImpl(OSystem *system)
- : _syst(system), _sampleRate(0), _mixerReady(false), _handleSeed(0) {
+MixerImpl::MixerImpl(OSystem *system, uint sampleRate)
+ : _syst(system), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0) {
+
+ assert(sampleRate > 0);
int i;
@@ -179,21 +181,12 @@ MixerImpl::~MixerImpl() {
void MixerImpl::setReady(bool ready) {
_mixerReady = ready;
-
- // If the mixer is set to ready, then we better have a positive sample rate!
- assert(!_mixerReady || _sampleRate > 0);
}
uint MixerImpl::getOutputRate() const {
return _sampleRate;
}
-void MixerImpl::setOutputRate(uint sampleRate) {
- if (_sampleRate != 0 && _sampleRate != sampleRate)
- error("Changing the Audio::Mixer output sample rate is not supported");
- _sampleRate = sampleRate;
-}
-
void MixerImpl::insertChannel(SoundHandle *handle, Channel *chan) {
int index = -1;
for (int i = 0; i != NUM_CHANNELS; i++) {
@@ -299,7 +292,6 @@ void MixerImpl::mixCallback(byte *samples, uint len) {
// Since the mixer callback has been called, the mixer must be ready...
_mixerReady = true;
- assert(_sampleRate > 0);
// zero the buf
memset(buf, 0, 2 * len * sizeof(int16));
@@ -376,7 +368,7 @@ Timestamp MixerImpl::getElapsedTime(SoundHandle handle) {
const int index = handle._val % NUM_CHANNELS;
if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
- return Timestamp(0, _sampleRate ? _sampleRate : 1);
+ return Timestamp(0, _sampleRate);
return _channels[index]->getElapsedTime();
}
diff --git a/sound/mixer_intern.h b/sound/mixer_intern.h
index a1037f1107..2ccd1ff2bf 100644
--- a/sound/mixer_intern.h
+++ b/sound/mixer_intern.h
@@ -60,7 +60,7 @@ private:
OSystem *_syst;
Common::Mutex _mutex;
- uint _sampleRate;
+ const uint _sampleRate;
bool _mixerReady;
uint32 _handleSeed;
@@ -69,7 +69,8 @@ private:
public:
- MixerImpl(OSystem *system);
+
+ MixerImpl(OSystem *system, uint sampleRate);
~MixerImpl();
virtual bool isReady() const { return _mixerReady; }
@@ -123,21 +124,9 @@ public:
/**
* Set the internal 'is ready' flag of the mixer.
* Backends should invoke Mixer::setReady(true) once initialisation of
- * their audio system has been completed (and in particular, *after*
- * setOutputRate() has been called).
+ * their audio system has been completed.
*/
void setReady(bool ready);
-
- /**
- * Set the output sample rate.
- *
- * @param sampleRate the new output sample rate
- *
- * @note Right now, this can be done exactly ONCE. That is, the mixer
- * currently does not support changing the output sample rate after it
- * has been set for the first time. This may change in the future.
- */
- void setOutputRate(uint sampleRate);
};