Does my code is Thread safe ?

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

 



Hi,


I fail to get a functionnal code for play Media and get sound from the sound card in the same time.


- Sometimes RTP are not send after some actions

- Sometimes only sound from sound card are not send

- Sometimes only player sound is not send


The error occurs after a random time.


Can somebody check my code to see if I do a error.



First the logic I use :

- Each player created is add to a list for cleaning them when call is closed.

- I use application mutex (pthread_mutex) to protect access to list


A typical mutex call :


pjsua_call *call;

pjsip_dialog *dlg;


do
{
syslog(LOG_DEBUG, "Trying to get pj lock...");
status = acquire_call("PlaySoundDuring call.", callId, &call, &dlg);
}
while(status != PJ_SUCCESS);
pthread_mutex_lock(&lockMedia);


         // Code

?// Close
pthread_mutex_unlock(&lockMedia);
  pjsip_dlg_dec_lock(dlg);


When I use a callback I do

// Open
PJSUA_LOCK();
pthread_mutex_lock(&lockMedia);

// Code

// Close

pthread_mutex_unlock(&lockMedia);

PJSUA_UNLOCK();



I have follow recommandation :

https://trac.pjsip.org/repos/wiki/PJSUA_Locks?


Regards

Swissdotnet SA
Marc Romanens                                E-mail : marc.romanens at swissdotnet.ch<mailto:steve.jacot-guillarmod at swissdotnet.ch>
Route St-Nicolas-de-Fl?e 2           Phone :  +41 26 510 29 33 (direct)
1700 Fribourg                    Phone :  +41 26 510 29 30
Switzerland                      Fax :    +41 26 510 29 34
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150303/e81a0992/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