Skip to content

Commit

Permalink
[core] New receiver buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Oct 13, 2021
1 parent 15f33d4 commit cac019c
Show file tree
Hide file tree
Showing 21 changed files with 3,027 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ option(USE_OPENSSL_PC "Use pkg-config to find OpenSSL libraries" ON)
option(USE_BUSY_WAITING "Enable more accurate sending times at a cost of potentially higher CPU load" OFF)
option(USE_GNUSTL "Get c++ library/headers from the gnustl.pc" OFF)
option(ENABLE_SOCK_CLOEXEC "Enable setting SOCK_CLOEXEC on a socket" ON)
option(ENABLE_NEW_RCVBUFFER "Enable new receiver buffer implementation" ON)

option(ENABLE_CLANG_TSA "Enable Clang Thread Safety Analysis" OFF)

Expand Down Expand Up @@ -486,6 +487,10 @@ if (ENABLE_SOCK_CLOEXEC)
add_definitions(-DENABLE_SOCK_CLOEXEC=1)
endif()

if (ENABLE_NEW_RCVBUFFER)
add_definitions(-DENABLE_NEW_RCVBUFFER=1)
endif()

if (CMAKE_MAJOR_VERSION LESS 3)
set (FORCE_CXX_STANDARD_GNUONLY 1)
endif()
Expand Down Expand Up @@ -1291,6 +1296,7 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
endif()

MafReadDir(test filelist.maf
HEADERS SOURCES_unittests
SOURCES SOURCES_unittests
)

Expand Down
13 changes: 13 additions & 0 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,19 @@ void srt::CUDTSocket::setBrokenClosed()

bool srt::CUDTSocket::readReady()
{
#if ENABLE_NEW_RCVBUFFER
if (m_UDT.m_bConnected && m_UDT.m_pRcvBuffer->isRcvDataReady())
return true;
#else
if (m_UDT->m_bConnected && m_UDT.m_pRcvBuffer->isRcvDataReady())
return true;
#endif


if (m_UDT.m_bListening)
{
return !m_QueuedSockets.empty();
}

return broken();
}
Expand Down Expand Up @@ -2627,7 +2636,11 @@ void srt::CUDTUnited::checkBrokenSockets()
// NOT WHETHER THEY ARE ALSO READY TO PLAY at the time when
// this function is called (isRcvDataReady also checks if the
// available data is "ready to play").
#if ENABLE_NEW_RCVBUFFER
&& s->core().m_pRcvBuffer->isRcvDataReady()) // zero time includes any available packets
#else
&& s->core().m_pRcvBuffer->isRcvDataAvailable())
#endif
{
const int bc = s->core().m_iBrokenCounter.load();
if (bc > 0)
Expand Down
4 changes: 4 additions & 0 deletions srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,8 @@ void CSndBuffer::increase()

////////////////////////////////////////////////////////////////////////////////

#if (!ENABLE_NEW_RCVBUFFER)

/*
* RcvBuffer (circular buffer):
*
Expand Down Expand Up @@ -2289,4 +2291,6 @@ bool CRcvBuffer::scanMsg(int& w_p, int& w_q, bool& w_passack)
return found;
}

#endif // !ENABLE_NEW_RCVBUFFER

} // namespace srt
4 changes: 4 additions & 0 deletions srtcore/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ class CSndBuffer

////////////////////////////////////////////////////////////////////////////////

#if (!ENABLE_NEW_RCVBUFFER)

class CRcvBuffer
{
typedef sync::steady_clock::time_point time_point;
Expand Down Expand Up @@ -562,6 +564,8 @@ class CRcvBuffer
CRcvBuffer& operator=(const CRcvBuffer&);
};

#endif // !ENABLE_NEW_RCVBUFFER

} // namespace srt

#endif
Loading

0 comments on commit cac019c

Please sign in to comment.