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

SRT: Refine the schedule resolution to 10ms if idle.

This commit is contained in:
winlin 2022-05-28 10:46:05 +08:00
parent b507a080b2
commit 4899be9c34
3 changed files with 17 additions and 7 deletions

View file

@ -450,12 +450,14 @@ srs_error_t SrsSrtPoller::del_socket(SrsSrtSocket* srt_skt)
return err;
}
srs_error_t SrsSrtPoller::wait(int timeout_ms)
srs_error_t SrsSrtPoller::wait(int timeout_ms, int* pn_fds)
{
srs_error_t err = srs_success;
// wait srt event fired, will timeout after `timeout_ms` milliseconds.
int ret = srt_epoll_uwait(srt_epoller_fd_, events_.data(), events_.size(), timeout_ms);
*pn_fds = ret;
if (ret < 0) {
return srs_error_new(ERROR_SRT_EPOLL, "srt_epoll_uwait, ret=%d, err=%s", ret, srt_getlasterror_str());
}

View file

@ -77,7 +77,9 @@ public:
srs_error_t add_socket(SrsSrtSocket* srt_skt);
srs_error_t mod_socket(SrsSrtSocket* srt_skt);
srs_error_t del_socket(SrsSrtSocket* srt_skt);
srs_error_t wait(int timeout_ms);
// Wait for the fds in its epoll to be fired in specified timeout_ms, where the pn_fds is the number of active fds.
// Note that for ST, please always use timeout_ms(0) and switch coroutine by yourself.
srs_error_t wait(int timeout_ms, int* pn_fds);
private:
// Find SrsSrtSocket* context by SRTSOCKET.
std::map<SRTSOCKET, SrsSrtSocket*> fd_sockets_;