Fix ASAN issue : heap-use-after-free 85/245985/3
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 21 Oct 2020 06:35:30 +0000 (15:35 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 21 Oct 2020 06:56:56 +0000 (15:56 +0900)
- The bus message callback from gstreamer could be invoked by gmainloop
  after source element of message is released by glibc.
- This patch drops all bus messages not to be called by gmainloop in bus sync callback.
- Minor change
 : Remove unused code

[Version] 0.10.220
[Issue Type] ASAN

Change-Id: Iaa921aab14897e0f03afb6acd9a3946a2b4b63d2
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder_internal.h
src/mm_camcorder_audiorec.c
src/mm_camcorder_gstcommon.c
src/mm_camcorder_internal.c
src/mm_camcorder_videorec.c

index 2284ad7..21e071b 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.219
+Version:    0.10.220
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index de12b82..1aa86c0 100755 (executable)
@@ -747,9 +747,6 @@ typedef struct mmf_camcorder {
        int rm_handle;                         /**< Resource manager handle */
        rm_consumer_info rci;                  /**< Resource consumer info */
 #endif /* _MMCAMCORDER_RM_SUPPORT */
-       guint pipeline_cb_event_id;            /**< Event source ID of pipeline message callback */
-       guint encode_pipeline_cb_event_id;     /**< Event source ID of encode pipeline message callback */
-       guint setting_event_id;                /**< Event source ID of attributes setting to sensor */
        SOUND_INFO snd_info;                   /**< Sound handle for multishot capture */
 
        /* callback handlers */
index 2023a31..fc8768c 100644 (file)
@@ -213,9 +213,6 @@ static int __mmcamcorder_create_audiop_with_encodebin(MMHandleType handle)
 
        bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
 
-       /* register message callback  */
-       hcamcorder->pipeline_cb_event_id = gst_bus_add_watch(bus, (GstBusFunc)_mmcamcorder_pipeline_cb_message, hcamcorder);
-
        /* set sync callback */
        gst_bus_set_sync_handler(bus, _mmcamcorder_encode_pipeline_bus_sync_callback, hcamcorder, NULL);
 
index 5406da7..0929a58 100755 (executable)
@@ -1690,9 +1690,6 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
 
        bus = gst_pipeline_get_bus(GST_PIPELINE(sc->element[_MMCAMCORDER_MAIN_PIPE].gst));
 
-       /* Register pipeline message callback */
-       hcamcorder->pipeline_cb_event_id = gst_bus_add_watch(bus, _mmcamcorder_pipeline_cb_message, (gpointer)hcamcorder);
-
        /* set sync handler */
        gst_bus_set_sync_handler(bus, _mmcamcorder_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
 
index b4a0859..ee7596a 100644 (file)
@@ -79,9 +79,9 @@ static void     __mmcamcorder_deinit_configure(mmf_camcorder_t *hcamcorder);
 static gboolean __mmcamcorder_init_gstreamer(camera_conf *conf);
 static void     __mmcamcorder_get_system_info(mmf_camcorder_t *hcamcorder);
 
-static GstBusSyncReply __mmcamcorder_handle_gst_sync_error(mmf_camcorder_t *hcamcorder, GstMessage *message);
-static GstBusSyncReply __mmcamcorder_gst_handle_sync_audio_error(mmf_camcorder_t *hcamcorder, gint err_code);
-static GstBusSyncReply __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_t *hcamcorder, gint err_code);
+static void     __mmcamcorder_handle_gst_sync_error(mmf_camcorder_t *hcamcorder, GstMessage *message);
+static void     __mmcamcorder_gst_handle_sync_audio_error(mmf_camcorder_t *hcamcorder, gint err_code);
+static void     __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_t *hcamcorder, gint err_code);
 static gboolean __mmcamcorder_handle_gst_error(MMHandleType handle, GstMessage *message, GError *error);
 static gint     __mmcamcorder_gst_handle_stream_error(MMHandleType handle, int code, GstMessage *message);
 static gint     __mmcamcorder_gst_handle_resource_error(MMHandleType handle, int code, GstMessage *message);
@@ -93,9 +93,6 @@ static gboolean __mmcamcorder_handle_gst_warning(MMHandleType handle, GstMessage
 static int      __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
        mm_resource_manager_res_h res, void *user_data);
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
-static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data);
-#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
 
 /*=======================================================================================
 |  FUNCTION DEFINITIONS                                                                        |
@@ -795,13 +792,6 @@ int _mmcamcorder_destroy(MMHandleType handle)
        _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
-       /* Remove idle function which is not called yet */
-       if (hcamcorder->setting_event_id) {
-               MMCAM_LOG_INFO("Remove remaining idle function");
-               g_source_remove(hcamcorder->setting_event_id);
-               hcamcorder->setting_event_id = 0;
-       }
-
        /* Remove messages which are not called yet */
        _mmcamcorder_remove_message_all(handle);
 
