diff options
author | Torbjörn Andersson | 2007-03-10 17:39:27 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2007-03-10 17:39:27 +0000 |
commit | 8d4e8adef3bc2f51d0cd64038bc7dca46d7dd402 (patch) | |
tree | 5f42e5c90039e853b38cc6c9ceeec506f0bc84cf /engines/sky/music/adlibmusic.cpp | |
parent | 06c2976fa08897b6d81eb702b349a343597d02d4 (diff) | |
download | scummvm-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/sky/music/adlibmusic.cpp')
-rw-r--r-- | engines/sky/music/adlibmusic.cpp | 25 |
1 files changed, 10 insertions, 15 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) { |