A very basic circular buffer implementation.
More...
|
| CircularBuffer (int size) |
| Create a new circular buffer.
|
|
int | Write (byte[] data, int offset, int count) |
| Writes the specified number of bytes from the input data array to the internal buffer, starting at the specified offset .
|
|
int | Read (byte[] data, int offset, int count) |
| Reads data from the buffer into the specified byte array.
|
|
void | Reset () |
| Resets the state of the object.
|
|
void | Advance (int count) |
| Advances the read position in the buffer by the specified count.
|
|
|
int | MaxLength [get] |
| Maximum length of this circular buffer.
|
|
int | Count [get] |
| Number of bytes currently stored in the circular buffer.
|
|
|
void | ResetInner () |
| Resets the internal state of the object.
|
|
A very basic circular buffer implementation.
◆ CircularBuffer()
NAudio.Utils.CircularBuffer.CircularBuffer |
( |
int | size | ) |
|
|
inline |
Create a new circular buffer.
- Parameters
-
size | Max buffer size in bytes |
◆ Advance()
void NAudio.Utils.CircularBuffer.Advance |
( |
int | count | ) |
|
|
inline |
Advances the read position in the buffer by the specified count.
- Parameters
-
count | The number of positions to advance the read position by. |
- Exceptions
-
System.ArgumentOutOfRangeException | Thrown when the count is negative. |
This method advances the read position in the buffer by the specified count. If the count is greater than or equal to the total byte count, it resets the buffer. Otherwise, it decrements the byte count by the specified count, advances the read position, and ensures that the read position wraps around if it exceeds the maximum length.
◆ Read()
int NAudio.Utils.CircularBuffer.Read |
( |
byte[] | data, |
|
|
int | offset, |
|
|
int | count ) |
|
inline |
Reads data from the buffer into the specified byte array.
- Parameters
-
data | The byte array to which the data will be read. |
offset | The zero-based byte offset in data at which to begin storing the data. |
count | The maximum number of bytes to read. |
- Returns
- The total number of bytes read into the buffer.
This method reads data from the internal buffer into the specified byte array. If the specified count is greater than the available bytes in the buffer, it only reads the available bytes. The method handles wrapping around the buffer if necessary and updates the internal state accordingly.
◆ Reset()
void NAudio.Utils.CircularBuffer.Reset |
( |
| ) |
|
|
inline |
Resets the state of the object.
This method locks the lockObject and then calls the ResetInner method to reset the state of the object.
◆ ResetInner()
void NAudio.Utils.CircularBuffer.ResetInner |
( |
| ) |
|
|
inlineprivate |
Resets the internal state of the object.
This method resets the byte count, read position, and write position to their initial values, effectively clearing the internal state of the object.
◆ Write()
int NAudio.Utils.CircularBuffer.Write |
( |
byte[] | data, |
|
|
int | offset, |
|
|
int | count ) |
|
inline |
Writes the specified number of bytes from the input data array to the internal buffer, starting at the specified offset .
- Parameters
-
data | The input byte array from which data will be written to the internal buffer. |
offset | The zero-based byte offset in the data array at which to begin copying bytes to the internal buffer. |
count | The number of bytes to write to the internal buffer. |
- Returns
- The actual number of bytes written to the internal buffer, which may be less than the specified count if the internal buffer does not have enough space.
This method locks the lockObject to ensure thread safety while writing to the internal buffer. If the specified count is greater than the available space in the internal buffer, only the available space is written. The method first writes to the end of the buffer, and if necessary, wraps around and writes to the start of the buffer to complete the write operation. The total number of bytes written is returned, and the internal byte count is updated accordingly.
◆ buffer
readonly byte [] NAudio.Utils.CircularBuffer.buffer |
|
private |
◆ byteCount
int NAudio.Utils.CircularBuffer.byteCount |
|
private |
◆ lockObject
readonly object NAudio.Utils.CircularBuffer.lockObject |
|
private |
◆ readPosition
int NAudio.Utils.CircularBuffer.readPosition |
|
private |
◆ writePosition
int NAudio.Utils.CircularBuffer.writePosition |
|
private |
◆ Count
int NAudio.Utils.CircularBuffer.Count |
|
get |
Number of bytes currently stored in the circular buffer.
◆ MaxLength
int NAudio.Utils.CircularBuffer.MaxLength |
|
get |
Maximum length of this circular buffer.
The documentation for this class was generated from the following file:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/Plugins/LiveMicrophone/lib/NAudio.Core/Utils/CircularBuffer.cs