aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTorbjörn Andersson2007-03-10 17:39:27 +0000
committerTorbjörn Andersson2007-03-10 17:39:27 +0000
commit8d4e8adef3bc2f51d0cd64038bc7dca46d7dd402 (patch)
tree5f42e5c90039e853b38cc6c9ceeec506f0bc84cf /engines
parent06c2976fa08897b6d81eb702b349a343597d02d4 (diff)
downloadscummvm-rg350-8d4e8adef3bc2f51d0cd64038bc7dca46d7dd402.tar.gz
scummvm-rg350-8d4e8adef3bc2f51d0cd64038bc7dca46d7dd402.tar.bz2
scummvm-rg350-8d4e8adef3bc2f51d0cd64038bc7dca46d7dd402.zip
Let the mixer worry about converting mono to stereo.
svn-id: r26065
Diffstat (limited to 'engines')
-rw-r--r--engines/sky/music/adlibmusic.cpp25
-rw-r--r--engines/sky/music/adlibmusic.h7
2 files changed, 12 insertions, 20 deletions
diff --git a/engines/sky/music/adlibmusic.cpp b/engines/sky/music/adlibmusic.cpp
index 36c962af5a..aa5d9ee51f 100644
--- a/engines/sky/music/adlibmusic.cpp
+++ b/engines/sky/music/adlibmusic.cpp
@@ -47,38 +47,33 @@ AdlibMusic::~AdlibMusic(void) {
_mixer->stopHandle(_soundHandle);
}
-void AdlibMusic::premixerCall(int16 *data, uint len) {
+int AdlibMusic::readBuffer(int16 *data, const int numSamples) {
if (_musicData == NULL) {
// no music loaded
- memset(data, 0, 2 * len * sizeof(int16));
+ memset(data, 0, numSamples * sizeof(int16));
} else if ((_currentMusic == 0) || (_numberOfChannels == 0)) {
// music loaded but not played as of yet
- memset(data, 0, 2 * len * sizeof(int16));
+ memset(data, 0, numSamples * sizeof(int16));
// poll anyways as pollMusic() can activate the music
pollMusic();
- _nextMusicPoll = _sampleRate/50;
+ _nextMusicPoll = _sampleRate / 50;
} else {
uint32 render;
- int16 *origData = data;
- uint origLen = len;
- while (len) {
- render = (len > _nextMusicPoll) ? (_nextMusicPoll) : (len);
- len -= render;
+ int remaining = numSamples;
+ while (remaining) {
+ render = (remaining > _nextMusicPoll) ? (_nextMusicPoll) : (remaining);
+ remaining -= render;
_nextMusicPoll -= render;
YM3812UpdateOne(_opl, data, render);
data += render;
if (_nextMusicPoll == 0) {
pollMusic();
- _nextMusicPoll = _sampleRate/50;
+ _nextMusicPoll = _sampleRate / 50;
}
}
-
- // Convert mono data to stereo
- for (int i = (origLen - 1); i >= 0; i--) {
- origData[2 * i] = origData[2 * i + 1] = origData[i];
- }
}
+ return numSamples;
}
void AdlibMusic::setupPointers(void) {
diff --git a/engines/sky/music/adlibmusic.h b/engines/sky/music/adlibmusic.h
index b50157c3b5..ee98229b61 100644
--- a/engines/sky/music/adlibmusic.h
+++ b/engines/sky/music/adlibmusic.h
@@ -36,11 +36,8 @@ public:
~AdlibMusic(void);
// AudioStream API
- int readBuffer(int16 *buffer, const int numSamples) {
- premixerCall(buffer, numSamples / 2);
- return numSamples;
- }
- bool isStereo() const { return true; }
+ int readBuffer(int16 *buffer, const int numSamples);
+ bool isStereo() const { return false; }
bool endOfData() const { return false; }
int getRate() const { return _sampleRate; }