[ITC][player][Non-ACR] Fix bug for media_format_h use 88/281288/1
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 15 Sep 2022 07:15:54 +0000 (16:15 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 15 Sep 2022 07:17:59 +0000 (07:17 +0000)
Change-Id: Ib70ec872db1c2dcf51ad98c0c2362b78a80dc78e

src/itc/player/ITs-player.c

index ee6212dcf891e2f6416b46af73a2b938198e91b1..b7ddf18f4cf01a6e8dac1a44588856d2274709e0 100755 (executable)
@@ -438,6 +438,7 @@ static void PlayerAudioDecodedCb(media_packet_h pkt, void *user_data)
        if(nRet != MEDIA_PACKET_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] media_format_get_audio_info failed.\n", __LINE__, API_NAMESPACE);
+               media_format_unref(hMediaFormat);
                return;
        }
 
@@ -445,9 +446,12 @@ static void PlayerAudioDecodedCb(media_packet_h pkt, void *user_data)
        if(nRet != MEDIA_PACKET_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] media_format_get_audio_channel_mask failed.\n", __LINE__, API_NAMESPACE);
+               media_format_unref(hMediaFormat);
                return;
        }
 
+       media_format_unref(hMediaFormat);
+
        if (tMask == 0) {
                tMask = tChannelMask;
        }
@@ -3683,6 +3687,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_le_deinterle
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -3699,7 +3704,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_le_deinterle
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -3812,6 +3816,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_le_no_sync_a
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -3828,7 +3833,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_le_no_sync_a
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -3941,6 +3945,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_be_deinterle
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -3957,7 +3962,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_be_deinterle
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -4070,6 +4074,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_be_no_sync_a
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -4086,7 +4091,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_signed_be_no_sync_a
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -4198,6 +4202,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_float_deinterleave_
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -4214,7 +4219,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_float_deinterleave_
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -4326,6 +4330,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_float_no_sync_and_d
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -4342,7 +4347,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_float_no_sync_and_d
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -4455,6 +4459,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_le_deinter
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -4471,7 +4476,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_le_deinter
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -4584,6 +4588,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_le_no_sync
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -4600,7 +4605,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_le_no_sync
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -4713,6 +4717,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_be_no_sync
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -4720,16 +4725,15 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_be_no_sync
                        nRet = player_start(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_start", PlayerGetError(nRet));
 
-                       for(nRepeat = 0; nRepeat < LIMIT; nRepeat++) {
+                       for (nRepeat = 0; nRepeat < LIMIT; nRepeat++) {
                                PlayerWaitForAsync2(TIMEOUT2);
-                               if(g_bPlayerAudioDecodedCallback)
+                               if (g_bPlayerAudioDecodedCallback)
                                        break;
                        }
 
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;
@@ -4842,6 +4846,7 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_be_deinter
 
                        nRet = media_format_unref(hMediaFormat);
                        PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_unref", MediaFormatGetError(nRet));
+                       hMediaFormat = NULL;
 
                        nRet = player_prepare(g_player);
                        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
@@ -4858,7 +4863,6 @@ int ITc_player_set_unset_media_packet_audio_frame_decoded_cb_unsigned_be_deinter
                        if (!g_bPlayerAudioDecodedCallback)
                        {
                                FPRINTF("[Line : %d][%s] player_audio_decoded_cb failed, error returned = callback not invoked\n", __LINE__, API_NAMESPACE);
-                               media_format_unref(hMediaFormat);
                                player_stop(g_player);
                                player_unprepare(g_player);
                                return 1;