From 32f43a992091be567821cb727873903b61b6e279 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 16 Apr 2020 18:52:17 +0800 Subject: [PATCH] For RTC, always try to read message first, to improve performance --- trunk/src/app/srs_app_rtc_conn.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index d35290f0f..c3232a476 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -694,26 +694,24 @@ srs_error_t SrsRtcSenderThread::cycle() return srs_error_wrap(err, "rtc sender thread"); } -#ifdef SRS_PERF_QUEUE_COND_WAIT - if (realtime) { - // for realtime, min required msgs is 0, send when got one+ msgs. - consumer->wait(SRS_PERF_MW_MIN_MSGS_FOR_RTC_REALTIME, mw_sleep); - } else { - // for no-realtime, got some msgs then send. - consumer->wait(SRS_PERF_MW_MIN_MSGS_FOR_RTC, mw_sleep); - } -#endif - int msg_count = 0; if ((err = consumer->dump_packets(&msgs, msg_count)) != srs_success) { continue; } - if (msg_count <= 0) { -#ifndef SRS_PERF_QUEUE_COND_WAIT + // For RTC, we always try to read messages, only wait when no message. + if (msg_count <= 0) { +#ifdef SRS_PERF_QUEUE_COND_WAIT + if (realtime) { + // for realtime, min required msgs is 0, send when got one+ msgs. + consumer->wait(SRS_PERF_MW_MIN_MSGS_FOR_RTC_REALTIME, mw_sleep); + } else { + // for no-realtime, got some msgs then send. + consumer->wait(SRS_PERF_MW_MIN_MSGS_FOR_RTC, mw_sleep); + } +#else srs_usleep(mw_sleep); #endif - // ignore when nothing got. continue; }