---
Although there should be no problem, feel a bit uncomfortable about it.
It's part of the per-worker-thread state, and hwaccel_serializing even
has an assert (which the async field could have too), so I'm wondering
if this change doesn't remove the potential for error checking.
---
 libavcodec/pthread_frame.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 9ca7a766df..5fe7d40d42 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -102,7 +102,6 @@ typedef struct PerThreadContext {
     int die;                       ///< Set when the thread should exit.
 
     int hwaccel_serializing;
-    int async_serializing;
 } PerThreadContext;
 
 /**
@@ -140,10 +139,10 @@ static void async_lock(FrameThreadContext *fctx)
     pthread_mutex_unlock(&fctx->async_mutex);
 }
 
+// This function is idempotent, and it's allowed to unlock while not locked.
 static void async_unlock(FrameThreadContext *fctx)
 {
     pthread_mutex_lock(&fctx->async_mutex);
-    av_assert0(fctx->async_lock);
     fctx->async_lock = 0;
     pthread_cond_broadcast(&fctx->async_cond);
     pthread_mutex_unlock(&fctx->async_mutex);
@@ -214,11 +213,7 @@ static attribute_align_arg void *frame_worker_thread(void 
*arg)
             pthread_mutex_unlock(&p->parent->hwaccel_mutex);
         }
 
-        if (p->async_serializing) {
-            p->async_serializing = 0;
-
-            async_unlock(p->parent);
-        }
+        async_unlock(p->parent);
 
         atomic_store(&p->state, STATE_INPUT_READY);
 
@@ -578,11 +573,8 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
 
     /* this assumes that no hwaccel calls happen before 
ff_thread_finish_setup() */
     if (avctx->hwaccel &&
-        !(avctx->hwaccel->caps_internal & HWACCEL_CAP_ASYNC_SAFE)) {
-        p->async_serializing = 1;
-
+        !(avctx->hwaccel->caps_internal & HWACCEL_CAP_ASYNC_SAFE))
         async_lock(p->parent);
-    }
 
     pthread_mutex_lock(&p->progress_mutex);
 
-- 
2.11.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to