aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2017-10-14 21:31:35 -0400
committerPaul Gilbert2017-10-14 21:31:35 -0400
commit23a6533c95d8ca80677113df68c678e23dda1311 (patch)
tree90a04abf390ef85e37c3b7e9e3d059af45d49a34 /engines/titanic
parent55947e8ae84b7f93f03e671435830573ddf6f667 (diff)
downloadscummvm-rg350-23a6533c95d8ca80677113df68c678e23dda1311.tar.gz
scummvm-rg350-23a6533c95d8ca80677113df68c678e23dda1311.tar.bz2
scummvm-rg350-23a6533c95d8ca80677113df68c678e23dda1311.zip
TITANIC: Properly flag audio buffer as finished when song is done
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/sound/audio_buffer.h12
-rw-r--r--engines/titanic/sound/music_room_handler.cpp4
-rw-r--r--engines/titanic/sound/wave_file.cpp2
3 files changed, 16 insertions, 2 deletions
diff --git a/engines/titanic/sound/audio_buffer.h b/engines/titanic/sound/audio_buffer.h
index c775c5bb35..6d074a356d 100644
--- a/engines/titanic/sound/audio_buffer.h
+++ b/engines/titanic/sound/audio_buffer.h
@@ -44,7 +44,7 @@ private:
* Leave a critical section
*/
void leaveCriticalSection();
-public:
+private:
bool _finished;
public:
CAudioBuffer(int maxSize);
@@ -75,6 +75,11 @@ public:
bool full() const { return _data.full(); }
/**
+ * Returns true if the audio buffering is finished
+ */
+ bool isFinished() const { return _finished && empty(); }
+
+ /**
* Adds a value to the buffer
*/
void push(int16 value);
@@ -93,6 +98,11 @@ public:
* Reads out a specified number of samples
*/
int read(int16 *values, int count);
+
+ /**
+ * Marks the buffer as finishing, and that no more new data will arrive
+ */
+ void finalize() { _finished = true; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index 5c1cd6012d..b7d6ea189e 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -232,6 +232,10 @@ void CMusicRoomHandler::updateAudio() {
_audioBuffer->push(audioData, size);
delete[] audioData;
}
+
+ if (_instrumentsActive == 0)
+ // Reaching end of music
+ _audioBuffer->finalize();
}
void CMusicRoomHandler::updateInstruments() {
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index ae633a2149..c2a66cfdcb 100644
--- a/engines/titanic/sound/wave_file.cpp
+++ b/engines/titanic/sound/wave_file.cpp
@@ -52,7 +52,7 @@ int AudioBufferStream::readBuffer(int16 *buffer, const int numSamples) {
}
bool AudioBufferStream::endOfData() const {
- return _audioBuffer->_finished;
+ return _audioBuffer->isFinished();
}
/*------------------------------------------------------------------------*/