@@ -2549,15 +2539,13 @@ gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpoi
 
        mmf_return_val_if_fail(hcamcorder, FALSE);
        mmf_return_val_if_fail(message, FALSE);
-       /* MMCAM_LOG_INFO("message type=(%d)", GST_MESSAGE_TYPE(message)); */
+
+       MMCAM_LOG_DEBUG("message type[0x%x]", GST_MESSAGE_TYPE(message));
 
        switch (GST_MESSAGE_TYPE(message)) {
-       case GST_MESSAGE_UNKNOWN:
-               MMCAM_LOG_INFO("GST_MESSAGE_UNKNOWN");
-               break;
        case GST_MESSAGE_EOS:
        {
-               MMCAM_LOG_ERROR("Got EOS from element \"%s\"... but should not be reached here!",
+               MMCAM_LOG_ERROR("Got EOS from element[%s]... but should not be reached here!",
                        GST_STR_NULL(GST_ELEMENT_NAME(GST_MESSAGE_SRC(message))));
                break;
        }
@@ -2597,15 +2585,6 @@ gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpoi
                g_free(debug);
                break;
        }
-       case GST_MESSAGE_INFO:
-               MMCAM_LOG_INFO("GST_MESSAGE_INFO");
-               break;
-       case GST_MESSAGE_TAG:
-               MMCAM_LOG_INFO("GST_MESSAGE_TAG");
-               break;
-       case GST_MESSAGE_BUFFERING:
-               MMCAM_LOG_INFO("GST_MESSAGE_BUFFERING");
-               break;
        case GST_MESSAGE_STATE_CHANGED:
        {
                const GValue *vnewstate;
@@ -2629,63 +2608,15 @@ gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpoi
                }
                break;
        }
-       case GST_MESSAGE_STATE_DIRTY:
-               MMCAM_LOG_INFO("GST_MESSAGE_STATE_DIRTY");
-               break;
-       case GST_MESSAGE_STEP_DONE:
-               MMCAM_LOG_INFO("GST_MESSAGE_STEP_DONE");
-               break;
-       case GST_MESSAGE_CLOCK_PROVIDE:
-               MMCAM_LOG_INFO("GST_MESSAGE_CLOCK_PROVIDE");
-               break;
-       case GST_MESSAGE_CLOCK_LOST:
-               MMCAM_LOG_INFO("GST_MESSAGE_CLOCK_LOST");
-               break;
        case GST_MESSAGE_NEW_CLOCK:
        {
                GstClock *pipe_clock = NULL;
                gst_message_parse_new_clock(message, &pipe_clock);
-               /*MMCAM_LOG_INFO("GST_MESSAGE_NEW_CLOCK : %s", (clock ? GST_OBJECT_NAME (clock) : "NULL"));*/
+               MMCAM_LOG_INFO("GST_MESSAGE_NEW_CLOCK[%s]", (pipe_clock ? GST_OBJECT_NAME(pipe_clock) : "NULL"));
                break;
        }
