Skip to content

Commit

Permalink
Introduced SRTRUNSTATUS to cover all cases of srt_startup(). Fixed do…
Browse files Browse the repository at this point in the history
…cumentation.
  • Loading branch information
Mikołaj Małecki committed Feb 19, 2024
1 parent 8c0102a commit d28e3b2
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 241 deletions.
1 change: 1 addition & 0 deletions common/devel_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct IntWrapperLoose: IntWrapper<INT, ambg>

typedef IntWrapper<int32_t, 0> SRTSOCKET;
typedef IntWrapper<int, 1> SRTSTATUS;
typedef IntWrapper<int, 2> SRTRUNSTATUS;
typedef IntWrapperLoose<int, 1> SRTSTATUS_LOOSE;


422 changes: 194 additions & 228 deletions docs/API/API-functions.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ string srt::CUDTUnited::CONID(SRTSOCKET sock)
return os.str();
}

SRTSTATUS srt::CUDTUnited::startup()
SRTRUNSTATUS srt::CUDTUnited::startup()
{
ScopedLock gcinit(m_InitLock);

if (m_iInstanceCount++ > 0)
return SRTSTATUS(1);
return SRT_RUN_ALREADY;

// Global initialization code
#ifdef _WIN32
Expand All @@ -258,18 +258,18 @@ SRTSTATUS srt::CUDTUnited::startup()
PacketFilter::globalInit();

if (m_bGCStatus)
return SRTSTATUS(1);
return SRT_RUN_ALREADY;

m_bClosing = false;

if (!StartThread(m_GCThread, garbageCollect, this, "SRT:GC"))
return SRT_ERROR;
return SRT_RUN_ERROR;

m_bGCStatus = true;

HLOGC(inlog.Debug, log << "SRT Clock Type: " << SRT_SYNC_CLOCK_STR);

return SRT_STATUS_OK;
return SRT_RUN_OK;
}

SRTSTATUS srt::CUDTUnited::cleanup()
Expand Down Expand Up @@ -3363,7 +3363,7 @@ void* srt::CUDTUnited::garbageCollect(void* p)

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

SRTSTATUS srt::CUDT::startup()
SRTRUNSTATUS srt::CUDT::startup()
{
return uglobal().startup();
}
Expand Down Expand Up @@ -4355,7 +4355,7 @@ SRT_SOCKSTATUS srt::CUDT::getsockstate(SRTSOCKET u)
namespace UDT
{

SRTSTATUS startup()
SRTRUNSTATUS startup()
{
return srt::CUDT::startup();
}
Expand Down
2 changes: 1 addition & 1 deletion srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class CUDTUnited

/// initialize the UDT library.
/// @return 0 if success, otherwise -1 is returned.
SRTSTATUS startup();
SRTRUNSTATUS startup();

/// release the UDT library.
/// @return 0 if success, otherwise -1 is returned.
Expand Down
2 changes: 1 addition & 1 deletion srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CUDT
~CUDT();

public: //API
static SRTSTATUS startup();
static SRTRUNSTATUS startup();
static SRTSTATUS cleanup();
static SRTSOCKET socket();
#if ENABLE_BONDING
Expand Down
13 changes: 11 additions & 2 deletions srtcore/srt.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ written by
// This is normal and should be normally used.
typedef int32_t SRTSOCKET;
typedef int SRTSTATUS;
typedef int SRTRUNSTATUS;
#else
// Used for development only.
#include "../common/devel_util.h"
Expand Down Expand Up @@ -770,21 +771,29 @@ static const SRTSOCKET SRT_INVALID_SOCK (-1);
static const SRTSOCKET SRT_SOCKID_CONNREQ (0);
static const SRTSTATUS SRT_ERROR (-1);
static const SRTSTATUS SRT_STATUS_OK (0);
static const SRTRUNSTATUS SRT_RUN_ERROR (-1);
static const SRTRUNSTATUS SRT_RUN_OK (0);
static const SRTRUNSTATUS SRT_RUN_ALREADY (1);

#else

#else // C version

static const SRTSOCKET SRT_INVALID_SOCK = -1;
static const SRTSOCKET SRT_SOCKID_CONNREQ = 0;
static const SRTSTATUS SRT_ERROR = -1;
static const SRTSTATUS SRT_STATUS_OK = 0;
static const SRTRUNSTATUS SRT_RUN_ERROR = -1;
static const SRTRUNSTATUS SRT_RUN_OK = 0;
static const SRTRUNSTATUS SRT_RUN_ALREADY = 1;

#endif


typedef struct CBytePerfMon SRT_TRACEBSTATS;


// library initialization
SRT_API SRTSTATUS srt_startup(void);
SRT_API SRTRUNSTATUS srt_startup(void);
SRT_API SRTSTATUS srt_cleanup(void);

//
Expand Down
2 changes: 1 addition & 1 deletion srtcore/srt_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace srt;

extern "C" {

SRTSTATUS srt_startup() { return CUDT::startup(); }
SRTRUNSTATUS srt_startup() { return CUDT::startup(); }
SRTSTATUS srt_cleanup() { return CUDT::cleanup(); }

// Socket creation.
Expand Down
2 changes: 1 addition & 1 deletion srtcore/udt.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ SRT_API extern const SRTSOCKET INVALID_SOCK;
#undef ERROR
SRT_API extern const SRTSTATUS ERROR;

SRT_API SRTSTATUS startup();
SRT_API SRTRUNSTATUS startup();
SRT_API SRTSTATUS cleanup();
SRT_API SRTSOCKET socket();
inline SRTSOCKET socket(int , int , int ) { return socket(); }
Expand Down

0 comments on commit d28e3b2

Please sign in to comment.