Merge "res_pjsip: Add fax_detect_timeout endpoint option."
[asterisk/asterisk.git] / channels / vgrabbers.c
index 470a19f..ce8bb2b 100644 (file)
  *                        `->--[enc_out]
  */
 
+/*** MODULEINFO
+       <support_level>extended</support_level>
+ ***/
+
 #include "asterisk.h"
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+ASTERISK_REGISTER_FILE()
 #include <sys/ioctl.h>
 #include "asterisk/file.h"
 #include "asterisk/utils.h"    /* ast_calloc */
@@ -69,6 +73,8 @@ struct grab_x11_desc {
        struct fbuf_t   b;              /* geometry and pointer into the XImage */
 };
 
+static void *grab_x11_close(void *desc);       /* forward declaration */
+
 /*! \brief open the grabber.
  * We use the special name 'X11' to indicate this grabber.
  */
@@ -127,12 +133,7 @@ static void *grab_x11_open(const char *name, struct fbuf_t *geom, int fps)
        return v;
 
 error:
-       /* XXX maybe XDestroy (v->image) ? */
-       if (v->dpy)
-               XCloseDisplay(v->dpy);
-       v->dpy = NULL;
-       ast_free(v);
-       return NULL;
+       return grab_x11_close(v);
 }
 
 static struct fbuf_t *grab_x11_read(void *desc)
@@ -170,7 +171,8 @@ static void *grab_x11_close(void *desc)
 {
        struct grab_x11_desc *v = desc;
 
-       XCloseDisplay(v->dpy);
+       if (v->dpy)
+               XCloseDisplay(v->dpy);
        v->dpy = NULL;
        v->image = NULL;
        ast_free(v);