| 53 | } |
| 54 | |
| 55 | unsigned int CircleBuffer::getFreeSize() |
| 56 | { |
| 57 | unsigned int iNumBytesFree; |
| 58 | |
| 59 | EnterCriticalSection(&this->m_csCircleBuffer); |
| 60 | |
| 61 | if (this->m_iInternalWriteCursor < this->m_iInternalReadCursor) |
| 62 | iNumBytesFree = (this->m_iInternalReadCursor - 1) - this->m_iInternalWriteCursor; |
| 63 | else if (this->m_iInternalWriteCursor == this->m_iInternalReadCursor) |
| 64 | iNumBytesFree = this->m_iBufferSize; |
| 65 | else |
| 66 | iNumBytesFree = (this->m_iInternalReadCursor - 1) + (this->m_iBufferSize - this->m_iInternalWriteCursor); |
| 67 | |
| 68 | LeaveCriticalSection(&this->m_csCircleBuffer); |
| 69 | return iNumBytesFree; |
| 70 | } |
| 71 | |
| 72 | unsigned int CircleBuffer::getUsedSize() |
| 73 | { |