From: Seungha Yang Date: Tue, 16 Jun 2020 10:26:13 +0000 (+0900) Subject: d3d11: Don't assume response of context query has valid d3d11 device context X-Git-Tag: 1.19.3~507^2~1753 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f899728dd45bbf154123bca3c1c8c9e2b6af5c24;p=platform%2Fupstream%2Fgstreamer.git d3d11: Don't assume response of context query has valid d3d11 device context Peer elements should return FALSE if d3d11 device context is unavailable but it might happen for some reason (e.g., wrong implementation or so) Part-of: --- diff --git a/sys/d3d11/gstd3d11utils.c b/sys/d3d11/gstd3d11utils.c index 7d33048..d306403 100644 --- a/sys/d3d11/gstd3d11utils.c +++ b/sys/d3d11/gstd3d11utils.c @@ -210,7 +210,7 @@ static void run_d3d11_context_query (GstElement * element, GstD3D11Device ** device) { GstQuery *query; - GstContext *ctxt; + GstContext *ctxt = NULL; /* 1) Query downstream with GST_QUERY_CONTEXT for the context and * check if downstream already has a context of the specific type @@ -218,18 +218,22 @@ run_d3d11_context_query (GstElement * element, GstD3D11Device ** device) query = gst_query_new_context (GST_D3D11_DEVICE_HANDLE_CONTEXT_TYPE); if (run_query (element, query, GST_PAD_SRC)) { gst_query_parse_context (query, &ctxt); - GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, - "found context (%" GST_PTR_FORMAT ") in downstream query", ctxt); - gst_element_set_context (element, ctxt); + if (ctxt) { + GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, + "found context (%" GST_PTR_FORMAT ") in downstream query", ctxt); + gst_element_set_context (element, ctxt); + } } /* 2) although we found d3d11 device context above, the element does not want * to use the context. Then try to find from the other direction */ if (*device == NULL && run_query (element, query, GST_PAD_SINK)) { gst_query_parse_context (query, &ctxt); - GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, - "found context (%" GST_PTR_FORMAT ") in upstream query", ctxt); - gst_element_set_context (element, ctxt); + if (ctxt) { + GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, + "found context (%" GST_PTR_FORMAT ") in upstream query", ctxt); + gst_element_set_context (element, ctxt); + } } if (*device == NULL) {