[FFmpeg-cvslog] xcbgrab: Unbreak parsing filename options

Luca Barbato git at videolan.org
Wed Feb 25 01:51:39 CET 2015


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sun Feb 22 20:36:09 2015 +0100| [85b3b1c4ba7af9c2658442b0aafd27d613e1854b] | committer: Luca Barbato

xcbgrab: Unbreak parsing filename options

CC: libav-stable at libav.org

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85b3b1c4ba7af9c2658442b0aafd27d613e1854b
---

 libavdevice/xcbgrab.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index a29cd9b..c4db983 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -495,7 +495,6 @@ static int create_stream(AVFormatContext *s)
 {
     XCBGrabContext *c = s->priv_data;
     AVStream *st      = avformat_new_stream(s, NULL);
-    const char *opts  = strchr(s->filename, '+');
     xcb_get_geometry_cookie_t gc;
     xcb_get_geometry_reply_t *geo;
     int ret;
@@ -511,9 +510,6 @@ static int create_stream(AVFormatContext *s)
     if (ret < 0)
         return ret;
 
-    if (opts)
-        sscanf(opts, "%d,%d", &c->x, &c->y);
-
     avpriv_set_pts_info(st, 64, 1, 1000000);
 
     gc  = xcb_get_geometry(c->conn, c->screen->root);
@@ -600,11 +596,23 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s)
     XCBGrabContext *c = s->priv_data;
     int screen_num, ret;
     const xcb_setup_t *setup;
+    char *host        = s->filename[0] ? s->filename : NULL;
+    const char *opts  = strchr(s->filename, '+');
+
+    if (opts) {
+        sscanf(opts, "%d,%d", &c->x, &c->y);
+        host = av_strdup(s->filename);
+        host[opts - s->filename] = '\0';
+    }
+
+    c->conn = xcb_connect(host, &screen_num);
+
+    if (opts)
+        av_free(host);
 
-    c->conn = xcb_connect(s->filename[0] ? s->filename : NULL, &screen_num);
     if ((ret = xcb_connection_has_error(c->conn))) {
         av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
-               s->filename[0] ? s->filename : "default", ret);
+               s->filename[0] ? host : "default", ret);
         return AVERROR(EIO);
     }
     setup = xcb_get_setup(c->conn);



More information about the ffmpeg-cvslog mailing list