In my code, I added a mutex for avformat_open_input and that seemed to make things work fine.
On Nov 8, 2011, at 2:10 PM, Evgeny Yakimov wrote: > Hello > > I've been getting a lot of issues when attempting to open/close input > files/streams in a multi threaded application, mostly resulting in memory > problems and segfaults. > I've found a small reference to thread-safety in the post here: > http://lists.libav.org/pipermail/libav-api/2011-June/000126.html but I'm > using a lot more calls than the ones referenced here. > > > My application has one input thread opened with avformat_open_input followed > by multiple output threads which use avio_open to send the stream over rtmp, > I've noticed that if all my output threads try to open the output stream at > the same time that I experience the problems, where as if I do this > sequentially, one after the other, they work fine. > > Are these functions thread-safe? if not which functions should I mutex/lock ? > > > My application currently runs in this order, > > Input (Thread 1) > > avformat_open_input > avformat_find_stream_info > av_find_best_stream > avcodec_open2 > > while(av_read_frame){ > avcodec_decode_audio3 > avcodec_decode_video2 > av_free_packet > } > > > /* Some encoder threads in the middle */ > > > Output (Thread 2,3....) > av_guess_format > avformat_alloc_context > av_new_stream > avio_open > avformat_write_header > while (/*packets to send */){ > av_write_frame > } > > > (I'm working under the assumption that ANY of the calls mentioned above can > occur at the same time.) > > Can you please advise which of these calls need to be protected with mutex > locks? > > Regard > Evgeny > _______________________________________________ > libav-api mailing list > [email protected] > https://lists.libav.org/mailman/listinfo/libav-api
_______________________________________________ libav-api mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-api
