Remove unnecessary initial value settings and delete redundant parts in function... 23/319523/7
authorGilbok Lee <gilbok.lee@samsung.com>
Fri, 25 Oct 2024 03:10:29 +0000 (12:10 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Tue, 29 Oct 2024 02:04:40 +0000 (11:04 +0900)
- Changed from g_malloc0() to g_new0() in order to use without type casting.
- The g_new0() fuction initializes to zero while malloc,
  so unnecessary initialization values and memset() were removed.
- When registering a callback using gst_pad_add_probe,
  if the GST_PAD_PROBE_REMOVE is returned within the callback,
  the callback is automatically unregistered without explicitly calling
  gst_pad_remove_probe().
- fix typo error

[Version] 0.4.3
[Issue Type] Clean up

Change-Id: I9a55af88bc72ef6743b3de8c7ec195a9a0087fc6

packaging/libmm-wfd.spec
src/include/mm_wfd_sink_wayland.h
src/mm_wfd_sink_config.c
src/mm_wfd_sink_priv.c
src/mm_wfd_sink_util.c
src/mm_wfd_sink_wayland.c

index afea7c47124d73a0597d8087bcbb10113189dd8b..c35ea869f2dd11a20a598036cb2856865c2c3a64 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-wfd
 Summary:    Multimedia Framework Wifi-Display Library
-Version:    0.4.2
+Version:    0.4.3
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 0a8f3702df272d010874b2101b38fa5f30edf043..e89711b5e17f7c237773838a69308272e36c3294 100644 (file)
@@ -36,7 +36,6 @@ typedef struct {
        struct tizen_resource *tz_resource;
 } wl_client;
 
-int mm_wfd_sink_wlclient_create(wl_client **wlclient);
 int mm_wfd_sink_wlclient_get_wl_window_wl_surface_id(wl_client *wlclient, struct wl_surface *surface, struct wl_display *display);
 void mm_wfd_sink_wlclient_finalize(wl_client *wlclient);
 
index 247d3021e769e8088d601488a6e8c3acfdc9e27d..1fecc518e4395dd2d0c777ceb4524d04fc98346a 100644 (file)
 #include <stdlib.h>
 #include <system_info.h>
 #include "mm_wfd_sink_config.h"
+#include "mm_wfd_sink_dlog.h"
 
 
 tizen_profile_t _get_tizen_profile()
 {
        static tizen_profile_t profile = __TIZEN_PROFILE_UNKNOWN;
-       if (__builtin_expect(profile != __TIZEN_PROFILE_UNKNOWN, 1))
+       if (G_LIKELY(profile != __TIZEN_PROFILE_UNKNOWN))
                return profile;
 
-       char *profileName;
-       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       char *profileName = NULL;
+       if (system_info_get_platform_string("http://tizen.org/feature/profile", &profileName)
+               != SYSTEM_INFO_ERROR_NONE) {
+               LOGE("Failed to get profile name from system info");
+               return __TIZEN_PROFILE_UNKNOWN;
+       }
+
+       if (!profileName) {
+               LOGE("profileName is NULL");
+               return __TIZEN_PROFILE_UNKNOWN;
+       }
+
        switch (*profileName) {
        case 'm':
        case 'M':
@@ -51,6 +62,7 @@ tizen_profile_t _get_tizen_profile()
        default: // common or unknown ==> ALL ARE COMMON.
                profile = __TIZEN_PROFILE_COMMON;
        }
+       LOGD("profile : %s", profileName);
        free(profileName);
 
        return profile;
index dc39acf3eaec7fe2f636062dd9ab2392fccea4e7..e3fb8f0b54ea9f58b4f1247b8ef25e09c7d6c3ff 100644 (file)
@@ -63,11 +63,7 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink, const char *ini_path)
        mm_wfd_sink_t *new_wfd_sink = NULL;
 
        /* create handle */
-       new_wfd_sink = g_malloc0(sizeof(mm_wfd_sink_t));
-       if (!new_wfd_sink) {
-               wfd_sink_error("failed to allocate memory for wi-fi display sink");
-               return MM_ERROR_WFD_NO_FREE_SPACE;
-       }
+       new_wfd_sink = g_new0(mm_wfd_sink_t, 1);
 
        /* initialize resource manager */
        result = mm_wfd_sink_rm_create(new_wfd_sink);
@@ -77,57 +73,8 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink, const char *ini_path)
                goto fail_to_attrs;
        }
 
