1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

SquashSRS4: Refine the init of global objects

This commit is contained in:
winlin 2021-05-08 11:51:54 +08:00
parent 276bd2223e
commit 3256c7c2fa
20 changed files with 412 additions and 153 deletions

View file

@ -1684,17 +1684,18 @@ srs_error_t SrsMetaCache::update_vsh(SrsSharedPtrMessage* msg)
return vformat->on_video(msg);
}
SrsSourceManager* _srs_sources = new SrsSourceManager();
SrsSourceManager* _srs_sources = NULL;
SrsSourceManager::SrsSourceManager()
{
lock = NULL;
timer_ = NULL;
lock = srs_mutex_new();
timer_ = new SrsHourGlass("sources", this, 1 * SRS_UTIME_SECONDS);
}
SrsSourceManager::~SrsSourceManager()
{
srs_mutex_destroy(lock);
srs_freep(timer_);
}
srs_error_t SrsSourceManager::initialize()
@ -1706,11 +1707,6 @@ srs_error_t SrsSourceManager::fetch_or_create(SrsRequest* r, ISrsSourceHandler*
{
srs_error_t err = srs_success;
// Lazy create lock, because ST is not ready in SrsSourceManager constructor.
if (!lock) {
lock = srs_mutex_new();
}
// Use lock to protect coroutine switch.
// @bug https://github.com/ossrs/srs/issues/1230
// TODO: FIXME: Use smaller lock.
@ -1778,9 +1774,6 @@ srs_error_t SrsSourceManager::setup_ticks()
{
srs_error_t err = srs_success;
srs_freep(timer_);
timer_ = new SrsHourGlass("sources", this, 1 * SRS_UTIME_SECONDS);
if ((err = timer_->tick(1, 1 * SRS_UTIME_SECONDS)) != srs_success) {
return srs_error_wrap(err, "tick");
}