From a242b93f334e1a5a262289eb8f2febf0a277b5c3 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 9 Jan 2024 22:40:55 +0900 Subject: [PATCH] d3d12decoder: Release decoder and heap on stop Sometimes driver crash happens if ID3D12VideoDevice got closed first, and then ID3D12VideoDecoderHeap/ID3D12VideoDecoder are released. Part-of: --- .../sys/d3d12/gstd3d12decoder.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp index c1fcad19af..c3ae03eb03 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp @@ -216,9 +216,6 @@ struct DecoderCmdData ~DecoderCmdData () { - if (queue) - gst_d3d12_command_queue_fence_wait (queue, G_MAXUINT64, event_handle); - CloseHandle (event_handle); gst_clear_object (&ca_pool); gst_clear_object (&queue); @@ -503,6 +500,14 @@ gst_d3d12_decoder_close (GstD3D12Decoder * decoder) { auto priv = decoder->priv; + GST_DEBUG_OBJECT (decoder, "Close"); + + if (priv->cmd) { + gst_d3d12_command_queue_fence_wait (priv->cmd->queue, priv->cmd->fence_val, + priv->cmd->event_handle); + } + + priv->session = nullptr; priv->cmd = nullptr; gst_clear_object (&decoder->device); @@ -775,6 +780,8 @@ gst_d3d12_decoder_stop (GstD3D12Decoder * decoder) { auto priv = decoder->priv; + GST_DEBUG_OBJECT (decoder, "Stop"); + priv->flushing = true; if (priv->cmd) { gst_d3d12_command_queue_fence_wait (priv->cmd->queue, priv->cmd->fence_val, @@ -791,6 +798,8 @@ gst_d3d12_decoder_stop (GstD3D12Decoder * decoder) g_clear_pointer (&priv->output_thread, g_thread_join); priv->flushing = false; + priv->session = nullptr; + return TRUE; } @@ -1565,7 +1574,8 @@ gst_d3d12_decoder_output_loop (GstD3D12Decoder * self) output_data.decoder, output_data.frame, output_data.picture, output_data.buffer_flags, output_data.width, output_data.height); - if (priv->last_flow != GST_FLOW_OK) { + if (priv->last_flow != GST_FLOW_FLUSHING && + priv->last_flow != GST_FLOW_OK) { GST_WARNING_OBJECT (self, "Last flow was %s", gst_flow_get_name (priv->last_flow)); }