-       /* Initialize gstreamer related */
-       new_wfd_sink->attrs = 0;
-
-       new_wfd_sink->pipeline = NULL;
-       new_wfd_sink->audio_decodebin_is_linked = FALSE;
-       new_wfd_sink->video_decodebin_is_linked = FALSE;
-
-       /* Initialize timestamp compensation related */
-       new_wfd_sink->need_to_reset_basetime = FALSE;
-       new_wfd_sink->clock = NULL;
-       new_wfd_sink->video_buffer_count = 0LL;
-       new_wfd_sink->video_average_gap = 0LL;
-       new_wfd_sink->video_accumulated_gap = 0LL;
-       new_wfd_sink->audio_buffer_count = 0LL;
-       new_wfd_sink->audio_average_gap = 0LL;
-       new_wfd_sink->audio_accumulated_gap = 0LL;
        new_wfd_sink->last_buffer_timestamp = GST_CLOCK_TIME_NONE;
-
-       /* Initialize all states */
-       MMWFDSINK_CURRENT_STATE(new_wfd_sink) = MM_WFD_SINK_STATE_NONE;
-       MMWFDSINK_PREVIOUS_STATE(new_wfd_sink) =  MM_WFD_SINK_STATE_NONE;
-       MMWFDSINK_PENDING_STATE(new_wfd_sink) =  MM_WFD_SINK_STATE_NONE;
-
-       /* initialize audio/video information */
-       new_wfd_sink->stream_info.audio_stream_info.codec = MM_WFD_SINK_AUDIO_CODEC_NONE;
-       new_wfd_sink->stream_info.audio_stream_info.channels = 0;
-       new_wfd_sink->stream_info.audio_stream_info.sample_rate = 0;
-       new_wfd_sink->stream_info.audio_stream_info.bitwidth = 0;
-       new_wfd_sink->stream_info.video_stream_info.codec = MM_WFD_SINK_VIDEO_CODEC_NONE;
-       new_wfd_sink->stream_info.video_stream_info.width = 0;
-       new_wfd_sink->stream_info.video_stream_info.height = 0;
-       new_wfd_sink->stream_info.video_stream_info.frame_rate = 0;
-
-       /* Initialize command */
        new_wfd_sink->cmd = MM_WFD_SINK_COMMAND_CREATE;
-       new_wfd_sink->waiting_cmd = FALSE;
-
-       /* Initialize manager related */
-       new_wfd_sink->manager_thread = NULL;
-       new_wfd_sink->manager_thread_cmd = NULL;
-       new_wfd_sink->manager_thread_exit = FALSE;
-
-       /* Initialize video resolution */
-       new_wfd_sink->supportive_resolution = MM_WFD_SINK_RESOLUTION_UNKNOWN;
-
-       /* Initialize coulped sink information */
-       new_wfd_sink->coupled_sink_address = NULL;
-       new_wfd_sink->coupled_sink_status = MM_WFD_COUPLED_SINK_STATUS_NOT_COUPLED;
-
-       /* In case of R2 sink, it would be TRUE */
-       new_wfd_sink->is_coupled_sink_supported = FALSE;
 
        /* construct attributes */
        new_wfd_sink->attrs = _mmwfd_construct_attribute((MMHandleType)new_wfd_sink);
@@ -403,10 +350,10 @@ int _mm_wfd_sink_unprepare(mm_wfd_sink_t *wfd_sink)
        /* release pipeline */
        result =  __mm_wfd_sink_destroy_pipeline(wfd_sink);
        if (result != MM_ERROR_NONE) {
-               wfd_sink_error("failed to destory pipeline");
+               wfd_sink_error("failed to destroy pipeline");
                return MM_ERROR_WFD_INTERNAL;
        } else {
-               wfd_sink_debug("success to destory pipeline");
+               wfd_sink_debug("success to destroy pipeline");
        }
 
        /* set state */
