Commit cd13f747 authored by Mickaël Turnel's avatar Mickaël Turnel

Add a mutex for the creation of async rtp recv thread in windows

parent c6224a9f
......@@ -359,6 +359,7 @@ typedef struct _RtpStream
struct _OrtpVideoBandwidthEstimator *video_bw_estimator;
ortp_thread_t win_t;
volatile bool_t is_win_thread_running;
ortp_mutex_t winthread_lock;
queue_t winrq;
ortp_mutex_t winrq_lock;
}RtpStream;
......
......@@ -314,6 +314,7 @@ rtp_session_init (RtpSession * session, int mode)
#if defined(_WIN32) || defined(_WIN32_WCE)
session->rtp.is_win_thread_running = FALSE;
ortp_mutex_init(&session->rtp.winthread_lock, NULL);
ortp_mutex_init(&session->rtp.winrq_lock, NULL);
#endif
}
......@@ -1574,6 +1575,7 @@ void rtp_session_uninit (RtpSession * session)
session->rtp.is_win_thread_running = FALSE;
ortp_thread_join(session->rtp.win_t, NULL);
}
ortp_mutex_destroy(&session->rtp.winthread_lock);
ortp_mutex_destroy(&session->rtp.winrq_lock);
#endif
......@@ -2515,10 +2517,12 @@ bool_t ortp_stream_is_ipv6(OrtpStream *os) {
void rtp_session_reset_recvfrom(RtpSession *session) {
#if defined(_WIN32) || defined(_WIN32_WCE)
ortp_mutex_lock(&session->rtp.winthread_lock);
if (session->rtp.is_win_thread_running) {
session->rtp.is_win_thread_running = FALSE;
ortp_thread_join(session->rtp.win_t, NULL);
}
ortp_mutex_unlock(&session->rtp.winthread_lock);
#endif
flushq(&session->rtp.winrq, FLUSHALL);
}
......@@ -1727,6 +1727,7 @@ int rtp_session_rtp_recv (RtpSession * session, uint32_t user_ts) {
while (1)
{
#if defined(_WIN32) || defined(_WIN32_WCE)
ortp_mutex_lock(&session->rtp.winthread_lock);
if (!session->rtp.is_win_thread_running) {
int errnum;
......@@ -1737,6 +1738,7 @@ int rtp_session_rtp_recv (RtpSession * session, uint32_t user_ts) {
return -1;
}
}
ortp_mutex_unlock(&session->rtp.winthread_lock);
#else
rtp_session_recvfrom_async((void*)session);
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment