[Scummvm-git-logs] scummvm master -> 23a6533c95d8ca80677113df68c678e23dda1311

dreammaster dreammaster at scummvm.org
Sun Oct 15 03:31:43 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
23a6533c95 TITANIC: Properly flag audio buffer as finished when song is done


Commit: 23a6533c95d8ca80677113df68c678e23dda1311
    https://github.com/scummvm/scummvm/commit/23a6533c95d8ca80677113df68c678e23dda1311
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-10-14T21:31:35-04:00

Commit Message:
TITANIC: Properly flag audio buffer as finished when song is done

Changed paths:
    engines/titanic/sound/audio_buffer.h
    engines/titanic/sound/music_room_handler.cpp
    engines/titanic/sound/wave_file.cpp


diff --git a/engines/titanic/sound/audio_buffer.h b/engines/titanic/sound/audio_buffer.h
index c775c5b..6d074a3 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 5c1cd60..b7d6ea1 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 ae633a2..c2a66cf 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();
 }
 
 /*------------------------------------------------------------------------*/





More information about the Scummvm-git-logs mailing list