baresip: re_unlock error when using sndfile module to record call
A user of my Android app noticed that the app hangs when call is recorded. The app uses sndfile module for call recording. The call starts fine, but then produces re_unlock error on the same debug line where sndfile module tells that it is dumping encode audio to file:
2024-09-01 08:44:51.031 25797-25850 Baresip Lib com.tutpro.baresip D started
stream: Enable RTP timeout (60000 milliseconds)
test@test.tutpro.com: Call established: sip:thetestcall@opensips.org
2024-09-01 08:44:51.041 25797-25850 Baresip Lib com.tutpro.baresip D rtp_receiver: RTP RX thread started
2024-09-01 08:44:51.141 25797-25972 Baresip Lib com.tutpro.baresip D ua event (MODULE) sndfile,dump,/data/user/0/com.tutpro.baresip/files/recordings/dump-sip:test@test.tutpro.com=>sip:thetestcall@opensips.org-2024-09-01-08-44-51-enc.wav
2024-09-01 08:44:51.143 25797-25850 Baresip Lib com.tutpro.baresip D sndfile: dumping encode audio to /data/user/0/com.tutpro.baresip/files/recordings/dump-sip:test@test.tutpro.com=>sip:thetestcall@opensips.org-2024-09-01-08-44-51-enc.wav
[31mmain: re_unlock error
[;m
2024-09-01 08:44:51.245 25797-25850 Baresip Lib com.tutpro.baresip D stream: incoming rtp for 'audio' established, receiving from 192.98.100.38:60336
...
After this the app stops responding and Android kills it.
If call is not recorded, the is no errors and everything works fine. Calls with recording used to work OK, but I don’t know when the error started to occur. The user reports that call recording was broken already at least on August 1 whatever were then the master versions baresip and re.
Any hints on how to find out where and why the re_unlock error happens? My app does not make any re_unlock calls, but does make re_thread_enter and re_thread_leave calls.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 33 (3 by maintainers)
In general it is good if all events come from the main thread. This simplifies the application and creates less threading headaches.
In the past I have used
mqueueto switch execution from media thread to main thread.@cspiel1 I think
module_eventinsndfileshould be called within main thread, since the event handlers are not thread safe, right?. Maybe withre_thread_async_main_idcallback or something similar.I tried also with
and still got the same
main: re_unlock error 2error.Ps.
rtp_rxmodeis not documented in Wiki.There is no crash and thus no backtrace. baresip app becomes unresponsive and Android kills it.
This is in config:
If you are able to run the same setup on Linux, you can try to use Helgrind to detect thread errors:
https://valgrind.org/docs/manual/hg-manual.html
OK, the commit after which the issue appeared is this https://github.com/baresip/baresip/commit/bb70d556bc5730c8d9b464cdef33e5613c618818. Call recording using the app worked fine when I built baresip lib using the previous version of sndfile.c.
@cspiel1 Could you take a look what in the commit could have caused the re_unlock error? I didn’t find any re_unlock calls in the commit.