From d9c26d3d084e60d9bd6796b353c1ea71a74fc8e8 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Tue, 21 Mar 2023 11:05:26 +0900 Subject: [PATCH] media_editor : Fix crash issue - initialized variable was not set to FALSE correctly [Version] 0.0.18-1 [Issue Type] Bug fix Change-Id: Ia3ac5222c66e16eb1692f0526b5e5d2334c21b8d --- packaging/capi-media-editor.spec | 2 +- src/media_editor.c | 16 +++++++++++++--- src/media_editor_private.c | 14 +++----------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packaging/capi-media-editor.spec b/packaging/capi-media-editor.spec index 573c3e0..02af3fe 100644 --- a/packaging/capi-media-editor.spec +++ b/packaging/capi-media-editor.spec @@ -1,7 +1,7 @@ Name: capi-media-editor Summary: A Tizen Media Editor API Version: 0.0.18 -Release: 0 +Release: 1 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/media_editor.c b/src/media_editor.c index 7324cb1..10d21d7 100644 --- a/src/media_editor.c +++ b/src/media_editor.c @@ -23,6 +23,8 @@ #define _MEDIAEDITOR_FEATURE_DISPLAY "http://tizen.org/feature/display" +static gint gst_initialized = 0; + int mediaeditor_create(mediaeditor_h *editor) { int ret = MEDIAEDITOR_ERROR_NONE; @@ -49,8 +51,14 @@ int mediaeditor_create(mediaeditor_h *editor) #endif } - if ((ret = _gst_init(_editor)) != MEDIAEDITOR_ERROR_NONE) - goto error; + if (!g_atomic_int_get(&gst_initialized)) { + if ((ret = _gst_init(_editor)) != MEDIAEDITOR_ERROR_NONE) + goto error; + + g_atomic_int_set(&gst_initialized, 1); + } else { + LOG_INFO("gstreamer is already initialized."); + } if ((ret = _mediaeditor_create_pipeline(_editor)) != MEDIAEDITOR_ERROR_NONE) goto error; @@ -104,6 +112,8 @@ int mediaeditor_destroy(mediaeditor_h editor) ges_deinit(); + g_atomic_int_set(&gst_initialized, 0); + g_cond_clear(&_editor->cond); g_mutex_clear(&_editor->event_src_mutex); @@ -613,7 +623,7 @@ int mediaeditor_get_clip_volume(mediaeditor_h editor, unsigned int clip_id, doub ret = _mediaeditor_get_clip_volume(_editor, clip_id, volume); - LOG_DEBUG("editor[%p], clip_id[%d], volumd[%f]", editor, clip_id, *volume); + LOG_DEBUG("editor[%p], clip_id[%d], volume[%f]", editor, clip_id, *volume); return ret; } diff --git a/src/media_editor_private.c b/src/media_editor_private.c index 41844c3..a7bedc7 100644 --- a/src/media_editor_private.c +++ b/src/media_editor_private.c @@ -98,7 +98,7 @@ static int __create_encoding_profile(mediaeditor_s *editor, const char* path) audio_caps = gst_caps_from_string(audio_mime_type); RET_VAL_IF(audio_caps == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to create audio_caps"); if (!gst_encoding_container_profile_add_profile(profile, (GstEncodingProfile *)gst_encoding_audio_profile_new(audio_caps, NULL, NULL, 0))) { - LOG_ERROR("failed to add audio prifile"); + LOG_ERROR("failed to add audio profile"); ret = MEDIAEDITOR_ERROR_INVALID_OPERATION; g_object_unref(profile); goto error_audio_caps; @@ -107,14 +107,14 @@ static int __create_encoding_profile(mediaeditor_s *editor, const char* path) video_caps = gst_caps_from_string(video_mime_type); RET_VAL_IF(video_caps == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to create video_caps"); if (!gst_encoding_container_profile_add_profile(profile, (GstEncodingProfile *)gst_encoding_video_profile_new(video_caps, NULL, NULL, 0))) { - LOG_ERROR("failed to add audio prifile"); + LOG_ERROR("failed to add audio profile"); ret = MEDIAEDITOR_ERROR_INVALID_OPERATION; g_object_unref(profile); goto error_video_caps; } if (!ges_pipeline_set_render_settings(editor->gst.pipeline, uri, (GstEncodingProfile *)profile)) { - LOG_ERROR("failed to add audio prifile"); + LOG_ERROR("failed to add audio profile"); ret = MEDIAEDITOR_ERROR_INVALID_OPERATION; g_object_unref(profile); } @@ -427,7 +427,6 @@ void _remove_remained_event_sources(mediaeditor_s *editor) int _gst_init(mediaeditor_s *editor) { - static gboolean initialized = FALSE; gboolean ret = FALSE; char **argv = NULL; gint argc = 1; @@ -436,11 +435,6 @@ int _gst_init(mediaeditor_s *editor) NULL_PARAM_CHECK(editor); - if (initialized) { - LOG_INFO("gstreamer is already initialized."); - return MEDIAEDITOR_ERROR_NONE; - } - gst_args = editor->ini.general.gst_args; if (gst_args) @@ -478,8 +472,6 @@ int _gst_init(mediaeditor_s *editor) /* Initialize the GStreamer Editing Services */ ges_init(); - initialized = TRUE; - return MEDIAEDITOR_ERROR_NONE; } -- 2.34.1