From: SeokHoon Lee Date: Wed, 8 Jun 2016 02:16:25 +0000 (+0900) Subject: [UTC][streamrecorder][Non-ACR][fix memleak in utc_media_streamrecorder_commit_p] X-Git-Tag: Beta_RC10~108^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7a0e88330f0148d5fa292fbaf9c53a7ab435d87;p=test%2Ftct%2Fnative%2Fapi.git [UTC][streamrecorder][Non-ACR][fix memleak in utc_media_streamrecorder_commit_p] Signed-off-by: SeokHoon Lee Change-Id: Ie832d78b4ed482baecf0267a970e5820af39c846 --- diff --git a/src/utc/streamrecorder/tct-streamrecorder-core_mobile.h b/src/utc/streamrecorder/tct-streamrecorder-core_mobile.h index 704f72d..1ffb0a6 100755 --- a/src/utc/streamrecorder/tct-streamrecorder-core_mobile.h +++ b/src/utc/streamrecorder/tct-streamrecorder-core_mobile.h @@ -67,14 +67,14 @@ extern int utc_media_streamrecorder_unset_error_cb_p(void); extern int utc_media_streamrecorder_unset_error_cb_n(void); extern int utc_media_streamrecorder_enable_source_buffer_n(void); extern int utc_media_streamrecorder_enable_source_buffer_p(void); -extern int utc_media_streamrecorder_cancel_p(void); -extern int utc_media_streamrecorder_cancel_n(void); extern int utc_media_streamrecorder_commit_p(void); extern int utc_media_streamrecorder_commit_n(void); -extern int utc_media_streamrecorder_destroy_p(void); -extern int utc_media_streamrecorder_destroy_n(void); extern int utc_media_streamrecorder_pause_p(void); extern int utc_media_streamrecorder_pause_n(void); +extern int utc_media_streamrecorder_cancel_p(void); +extern int utc_media_streamrecorder_cancel_n(void); +extern int utc_media_streamrecorder_destroy_p(void); +extern int utc_media_streamrecorder_destroy_n(void); extern int utc_media_streamrecorder_prepare_p(void); extern int utc_media_streamrecorder_prepare_n1(void); extern int utc_media_streamrecorder_prepare_n2(void); @@ -194,14 +194,14 @@ testcase tc_array[] = { {"utc_media_streamrecorder_unset_error_cb_n", utc_media_streamrecorder_unset_error_cb_n, utc_media_streamrecorder_callback_startup, utc_media_streamrecorder_callback_cleanup}, {"utc_media_streamrecorder_enable_source_buffer_n", utc_media_streamrecorder_enable_source_buffer_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_enable_source_buffer_p", utc_media_streamrecorder_enable_source_buffer_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_cancel_p", utc_media_streamrecorder_cancel_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_cancel_n", utc_media_streamrecorder_cancel_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_commit_p", utc_media_streamrecorder_commit_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_commit_n", utc_media_streamrecorder_commit_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_destroy_p", utc_media_streamrecorder_destroy_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_destroy_n", utc_media_streamrecorder_destroy_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_pause_p", utc_media_streamrecorder_pause_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_pause_n", utc_media_streamrecorder_pause_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_cancel_p", utc_media_streamrecorder_cancel_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_cancel_n", utc_media_streamrecorder_cancel_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_destroy_p", utc_media_streamrecorder_destroy_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_destroy_n", utc_media_streamrecorder_destroy_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_p", utc_media_streamrecorder_prepare_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_n1", utc_media_streamrecorder_prepare_n1, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_n2", utc_media_streamrecorder_prepare_n2, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, diff --git a/src/utc/streamrecorder/tct-streamrecorder-core_tv.h b/src/utc/streamrecorder/tct-streamrecorder-core_tv.h index 704f72d..1ffb0a6 100755 --- a/src/utc/streamrecorder/tct-streamrecorder-core_tv.h +++ b/src/utc/streamrecorder/tct-streamrecorder-core_tv.h @@ -67,14 +67,14 @@ extern int utc_media_streamrecorder_unset_error_cb_p(void); extern int utc_media_streamrecorder_unset_error_cb_n(void); extern int utc_media_streamrecorder_enable_source_buffer_n(void); extern int utc_media_streamrecorder_enable_source_buffer_p(void); -extern int utc_media_streamrecorder_cancel_p(void); -extern int utc_media_streamrecorder_cancel_n(void); extern int utc_media_streamrecorder_commit_p(void); extern int utc_media_streamrecorder_commit_n(void); -extern int utc_media_streamrecorder_destroy_p(void); -extern int utc_media_streamrecorder_destroy_n(void); extern int utc_media_streamrecorder_pause_p(void); extern int utc_media_streamrecorder_pause_n(void); +extern int utc_media_streamrecorder_cancel_p(void); +extern int utc_media_streamrecorder_cancel_n(void); +extern int utc_media_streamrecorder_destroy_p(void); +extern int utc_media_streamrecorder_destroy_n(void); extern int utc_media_streamrecorder_prepare_p(void); extern int utc_media_streamrecorder_prepare_n1(void); extern int utc_media_streamrecorder_prepare_n2(void); @@ -194,14 +194,14 @@ testcase tc_array[] = { {"utc_media_streamrecorder_unset_error_cb_n", utc_media_streamrecorder_unset_error_cb_n, utc_media_streamrecorder_callback_startup, utc_media_streamrecorder_callback_cleanup}, {"utc_media_streamrecorder_enable_source_buffer_n", utc_media_streamrecorder_enable_source_buffer_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_enable_source_buffer_p", utc_media_streamrecorder_enable_source_buffer_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_cancel_p", utc_media_streamrecorder_cancel_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_cancel_n", utc_media_streamrecorder_cancel_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_commit_p", utc_media_streamrecorder_commit_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_commit_n", utc_media_streamrecorder_commit_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_destroy_p", utc_media_streamrecorder_destroy_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_destroy_n", utc_media_streamrecorder_destroy_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_pause_p", utc_media_streamrecorder_pause_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_pause_n", utc_media_streamrecorder_pause_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_cancel_p", utc_media_streamrecorder_cancel_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_cancel_n", utc_media_streamrecorder_cancel_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_destroy_p", utc_media_streamrecorder_destroy_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_destroy_n", utc_media_streamrecorder_destroy_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_p", utc_media_streamrecorder_prepare_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_n1", utc_media_streamrecorder_prepare_n1, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_n2", utc_media_streamrecorder_prepare_n2, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, diff --git a/src/utc/streamrecorder/tct-streamrecorder-core_wearable.h b/src/utc/streamrecorder/tct-streamrecorder-core_wearable.h index 704f72d..1ffb0a6 100755 --- a/src/utc/streamrecorder/tct-streamrecorder-core_wearable.h +++ b/src/utc/streamrecorder/tct-streamrecorder-core_wearable.h @@ -67,14 +67,14 @@ extern int utc_media_streamrecorder_unset_error_cb_p(void); extern int utc_media_streamrecorder_unset_error_cb_n(void); extern int utc_media_streamrecorder_enable_source_buffer_n(void); extern int utc_media_streamrecorder_enable_source_buffer_p(void); -extern int utc_media_streamrecorder_cancel_p(void); -extern int utc_media_streamrecorder_cancel_n(void); extern int utc_media_streamrecorder_commit_p(void); extern int utc_media_streamrecorder_commit_n(void); -extern int utc_media_streamrecorder_destroy_p(void); -extern int utc_media_streamrecorder_destroy_n(void); extern int utc_media_streamrecorder_pause_p(void); extern int utc_media_streamrecorder_pause_n(void); +extern int utc_media_streamrecorder_cancel_p(void); +extern int utc_media_streamrecorder_cancel_n(void); +extern int utc_media_streamrecorder_destroy_p(void); +extern int utc_media_streamrecorder_destroy_n(void); extern int utc_media_streamrecorder_prepare_p(void); extern int utc_media_streamrecorder_prepare_n1(void); extern int utc_media_streamrecorder_prepare_n2(void); @@ -194,14 +194,14 @@ testcase tc_array[] = { {"utc_media_streamrecorder_unset_error_cb_n", utc_media_streamrecorder_unset_error_cb_n, utc_media_streamrecorder_callback_startup, utc_media_streamrecorder_callback_cleanup}, {"utc_media_streamrecorder_enable_source_buffer_n", utc_media_streamrecorder_enable_source_buffer_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_enable_source_buffer_p", utc_media_streamrecorder_enable_source_buffer_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_cancel_p", utc_media_streamrecorder_cancel_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_cancel_n", utc_media_streamrecorder_cancel_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_commit_p", utc_media_streamrecorder_commit_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_commit_n", utc_media_streamrecorder_commit_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_destroy_p", utc_media_streamrecorder_destroy_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, - {"utc_media_streamrecorder_destroy_n", utc_media_streamrecorder_destroy_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_pause_p", utc_media_streamrecorder_pause_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_pause_n", utc_media_streamrecorder_pause_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_cancel_p", utc_media_streamrecorder_cancel_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_cancel_n", utc_media_streamrecorder_cancel_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_destroy_p", utc_media_streamrecorder_destroy_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, + {"utc_media_streamrecorder_destroy_n", utc_media_streamrecorder_destroy_n, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_p", utc_media_streamrecorder_prepare_p, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_n1", utc_media_streamrecorder_prepare_n1, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, {"utc_media_streamrecorder_prepare_n2", utc_media_streamrecorder_prepare_n2, utc_media_streamrecorder_lifecycle_startup, utc_media_streamrecorder_lifecycle_cleanup}, diff --git a/src/utc/streamrecorder/utc_media_streamrecorder_lifecycle.c b/src/utc/streamrecorder/utc_media_streamrecorder_lifecycle.c index 635c524..f3a59aa 100644 --- a/src/utc/streamrecorder/utc_media_streamrecorder_lifecycle.c +++ b/src/utc/streamrecorder/utc_media_streamrecorder_lifecycle.c @@ -76,16 +76,15 @@ static void _consume_completed_cb(void *buffer , void *user_data){ */ void utc_media_streamrecorder_lifecycle_startup(void) { + startup_ret = STREAMRECORDER_ERROR_NONE; - startup_ret = STREAMRECORDER_ERROR_NONE; - - storage_foreach_device_supported(storage_device_cb,NULL); - startup_ret |= streamrecorder_create(&recorder); + storage_foreach_device_supported(storage_device_cb,NULL); + startup_ret |= streamrecorder_create(&recorder); } /** - * @function utc_media_streamrecorder_lifecycle_cleanup + * @function utc_media_streamrecorder_lifecycle_cleanup * @description Called after each test. This is the postcondition for checking apis. \n This postcondition is streamrecorder_destroy api for cleaning up the resources properly. @@ -96,6 +95,8 @@ void utc_media_streamrecorder_lifecycle_startup(void) */ void utc_media_streamrecorder_lifecycle_cleanup(void) { + int i; + if (recorder) { streamrecorder_destroy(recorder); recorder = NULL; @@ -108,6 +109,17 @@ void utc_media_streamrecorder_lifecycle_cleanup(void) free(file_path); file_path = NULL; } + + for (i = 0; i < 10; i++) { + if (media_format[i] != NULL) { + media_format_unref(media_format[i]); + media_format[i] = NULL; + } + if (vid_pkt[i] != NULL) { + media_packet_destroy(vid_pkt[i]); + vid_pkt[i] = NULL; + } + } } @@ -247,12 +259,7 @@ int utc_media_streamrecorder_cancel_p(void) } ret = streamrecorder_cancel(recorder); streamrecorder_unprepare(recorder); - for (i = 0; i <10;i++) { - if (media_format[i] != NULL) - media_format_unref(media_format[i]); - if (vid_pkt[i] != NULL) - media_packet_destroy(vid_pkt[i]); - } + fclose(pvFile); assert_eq(ret, STREAMRECORDER_ERROR_NONE); return 0; @@ -375,12 +382,6 @@ int utc_media_streamrecorder_commit_p(void) ret = streamrecorder_commit(recorder); streamrecorder_unprepare(recorder); - for (i = 0; i <10;i++) { - if (media_format[i] != NULL) - media_format_unref(media_format[i]); - if (vid_pkt[i] != NULL) - media_packet_destroy(vid_pkt[i]); - } fclose(pvFile); assert_eq(ret, STREAMRECORDER_ERROR_NONE); @@ -565,16 +566,9 @@ int utc_media_streamrecorder_pause_p(void) count = count + 33000000; } - ret = streamrecorder_pause(recorder); streamrecorder_cancel(recorder); streamrecorder_unprepare(recorder); - for (i = 0; i <10;i++) { - if (media_format[i] != NULL) - media_format_unref(media_format[i]); - if (vid_pkt[i] != NULL) - media_packet_destroy(vid_pkt[i]); - } fclose(pvFile); assert_eq(ret, STREAMRECORDER_ERROR_NONE);