Fix SVACE 71/55971/2 accepted/tizen/mobile/20151231.072009 accepted/tizen/tv/20151231.072025 accepted/tizen/wearable/20151231.072043 submit/tizen/20151230.232626
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 30 Dec 2015 13:49:11 +0000 (22:49 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 30 Dec 2015 13:50:43 +0000 (22:50 +0900)
Change-Id: Ie7590cb3fc15ec2423a742c319f088af2a0f2057

mm_sound_pa_client.c
server/mm_sound_mgr_codec.c
server/plugin/ogg/mm_sound_plugin_codec_ogg.c
testsuite/mm_sound_testsuite_simple.c

index b6baf58..e2e0af9 100644 (file)
@@ -204,7 +204,7 @@ int mm_sound_pa_open(MMSoundHandleMode mode, mm_sound_handle_route_info *route_i
     int handle_mode = mode;
     int handle_inout = HANDLE_DIRECTION_NONE;
     int sample_size = 0;
-    pa_proplist *proplist = pa_proplist_new();
+    pa_proplist *proplist = NULL;
 
     mm_sound_handle_t* handle = NULL;
     MMSoundHandleRoutePolicy policy = HANDLE_ROUTE_POLICY_DEFAULT;
@@ -216,6 +216,8 @@ int mm_sound_pa_open(MMSoundHandleMode mode, mm_sound_handle_route_info *route_i
     if (ss->channels < MM_SOUND_CHANNEL_MIN || ss->channels > MM_SOUND_CHANNEL_MAX)
         return MM_ERROR_INVALID_ARGUMENT;
 
+    proplist = pa_proplist_new();
+
     if(channel_map == NULL) {
         pa_channel_map_init_auto(&maps, ss->channels, PA_CHANNEL_MAP_ALSA);
         channel_map = &maps;
index fb030b9..2a0a3d8 100644 (file)
@@ -847,10 +847,14 @@ static int _MMSoundMgrCodecStopCallback(int param)
 
        debug_enter("(Slot : %d)\n", param);
 
+       if (param < 0 || param >= MANAGER_HANDLE_MAX) {
+               debug_error ("Slot index param [%d] is invalid", param);
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
        pthread_mutex_lock(&g_slot_mutex);
        debug_msg("[CODEC MGR] Slot_mutex lock done\n");
 
-
        /*
         * Unregister FOCUS here
         */
index 43db7b0..ee7d4e4 100644 (file)
@@ -206,6 +206,7 @@ int MMSoundPlugCodecOggCreate(mmsound_codec_param_t *param, mmsound_codec_info_t
        MMSourceType *source = NULL;
        OGG_DEC_INFO ogg_info;
        int err, used_size, skipsize;
+       int ret = MM_ERROR_NONE;
 
        mm_sound_handle_route_info route_info;
        route_info.policy = HANDLE_ROUTE_POLICY_OUT_AUTO;
@@ -239,64 +240,43 @@ int MMSoundPlugCodecOggCreate(mmsound_codec_param_t *param, mmsound_codec_info_t
        err = sem_init(&p->start_ogg_signal, 0, 0);
        if (err == -1) {
                debug_error("[CODEC OGG]Semaphore init fail\n");
-               free(p);
-               return MM_ERROR_SOUND_INTERNAL;
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto error_before_create;
        }
 
        err = sem_init(&p->start_wave_signal, 0, 0);
        if (err == -1) {
                debug_error("[CODEC OGG]Semaphore init fail\n");
                sem_destroy(&p->start_ogg_signal);
-               free(p);
-               return MM_ERROR_SOUND_INTERNAL;
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto error_before_create;
        }
 
        err = OGGDEC_CreateDecode(&p->decoder);
        if (err != OGGDEC_SUCCESS) {
                debug_error("[CODEC OGG]Fail to Create ogg decoder\n");
-               sem_destroy(&p->start_ogg_signal);
-               sem_destroy(&p->start_wave_signal);
-               if (p->decoder) {
-                       OGGDEC_ResetDecode(p->decoder);
-                       OGGDEC_DeleteDecode(p->decoder);
-               }
-               free(p);
-               return MM_ERROR_SOUND_INTERNAL;
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto error_before_create;
        }
        p->pcm_out_buf = (char *)malloc(sizeof(char)*OGG_DEC_BUF_SIZE);
        if (p->pcm_out_buf == NULL) {
                debug_error("[CODEC OGG]Memory allocation fail\n");
-               sem_destroy(&p->start_ogg_signal);
-               sem_destroy(&p->start_wave_signal);
-               OGGDEC_ResetDecode(p->decoder);
-               OGGDEC_DeleteDecode(p->decoder);
-               free(p);
-               return MM_ERROR_SOUND_NO_FREE_SPACE;
+               ret = MM_ERROR_SOUND_NO_FREE_SPACE;
+               goto error_after_create;
        }
        err = OGGDEC_InitDecode(p->decoder, (unsigned char*)p->source->ptr, p->BufferSize, &skipsize);
-       if (err != OGGDEC_SUCCESS || p->decoder == NULL) {
+       if (err != OGGDEC_SUCCESS) {
                debug_error("Fail to init ogg decoder\n");
-               sem_destroy(&p->start_ogg_signal);
-               sem_destroy(&p->start_wave_signal);
-               OGGDEC_ResetDecode(p->decoder);
-               OGGDEC_DeleteDecode(p->decoder);
-               free(p->pcm_out_buf);
-               free(p);
-               return MM_ERROR_SOUND_INTERNAL;
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto error_after_buffer;
        }
        p->offset = skipsize;
 
        err = OGGDEC_InfoDecode(p->decoder, p->source->ptr+p->offset, &used_size, &ogg_info);
-       if (err != OGGDEC_SUCCESS || p->decoder == NULL)
-       {
+       if (err != OGGDEC_SUCCESS) {
                debug_error("[CODEC OGG]Fail to get ogg info\n");
-               sem_destroy(&p->start_ogg_signal);
-               sem_destroy(&p->start_wave_signal);
-               OGGDEC_ResetDecode(p->decoder);
-               OGGDEC_DeleteDecode(p->decoder);
-               free(p->pcm_out_buf);
-               free(p);
-               return MM_ERROR_SOUND_INTERNAL;
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto error_after_buffer;
        }
        p->offset += used_size;
        p->Duration = info->duration;
@@ -380,14 +360,9 @@ int MMSoundPlugCodecOggCreate(mmsound_codec_param_t *param, mmsound_codec_info_t
                if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) {
                        __mm_sound_unlock();
                }
-               
-               sem_destroy(&p->start_ogg_signal);
-               sem_destroy(&p->start_wave_signal);
-               OGGDEC_ResetDecode(p->decoder);
-               OGGDEC_DeleteDecode(p->decoder);
-               free(p->pcm_out_buf);
-               free(p);
-               return MM_ERROR_SOUND_INTERNAL;
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto error_after_buffer;
+
        }
 
        pthread_mutex_lock(&p->mutex);
@@ -399,19 +374,27 @@ int MMSoundPlugCodecOggCreate(mmsound_codec_param_t *param, mmsound_codec_info_t
        if (err) {
                if (p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER || p->handle_route == MM_SOUND_HANDLE_ROUTE_SPEAKER_NO_RESTORE) {
                        __mm_sound_unlock();
-               }               
-               sem_destroy(&p->start_ogg_signal);
-               sem_destroy(&p->start_wave_signal);
-               OGGDEC_ResetDecode(p->decoder);
-               OGGDEC_DeleteDecode(p->decoder);
-               free(p->pcm_out_buf);
-               free(p);
+               }
                debug_error("[CODEC OGG]pthread_create() fail in pcm thread\n");
-               return MM_ERROR_SOUND_INTERNAL;
+               ret = MM_ERROR_SOUND_INTERNAL;
+               goto error_after_buffer;
        }
 
        debug_leave("\n");
        return MM_ERROR_NONE;
+
+error_after_buffer:
+       free(p->pcm_out_buf);
+
+error_after_create:
+       sem_destroy(&p->start_ogg_signal);
+       sem_destroy(&p->start_wave_signal);
+       OGGDEC_ResetDecode(p->decoder);
+       OGGDEC_DeleteDecode(p->decoder);
+
+error_before_create:
+       free(p);
+       return ret;
 }
 
 int MMSoundPlugCodecOggPlay(MMHandleType handle)
index d6c9a39..c8424ce 100755 (executable)
@@ -692,7 +692,6 @@ static void interpret (char *cmd)
 
                                if(flag_1 == '0') { id = 0; }
                                else if(flag_1 == '1') { id = 1; }
-                               else if(flag_1 == '2') { id = 2; }
                                else { id = 2; }
 
                                if(flag_2 == '1') { type = FOCUS_FOR_PLAYBACK; }