@@ -1758,14 +1705,14 @@ __mm_wfd_sink_prepare_video_pipeline(mm_wfd_sink_t *wfd_sink, GstPad **pad)
 
                        srcpad = gst_element_get_static_pad(v_decodebin, "src");
                        if (!srcpad) {
-                               wfd_sink_error("faied to get srcpad from %s", GST_ELEMENT_NAME(v_decodebin));
+                               wfd_sink_error("failed to get srcpad from %s", GST_ELEMENT_NAME(v_decodebin));
                                goto ERROR;
                        }
 
                        if (!gst_pad_is_linked(srcpad)) {
                                sinkpad = gst_element_get_static_pad(v_sinkbin, "sink");
                                if (!sinkpad) {
-                                       wfd_sink_error("faied to get sinkpad from %s", GST_ELEMENT_NAME(v_sinkbin));
+                                       wfd_sink_error("failed to get sinkpad from %s", GST_ELEMENT_NAME(v_sinkbin));
                                        goto ERROR;
                                }
 
@@ -2153,14 +2100,14 @@ __mm_wfd_sink_prepare_audio_pipeline(mm_wfd_sink_t *wfd_sink, GstPad **pad)
 
                        srcpad = gst_element_get_static_pad(a_decodebin, "src");
                        if (!srcpad) {
-                               wfd_sink_error("faied to get srcpad from %s", GST_ELEMENT_NAME(a_decodebin));
+                               wfd_sink_error("failed to get srcpad from %s", GST_ELEMENT_NAME(a_decodebin));
                                goto ERROR;
                        }
 
                        if (!gst_pad_is_linked(srcpad)) {
                                sinkpad = gst_element_get_static_pad(a_sinkbin, "sink");
                                if (!sinkpad) {
-                                       wfd_sink_error("faied to get sinkpad from %s", GST_ELEMENT_NAME(a_sinkbin));
+                                       wfd_sink_error("failed to get sinkpad from %s", GST_ELEMENT_NAME(a_sinkbin));
                                        goto ERROR;
                                }
 
@@ -2282,7 +2229,7 @@ _mm_wfd_sink_check_running_time(GstPad *pad, GstPadProbeInfo *info, gpointer u_d
        render_time = GST_BUFFER_TIMESTAMP(buffer);
        render_time += ts_offset;
 
-       /* chekc this buffer could be rendered or not */
+       /* check this buffer could be rendered or not */
        if (GST_CLOCK_TIME_IS_VALID(running_time) && GST_CLOCK_TIME_IS_VALID(render_time)) {
                diff = GST_CLOCK_DIFF(running_time, render_time);
                if (diff < 0) {
@@ -2311,7 +2258,7 @@ _mm_wfd_sink_check_running_time(GstPad *pad, GstPadProbeInfo *info, gpointer u_d
        }
 
        if (GST_CLOCK_TIME_IS_VALID(wfd_sink->last_buffer_timestamp)) {
-               /* fisrt 60sec, just calculate the gap between source device and sink device */
+               /* first 60sec, just calculate the gap between source device and sink device */
                if (GST_BUFFER_TIMESTAMP(buffer) < 60 * GST_SECOND)
                        return GST_PAD_PROBE_OK;
 
@@ -2373,7 +2320,7 @@ _mm_wfd_sink_check_running_time(GstPad *pad, GstPadProbeInfo *info, gpointer u_d
                                                                GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)));
                        }
 
-                       /* selecet average_gap_diff between video and audio */
+                       /* select average_gap_diff between video and audio */
                        /*  which makes no buffer drop in the sink elements */
                        if (video_avgrage_gap_diff && audio_avgrage_gap_diff) {
                                if (!video_minus_compensation && !audio_minus_compensation) {
@@ -2403,7 +2350,7 @@ _mm_wfd_sink_check_running_time(GstPad *pad, GstPadProbeInfo *info, gpointer u_d
                                avgrage_gap_diff = audio_avgrage_gap_diff;
                        }
 
-                       wfd_sink_debug("average diff gap difference beween audio:%s%"G_GINT64_FORMAT"d and video:%s%"G_GINT64_FORMAT"d ",
+                       wfd_sink_debug("average diff gap difference between audio:%s%"G_GINT64_FORMAT"d and video:%s%"G_GINT64_FORMAT"d ",
                                                        audio_minus_compensation ? "-" : "", audio_avgrage_gap_diff,
                                                        video_minus_compensation ? "-" : "", video_avgrage_gap_diff);
 
@@ -2474,7 +2421,7 @@ __mm_wfd_sink_demux_pad_added(GstElement *demux, GstPad *pad, gpointer data)
                                wfd_sink->stream_info.audio_stream_info.codec,
                                name[0]);
 
-       //In case of none vieo codec, we don't add video pad
+       //In case of none video codec, we don't add video pad
        if (wfd_sink->stream_info.video_stream_info.codec == MM_WFD_SINK_VIDEO_CODEC_NONE && name[0] == 'v') {
                wfd_sink_error("Skip video pad add for none video codec");
                // Do nothing
@@ -3031,18 +2978,10 @@ int __mm_wfd_sink_create_pipeline(mm_wfd_sink_t *wfd_sink)
        wfd_sink_return_val_if_fail(wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* Create pipeline */
-       wfd_sink->pipeline = (MMWFDSinkGstPipelineInfo *) g_malloc0(sizeof(MMWFDSinkGstPipelineInfo));
-       if (wfd_sink->pipeline == NULL)
-               goto CREATE_ERROR;
-
-       memset(wfd_sink->pipeline, 0, sizeof(MMWFDSinkGstPipelineInfo));
+       wfd_sink->pipeline = g_new0(MMWFDSinkGstPipelineInfo, 1);
 
        /* create mainbin */
-       mainbin = (MMWFDSinkGstElement *) g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
-       if (mainbin == NULL)
-               goto CREATE_ERROR;
-
-       memset(mainbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
+       mainbin = g_new0(MMWFDSinkGstElement, WFD_SINK_M_NUM);
 
        /* create pipeline */
        mainbin[WFD_SINK_M_PIPE].id = WFD_SINK_M_PIPE;
@@ -3250,7 +3189,7 @@ int __mm_wfd_sink_link_audio_decodebin(mm_wfd_sink_t *wfd_sink)
                break;
 
        default:
-               wfd_sink_error("audio codec is not decied yet. cannot link audio decodebin...");
+               wfd_sink_error("audio codec is not decide yet. cannot link audio decodebin...");
                goto fail_to_link;
                break;
        }
@@ -3410,7 +3349,7 @@ int  __mm_wfd_sink_destroy_audio_decodebin(mm_wfd_sink_t *wfd_sink)
 
        parent = gst_element_get_parent(a_decodebin[WFD_SINK_A_D_BIN].gst);
        if (!parent) {
-               wfd_sink_debug("audio decodebin has no parent.. need to relase by itself");
+               wfd_sink_debug("audio decodebin has no parent.. need to release by itself");
 
                if (GST_STATE(a_decodebin[WFD_SINK_A_D_BIN].gst) >= GST_STATE_READY) {
                        wfd_sink_error("try to change state of audio decodebin to NULL");
@@ -3512,13 +3451,7 @@ int __mm_wfd_sink_create_audio_decodebin(mm_wfd_sink_t *wfd_sink)
        }
 
        /* alloc handles */
-       a_decodebin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_A_D_NUM);
-       if (!a_decodebin) {
-               wfd_sink_error("failed to allocate memory for audio decodebin");
-               return MM_ERROR_WFD_NO_FREE_SPACE;
-       }
-
-       memset(a_decodebin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_A_D_NUM);
+       a_decodebin = g_new0(MMWFDSinkGstElement, WFD_SINK_A_D_NUM);
 
        /* create audio decodebin */
        a_decodebin[WFD_SINK_A_D_BIN].id = WFD_SINK_A_D_BIN;
@@ -3729,13 +3662,7 @@ int __mm_wfd_sink_create_audio_sinkbin(mm_wfd_sink_t *wfd_sink)
        }
 
        /* alloc handles */
-       a_sinkbin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_A_S_NUM);
-       if (!a_sinkbin) {
-               wfd_sink_error("failed to allocate memory for audio sinkbin");
-               return MM_ERROR_WFD_NO_FREE_SPACE;
-       }
-
-       memset(a_sinkbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_A_S_NUM);
+       a_sinkbin = g_new0(MMWFDSinkGstElement, WFD_SINK_A_S_NUM);
 
        /* create audio sinkbin */
        a_sinkbin[WFD_SINK_A_S_BIN].id = WFD_SINK_A_S_BIN;
@@ -3781,7 +3708,7 @@ int __mm_wfd_sink_create_audio_sinkbin(mm_wfd_sink_t *wfd_sink)
 
        /* linking elements in the bucket by added order. */
        if (__mm_wfd_sink_gst_element_link_bucket(element_bucket) == -1) {
-               wfd_sink_error("failed to link elements fo the audio sinkbin");
+               wfd_sink_error("failed to link elements for the audio sinkbin");
                goto CREATE_ERROR;
        }
 
@@ -3935,7 +3862,7 @@ int __mm_wfd_sink_link_video_decodebin(mm_wfd_sink_t *wfd_sink)
                break;
 
        default:
-               wfd_sink_error("video codec is not decied yet. cannot link video decpdebin...");
+               wfd_sink_error("video codec is not decied yet. cannot link video decodebin...");
                goto fail_to_link;
                break;
        }
@@ -4265,13 +4192,7 @@ int __mm_wfd_sink_create_video_decodebin(mm_wfd_sink_t *wfd_sink)
        }
 
        /* alloc handles */
-       v_decodebin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_V_D_NUM);
-       if (!v_decodebin) {
-               wfd_sink_error("failed to allocate memory for video decodebin");
-               return MM_ERROR_WFD_NO_FREE_SPACE;
-       }
-
-       memset(v_decodebin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_V_D_NUM);
+       v_decodebin = g_new0(MMWFDSinkGstElement, WFD_SINK_V_D_NUM);
 
        /* create video decodebin */
        v_decodebin[WFD_SINK_V_D_BIN].id = WFD_SINK_V_D_BIN;
@@ -4508,13 +4429,7 @@ int __mm_wfd_sink_create_video_sinkbin(mm_wfd_sink_t *wfd_sink)
        }
 
        /* alloc handles */
-       v_sinkbin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_V_S_NUM);
-       if (!v_sinkbin) {
-               wfd_sink_error("failed to allocate memory for video sinkbin");
-               return MM_ERROR_WFD_NO_FREE_SPACE;
-       }
-
-       memset(v_sinkbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_V_S_NUM);
+       v_sinkbin = g_new0(MMWFDSinkGstElement, WFD_SINK_V_S_NUM);
 
        /* create video sinkbin */
        v_sinkbin[WFD_SINK_V_S_BIN].id = WFD_SINK_V_S_BIN;
