[ITC][player][Non-ACR] Fix bug for media_format_h use 87/281287/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:46 +0000 (07:17 +0000)
Change-Id: Ib70ec872db1c2dcf51ad98c0c2362b78a80dc78e

src/itc/player/ITs-player.c

index 84ff599e470f064bafbd0ef957ea06bc8c176a57..fe107d676b83e2934cd0bc409d896a5b8f0be32b 100755 (executable)
@@ -434,6 +434,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;
        }
 
@@ -441,9 +442,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;
        }
@@ -3437,6 +3441,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));
@@ -3453,7 +3458,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;
@@ -3566,6 +3570,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));
@@ -3582,7 +3587,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;
@@ -3695,6 +3699,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));
@@ -3711,7 +3716,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;
@@ -3824,6 +3828,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));
@@ -3840,7 +3845,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;
@@ -3952,6 +3956,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));
@@ -3968,7 +3973,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;
@@ -4080,6 +4084,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));
@@ -4096,7 +4101,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;
@@ -4209,6 +4213,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));
@@ -4225,7 +4230,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;
@@ -4338,6 +4342,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));
@@ -4354,7 +4359,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;
@@ -4467,6 +4471,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));
@@ -4474,16 +4479,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;
@@ -4596,6 +4600,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));
@@ -4612,7 +4617,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;