[Spice-devel,client,v3,4/4] streaming: Create the pipeline at the same time as the GStreamer decoder

Submitted by Francois Gouget on Aug. 11, 2016, 10:22 a.m.

Details

Message ID df332b8a54bdc75a0c9fc95a6df7313fdf2de1ba.1470910527.git.fgouget@free.fr
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Francois Gouget Aug. 11, 2016, 10:22 a.m.
This lets create_gstreamer_decoder() fail if it cannot create the
pipeline it needs, allowing the caller to try fallbacks.
This also means the pipeline has the same lifetime as the decoder which
makes it possible to remove a check in queue_frame().

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---
 src/channel-display-gst.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index c752639..647afc1 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -407,11 +407,6 @@  static void spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
         return;
     }
 
-    if (!decoder->pipeline && !create_pipeline(decoder)) {
-        stream_dropped_frame_on_playback(decoder->base.stream);
-        return;
-    }
-
     /* ref() the frame_msg for the buffer */
     spice_msg_in_ref(frame_msg);
     GstBuffer *buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS,
@@ -463,6 +458,12 @@  VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)
         g_mutex_init(&decoder->queues_mutex);
         decoder->decoding_queue = g_queue_new();
         decoder->display_queue = g_queue_new();
+
+        if (!create_pipeline(decoder))
+        {
+            decoder->base.destroy((VideoDecoder*)decoder);
+            decoder = NULL;
+        }
     }
 
     return (VideoDecoder*)decoder;
@@ -475,7 +476,7 @@  gboolean gstvideo_has_codec(int codec_type)
 
     VideoDecoder *decoder = create_gstreamer_decoder(codec_type, NULL);
     if (decoder) {
-        has_codec = create_pipeline((SpiceGstDecoder*)decoder);
+        has_codec = TRUE;
         decoder->destroy(decoder);
     }
 

Comments

Hi,

On Thu, Aug 11, 2016 at 12:22:24PM +0200, Francois Gouget wrote:
> This lets create_gstreamer_decoder() fail if it cannot create the
> pipeline it needs, allowing the caller to try fallbacks.
> This also means the pipeline has the same lifetime as the decoder which
> makes it possible to remove a check in queue_frame().

Great,

>
> Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
> ---
>  src/channel-display-gst.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
> index c752639..647afc1 100644
> --- a/src/channel-display-gst.c
> +++ b/src/channel-display-gst.c
> @@ -407,11 +407,6 @@ static void spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
>          return;
>      }
>  
> -    if (!decoder->pipeline && !create_pipeline(decoder)) {
> -        stream_dropped_frame_on_playback(decoder->base.stream);
> -        return;
> -    }
> -
>      /* ref() the frame_msg for the buffer */
>      spice_msg_in_ref(frame_msg);
>      GstBuffer *buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS,
> @@ -463,6 +458,12 @@ VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)
>          g_mutex_init(&decoder->queues_mutex);
>          decoder->decoding_queue = g_queue_new();
>          decoder->display_queue = g_queue_new();
> +
> +        if (!create_pipeline(decoder))
> +        {

Opening brace should be in the line above

> +            decoder->base.destroy((VideoDecoder*)decoder);
> +            decoder = NULL;
> +        }

I'll do the change and push the series. Many thanks!

Acked-by: Victor Toso <victortoso@redhat.com>

>      }
>  
>      return (VideoDecoder*)decoder;
> @@ -475,7 +476,7 @@ gboolean gstvideo_has_codec(int codec_type)
>  
>      VideoDecoder *decoder = create_gstreamer_decoder(codec_type, NULL);
>      if (decoder) {
> -        has_codec = create_pipeline((SpiceGstDecoder*)decoder);
> +        has_codec = TRUE;
>          decoder->destroy(decoder);
>      }
>  
> -- 
> 2.8.1
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel