Gesendet: Montag, 05. September 2022 um 12:45 Uhr Von: "Andreas Rheinhardt" <andreas.rheinha...@outlook.com> An: ffmpeg-devel@ffmpeg.org Betreff: Re: [FFmpeg-devel] [PATCH v3 2/3] lavf/dashdec: Multithreaded DASH initialization Lukas Fellechner: >>> Moreover, older pthread standards did not allow to use >>> PTHREAD_MUTEX_INITIALIZER with non-static mutexes, so I don't know >>> whether we can use that. Also our pthreads-wrapper on top of >>> OS/2-threads does not provide PTHREAD_COND_INITIALIZER (which is used >>> nowhere in the codebase). >> >> I missed that detail about the initializer macro. Thank you for clearing >> that up. >> >> After looking more into threads implementation in ffmpeg, I wonder if I >> really need to check any results of init/destroy or other functions. >> In slicethreads.c, there is zero checking on any of the lock functions. >> The pthreads-based implementation does internally check the results of all >> function calls and calls abort() in case of errors ("strict_" wrappers). >> The Win32 implementation uses SRW locks which cannot even return errors. >> And the OS2 implementation returns 0 on all calls as well. >> >> So right now, I think that I should continue with normal _init() calls >> (no macros) and drop all error checking, just like slicethread does. >> Are you fine with that approach? > > Zero checking is our old approach; the new approach checks for errors > and ensures that only mutexes/condition variables that have been > properly initialized are destroyed. See ff_pthread_init/free in > libavcodec/pthread.c (you can't use this in libavformat, because these > functions are local to libavcodec). > > - Andreas
I was able to switch to using the slicethread implementation. It has a very minor delay on init, because it waits for all threads to fully start up before continueing. But it is only few ms and not worth adding a new implementation just for that. I also changed the initialization and release of mutex and conds, with full return code checking and safe release. There was one cross-thread issue I needed to address. A multi hour duration test (connecting in endless loop) did not show any issues after fixing the avio_opts cross thread access. Please see the v4 patch for all the changes. - Lukas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".