aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/sound/audio_buffer.h
diff options
context:
space:
mode:
authorPaul Gilbert2017-09-14 22:34:04 -0400
committerPaul Gilbert2017-09-14 22:34:04 -0400
commit3ed7ef57aec38a39d7887a520c8eaf510f19804e (patch)
tree9018ecf269c414c141c76ff3a5440c6c86c88a23 /engines/titanic/sound/audio_buffer.h
parent8607b702edd594264378f15dfe420fb0fc5881d0 (diff)
downloadscummvm-rg350-3ed7ef57aec38a39d7887a520c8eaf510f19804e.tar.gz
scummvm-rg350-3ed7ef57aec38a39d7887a520c8eaf510f19804e.tar.bz2
scummvm-rg350-3ed7ef57aec38a39d7887a520c8eaf510f19804e.zip
TITANIC: Moved queue logic within CAUdioBuffer to new FixedQueue class
This is a cleaner implementation, since all the pointer logic and queue management is now better encapsulated in it's own class. I felt a new FixedQueue class was necessary because the standard Queue class uses a Common::List internally, which would be unsuitable for containing 100,000 elements, since each int value would need it's own list node. This way uses an array internally, like FixedStack
Diffstat (limited to 'engines/titanic/sound/audio_buffer.h')
-rw-r--r--engines/titanic/sound/audio_buffer.h23
1 files changed, 8 insertions, 15 deletions
diff --git a/engines/titanic/sound/audio_buffer.h b/engines/titanic/sound/audio_buffer.h
index 8d27667e93..1f157b9346 100644
--- a/engines/titanic/sound/audio_buffer.h
+++ b/engines/titanic/sound/audio_buffer.h
@@ -23,7 +23,7 @@
#ifndef TITANIC_AUDIO_BUFFER_H
#define TITANIC_AUDIO_BUFFER_H
-#include "common/array.h"
+#include "titanic/support/fixed_queue.h"
#include "common/mutex.h"
namespace Titanic {
@@ -31,14 +31,7 @@ namespace Titanic {
class CAudioBuffer {
private:
Common::Mutex _mutex;
- Common::Array<int16> _data;
- int16 *_frontP, *_backP;
-
- /**
- * Reclaims any space at the start of the array resulting from
- * having read values off the font
- */
- void compact();
+ FixedQueue<int16, 88200> _data;
public:
bool _finished;
public:
@@ -57,17 +50,17 @@ public:
/**
* Returns the number of 16-bit entries in the buffer
*/
- int size() const { return _backP - _frontP; }
+ int size() const { return _data.size(); }
/**
- * Returns true if the buffer is full
+ * Returns the number of entries free in the buffer
*/
- bool full() const { return (_backP - _frontP) == (int)_data.size(); }
+ int freeSize() const { return _data.freeSize(); }
/**
- * Returns the number of entries free in the buffer
+ * Returns true if the buffer is full
*/
- int freeSize();
+ bool full() const { return _data.full(); }
/**
* Adds a value to the buffer
@@ -77,7 +70,7 @@ public:
/**
* Adds a value to the buffer
*/
- void push(int16 *values, int count);
+ void push(const int16 *values, int count);
/**
* Removes a value from the buffer