Hi David Thanks for the suggestions. I was doing the playing/recording/conference add/remove port inside the on_call_state callback event. After some research, I think the issue I mentioned has got to do with this [pjsip] Infinite loop in jbuf causing deadlock, http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2009-March/006761.htm l There was a bug in jbuf.c (v1.1) which resulted in an infinite loop. The PJSIP release log shows that the issue has been fixed in PJSIP 1.2. So I upgraded to 1.2 (I was using 1.1), did not change my code at all, and the issue doesn't seem to appear anymore. Nevertheless, you have a valid point that a deadlock may happen when calling pjsua_ calls from a PJSIP callback event. Previously I observed deadlocks when calling pjsua_call_makecall and pjsua_call_hangup, which could only be resolved by calling these APIs from a separate thread but I did not know it had to do with the callback event. As an experiment, I run PJSIP 1.1 with code modified to do the pjsua_ calls from a separate thread (and not in the PJSIP callback function) and the issue also does not appear again. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090617/2cf7e0a4/attachment.html>