-       case GST_MESSAGE_STRUCTURE_CHANGE:
-               MMCAM_LOG_INFO("GST_MESSAGE_STRUCTURE_CHANGE");
-               break;
-       case GST_MESSAGE_STREAM_STATUS:
-               /*MMCAM_LOG_INFO("GST_MESSAGE_STREAM_STATUS");*/
-               break;
-       case GST_MESSAGE_APPLICATION:
-               MMCAM_LOG_INFO("GST_MESSAGE_APPLICATION");
-               break;
-       case GST_MESSAGE_ELEMENT:
-               /*MMCAM_LOG_INFO("GST_MESSAGE_ELEMENT");*/
-               break;
-       case GST_MESSAGE_SEGMENT_START:
-               MMCAM_LOG_INFO("GST_MESSAGE_SEGMENT_START");
-               break;
-       case GST_MESSAGE_SEGMENT_DONE:
-               MMCAM_LOG_INFO("GST_MESSAGE_SEGMENT_DONE");
-               break;
-       case GST_MESSAGE_DURATION_CHANGED:
-               MMCAM_LOG_INFO("GST_MESSAGE_DURATION_CHANGED");
-               break;
-       case GST_MESSAGE_LATENCY:
-               MMCAM_LOG_INFO("GST_MESSAGE_LATENCY");
-               break;
-       case GST_MESSAGE_ASYNC_START:
-               MMCAM_LOG_INFO("GST_MESSAGE_ASYNC_START");
-               break;
-       case GST_MESSAGE_ASYNC_DONE:
-               /*MMCAM_LOG_INFO("GST_MESSAGE_ASYNC_DONE");*/
-               break;
-       case GST_MESSAGE_ANY:
-               MMCAM_LOG_INFO("GST_MESSAGE_ANY");
-               break;
-       case GST_MESSAGE_QOS:
-               /* MMCAM_LOG_INFO("GST_MESSAGE_QOS"); */
-               break;
        default:
-               MMCAM_LOG_INFO("not handled message type=(%d)", GST_MESSAGE_TYPE(message));
+               MMCAM_LOG_DEBUG("unhandled message type[0x%x]", GST_MESSAGE_TYPE(message));
                break;
        }
 
@@ -2695,18 +2626,17 @@ gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpoi
 
 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
 {
-       GstElement *element = NULL;
        GError *err = NULL;
        gchar *debug_info = NULL;
 
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
        _MMCamcorderSubContext *sc = NULL;
 
-       mmf_return_val_if_fail(hcamcorder, GST_BUS_PASS);
-       mmf_return_val_if_fail(message, GST_BUS_PASS);
+       mmf_return_val_if_fail(hcamcorder, GST_BUS_DROP);
+       mmf_return_val_if_fail(message, GST_BUS_DROP);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
-       mmf_return_val_if_fail(sc, GST_BUS_PASS);
+       mmf_return_val_if_fail(sc, GST_BUS_DROP);
 
        if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
                /* parse error message */
@@ -2723,11 +2653,9 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
                        return GST_BUS_PASS;
                }
 
