diff options
-rw-r--r-- | pjlib/include/pj/os.h | 4 | ||||
-rw-r--r-- | pjlib/src/pj/os_core_unix.c | 3 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/vid_port.c | 12 |
3 files changed, 16 insertions, 3 deletions
diff --git a/pjlib/include/pj/os.h b/pjlib/include/pj/os.h index 8cf9bcd9..8d8e602b 100644 --- a/pjlib/include/pj/os.h +++ b/pjlib/include/pj/os.h @@ -311,8 +311,10 @@ PJ_DECL(pj_thread_t*) pj_thread_this(void); /** * Join thread, and block the caller thread until the specified thread exits. + * If it is called from within the thread itself, it will return immediately + * with failure status. * If the specified thread has already been dead, or it does not exist, - * the function will return immediately with successfull status. + * the function will return immediately with successful status. * * @param thread The thread handle. * diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c index 8ec0cdb7..1a9fedd0 100644 --- a/pjlib/src/pj/os_core_unix.c +++ b/pjlib/src/pj/os_core_unix.c @@ -717,6 +717,9 @@ PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *p) PJ_CHECK_STACK(); + if (p == pj_thread_this()) + return PJ_ECANCELLED; + PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name)); result = pthread_join( rec->thread, &ret); diff --git a/pjmedia/src/pjmedia/vid_port.c b/pjmedia/src/pjmedia/vid_port.c index 2444402a..a5dcfcdb 100644 --- a/pjmedia/src/pjmedia/vid_port.c +++ b/pjmedia/src/pjmedia/vid_port.c @@ -580,7 +580,14 @@ static pj_status_t client_port_event_cb(pjmedia_event *event, pjmedia_vid_dev_param vid_param; pj_status_t status; - pjmedia_vid_port_stop(vp); + /* Ticket #1827: + * Stopping video port should not be necessary here because + * it will also try to stop the clock, from inside the clock's + * own thread, so it may get stuck. We just stop the video device + * stream instead. + * pjmedia_vid_port_stop(vp); + */ + pjmedia_vid_dev_stream_stop(vp->strm); /* Retrieve the video format detail */ vfd = pjmedia_format_get_video_format_detail( @@ -635,7 +642,8 @@ static pj_status_t client_port_event_cb(pjmedia_event *event, pjmedia_clock_modify(vp->clock, &clock_param); } - pjmedia_vid_port_start(vp); + /* pjmedia_vid_port_start(vp); */ + pjmedia_vid_dev_stream_start(vp->strm); } /* Republish the event, post the event to the event manager |