CRYO: Fix broken sound in FMV scenes

This commit is contained in:
Retro-Junk 2017-01-25 00:05:42 +03:00 committed by Eugene Sandulenko
parent 30eb57b4b2
commit 7e4043ec85
3 changed files with 13 additions and 4 deletions

View File

@ -16,5 +16,4 @@ E. Bogus hitbox in upper right corner of mirror screen (under mini-map)
F. Wrong frescoes cursor on PC
G. Junk on a valley entrance screen on PC
H. On PC, no sound during first Mungo's dialogue, memory corruption after that
I. Crackling sound in HNM videos (ex. Mac intro video)
J. PC intro video is out of sync with background voice, crashes later

View File

@ -41,12 +41,22 @@ CSoundChannel::~CSoundChannel() {
delete _audioStream;
}
void CSoundChannel::queueBuffer(byte *buffer, unsigned int size, bool playNow, bool playQueue) {
void CSoundChannel::queueBuffer(byte *buffer, unsigned int size, bool playNow, bool playQueue, bool buffering = true) {
if (playNow)
stop();
if (!buffer || !size)
return;
if (!_audioStream)
_audioStream = Audio::makeQueuingAudioStream(_sampleRate, _stereo);
_audioStream->queueBuffer(buffer, size, DisposeAfterUse::NO, _bufferFlags);
if (buffering) {
byte *localBuffer = (byte*)malloc(size);
memcpy(localBuffer, buffer, size);
_audioStream->queueBuffer(localBuffer, size, DisposeAfterUse::YES, _bufferFlags);
} else
_audioStream->queueBuffer(buffer, size, DisposeAfterUse::NO, _bufferFlags);
if (playNow || playQueue)
play();
}

View File

@ -48,7 +48,7 @@ public:
~CSoundChannel();
// Queue a new buffer, cancel any previously queued buffers if playNow is set
void queueBuffer(byte *buffer, unsigned int size, bool playNow = false, bool playQueue = true);
void queueBuffer(byte *buffer, unsigned int size, bool playNow = false, bool playQueue = true, bool buffering = true);
// Play any queued buffers
void play();