-               /* set videosrc element to compare */
-               element = GST_ELEMENT_CAST(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
-
                /* check domain[RESOURCE] and element[VIDEOSRC] */
-               if (err->domain == GST_RESOURCE_ERROR && GST_ELEMENT_CAST(message->src) == element) {
+               if (err->domain == GST_RESOURCE_ERROR &&
+                       GST_ELEMENT_CAST(message->src) == GST_ELEMENT_CAST(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
                        switch (err->code) {
                        case GST_RESOURCE_ERROR_BUSY:
                                MMCAM_LOG_ERROR("Camera device [busy]");
@@ -2736,7 +2664,6 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
                        case GST_RESOURCE_ERROR_OPEN_WRITE:
                                MMCAM_LOG_ERROR("Camera device [open failed]");
                                hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
-                               /* sc->error_code = MM_ERROR_CAMCORDER_DEVICE_OPEN; // SECURITY PART REQUEST PRIVILEGE */
                                break;
                        case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
                                MMCAM_LOG_ERROR("Camera device [open failed]");
@@ -2782,8 +2709,6 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
                        msg.id = MM_MESSAGE_CAMCORDER_ERROR;
                        msg.param.code = hcamcorder->error_code;
                        _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-
-                       goto DROP_MESSAGE;
                }
        } else if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ELEMENT) {
                _MMCamcorderMsgItem msg;
@@ -2798,8 +2723,6 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
                        msg.id = MM_MESSAGE_CAMCORDER_FOCUS_CHANGED;
                        msg.param.code = focus_state;
                        _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-
-                       goto DROP_MESSAGE;
                } else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-HDR")) {
                        int progress = 0;
                        int status = 0;
@@ -2812,8 +2735,6 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
                                msg.param.code = progress;
                                _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
                        }
-
-                       goto DROP_MESSAGE;
                } else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-FD")) {
                        int i = 0;
                        const GValue *g_value = gst_structure_get_value(gst_message_get_structure(message), "face-info");;
@@ -2825,7 +2746,8 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
 
                        if (fd_info == NULL) {
                                MMCAM_LOG_WARNING("fd_info is NULL");
-                               goto DROP_MESSAGE;
+                               gst_message_unref(message);
+                               return GST_BUS_DROP;
                        }
 
                        cam_fd_info = (MMCamFaceDetectInfo *)g_malloc(sizeof(MMCamFaceDetectInfo));
@@ -2868,8 +2790,6 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
                        /* free fd_info allocated by plugin */
                        free(fd_info);
                        fd_info = NULL;
-
-                       goto DROP_MESSAGE;
                } else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-Capture")) {
                        int capture_done = FALSE;
 
@@ -2879,28 +2799,24 @@ GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage
                                        _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE01, FALSE);
                                }
                        }
-
-                       goto DROP_MESSAGE;
+               } else {
+                       _mmcamcorder_pipeline_cb_message(bus, message, data);
                }
+       } else {
+               _mmcamcorder_pipeline_cb_message(bus, message, data);
        }
 
-       return GST_BUS_PASS;
-
-DROP_MESSAGE:
        gst_message_unref(message);
 
        return GST_BUS_DROP;
 }
 
 
-static GstBusSyncReply __mmcamcorder_gst_handle_sync_audio_error(mmf_camcorder_t *hcamcorder, gint err_code)
+static void __mmcamcorder_gst_handle_sync_audio_error(mmf_camcorder_t *hcamcorder, gint err_code)
 {
        _MMCamcorderMsgItem msg;
 
-       if (!hcamcorder) {
-               MMCAM_LOG_ERROR("NULL handle");
-               return GST_BUS_PASS;
-       }
+       mmf_return_if_fail(hcamcorder);
 
        switch (err_code) {
        case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
@@ -2915,38 +2831,31 @@ static GstBusSyncReply __mmcamcorder_gst_handle_sync_audio_error(mmf_camcorder_t
                msg.param.code = hcamcorder->error_code;
 
                _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-
-               MMCAM_LOG_ERROR("error : sc->error_occurs %d", hcamcorder->error_occurs);
-
-               return GST_BUS_DROP;
+               break;
        default:
+               MMCAM_LOG_ERROR("unhandled error code[%d]", err_code);
                break;
        }
-
-       return GST_BUS_PASS;
 }
 
 
-static GstBusSyncReply __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_t *hcamcorder, gint err_code)
+static void __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_t *hcamcorder, gint err_code)
 {
        gboolean b_committing = FALSE;
        storage_state_e storage_state = STORAGE_STATE_UNMOUNTABLE;
        _MMCamcorderMsgItem msg;
        _MMCamcorderSubContext *sc = NULL;
 
-       if (!hcamcorder) {
-               MMCAM_LOG_ERROR("NULL handle");
-               return GST_BUS_PASS;
-       }
+       mmf_return_if_fail(hcamcorder);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
-       mmf_return_val_if_fail(sc, GST_BUS_PASS);
+       mmf_return_if_fail(sc);
 
        if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
-               mmf_return_val_if_fail(sc->info_video, GST_BUS_PASS);
+               mmf_return_if_fail(sc->info_video);
                b_committing = sc->info_video->b_committing;
        } else {
-               mmf_return_val_if_fail(sc->info_audio, GST_BUS_PASS);
+               mmf_return_if_fail(sc->info_audio);
                b_committing = sc->info_audio->b_committing;
        }
 
