[Libav-user] calling av_register_all() twice makes libav stuck.
vania_yyyy at 126.com
Mon May 22 11:50:56 EEST 2017
I tried to call av_register_all() multiple times, and it works well
for old lib version, but now it will cause the following call to
avformat_open_input() stuck forever.
After examining the code for libavformat, I found that there was
a code change about Mar, 2017 that changed av_register_all()
to use pthread_once(), and it seems that the guarding variable
for once-control failed to protect register_all() to be called
multiple times. Refer to the following code:
AVOnce control = AV_ONCE_INIT;
Should it be a static or a global variable here?
The reason it will cause avformat_open_input() to be stuck
forever is that each time register_all() is called,
ff_register_rtp_dynamic_payload_handlers() will also be called.
It will cause the linked list rtp_first_dynamic_payload_handler
to become a loop. When we call avformat_open_input() it will
try to find the rtp handler in this linked list, and if unfortunately
there is no matched handler in the list, it will loop forever.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user