amazon-kinesis-video-streams-webrtc-sdk-c
amazon-kinesis-video-streams-webrtc-sdk-c copied to clipboard
Rolling buffer size enhancements, bug fix, and unit tests
Issue #, if available: N/A
What was changed?
- Add proper size tracking (bug fix), which allows:
- Able to check if it's at capacity and data will be overwritten.
DLOGI("Extract! Size: %d, index: %u, bounds: [%u - %u). Ago=%d", pRollingBuffer->size, index, pRollingBuffer->tailIndex, pRollingBuffer->headIndex, pRollingBuffer->headIndex - index);to check how many elements away from the head of the queue upon request.
- Handle integer overflow case when indexes wrap around UINT64_MAX.
- Add documentation for methods
- Add comments in the code
- Factored out the range check to a separate method.
- Added more unit tests to confirm behavior.
- Make rollingBufferGetSize and rollingBufferIsEmpty thread safe by adding locks.
Why was it changed?
- Make rolling buffer code more robust and more readable.
How was it changed?
- Refer to the code above.
- Note: The size needed to be its own variable because you can remove items from the buffer in an arbitrary order.
What testing was done for the changes?
- Run the new unit tests and they pass.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.