iface: Add inner ring-buffer implementation

Two buffers, inner and outer, are used in the transceiver
implementation. The outer buffer interfaces with the device receive
interface to guarantee timestamp aligned and contiguously allocated
sample buffers. The inner buffer absorbs vector size differences between
GSM bursts (156 or 157 samples) and the resampler interface (typically
fixed multiples of 65).

Reimplement the inner buffer with a ring buffer that allows fixed size
segments on the outer (resampler) portion and variable lengths (GSM
side) on the inner side. Compared to the previous stack-like version,
this implementation removes unnecessary copying of buffer contents.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
diff --git a/Transceiver52M/radioBuffer.h b/Transceiver52M/radioBuffer.h
new file mode 100644
index 0000000..afb6e63
--- /dev/null
+++ b/Transceiver52M/radioBuffer.h
@@ -0,0 +1,45 @@
+#include <stdlib.h>
+#include <stddef.h>
+#include <vector>
+
+class RadioBuffer {
+public:
+	RadioBuffer(size_t numSegments, size_t segmentLen,
+		    size_t hLen, bool outDirection);
+
+	~RadioBuffer();
+
+	const size_t getSegmentLen() { return segmentLen; };
+	const size_t getNumSegments() { return numSegments; };
+	const size_t getAvailSamples() { return availSamples; };
+	const size_t getAvailSegments() { return availSamples / segmentLen; };
+
+	const size_t getFreeSamples()
+	{
+		return bufferLen - availSamples;
+	}
+
+	const size_t getFreeSegments()
+	{
+		return getFreeSamples() / segmentLen;
+	}
+
+	void reset();
+
+	/* Output direction */
+	const float *getReadSegment();
+	bool write(const float *wr, size_t len);
+	bool zero(size_t len);
+
+	/* Input direction */
+	float *getWriteSegment();
+	bool zeroWriteSegment();
+	bool read(float *rd, size_t len);
+
+private:
+	size_t writeIndex, readIndex, availSamples;
+	size_t bufferLen, numSegments, segmentLen, hLen;
+	float *buffer;
+	std::vector<float *> segments;
+	bool outDirection;
+};