Skip to content

Commit

Permalink
Added minimum number of packages to buffer before starting playback, …
Browse files Browse the repository at this point in the history
…closing #24

Signed-off-by:doe300 <stadeldani@web.de>
  • Loading branch information
doe300 committed Jun 17, 2015
1 parent c902827 commit 28981b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion include/RTPBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class RTPBuffer
/*!
* \param maxCapacity The maximum number of packages to buffer
* \param maxDelay The maximum delay in milliseconds before dropping packages
* \param minBufferPackages The minimum of packages to buffer before returning valid audio-data
*/
RTPBuffer(uint16_t maxCapacity, uint16_t maxDelay);
RTPBuffer(uint16_t maxCapacity, uint16_t maxDelay, uint16_t minBufferPackages = 1);
virtual ~RTPBuffer();

/*!
Expand Down Expand Up @@ -119,6 +120,11 @@ class RTPBuffer
* The maximum delay (in milliseconds) before dropping a package
*/
const uint16_t maxDelay;
/*!
* The minimum number of packages this buffer must contain before packages are read.
* Until this lower limit is reached, silence-packages are returned.
*/
const uint16_t minBufferPackages;
/*!
* The index to read the next package from, the last position in the buffer
*/
Expand Down
4 changes: 2 additions & 2 deletions src/RTPBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//TODO implement maxDelay (problem: RTP-timestamp is not guaranteed to be in ms or ns or s, ...)

RTPBuffer::RTPBuffer(uint16_t maxCapacity, uint16_t maxDelay): capacity(maxCapacity), maxDelay(maxDelay)
RTPBuffer::RTPBuffer(uint16_t maxCapacity, uint16_t maxDelay, uint16_t minBufferPackages): capacity(maxCapacity), maxDelay(maxDelay), minBufferPackages(minBufferPackages)
{
nextReadIndex = 0;
ringBuffer = new RTPBufferPackage[maxCapacity];
Expand Down Expand Up @@ -89,7 +89,7 @@ RTPBufferStatus RTPBuffer::addPackage(RTPPackage &package, unsigned int contentS
RTPBufferStatus RTPBuffer::readPackage(RTPPackage &package)
{
lockMutex();
if(size <= 0)
if(size < minBufferPackages)
{
//buffer is empty
//write placeholder package
Expand Down

0 comments on commit 28981b3

Please sign in to comment.