You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavd/xv: handle delete window message
User may close X11 window by close button on tray. FFmpeg leaves in graceless way. This commit detects it and return EPIPE error. Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
committed by
Michael Niedermayer
parent
e429d6c197
commit
e5c806fd67
@@ -58,6 +58,7 @@ typedef struct {
|
|||||||
int image_width, image_height;
|
int image_width, image_height;
|
||||||
XShmSegmentInfo yuv_shminfo;
|
XShmSegmentInfo yuv_shminfo;
|
||||||
int xv_port;
|
int xv_port;
|
||||||
|
Atom wm_delete_message;
|
||||||
} XVContext;
|
} XVContext;
|
||||||
|
|
||||||
typedef struct XVTagFormatMap
|
typedef struct XVTagFormatMap
|
||||||
@@ -156,6 +157,8 @@ static int xv_write_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
XStoreName(xv->display, xv->window, xv->window_title);
|
XStoreName(xv->display, xv->window, xv->window_title);
|
||||||
|
xv->wm_delete_message = XInternAtom(xv->display, "WM_DELETE_WINDOW", False);
|
||||||
|
XSetWMProtocols(xv->display, xv->window, &xv->wm_delete_message, 1);
|
||||||
XMapWindow(xv->display, xv->window);
|
XMapWindow(xv->display, xv->window);
|
||||||
} else
|
} else
|
||||||
xv->window = xv->window_id;
|
xv->window = xv->window_id;
|
||||||
@@ -297,6 +300,19 @@ static int write_picture(AVFormatContext *s, AVPicture *pict)
|
|||||||
img->data + img->offsets[1],
|
img->data + img->offsets[1],
|
||||||
img->data + img->offsets[2]
|
img->data + img->offsets[2]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Check messages. Window might get closed. */
|
||||||
|
if (!xv->window_id) {
|
||||||
|
XEvent event;
|
||||||
|
while (XPending(xv->display)) {
|
||||||
|
XNextEvent(xv->display, &event);
|
||||||
|
if (event.type == ClientMessage && event.xclient.data.l[0] == xv->wm_delete_message)
|
||||||
|
av_log(xv, AV_LOG_DEBUG, "Window close event.\n");
|
||||||
|
return AVERROR(EPIPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
av_image_copy(data, img->pitches, (const uint8_t **)pict->data, pict->linesize,
|
av_image_copy(data, img->pitches, (const uint8_t **)pict->data, pict->linesize,
|
||||||
xv->image_format, img->width, img->height);
|
xv->image_format, img->width, img->height);
|
||||||
return xv_repaint(s);
|
return xv_repaint(s);
|
||||||
|
Reference in New Issue
Block a user