@@ -4683,7 +4598,7 @@ int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink)
                                wfd_sink_error("failed to change state of pipeline to NULL. ret[%d]", ret);
                                return MM_ERROR_WFD_INTERNAL;
                        } else {
-                               wfd_sink_debug("Successed to change state of pipeline to NULL");
+                               wfd_sink_debug("Succeed to change state of pipeline to NULL");
                        }
 
                        bus = gst_pipeline_get_bus(GST_PIPELINE(mainbin[WFD_SINK_M_PIPE].gst));
@@ -4841,7 +4756,7 @@ _mm_wfds_sink_get_state_name(MMWFDSinkStateType state)
        case MM_WFD_SINK_STATE_DISCONNECTED:
                return "DISCONNECTED";
        default:
-               return "INVAID";
+               return "INVAILD";
        }
 }
 
@@ -4930,12 +4845,8 @@ int _mm_wfd_sink_set_display_overlay(mm_wfd_sink_t *wfd_sink, void *display_obje
                wfd_sink_debug("surface = %p, wl_display = %p", wl_surface, wl_display);
                display_overlay = object;
 
-               ret = mm_wfd_sink_wlclient_create(&wlclient);
-               if (ret != MM_ERROR_NONE) {
-                       wfd_sink_error("Wayland client create failure");
-                       return MM_ERROR_WFD_INTERNAL;
-               }
-               wfd_sink_debug("Try to get surface id");
+               wlclient = g_new0(wl_client, 1);
+               wfd_sink_debug("Success create wlclient(%p) Try to get surface id", wlclient);
 
                wl_surface_id = mm_wfd_sink_wlclient_get_wl_window_wl_surface_id(wlclient, wl_surface, wl_display);
 
index 2c4feb5fe10025fa8263b7dd5331b1b8b8c6adda..f02fce68c1d0689700f392f845807d17793c8d67 100644 (file)
@@ -125,7 +125,7 @@ _mm_wfd_sink_util_pad_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer u_da
                                                                GST_TIME_ARGS(segment->start), GST_TIME_ARGS(segment->stop),
                                                                GST_TIME_ARGS(segment->time));
 
