[Libav-user] calling av_register_all() twice makes libav stuck.
易源
vania_yyyy at 126.com
Mon May 22 11:50:56 EEST 2017
Hi,
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:
void av_register_all(void)
{
AVOnce control = AV_ONCE_INIT;
ff_thread_once(&control, register_all);
}
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.
Thanks!
Yuan Yi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170522/d1d9da53/attachment.html>
More information about the Libav-user
mailing list