From 688aea54fce7e4c1cfd5ee9ce0b9e7fce09d3d03 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 9 Jul 2024 10:13:49 +0800 Subject: [PATCH] Never create consumer if error. --- trunk/src/app/srs_app_source.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 705c4e8979..2a9c59a58d 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -2660,13 +2660,6 @@ void SrsLiveSource::on_unpublish() srs_error_t SrsLiveSource::create_consumer(SrsLiveConsumer*& consumer) { srs_error_t err = srs_success; - - consumer = new SrsLiveConsumer(this); - consumers.push_back(consumer); - - // There should be one consumer, so reset the timeout. - stream_die_at_ = 0; - publisher_idle_at_ = 0; // for edge, when play edge stream, check the state if (_srs_config->get_vhost_is_edge(req->vhost)) { @@ -2675,6 +2668,13 @@ srs_error_t SrsLiveSource::create_consumer(SrsLiveConsumer*& consumer) return srs_error_wrap(err, "play edge"); } } + + consumer = new SrsLiveConsumer(this); + consumers.push_back(consumer); + + // There are more than one consumer, so reset the timeout. + stream_die_at_ = 0; + publisher_idle_at_ = 0; return err; }