From: "Chen, Angus" <angus.c...@intel.com>

sdl2_muxer(wayland):
In ffmpeg6, we create a separate thread for muxer after calling 
avformat_write_header().
It may generate EGL_BAD_ACCESS when we call write_packet. This is because 
egl_context
is bound to previous thread.
>From EGL spec: If ctx is current to some other thread, or if either draw or 
>read are
bound to contexts in another thread, an EGL_BAD_ACCESS error is generated.

Signed-off-by: Chen, Angus <angus.c...@intel.com>
---
 fftools/ffmpeg_mux.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 7a924dba6c..d9eee3bb6d 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -215,12 +215,21 @@ static void *muxer_thread(void *arg)
     OutputFile *of = &mux->of;
     AVPacket  *pkt = NULL;
     int        ret = 0;
+    AVFormatContext *fc = mux->fc;
 
     pkt = av_packet_alloc();
     if (!pkt) {
         ret = AVERROR(ENOMEM);
         goto finish;
     }
+    ret = avformat_write_header(fc, &mux->opts);
+    if (ret < 0) {
+        av_log(mux, AV_LOG_ERROR, "Could not write header (incorrect codec "
+               "parameters ?): %s\n", av_err2str(ret));
+        goto finish;
+    }
+    //assert_avoptions(of->opts);
+    mux->header_written = 1;
 
     thread_set_name(of);
 
@@ -599,15 +608,6 @@ int mux_check_init(Muxer *mux)
             return 0;
     }
 
-    ret = avformat_write_header(fc, &mux->opts);
-    if (ret < 0) {
-        av_log(mux, AV_LOG_ERROR, "Could not write header (incorrect codec "
-               "parameters ?): %s\n", av_err2str(ret));
-        return ret;
-    }
-    //assert_avoptions(of->opts);
-    mux->header_written = 1;
-
     av_dump_format(fc, of->index, fc->url, 1);
     nb_output_dumped++;
 
-- 
2.29.0

_______________________________________________
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".

Reply via email to