imuse audio stream are use dynamic append size now

svn-id: r13647
This commit is contained in:
Paweł Kołodziejski 2004-04-26 21:29:49 +00:00
parent d2fa7bbcc7
commit 88643e3363
3 changed files with 23 additions and 16 deletions

View File

@ -153,14 +153,9 @@ void IMuseDigital::callback() {
}
if (_track[l]->stream) {
int32 mixer_size = _track[l]->pullSize;
byte *data = NULL;
int32 result = 0;
if (_track[l]->stream->endOfData()) {
mixer_size *= 2;
}
if (_track[l]->curRegion == -1) {
switchToNextRegion(l);
if (_track[l]->toBeRemoved)
@ -168,6 +163,25 @@ void IMuseDigital::callback() {
}
int bits = _sound->getBits(_track[l]->soundHandle);
int channels = _sound->getChannels(_track[l]->soundHandle);
int32 mixer_size = _track[l]->stream->getFreeSpace() - 4;
if ((_track[l]->iteration / 2) > mixer_size)
continue;
if ((bits == 12) || (bits == 16)) {
if (channels == 1)
mixer_size &= ~1;
if (channels == 2)
mixer_size &= ~3;
} else {
if (channels == 2)
mixer_size &= ~1;
}
if (mixer_size == 0)
continue;
do {
if (bits == 12) {
byte *ptr = NULL;
@ -184,16 +198,15 @@ void IMuseDigital::callback() {
free(ptr);
} else if (bits == 16) {
result = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &data, _track[l]->regionOffset, mixer_size);
if (_sound->getChannels(_track[l]->soundHandle) == 1) {
if (channels == 1) {
result &= ~1;
}
if (_sound->getChannels(_track[l]->soundHandle) == 2) {
if (result & 2)
result &= ~2;
if (channels == 2) {
result &= ~3;
}
} else if (bits == 8) {
result = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &data, _track[l]->regionOffset, mixer_size);
if (_sound->getChannels(_track[l]->soundHandle) == 2) {
if (channels == 2) {
result &= ~1;
}
}

View File

@ -63,7 +63,6 @@ private:
int volGroupId;
int iteration;
int mod;
int32 pullSize;
int32 mixerFlags;
int mixerVol;
int mixerPan;

View File

@ -145,20 +145,16 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
freq -= (freq % 25);
_track[l]->iteration = freq * channels;
_track[l]->pullSize = _track[l]->iteration;
if (channels == 2)
_track[l]->mixerFlags = SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO;
if ((bits == 12) || (bits == 16)) {
_track[l]->mixerFlags |= SoundMixer::FLAG_16BITS;
_track[l]->iteration *= 2;
_track[l]->pullSize = _track[l]->iteration;
} else if (bits == 8) {
_track[l]->mixerFlags |= SoundMixer::FLAG_UNSIGNED;
} else
error("IMuseDigital::startSound(): Can't handle %d bit samples", bits);
_track[l]->pullSize /= 25; // We want a "frame rate" of 25 audio blocks per second
}
if (input) {
@ -292,7 +288,6 @@ int IMuseDigital::cloneToFadeOutTrack(int track, int fadeDelay, int killNormalTr
_track[track]->mixerVol = _track[fadeTrack]->mixerVol;
_track[track]->mixerPan = _track[fadeTrack]->mixerPan;
_track[track]->mod = _track[fadeTrack]->mod;
_track[track]->pullSize = _track[fadeTrack]->pullSize;
_track[track]->used = _track[fadeTrack]->used;
_track[track]->toBeRemoved = _track[fadeTrack]->toBeRemoved;
_track[track]->started = _track[fadeTrack]->started;