-                               wfd_sink_debug("NEWSEGMENT : flags[%d] rate[%lf] applied_rate[%lf] foramt[%d] base[%"G_GUINT64_FORMAT"d] offset[%"G_GUINT64_FORMAT"d] position[%"G_GUINT64_FORMAT"d] duration[%"G_GUINT64_FORMAT"d]",
+                               wfd_sink_debug("NEWSEGMENT : flags[%d] rate[%lf] applied_rate[%lf] format[%d] base[%"G_GUINT64_FORMAT"d] offset[%"G_GUINT64_FORMAT"d] position[%"G_GUINT64_FORMAT"d] duration[%"G_GUINT64_FORMAT"d]",
                                                                segment->flags, segment->rate, segment->applied_rate, segment->format, segment->base, segment->offset, segment->position, segment->duration);
 
                        }
@@ -200,7 +200,6 @@ _mm_wfd_sink_util_check_first_buffer_cb(GstPad *pad, GstPadProbeInfo *info, gpoi
 {
        GstElement *parent = NULL;
        GstBuffer *buffer = NULL;
-       guint *probe_id = (guint *)user_data;
 
        wfd_sink_return_val_if_fail(pad, GST_PAD_PROBE_DROP);
        wfd_sink_return_val_if_fail(info, GST_PAD_PROBE_DROP);
@@ -217,13 +216,6 @@ _mm_wfd_sink_util_check_first_buffer_cb(GstPad *pad, GstPadProbeInfo *info, gpoi
                                        GST_STR_NULL(GST_ELEMENT_NAME(parent)), GST_STR_NULL(GST_PAD_NAME(pad)),
                                        GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)), gst_buffer_get_size(buffer));
 
