From 99f95690b5facbe9c823df1e20438be3936813c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 21 Apr 2015 10:00:36 +0200 Subject: [PATCH] vaapidecode: refactor gst_vaapidecode_internal_flush() This a cosmetic refactor: gst_vaapidecode_internal_flush() removes its only label; gst_vaapidecode_finish() is more readable and gst_vaapidecode_purge() shares the same error message of gst_vaapidecode_internal_flush() when flush fails. --- gst/vaapi/gstvaapidecode.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 002e0ad7ce..4a9653420e 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -471,32 +471,29 @@ gst_vaapidecode_internal_flush (GstVideoDecoder * vdec) } status = gst_vaapi_decoder_flush (decode->decoder); - if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) - goto error_flush; - return TRUE; - - /* ERRORS */ -error_flush: - { - GST_ERROR ("failed to flush decoder (status %d)", status); + if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) { + GST_WARNING_OBJECT (decode, "failed to flush decoder (status %d)", status); return FALSE; } + + return TRUE; } static GstFlowReturn gst_vaapidecode_finish (GstVideoDecoder * vdec) { GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); + gboolean flushed; + GstFlowReturn ret; if (!decode->decoder) return GST_FLOW_OK; - if (!gst_vaapidecode_internal_flush (vdec)) { - gst_vaapidecode_push_all_decoded_frames (decode); + flushed = gst_vaapidecode_internal_flush (vdec); + ret = gst_vaapidecode_push_all_decoded_frames (decode); + if (!flushed) return GST_FLOW_ERROR; - } - - return gst_vaapidecode_push_all_decoded_frames (decode); + return ret; } static gboolean @@ -640,7 +637,7 @@ gst_vaapidecode_purge (GstVaapiDecode * decode) status = gst_vaapi_decoder_flush (decode->decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) - GST_INFO_OBJECT (decode, "decoder flush failed"); + GST_INFO_OBJECT (decode, "failed to flush decoder (status %d)", status); /* Purge all decoded frames as we don't need them (e.g. flush and close) * Releasing the frames is important, otherwise the frames are not