@@ -2969,7 +2878,7 @@ static GstBusSyncReply __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_
                } else {
                        MMCAM_LOG_ERROR("error was already sent");
                        _MMCAMCORDER_UNLOCK(hcamcorder);
-                       return GST_BUS_DROP;
+                       return;
                }
                break;
        case GST_RESOURCE_ERROR_NO_SPACE_LEFT:
@@ -3001,25 +2910,20 @@ static GstBusSyncReply __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_
 
                _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
        }
-
-       return GST_BUS_DROP;
 }
 
 
-static GstBusSyncReply __mmcamcorder_handle_gst_sync_error(mmf_camcorder_t *hcamcorder, GstMessage *message)
+static void __mmcamcorder_handle_gst_sync_error(mmf_camcorder_t *hcamcorder, GstMessage *message)
 {
        GError *err = NULL;
        gchar *debug_info = NULL;
-       GstBusSyncReply ret = GST_BUS_PASS;
        _MMCamcorderSubContext *sc = NULL;
 
-       if (!message || !hcamcorder) {
-               MMCAM_LOG_ERROR("NULL message(%p) or handle(%p)", message, hcamcorder);
-               return GST_BUS_PASS;
-       }
+       mmf_return_if_fail(hcamcorder);
+       mmf_return_if_fail(message);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
-       mmf_return_val_if_fail(sc, GST_BUS_PASS);
+       mmf_return_if_fail(sc);
 
        /* parse error message */
        gst_message_parse_error(message, &err, &debug_info);
@@ -3031,35 +2935,31 @@ static GstBusSyncReply __mmcamcorder_handle_gst_sync_error(mmf_camcorder_t *hcam
        }
 
        if (!err) {
-               MMCAM_LOG_WARNING("failed to parse error message");
-               return GST_BUS_PASS;
+               MMCAM_LOG_ERROR("failed to parse error message");
+               return;
        }
 
        /* check domain[RESOURCE] and element[AUDIOSRC] */
        if (err->domain == GST_RESOURCE_ERROR &&
                GST_ELEMENT_CAST(message->src) == GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst))
-               ret = __mmcamcorder_gst_handle_sync_audio_error(hcamcorder, err->code);
+               __mmcamcorder_gst_handle_sync_audio_error(hcamcorder, err->code);
        else
-               ret = __mmcamcorder_gst_handle_sync_others_error(hcamcorder, err->code);
+               __mmcamcorder_gst_handle_sync_others_error(hcamcorder, err->code);
 
        g_error_free(err);
-
-       return ret;
 }
 
 
 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
 {
-       GstBusSyncReply ret = GST_BUS_PASS;
-
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
        _MMCamcorderSubContext *sc = NULL;
 
-       mmf_return_val_if_fail(hcamcorder, GST_BUS_PASS);
-       mmf_return_val_if_fail(message, GST_BUS_PASS);
+       mmf_return_val_if_fail(hcamcorder, GST_BUS_DROP);
+       mmf_return_val_if_fail(message, GST_BUS_DROP);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
-       mmf_return_val_if_fail(sc, GST_BUS_PASS);
+       mmf_return_val_if_fail(sc, GST_BUS_DROP);
 
        if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS) {
                MMCAM_LOG_INFO("got EOS from pipeline");
@@ -3070,16 +2970,15 @@ GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstM
                _MMCAMCORDER_SIGNAL(hcamcorder);
 
                _MMCAMCORDER_UNLOCK(hcamcorder);
-
-               ret = GST_BUS_DROP;
        } else if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
