Fix deadlock if sound stream info is set after audiosrc is created 04/94204/1
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 27 Oct 2016 11:43:49 +0000 (20:43 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 27 Oct 2016 11:43:49 +0000 (20:43 +0900)
sound stream info includes string and integer types.
They have each attribute and can be set at the same time,
but string type attribute uses write lock and it causes deadlock.
So, this commit avoids it by changing attribute sequence.

[Version] 0.10.88
[Profile] Common
[Issue Type] Bug fix
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161027.1]

Change-Id: I4b39b2638a46abee7a3a9a64dd3ad48129554763
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder_attribute.h
src/mm_camcorder_attribute.c

index b49e5d6..35208a7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.87
+Version:    0.10.88
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 48515e8..4227e42 100644 (file)
@@ -181,8 +181,8 @@ typedef enum {
        MM_CAM_DISPLAY_SOCKET_PATH,
        MM_CAM_PID_FOR_SOUND_FOCUS,
        MM_CAM_ROOT_DIRECTORY,
-       MM_CAM_SOUND_STREAM_TYPE,
        MM_CAM_SOUND_STREAM_INDEX,
+       MM_CAM_SOUND_STREAM_TYPE,
        MM_CAM_DISPLAY_REUSE_HINT,
        MM_CAM_DISPLAY_REUSE_ELEMENT,
        MM_CAM_GDBUS_CONNECTION,                        /* 130 */
index 331ac68..e6c056a 100644 (file)
@@ -1534,17 +1534,6 @@ _mmcamcorder_alloc_attribute(MMHandleType handle, MMCamPreset *info)
                        NULL,
                },
                {
-                       MM_CAM_SOUND_STREAM_TYPE,
-                       "sound-stream-type",
-                       MMF_VALUE_TYPE_STRING,
-                       MM_ATTRS_FLAG_RW,
-                       {(void*)NULL},
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       {0},
-                       {0},
-                       NULL,
-               },
-               {
                        MM_CAM_SOUND_STREAM_INDEX,
                        "sound-stream-index",
                        MMF_VALUE_TYPE_INT,
@@ -1553,6 +1542,17 @@ _mmcamcorder_alloc_attribute(MMHandleType handle, MMCamPreset *info)
                        MM_ATTRS_VALID_TYPE_INT_RANGE,
                        {.int_min = -1},
                        {.int_max = _MMCAMCORDER_MAX_INT},
+                       NULL,
+               },
+               {
+                       MM_CAM_SOUND_STREAM_TYPE,
+                       "sound-stream-type",
+                       MMF_VALUE_TYPE_STRING,
+                       MM_ATTRS_FLAG_RW,
+                       {(void*)NULL},
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       {0},
+                       {0},
                        _mmcamcorder_commit_sound_stream_info,
                },
                {
@@ -4606,12 +4606,18 @@ bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx,
 
 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const mmf_value_t *value)
 {
+       int stream_index = 0;
        char *stream_type = NULL;
-       int stream_type_len = 0;
        _MMCamcorderSubContext *sc = NULL;
 
        mmf_return_val_if_fail(handle && value, FALSE);
 
+       stream_type = value->value.s_val;
+       if (!stream_type) {
+               _mmcam_dbg_err("NULL string");
+               return FALSE;
+       }
+
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
        if (!sc || !sc->encode_element ||
            !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
@@ -4620,17 +4626,16 @@ bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, co
        }
 
        mm_camcorder_get_attributes(handle, NULL,
-               MMCAM_SOUND_STREAM_TYPE, &stream_type, &stream_type_len,
+               MMCAM_SOUND_STREAM_INDEX, &stream_index,
                NULL);
-
-       if (stream_type == NULL) {
-               _mmcam_dbg_err("stream type is not set");
+       if (stream_index < 0) {
+               _mmcam_dbg_err("invalid stream index %d", stream_index);
                return FALSE;
        }
 
-       _mmcam_dbg_log("Commit : sound stream info - type %s", stream_type);
+       _mmcam_dbg_log("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
 
-       return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, value->value.i_val);
+       return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
 }