From f44e2a2eafe54a78eb7c1186fd8285be523525d6 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Sun, 8 Apr 2018 17:13:42 +0200
Subject: [PATCH 3/3] avdevice/sdl2 : add option to define if the window quit
 action is available

---
 libavdevice/sdl2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavdevice/sdl2.c b/libavdevice/sdl2.c
index c0996311a3..74ed7d6661 100644
--- a/libavdevice/sdl2.c
+++ b/libavdevice/sdl2.c
@@ -44,6 +44,7 @@ typedef struct {
     int window_borderless;
     int window_pos_x;
     int window_pos_y;
+    int enable_quit_action;
 
     SDL_Texture *texture;
     int texture_fmt;
@@ -283,7 +284,7 @@ static int sdl2_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
-    if (quit) {
+    if (quit && sdl->enable_quit_action) {
         sdl2_write_trailer(s);
         return AVERROR(EIO);
     }
@@ -346,6 +347,7 @@ static const AVOption options[] = {
     { "window_borderless", "set SDL window border off",  OFFSET(window_borderless), AV_OPT_TYPE_BOOL,  { .i64 = 0 },    0, 1, AV_OPT_FLAG_ENCODING_PARAM },
     { "window_pos_x", "set top left window position",  OFFSET(window_pos_x), AV_OPT_TYPE_INT, {.i64=INT_MAX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
     { "window_pos_y", "set top left window position", OFFSET(window_pos_y), AV_OPT_TYPE_INT, {.i64=INT_MAX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+    { "window_enable_quit", "set if quit action is available", OFFSET(enable_quit_action), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
     { NULL },
 };
 
-- 
2.14.3 (Apple Git-98)