-               ret = __mmcamcorder_handle_gst_sync_error(hcamcorder, message);
+               __mmcamcorder_handle_gst_sync_error(hcamcorder, message);
+       } else {
+               _mmcamcorder_pipeline_cb_message(bus, message, data);
        }
 
-       if (ret == GST_BUS_DROP)
-               gst_message_unref(message);
+       gst_message_unref(message);
 
-       return ret;
+       return GST_BUS_DROP;
 }
 
 
@@ -3181,7 +3080,6 @@ void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type)
        gint i = 0;
        int element_num = 0;
        _MMCamcorderGstElement *element = NULL;
-       GstBus *bus = NULL;
 
        mmf_return_if_fail(hcamcorder);
 
@@ -3195,13 +3093,11 @@ void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type)
        case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
                element = sc->element;
                element_num = sc->element_num;
-               bus = gst_pipeline_get_bus(GST_PIPELINE(sc->element[_MMCAMCORDER_MAIN_PIPE].gst));
                _mmcamcorder_destroy_video_capture_pipeline(handle);
                break;
        case MM_CAMCORDER_MODE_AUDIO:
                element = sc->encode_element;
                element_num = sc->encode_element_num;
-               bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
                _mmcamcorder_destroy_audio_pipeline(handle);
                break;
        default:
@@ -3211,24 +3107,6 @@ void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type)
 
        MMCAM_LOG_INFO("Pipeline clear!!");
 
-       /* Remove pipeline message callback */
-       if (hcamcorder->pipeline_cb_event_id > 0) {
-               g_source_remove(hcamcorder->pipeline_cb_event_id);
-               hcamcorder->pipeline_cb_event_id = 0;
-       }
-
-       /* Remove remained message in bus */
-       if (bus) {
-               GstMessage *gst_msg = NULL;
-               while ((gst_msg = gst_bus_pop(bus)) != NULL) {
-                       _mmcamcorder_pipeline_cb_message(bus, gst_msg, (gpointer)hcamcorder);
-                       gst_message_unref(gst_msg);
-                       gst_msg = NULL;
-               }
-               gst_object_unref(bus);
-               bus = NULL;
-       }
-
        /* checking unreleased element */
        for (i = 0 ; i < element_num ; i++) {
                if (element[i].gst) {
@@ -3252,28 +3130,6 @@ void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type)
 }
 
 
-#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
-static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data)
-{
-       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
-
-       mmf_return_val_if_fail(hcamcorder, FALSE);
-
-       MMCAM_LOG_INFO("");
-
-       _mmcamcorder_set_attribute_to_camsensor((MMHandleType)hcamcorder);
-
-       /* initialize */
-       hcamcorder->setting_event_id = 0;
-
-       MMCAM_LOG_INFO("Done");
-
-       /* once */
-       return FALSE;
-}
-#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
-
-
 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state)
 {
        unsigned int k = 0;
index 23e15fb..b90fa91 100644 (file)
@@ -374,9 +374,6 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
 
        bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
 
-       /* register pipeline message callback */
-       hcamcorder->encode_pipeline_cb_event_id = gst_bus_add_watch(bus, (GstBusFunc)_mmcamcorder_pipeline_cb_message, hcamcorder);
-
        /* set sync handler */
        gst_bus_set_sync_handler(bus, _mmcamcorder_encode_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
 
@@ -555,12 +552,6 @@ int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle)
                return ret;
        }
 
-       /* Remove pipeline message callback */
-       if (hcamcorder->encode_pipeline_cb_event_id != 0) {
-               g_source_remove(hcamcorder->encode_pipeline_cb_event_id);
-               hcamcorder->encode_pipeline_cb_event_id = 0;
-       }
-
        /* Remove remained message */
        if (bus) {
                GstMessage *gst_msg = NULL;