[Spice-devel] [PATCH] streaming: Tweak the GStreamer decoder to avoid a compiler warning

Pavel Grunt pgrunt at redhat.com
Wed Jun 1 06:41:36 UTC 2016


On Mon, 2016-05-30 at 21:37 +0200, Francois Gouget wrote:
> We check that there is a matching frame in the queue before popping the
> old ones. So we know the inner loop will find a match and thus that
> frame will not be NULL. But figuring that out is too hard for the
> compiler.
> 
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
> ---
> 
> Adding an if (frame) check suggests that frame can indeed be NULL which 
> is not the case (verifying that we will find a match is the point of the 
> outer loop). So if this patch gets the compiler off our back it may be a 
> better solution.
> 
>  src/channel-display-gst.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
> index 46a85ea..87741d9 100644
> --- a/src/channel-display-gst.c
> +++ b/src/channel-display-gst.c
> @@ -174,7 +174,11 @@ static GstFlowReturn new_sample(GstAppSink *gstappsink,
> gpointer video_decoder)
>          while (l) {
>              frame = l->data;
>              if (frame->timestamp == GST_BUFFER_PTS(buffer)) {
> -                /* Now that we know there is a match, remove the older
> +                /* The frame is now ready for display */
> +                frame->sample = sample;
> +                g_queue_push_tail(decoder->display_queue, frame);
> +
> +                /* Now that we know there is a match, remove it and the older
>                   * frames from the decoding queue.
>                   */
>                  while ((frame = g_queue_pop_head(decoder->decoding_queue))) {
> @@ -187,10 +191,6 @@ static GstFlowReturn new_sample(GstAppSink *gstappsink,
> gpointer video_decoder)
>                      SPICE_DEBUG("the GStreamer pipeline dropped a frame");
>                      free_frame(frame);
>                  }
> -
> -                /* The frame is now ready for display */
> -                frame->sample = sample;
> -                g_queue_push_tail(decoder->display_queue, frame);
>                  break;
>              }
>              l = l->next;


More information about the Spice-devel mailing list