-       if (probe_id && *probe_id > 0) {
-               wfd_sink_debug("remove buffer probe[%d]\n", *probe_id);
-               gst_pad_remove_probe(pad, *probe_id);
-
-               MMWFDSINK_FREEIF(probe_id);
-       }
-
        if (parent)
                gst_object_unref(parent);
 
@@ -234,31 +226,20 @@ void
 mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer(GstPad *pad, GstElement *element, const gchar *pad_name)
 {
        GstPad *probe_pad = NULL;
-       guint *probe_id = NULL;
 
        if (!pad) {
                if (element && pad_name)
                        probe_pad = gst_element_get_static_pad(element, pad_name);
        } else {
-               probe_pad = pad;
-               gst_object_ref(probe_pad);
+               probe_pad = gst_object_ref(pad);
        }
 
-       if (probe_pad) {
-               probe_id  = g_malloc0(sizeof(guint));
-               if (!probe_id) {
-                       wfd_sink_error("failed to allocate memory for probe id\n");
-                       gst_object_unref(probe_pad);
-                       return;
-               }
+       if (!probe_pad)
+               return;
 
-               *probe_id = gst_pad_add_probe(probe_pad, GST_PAD_PROBE_TYPE_BUFFER, _mm_wfd_sink_util_check_first_buffer_cb, (gpointer)probe_id, NULL);
-               wfd_sink_debug("add pad(%s) probe, %d",
-                                               GST_STR_NULL(GST_PAD_NAME(probe_pad)), *probe_id);
+       gst_pad_add_probe(probe_pad, GST_PAD_PROBE_TYPE_BUFFER, _mm_wfd_sink_util_check_first_buffer_cb, NULL, NULL);
+       wfd_sink_debug("add pad(%s) probe",
+                                       GST_STR_NULL(GST_PAD_NAME(probe_pad)));
 
-               gst_object_unref(probe_pad);
-       }
-
-       return;
+       gst_object_unref(probe_pad);
 }
-
index e0d27f4cb69c1acda6d51a6d0f95a618ef8e4dfc..d6ec558e7bbc36eda5ca837dcc22c0b670efc773 100644 (file)
@@ -71,26 +71,6 @@ static const struct wl_registry_listener registry_listener = {
        mm_wfd_sink_handle_global_remove
 };
 
-int mm_wfd_sink_wlclient_create(wl_client **wlclient)
-{
-       wl_client *ptr = NULL;
-
-       ptr = g_malloc0(sizeof(wl_client));
-       if (!ptr) {
-               wfd_sink_error("Cannot allocate memory for wlclient\n");
-               goto ERROR;
-       } else {
-               *wlclient = ptr;
-               wfd_sink_debug("Success create wlclient(%p)", *wlclient);
-       }
-       return MM_ERROR_NONE;
-
-ERROR:
-       *wlclient = NULL;
-       return MM_ERROR_WFD_NO_FREE_SPACE;
-}
-
-
 int mm_wfd_sink_wlclient_get_wl_window_wl_surface_id(wl_client *wlclient, struct wl_surface *surface, struct wl_display *display)
 {
        unsigned int wl_surface_id = 0;