| Index: webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/ssrc_database.cc b/webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| index fb02b7ef12cd12f785fd18ed331e1407d3fd38c4..7a62236593da82694fcea7a58903cb565a184009 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| @@ -11,26 +11,27 @@
|
| #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
|
|
|
| #include "webrtc/base/checks.h"
|
| -#include "webrtc/system_wrappers/include/clock.h"
|
| -#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
| +#include "webrtc/system_wrappers/include/tick_util.h"
|
|
|
| namespace webrtc {
|
| -namespace {
|
| -uint64_t Seed() {
|
| - return Clock::GetRealTimeClock()->TimeInMicroseconds();
|
| -}
|
| -} // namespace
|
| -
|
| -SSRCDatabase* SSRCDatabase::GetSSRCDatabase() {
|
| - return GetStaticInstance<SSRCDatabase>(kAddRef);
|
| -}
|
| -
|
| -void SSRCDatabase::ReturnSSRCDatabase() {
|
| - GetStaticInstance<SSRCDatabase>(kRelease);
|
| -}
|
|
|
| +// For initializing the random seed, we don't use TimeInMicroseconds() since it
|
| +// can return 0 on Mac if we're called early on during process startup (e.g.
|
| +// in tests). This is because when the tick count gets converted into
|
| +// microseconds, we can end up multiplying with 0 and end up with a seed of 0.
|
| +// TODO(tommi): Move this into the Random() class itself. At the moment that's
|
| +// not possible because the Random class is in webrtc/base but TickTime is
|
| +// in webrtc/system_wrappers/include/.
|
| +SSRCDatabase::SSRCDatabase() : random_(TickTime::Now().Ticks()) {}
|
| +
|
| +SSRCDatabase::~SSRCDatabase() {}
|
| +
|
| +// TODO(tommi, holmer): Look into whether we can eliminate locking in this
|
| +// class. At the moment voe_auto_test requires it, but it's not clear if that's
|
| +// an issue with the test code or if it reflects real world usage or if that's
|
| +// the best design performance wise.
|
| uint32_t SSRCDatabase::CreateSSRC() {
|
| - CriticalSectionScoped lock(crit_.get());
|
| + rtc::CritScope lock(&crit_);
|
|
|
| while (true) { // Try until get a new ssrc.
|
| // 0 and 0xffffffff are invalid values for SSRC.
|
| @@ -42,19 +43,13 @@ uint32_t SSRCDatabase::CreateSSRC() {
|
| }
|
|
|
| void SSRCDatabase::RegisterSSRC(uint32_t ssrc) {
|
| - CriticalSectionScoped lock(crit_.get());
|
| + rtc::CritScope lock(&crit_);
|
| ssrcs_.insert(ssrc);
|
| }
|
|
|
| void SSRCDatabase::ReturnSSRC(uint32_t ssrc) {
|
| - CriticalSectionScoped lock(crit_.get());
|
| + rtc::CritScope lock(&crit_);
|
| ssrcs_.erase(ssrc);
|
| }
|
|
|
| -SSRCDatabase::SSRCDatabase()
|
| - : crit_(CriticalSectionWrapper::CreateCriticalSection()), random_(Seed()) {}
|
| -
|
| -SSRCDatabase::~SSRCDatabase() {
|
| -}
|
| -
|
| } // namespace webrtc
|
|
|