<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi,<br><br>I tried to call av_register_all() multiple times, and it works well<br>for old lib version, but now it will cause the following call to<br>avformat_open_input() stuck forever.<br><br>After examining the code for libavformat, I found that there was<br>a code change about Mar, 2017 that changed av_register_all()<br>to use pthread_once(), and it seems that the guarding variable<br>for once-control failed to protect register_all() to be called<br>multiple times. Refer to the following code:<br><br>void av_register_all(void)<br>{<br>    AVOnce control = AV_ONCE_INIT;<br><br>    ff_thread_once(&control, register_all);<br>}<br><br>Should it be a static or a global variable here?<br><br>The reason it will cause avformat_open_input() to be stuck<br>forever is that each time register_all() is called, <br>ff_register_rtp_dynamic_payload_handlers() will also be called.<br>It will cause the linked list rtp_first_dynamic_payload_handler<br>to become a loop. When we call avformat_open_input() it will<br>try to find the rtp handler in this linked list, and if unfortunately<br>there is no matched handler in the list, it will loop forever.<br><br><br>Thanks!<br>Yuan Yi<br></div></div><br><br><span title="neteasefooter"><p> </p></span>