Re: [PATCH spice-streaming-agent] gst-plugin: Initialize X connection also when ximagesrc is used

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> In order to get graphic devices info a connection to X server
> is required, make sure we get it also when ximagesrc capture
> is used ( XLIB_CAPTURE=0 ).
> 
> Signed-off-by: Snir Sheriber <ssheribe@xxxxxxxxxx>
> ---
>  src/gst-plugin.cpp | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/src/gst-plugin.cpp b/src/gst-plugin.cpp
> index 3edf9f5..0814ef5 100644
> --- a/src/gst-plugin.cpp
> +++ b/src/gst-plugin.cpp
> @@ -84,9 +84,9 @@ private:
>      GstElement *get_encoder_plugin(const GstreamerEncoderSettings &settings,
>      GstCapsUPtr &sink_caps);
>      GstElement *get_capture_plugin(const GstreamerEncoderSettings
>      &settings);
>      void pipeline_init(const GstreamerEncoderSettings &settings);
> +    Display *dpy;

Maybe you can have "Display *const dpy;" ?

>  #if XLIB_CAPTURE
>      void xlib_capture();
> -    Display *dpy;
>      XImage *image = nullptr;
>  #endif
>      GstObjectUPtr<GstElement> pipeline, capture, sink;
> @@ -251,13 +251,6 @@ void GstreamerFrameCapture::pipeline_init(const
> GstreamerEncoderSettings &settin
>          throw std::runtime_error("Linking gstreamer's elements failed");
>      }
>  
> -#if XLIB_CAPTURE
> -    dpy = XOpenDisplay(nullptr);
> -    if (!dpy) {
> -        throw std::runtime_error("Unable to initialize X11");
> -    }
> -#endif
> -
>      gst_element_set_state(pipeline.get(), GST_STATE_PLAYING);
>  
>  #if !XLIB_CAPTURE
> @@ -292,6 +285,10 @@ void GstreamerFrameCapture::pipeline_init(const
> GstreamerEncoderSettings &settin
>  GstreamerFrameCapture::GstreamerFrameCapture(const GstreamerEncoderSettings
>  &settings):
>      settings(settings)
>  {
> +    dpy = XOpenDisplay(nullptr);
> +    if (!dpy) {
> +        throw std::runtime_error("Unable to initialize X11");
> +    }
>      pipeline_init(settings);
>  }
>  
> @@ -313,9 +310,7 @@ GstreamerFrameCapture::~GstreamerFrameCapture()
>  {
>      free_sample();
>      gst_element_set_state(pipeline.get(), GST_STATE_NULL);
> -#if XLIB_CAPTURE
>      XCloseDisplay(dpy);
> -#endif
>  }
>  
>  void GstreamerFrameCapture::Reset()
> @@ -326,6 +321,9 @@ void GstreamerFrameCapture::Reset()
>  #if XLIB_CAPTURE
>  void GstreamerFrameCapture::xlib_capture()
>  {
> +    if (!dpy) {
> +        throw std::runtime_error("X11 connection is not initialized");
> +    }

Why do you need this? dpy is initialized on the constructor, who should
clear the pointer?

>      int screen = XDefaultScreen(dpy);
>  
>      Window win = RootWindow(dpy, screen);

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]