16 odata =
new Type [osize];
43 odata =
new Type [osize];
53 if(oreadPos > owritePos){
54 err.
set(1,
"BFifo is wrapped");
58 if(owritePos - oreadPos)
59 memmove(odata, &odata[oreadPos],
sizeof(Type) * (owritePos - oreadPos));
60 owritePos -= oreadPos;
69 BUInt readPos = oreadPos;
71 if(readPos <= owritePos)
72 return osize - owritePos + readPos - 1;
74 return (readPos - owritePos - 1);
78 BUInt readPos = oreadPos;
81 return osize - owritePos - 1;
82 else if(readPos <= owritePos)
83 return osize - owritePos;
85 return (readPos - owritePos - 1);
92 if(owritePos < (osize-1))
106 if(nt > (osize - owritePos))
107 nt = (osize - owritePos);
109 memcpy(&odata[owritePos],
data, nt *
sizeof(Type));
111 if((owritePos + nt) == osize)
124 return &odata[owritePos];
128 num = writeAvailableChunk();
133 if((owritePos + num) >= osize)
134 owritePos = owritePos + num - osize;
141 BUInt ra = readAvailable();
147 owritePos = owritePos + osize - n;
154 BUInt writePos = owritePos;
156 if(oreadPos <= writePos)
157 return writePos - oreadPos;
159 return osize - oreadPos + writePos;
163 BUInt writePos = owritePos;
165 if(oreadPos <= writePos)
166 return writePos - oreadPos;
168 return osize - oreadPos;
175 if(oreadPos < (osize-1))
189 if(nt > (osize - oreadPos))
190 nt = (osize - oreadPos);
192 memcpy(
data, &odata[oreadPos], nt *
sizeof(Type));
194 if((oreadPos + nt) == osize)
207 return &odata[oreadPos];
211 num = readAvailableChunk();
216 if((oreadPos + num) >= osize)
217 oreadPos = oreadPos + num - osize;
223 BUInt p = oreadPos + pos;
226 return odata[p - osize];
232 BUInt p = oreadPos + pos;
235 odata[p - osize] = v;
241 BUInt p = oreadPos + pos;
244 return odata[p - osize];
BUInt32 BUInt
Definition BTypes.h:33
BFloat32 BFloat
Definition BTypes.h:34
char data[8]
Definition BoapMc1.h:2
Error return class. This class is used to return the error status from a function....
Definition BError.h:31
BError & set(int errNo, BString errStr="")
Set error number and message.
Definition BError.cpp:24
Type read()
Read one item.
BError resize(BUInt size)
Resize FIFO, clears it as well.
BUInt writeAvailableChunk()
How many items that can be written in a chunk.
BUInt size()
Returns fifo size.
void writeDone(BUInt num)
Indicates when write is complete.
BError rebase()
Rebases fifo so read pointer is at zero moving memory as needed.
Type readPos(BUInt pos)
Read item at given offset from current read position.
void writeBackup(BUInt num)
Backup, remove num items at end of fifo. Careful, make sure read is not already happening.
void writePos(BUInt pos, const Type &v)
Write item at given offset from current read position.
Type & operator[](int pos)
Direct access to read samples in buffer.
BUInt readAvailableChunk()
How many items are available to read in a chunk.
BUInt writeAvailable()
How many items that can be written.
Type * writeData()
Returns a pointer to the data.
BUInt readAvailable()
How many items are available to read.
BError write(const Type v)
Write a single item.
Type * readData()
Returns a pointer to the data.