[Scummvm-git-logs] scummvm master -> 0ad57c0fed30bf404165b90da86bf7862da4c59e

dreammaster dreammaster at scummvm.org
Mon Feb 6 05:23:03 CET 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:
0ad57c0fed TITANIC: Further renamings for the audio buffer


Commit: 0ad57c0fed30bf404165b90da86bf7862da4c59e
    https://github.com/scummvm/scummvm/commit/0ad57c0fed30bf404165b90da86bf7862da4c59e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-05T23:22:43-05:00

Commit Message:
TITANIC: Further renamings for the audio buffer

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


diff --git a/engines/titanic/sound/audio_buffer.cpp b/engines/titanic/sound/audio_buffer.cpp
index 6798c8b..aa4bb8c 100644
--- a/engines/titanic/sound/audio_buffer.cpp
+++ b/engines/titanic/sound/audio_buffer.cpp
@@ -24,7 +24,7 @@
 
 namespace Titanic {
 
-CAudioBuffer::CAudioBuffer(int bufferSize) : _flag(true), _field18(0) {
+CAudioBuffer::CAudioBuffer(int bufferSize) : _flag(true), _disabled(false) {
 	_buffer.resize(bufferSize);
 	reset();
 }
@@ -35,7 +35,7 @@ CAudioBuffer::~CAudioBuffer() {
 
 void CAudioBuffer::reset() {
 	_flag = true;
-	_fieldC = _writeBytesLeft = _buffer.size() / 2;
+	_readBytesLeft = _writeBytesLeft = _buffer.size() / 2;
 }
 
 byte *CAudioBuffer::getBegin() {
@@ -46,9 +46,9 @@ byte *CAudioBuffer::getEnd() {
 	return _flag ? &_buffer[0] : &_buffer[_buffer.size() / 2];
 }
 
-byte *CAudioBuffer::getPtr1() {
+uint16 *CAudioBuffer::getReadPtr() {
 	byte *ptr = getBegin();
-	return ptr + (_buffer.size() / 2 - _fieldC);
+	return (uint16 *)(ptr + (_buffer.size() / 2 - _readBytesLeft));
 }
 
 uint16 *CAudioBuffer::getWritePtr() {
@@ -56,11 +56,11 @@ uint16 *CAudioBuffer::getWritePtr() {
 	return (uint16 *)(ptr + (_buffer.size() / 2 - _writeBytesLeft));
 }
 
-void CAudioBuffer::setC(int val) {
-	_fieldC -= val;
-	if (_fieldC < 0) {
-		_fieldC = 0;
-	} else if (val && !_writeBytesLeft) {
+void CAudioBuffer::advanceRead(int size) {
+	_readBytesLeft -= size;
+	if (_readBytesLeft < 0) {
+		_readBytesLeft = 0;
+	} else if (size && !_writeBytesLeft) {
 		reverse();
 	}
 }
@@ -69,14 +69,14 @@ void CAudioBuffer::advanceWrite(int size) {
 	_writeBytesLeft -= size;
 	if (_writeBytesLeft < 0) {
 		_writeBytesLeft = 0;
-	} else if (size && !_fieldC) {
+	} else if (size && !_readBytesLeft) {
 		reverse();
 	}
 }
 
 void CAudioBuffer::reverse() {
 	_flag = !_flag;
-	_fieldC = _writeBytesLeft = _buffer.size() / 2;
+	_readBytesLeft = _writeBytesLeft = _buffer.size() / 2;
 }
 
 void CAudioBuffer::enterCriticalSection() {
diff --git a/engines/titanic/sound/audio_buffer.h b/engines/titanic/sound/audio_buffer.h
index 5b6fb11..32a5790 100644
--- a/engines/titanic/sound/audio_buffer.h
+++ b/engines/titanic/sound/audio_buffer.h
@@ -48,20 +48,39 @@ private:
 	void reverse();
 public:
 	Common::Array<byte> _buffer;
-	int _fieldC;
+	int _readBytesLeft;
 	int _writeBytesLeft;
 	bool _flag;
-	int _field18;
+	bool _disabled;
 public:
 	CAudioBuffer(int bufferSize);
 	~CAudioBuffer();
 
+	/**
+	 * Resets the audio buffer
+	 */
 	void reset();
 
-	byte *getPtr1();
+	/**
+	 * Gets a pointer to the start of previously written data
+	 */
+	uint16 *getReadPtr();
+
+	/**
+	 * Returns the number of bytes that can be read
+	 */
+	int getBytesToRead() const { return _readBytesLeft; }
+
+	/**
+	 * Advances the read index
+	 */
+	void advanceRead(int size);
+
+	/**
+	 * Gets a pointer to the remainder of the audio buffer that
+	 * can be written to
+	 */
 	uint16 *getWritePtr();
-	int getC() const { return _fieldC; }
-	void setC(int val);
 
 	/**
 	 * Returns how many bytes can be written before hitting the
diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index e716ebc..d3ced80 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -96,7 +96,7 @@ void CMusicRoomHandler::setup(int volume) {
 	update();
 
 	_waveFile = _soundManager->loadMusic(_audioBuffer, DisposeAfterUse::NO);
-	_audioBuffer->setC(_audioBuffer->getC());
+	_audioBuffer->advanceRead(_audioBuffer->getBytesToRead());
 	update();
 }
 
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp
index 2dc7b02..5a1ae73 100644
--- a/engines/titanic/sound/music_wave.cpp
+++ b/engines/titanic/sound/music_wave.cpp
@@ -326,6 +326,7 @@ void CMusicWave::setupArray(int minVal, int maxVal) {
 
 	// TODO: Figure out if the weird shift can be represented as a simpler equation
 	uint32 arrSize = ((uint32)minVal << 29) - (uint32)minVal + maxVal;
+
 	_array = new double[arrSize / 8];
 	_arrayIndex = maxVal;
 





More information about the Scummvm-git-logs mailing list