From: Jeongmo Yang Date: Thu, 24 Apr 2025 11:46:50 +0000 (+0900) Subject: Fix duplicated buffer issue for output buffer X-Git-Tag: accepted/tizen/unified/20250530.090452^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F323243%2F1;p=platform%2Fhal%2Fapi%2Fcodec.git Fix duplicated buffer issue for output buffer - Previously, the mutex for output buffer was locked after return rpc_port_proxy_codec_invoke_release_output_buffer(). The problem is that output_buffer[] array could be accessed in message_cb() before remove released buffer in output_buffer[] array and it caused duplicated output buffer error although it's released actually. [Version] 1.5.1 [Issue Type] Bug fix Change-Id: I31ac0afba1ae5323ab19c52cf3a41862ec54543f Signed-off-by: Jeongmo Yang --- diff --git a/packaging/hal-api-codec.spec b/packaging/hal-api-codec.spec index b009576..a243583 100644 --- a/packaging/hal-api-codec.spec +++ b/packaging/hal-api-codec.spec @@ -6,7 +6,7 @@ ### main package ######### Name: %{name} Summary: %{name} interface -Version: 1.5.0 +Version: 1.5.1 Release: 0 Group: Development/Libraries License: Apache-2.0 diff --git a/src/hal-api-codec-ipc.c b/src/hal-api-codec-ipc.c index eac6626..33b11d0 100644 --- a/src/hal-api-codec-ipc.c +++ b/src/hal-api-codec-ipc.c @@ -1307,26 +1307,19 @@ int hal_codec_ipc_release_output_buffer(void *codec_handle, int buffer_index) hal_codec_buffer_s *hal_buffer = NULL; hal_codec_ipc_buffer_s *ipc_buffer = NULL; - g_autoptr(GMutexLocker) locker = NULL; - HAL_CODEC_RETURN_VAL_IF_FAILED(handle, HAL_CODEC_ERROR_INVALID_PARAMETER); HAL_CODEC_RETURN_VAL_IF_FAILED(handle->rpc_handle, HAL_CODEC_ERROR_INVALID_PARAMETER); ipc_buffer = &handle->ipc_buffer; - ret = rpc_port_proxy_codec_invoke_release_output_buffer(handle->rpc_handle, buffer_index); - if (ret != HAL_CODEC_ERROR_NONE) { - SLOGE("invoke release output buffer failed[0x%x]", ret); - return ret; - } - - locker = g_mutex_locker_new(&ipc_buffer->lock); + g_mutex_lock(&ipc_buffer->lock); hal_buffer = ipc_buffer->output_buffers[buffer_index]; ipc_buffer->output_buffers[buffer_index] = NULL; if (!hal_buffer) { SLOGW("NULL buffer for index[%d]", buffer_index); + g_mutex_unlock(&ipc_buffer->lock); return HAL_CODEC_ERROR_NONE; } @@ -1336,12 +1329,18 @@ int hal_codec_ipc_release_output_buffer(void *codec_handle, int buffer_index) ipc_buffer->output_buffer_count--; + g_mutex_unlock(&ipc_buffer->lock); + if (handle->type == HAL_CODEC_TYPE_DECODER) __hal_codec_ipc_hal_buffer_release_decoder_output(hal_buffer); else __hal_codec_ipc_hal_buffer_release_encoder_output(hal_buffer); - return HAL_CODEC_ERROR_NONE; + ret = rpc_port_proxy_codec_invoke_release_output_buffer(handle->rpc_handle, buffer_index); + if (ret != HAL_CODEC_ERROR_NONE) + SLOGE("invoke release output buffer failed[0x%x]", ret); + + return ret; }