mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine init of global objects
This commit is contained in:
parent
b1e85664a1
commit
8b58d18a5a
6 changed files with 53 additions and 29 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue