]> git.sesse.net Git - ffmpeg/commit
avcodec/pthread_frame: Check initializing mutexes/condition variables
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 23 Mar 2021 05:34:11 +0000 (06:34 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 26 Mar 2021 02:04:28 +0000 (03:04 +0100)
commitc85fcc96b79a502b1d2cd022c6f0c638e4527732
treeb2a30ed5e6930327a399027a8ce15050ce214574
parente9b66175793e5c2af19beefe8e143f6e4901b5df
avcodec/pthread_frame: Check initializing mutexes/condition variables

Up until now, initializing the mutexes/condition variables wasn't
checked by ff_frame_thread_init(). This commit changes this.

Given that it is not documented to be save to destroy a zeroed but
otherwise uninitialized mutex/condition variable, one has to choose
between two approaches: Either one duplicates the code to free them
in ff_frame_thread_init() in case of errors or one records which have
been successfully initialized. This commit takes the latter approach:
For each of the two structures with mutexes/condition variables
an array containing the offsets of the members to initialize is added.
Said array is used both for initializing and freeing and the only thing
that needs to be recorded is how many of these have been successfully
initialized.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/pthread_frame.c