Calling pjlib from unknown/external thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also, another problem is that the pj_thread_desc is currently allocated 
on the stack (it's an automatic variable), you should allocate it from 
the C runtime heap using malloc, or from a pj memory pool. Here is an 
alternative method to use, originally provided by Jim Gomes on pjsip 
forum. It leaks some memory every time it registers a thread.

PJ_DEF(pj_status_t) pj_thread_auto_register(void)
{
     pj_status_t rc;

     if(!pj_thread_is_registered())
     {
         pj_thread_desc *p_thread_desc;
         pj_thread_t* thread_ptr;
         p_thread_desc = (pj_thread_desc *) calloc(1, 
sizeof(pj_thread_desc));
         rc = pj_thread_register("auto_thr%p", *p_thread_desc, &thread_ptr);
     }
     else
     {
         rc = PJ_SUCCESS;
     }
     return rc;
}


On 6/13/2014 6:57 AM, Joel Centelles wrote:
> Hi Jason,
>
> your builder is complaining because your pj_boo_t variable 
> thread_registered has not been defined.
>
> On the other hand, seems that your platform doesn't has a proper 
> declaration of pj_thread_t (it is forward declared in types.h).
>
> Hope this helps,
> Joel.
>
>
> 2014-06-13 11:00 GMT+02:00 Jason Chen ??? <Jason.Chen at tpv-tech.com 
> <mailto:Jason.Chen at tpv-tech.com>>:
>
>     Dear all
>
>        I want to call  "pjmedia_transport_send_rtp()",  and I get the
>     error message:
>
>     06-13 08:34:13.949: A/libc(3106): ../src/pj/os_core_unix.c:674:
>     pj_thread_this: assertion "!"Calling pjlib from unknown/external
>     thread. You must " "register external threads with
>     pj_thread_register() " "before calling any pjlib functions."" failed
>
>     06-13 08:34:13.949: A/libc(3106): Fatal signal 11 (SIGSEGV) at
>     0xdeadbaad (code=1), thread 3159 (Thread-329)
>
>     Then I change my code:
>
>     void my_send_rtp(){
>
>     if(!thread_registered && !pj_thread_is_registered())
>
>         {
>
>     pj_thread_desc desc;
>
>     pj_bzero(desc, sizeof(desc));
>
>     pj_thread_t t;
>
>     if (pj_thread_register(NULL,desc,&t) == PJ_SUCCESS)
>
>     {
>
>     thread_registered = PJ_TRUE;
>
>     }
>
>         }
>
>         if (!my_call_med->call || !my_call_med->call->inv ||
>     !my_call_med->tp) {
>
>              return;
>
>         }
>
>     pjmedia_transport_send_rtp(my_call_med->tp, "pkt", strlen("pkt"));
>
>     }
>
>     I get another error:
>
>     ../src/pjsua-lib/pjsua_aud.c:639:9: error: 'thread_registered'
>     undeclared (first use in this function)
>
>     if(!thread_registered && !pj_thread_is_registered())
>
>     ^
>
>     ../src/pjsua-lib/pjsua_aud.c:639:9: note: each undeclared
>     identifier is reported only once for each function it appears in
>
>     ../src/pjsua-lib/pjsua_aud.c:643:15: error: storage size of 't'
>     isn't known
>
>        pj_thread_t t;
>
>     how can I do if I want to call pjmedia_transport_send_rtp()?
>
>     *Best Regards, *
>
>     *jason.chen*
>
>
>     _______________________________________________
>     Visit our blog: http://blog.pjsip.org
>
>     pjsip mailing list
>     pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>
>     http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>
>
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20140613/494babb9/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux