[0.6.100] remove session backward compatibility codes 64/174564/3
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 3 Apr 2018 04:29:29 +0000 (13:29 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 4 Apr 2018 02:05:51 +0000 (11:05 +0900)
Change-Id: Ic580cdaa08bb0956dc94801e9b40678dffaf5851
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/libmm-player.spec
src/Makefile.am
src/include/mm_player.h
src/include/mm_player_priv.h
src/include/mm_player_sound_focus.h [deleted file]
src/include/mm_player_utils.h
src/mm_player.c
src/mm_player_priv.c
src/mm_player_sound_focus.c [deleted file]

index d2dceba..b00325a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.99
+Version:    0.6.100
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 2458c29..97ba074 100644 (file)
@@ -9,7 +9,6 @@ includelibmmfplayer_HEADERS = include/mm_player.h \
 libmmfplayer_la_SOURCES = mm_player.c \
                          mm_player_priv.c \
                          mm_player_utils.c \
-                         mm_player_sound_focus.c \
                          mm_player_capture.c \
                          mm_player_pd.c \
                          mm_player_streaming.c \
@@ -27,7 +26,6 @@ libmmfplayer_la_CFLAGS =  -I$(srcdir)/include \
                        $(GST_CFLAGS) \
                        $(GST_VIDEO_CFLAGS) \
                        $(GST_APP_CFLAGS) \
-                       $(MMSESSION_CFLAGS) \
                        $(MMSOUND_CFLAGS) \
                        $(MM_RESOURCE_MANAGER_CFLAGS) \
                        $(ICU_CFLAGS) \
@@ -43,7 +41,6 @@ libmmfplayer_la_CFLAGS =  -I$(srcdir)/include \
 noinst_HEADERS = include/mm_player_utils.h \
                 include/mm_player_ini.h \
                 include/mm_player_priv.h \
-                include/mm_player_sound_focus.h \
                 include/mm_player_attrs.h \
                 include/mm_player_capture.h \
                 include/mm_player_pd.h \
@@ -59,7 +56,6 @@ libmmfplayer_la_LIBADD = $(GST_LIBS) \
                $(GST_VIDEO_LIBS) \
                $(GST_APP_LIBS) \
                $(INIPARSER_LIBS) \
-               $(MMSESSION_LIBS) \
                $(MMSOUND_LIBS) \
                $(MM_RESOURCE_MANAGER_LIBS) \
                $(ICU_LIBS) \
index a8f7c05..7638534 100644 (file)
@@ -1066,34 +1066,6 @@ if (mm_player_destroy(g_player) != MM_ERROR_NONE) {
 int mm_player_destroy(MMHandleType player);
 
 /**
- * This function register the sound focus using application PID \n
- * So, application PID should be set before realizing with mm_player_set_attribute(). \n
- *
- * @param      player          [in]    Handle of player
- * @param      pid                     [in]    application PID
- *
- * @return     This function returns zero on success, or negative value with error code.
- *
- * @pre                Player state should be MM_PLAYER_STATE_NULL.
- * @remark     None
- */
-int mm_player_sound_register(MMHandleType player, int pid);
-
-/**
- * This function get the application PID that is registered \n
- * So, application PID should be set before realizing with mm_player_set_attribute(). \n
- *
- * @param      player          [in]    Handle of player
- * @param      pid                     [out]   application PID
- *
- * @return     This function returns zero on success, or negative value with error code.
- *
- * @pre                Player state should be MM_PLAYER_STATE_NULL.
- * @remark     None
- */
-int mm_player_get_client_pid(MMHandleType player, int* pid);
-
-/**
  * This function parses uri and makes gstreamer pipeline by uri scheme. \n
  * So, uri should be set before realizing with mm_player_set_attribute(). \n
  *
index 972aded..7e7a64e 100644 (file)
@@ -44,7 +44,6 @@
 #include "mm_message.h"
 #include "mm_player_ini.h"
 #include <mm_resource_manager.h>
-#include "mm_player_sound_focus.h"
 #include "mm_player_pd.h"
 #include "mm_player_streaming.h"
 
@@ -404,6 +403,7 @@ typedef struct {
        float volume;
        int mute;
        int bluetooth;  /* enable/disable */
+       int focus_id;
 } MMPlayerSoundInfo;
 
 typedef struct {
@@ -757,9 +757,6 @@ typedef struct {
        mm_resource_manager_res_h video_decoder_resource;
        gboolean interrupted_by_resource;
 
-       /* sound focus for being compatible with legacy session policy internally */
-       MMPlayerSoundFocus sound_focus;
-
        gboolean is_subtitle_off;
        gboolean is_external_subtitle_present;
        gboolean is_external_subtitle_added_now;
@@ -774,10 +771,6 @@ typedef struct {
        /* prevent it from posting duplicatly*/
        gboolean sent_bos;
 
-       /* timeout source for lazy pause */
-       guint resume_event_id;
-       guint resumable_cancel_id;
-
        gboolean play_subtitle;
        gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
 
@@ -973,8 +966,6 @@ gint __gst_handle_core_error(mm_player_t* player, int code);
 gint __gst_handle_library_error(mm_player_t* player, int code);
 gint __gst_handle_resource_error(mm_player_t* player, int code, GstMessage * message);
 gint __gst_handle_stream_error(mm_player_t* player, GError* error, GstMessage * message);
-int _mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid);
-int _mmplayer_get_client_pid(MMHandleType hplayer, int* pid);
 int __mmplayer_get_video_angle(mm_player_t* player, int *user_angle, int *org_angle);
 int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo);
 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
diff --git a/src/include/mm_player_sound_focus.h b/src/include/mm_player_sound_focus.h
deleted file mode 100644 (file)
index 4538dce..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * libmm-player
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Heechul Jeon <heechul.jeon@samsung.com>
- * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_PLAYER_SOUND_FOCUS_H__
-#define __MM_PLAYER_SOUND_FOCUS_H__
-
-#include <glib.h>
-#include <mm_types.h>
-
-#include <mm_session.h>
-#include <mm_session_private.h>
-#include <mm_sound_focus.h>
-#include <mm_sound.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
-       int focus_id;
-       int watch_id;
-       unsigned int subscribe_id;
-       unsigned int connected_id;
-       int pid;
-       bool by_asm_cb;
-       int antishock;
-       bool keep_last_pos;
-       int user_route_policy;
-       bool exit_cb;
-       bool cb_pending;
-       bool acquired;
-       int session_type;
-       int session_flags;
-       int focus_changed_msg;  // MMPlayerFocusChangedMsg
-       GMutex focus_lock;
-
-} MMPlayerSoundFocus;
-
-gint _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus, mm_sound_focus_changed_cb focus_cb, mm_sound_focus_changed_watch_cb watch_cb, void* param);
-gint _mmplayer_sound_unregister(MMPlayerSoundFocus* sound_focus);
-int _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus);
-int _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus);
-bool _mmplayer_is_using_internal_sound_focus(MMPlayerSoundFocus* sound_focus);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MM_PLAYER_SOUND_FOCUS_H__ */
index 9cca3ce..281250d 100644 (file)
@@ -118,10 +118,6 @@ do {       \
 #define MMPLAYER_SUBTITLE_INFO_WAIT_UNTIL(x_player, end_time)     g_cond_wait_until(&((mm_player_t *)x_player)->subtitle_info_cond, &((mm_player_t *)x_player)->subtitle_info_mutex, end_time)
 #define MMPLAYER_SUBTITLE_INFO_SIGNAL(x_player)                   g_cond_signal(&((mm_player_t *)x_player)->subtitle_info_cond);
 
-/* sound focus lock */
-#define MMPLAYER_SOUND_FOCUS_LOCK(x_player_sound_focus)           g_mutex_lock(&((MMPlayerSoundFocus *)x_player_sound_focus)->focus_lock)
-#define MMPLAYER_SOUND_FOCUS_UNLOCK(x_player_sound_focus)         g_mutex_unlock(&((MMPlayerSoundFocus *)x_player_sound_focus)->focus_lock)
-
 #if 0
 #define MMPLAYER_FENTER();                                     LOGD("<ENTER>");
 #define MMPLAYER_FLEAVE();                                     LOGD("<LEAVE>");
index c5e2cff..beb2564 100644 (file)
@@ -35,7 +35,6 @@
 #include "mm_player_capture.h"
 #include "mm_player_tracks.h"
 #include "mm_player_es.h"
-#include "mm_player_sound_focus.h"
 #include "mm_player_360.h"
 
 int mm_player_create(MMHandleType *player)
@@ -125,37 +124,6 @@ int  mm_player_destroy(MMHandleType player)
        return result;
 }
 
-int mm_player_sound_register(MMHandleType player, int pid)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_sound_register_with_pid(player, pid);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
-int mm_player_get_client_pid(MMHandleType player, int* pid)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_get_client_pid(player, pid);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
 int mm_player_realize(MMHandleType player)
 {
        int result = MM_ERROR_NONE;
@@ -1217,7 +1185,6 @@ int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int
 
        MMPLAYER_CMD_LOCK(player);
 
-       _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
        result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
 
        MMPLAYER_CMD_UNLOCK(player);
index 5658983..9b8216d 100755 (executable)
@@ -40,8 +40,6 @@
 #include <mm_error.h>
 #include <mm_attrs.h>
 #include <mm_attrs_private.h>
-#include <mm_sound.h>
-#include <mm_sound_focus.h>
 
 #include "mm_player_priv.h"
 #include "mm_player_ini.h"
@@ -570,9 +568,7 @@ int
 __mmplayer_set_state(mm_player_t* player, int state)
 {
        MMMessageParamType msg = {0, };
-       int sound_result = MM_ERROR_NONE;
        gboolean post_bos = FALSE;
-       gboolean interrupted_by_focus = FALSE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -592,21 +588,9 @@ __mmplayer_set_state(mm_player_t* player, int state)
        /* print state */
        MMPLAYER_PRINT_STATE(player);
 
-       /* do some FSM stuffs before posting new state to application  */
-       interrupted_by_focus = player->sound_focus.by_asm_cb;
-
        switch (MMPLAYER_CURRENT_STATE(player)) {
        case MM_PLAYER_STATE_NULL:
        case MM_PLAYER_STATE_READY:
-               {
-                       if (player->cmd == MMPLAYER_COMMAND_STOP) {
-                               sound_result = _mmplayer_sound_release_focus(&player->sound_focus);
-                               if (sound_result != MM_ERROR_NONE) {
-                                       LOGE("failed to release sound focus\n");
-                                       return MM_ERROR_POLICY_INTERNAL;
-                               }
-                       }
-               }
                break;
 
        case MM_PLAYER_STATE_PAUSED:
@@ -637,14 +621,6 @@ __mmplayer_set_state(mm_player_t* player, int state)
                        if (!player->audio_cb_probe_id && player->set_mode.pcm_extraction && !player->audio_stream_render_cb_ex)
                                __mmplayer_configure_audio_callback(player);
                                /* FIXIT : handle return value */
-
-                       if (!MMPLAYER_IS_STREAMING(player) || (player->streamer && !player->streamer->is_buffering)) {
-                               sound_result = _mmplayer_sound_release_focus(&player->sound_focus);
-                               if (sound_result != MM_ERROR_NONE) {
-                                       LOGE("failed to release sound focus\n");
-                                       return MM_ERROR_POLICY_INTERNAL;
-                               }
-                       }
                }
                break;
 
@@ -661,26 +637,6 @@ __mmplayer_set_state(mm_player_t* player, int state)
                        if ((player->cmd == MMPLAYER_COMMAND_START) || (player->cmd == MMPLAYER_COMMAND_RESUME)) {
                                if (!player->sent_bos)
                                        __mmplayer_handle_missed_plugin(player);
-                               sound_result = _mmplayer_sound_acquire_focus(&player->sound_focus);
-                               if (sound_result != MM_ERROR_NONE) {
-                                       // FIXME : need to check history
-                                       if (player->pipeline->videobin) {
-                                               MMMessageParamType msg = {0, };
-
-                                               LOGE("failed to go ahead because of video conflict\n");
-
-                                               msg.union_type = MM_MSG_UNION_CODE;
-                                               msg.code = MM_PLAYER_FOCUS_CHANGED_BY_RESOURCE_CONFLICT;
-                                               MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, &msg);
-
-                                               _mmplayer_unrealize((MMHandleType)player);
-                                       } else {
-                                               LOGE("failed to play by sound focus error : 0x%X\n", sound_result);
-                                               _mmplayer_pause((MMHandleType)player);
-                                       }
-
-                                       return MM_ERROR_POLICY_INTERNAL;
-                               }
                        }
 
                        if (player->resumed_by_rewind && player->playback_rate < 0.0) {
@@ -739,12 +695,9 @@ __mmplayer_set_state(mm_player_t* player, int state)
 
                LOGD("player reach the target state (%s)", MMPLAYER_STATE_GET_NAME(MMPLAYER_TARGET_STATE(player)));
 
-               /* state changed by focus or resource callback */
-               if (interrupted_by_focus || player->interrupted_by_resource) {
-                       if (interrupted_by_focus)
-                               msg.state.code = player->sound_focus.focus_changed_msg;
-                       else if (player->interrupted_by_resource)
-                               msg.state.code = MM_PLAYER_FOCUS_CHANGED_BY_RESOURCE_CONFLICT;
+               /* state changed by resource callback */
+               if (player->interrupted_by_resource) {
+                       msg.state.code = MM_PLAYER_FOCUS_CHANGED_BY_RESOURCE_CONFLICT;
                        MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, &msg);
                } else { /* state changed by usecase */
                        MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_CHANGED, &msg);
@@ -4564,16 +4517,16 @@ void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType att
        if (!stream_type) {
                LOGE("stream_type is null.\n");
        } else {
-               if (player->sound_focus.focus_id)
-                       snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_id=%d, mused.client_pid=%d",
-                                       stream_type, stream_id, player->sound_focus.focus_id, player->sound_focus.pid);
+               if (player->sound.focus_id)
+                       snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_id=%d",
+                                       stream_type, stream_id, player->sound.focus_id);
                else
-                       snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, mused.client_pid=%d",
-                                       stream_type, stream_id, player->sound_focus.pid);
+                       snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d",
+                                       stream_type, stream_id);
                props = gst_structure_from_string(stream_props, NULL);
                g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "stream-properties", props, NULL);
-               LOGI("stream_type[%s], stream_id[%d], focus_id[%d], client_pid[%d], result[%s].\n",
-                       stream_type, stream_id, player->sound_focus.focus_id, player->sound_focus.pid, stream_props);
+               LOGI("stream_type[%s], stream_id[%d], focus_id[%d], result[%s].\n",
+                       stream_type, stream_id, player->sound.focus_id, stream_props);
                gst_structure_free(props);
        }
 
@@ -4591,20 +4544,6 @@ void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType att
                break;
        };
 
-#if 0 //need to check
-       if (player->sound_focus.user_route_policy != 0)
-               route_path = player->sound_focus.user_route_policy;
-
-       g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst,
-                       "latency", latency_mode,
-                       NULL);
-
-       LOGD("audiosink property status...volume type:%d, user-route=%d, latency=%d \n",
-               volume_type, route_path, latency_mode);
-       MMPLAYER_FLEAVE();
-
-#endif
-
        g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst,
                        "latency", latency,
                        NULL);
@@ -7463,7 +7402,7 @@ static int __gst_stop(mm_player_t* player)
        mm_attrs_get_int_by_name(attrs, "sound_fadedown", &fadedown);
 
        /* enable fadedown */
-       if (fadedown || player->sound_focus.by_asm_cb)
+       if (fadedown)
                __mmplayer_do_sound_fadedown(player, MM_PLAYER_FADEOUT_TIME_DEFAULT);
 
        /* Just set state to PAUESED and the rewind. it's usual player behavior. */
@@ -7479,7 +7418,7 @@ static int __gst_stop(mm_player_t* player)
        ret = __mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PAUSED, async, timeout);
 
        /* disable fadeout */
-       if (fadedown || player->sound_focus.by_asm_cb)
+       if (fadedown)
                __mmplayer_undo_sound_fadedown(player);
 
        /* return if set_state has failed */
@@ -7916,12 +7855,7 @@ __gst_get_position(mm_player_t* player, int format, unsigned long* position)
                if (player->duration > 0 && pos_msec > player->duration)
                        pos_msec = player->duration;
 
-               if (player->sound_focus.keep_last_pos) {
-                       LOGD("return last pos as stop by asm, %"GST_TIME_FORMAT, GST_TIME_ARGS(player->last_position));
-                       pos_msec = player->last_position;
-               } else {
-                       player->last_position = pos_msec;
-               }
+               player->last_position = pos_msec;
        }
 
        switch (format) {
@@ -8288,60 +8222,6 @@ exit:
        return ret;
 }
 
-gboolean _asm_postmsg(gpointer *data)
-{
-       mm_player_t* player = (mm_player_t*)data;
-       MMMessageParamType msg = {0, };
-
-       MMPLAYER_FENTER();
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
-       LOGW("get notified");
-
-       if ((player->cmd == MMPLAYER_COMMAND_DESTROY) ||
-               (player->cmd == MMPLAYER_COMMAND_UNREALIZE)) {
-               LOGW("dispatched");
-               return FALSE;
-       }
-
-
-       msg.union_type = MM_MSG_UNION_CODE;
-       msg.code = player->sound_focus.focus_changed_msg;
-
-       MMPLAYER_POST_MSG(player, MM_MESSAGE_READY_TO_RESUME, &msg);
-       player->resume_event_id = 0;
-
-       LOGW("dispatched");
-       return FALSE;
-}
-
-gboolean _asm_lazy_pause(gpointer *data)
-{
-       mm_player_t* player = (mm_player_t*)data;
-       int ret = MM_ERROR_NONE;
-
-       MMPLAYER_FENTER();
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
-
-       if (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PLAYING) {
-               LOGD("Ready to proceed lazy pause\n");
-               ret = _mmplayer_pause((MMHandleType)player);
-               if (MM_ERROR_NONE != ret)
-                       LOGE("MMPlayer pause failed in ASM callback lazy pause\n");
-       } else
-               LOGD("Invalid state to proceed lazy pause\n");
-
-       /* unset mute */
-       if (player->pipeline && player->pipeline->audiobin)
-               g_object_set(G_OBJECT(player->pipeline->audiobin[MMPLAYER_A_SINK].gst), "mute", 0, NULL);
-
-       player->sound_focus.by_asm_cb = FALSE; //should be reset here
-
-       MMPLAYER_FLEAVE();
-
-       return FALSE;
-}
-
 gboolean
 __mmplayer_can_do_interrupt(mm_player_t *player)
 {
@@ -8350,8 +8230,8 @@ __mmplayer_can_do_interrupt(mm_player_t *player)
                goto FAILED;
        }
 
-       if ((player->sound_focus.exit_cb) || (player->set_mode.pcm_extraction)) {
-               LOGW("leave from asm cb right now, %d, %d", player->sound_focus.exit_cb, player->set_mode.pcm_extraction);
+       if (player->set_mode.pcm_extraction) {
+               LOGW("leave right now, %d", player->set_mode.pcm_extraction);
                goto FAILED;
        }
 
@@ -8441,244 +8321,6 @@ __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res,
        return FALSE;
 }
 
-/* if you want to enable USE_ASM, please check the history get the ASM cb code. */
-static int
-__mmplayer_convert_sound_focus_state(gboolean acquire, const char *reason_for_change, MMPlayerFocusChangedMsg *msg)
-{
-       int ret = MM_ERROR_NONE;
-       MMPlayerFocusChangedMsg focus_msg = MM_PLAYER_FOCUS_CHANGED_BY_UNKNOWN;
-
-       if (strstr(reason_for_change, "alarm")) {
-               focus_msg = MM_PLAYER_FOCUS_CHANGED_BY_ALARM;
-
-       } else if (strstr(reason_for_change, "notification")) {
-               focus_msg = MM_PLAYER_FOCUS_CHANGED_BY_NOTIFICATION;
-
-       } else if (strstr(reason_for_change, "emergency")) {
-               focus_msg = MM_PLAYER_FOCUS_CHANGED_BY_EMERGENCY;
-
-       } else if (strstr(reason_for_change, "call-voice") ||
-                               strstr(reason_for_change, "call-video") ||
-                               strstr(reason_for_change, "voip") ||
-                               strstr(reason_for_change, "ringtone-voip") ||
-                               strstr(reason_for_change, "ringtone-call")) {
-               focus_msg = MM_PLAYER_FOCUS_CHANGED_BY_CALL;
-
-       } else if (strstr(reason_for_change, "media") ||
-                               strstr(reason_for_change, "radio") ||
-                               strstr(reason_for_change, "loopback") ||
-                               strstr(reason_for_change, "system") ||
-                               strstr(reason_for_change, "voice-information") ||
-                               strstr(reason_for_change, "voice-recognition")) {
-               focus_msg = MM_PLAYER_FOCUS_CHANGED_BY_MEDIA;
-
-       } else {
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               LOGW("not supported reason(%s), err(0x%08x)", reason_for_change, ret);
-               goto DONE;
-       }
-
-       if (acquire && (focus_msg != MM_PLAYER_FOCUS_CHANGED_BY_MEDIA))
-               /* can acqurie */
-               focus_msg = MM_PLAYER_FOCUS_CHANGED_COMPLETED;
-
-       LOGD("converted from reason(%s) to msg(%d)", reason_for_change, focus_msg);
-       *msg = focus_msg;
-
-DONE:
-       return ret;
-}
-
-/* FIXME: will be updated with new funct */
-void __mmplayer_sound_focus_watch_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
-                                      const char *reason_for_change, const char *additional_info, void *user_data)
-{
-       mm_player_t* player = (mm_player_t*) user_data;
-       int result = MM_ERROR_NONE;
-       MMPlayerFocusChangedMsg msg = MM_PLAYER_FOCUS_CHANGED_BY_UNKNOWN;
-
-       LOGW("[handle: %p] focus watch notified", player);
-
-       if (!__mmplayer_can_do_interrupt(player)) {
-               LOGW("no need to interrupt, so leave");
-               goto EXIT_WITHOUT_UNLOCK;
-       }
-
-       if (player->sound_focus.session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
-               LOGW("flags is UNINTERRUPTIBLE. do nothing.");
-               goto EXIT;
-       }
-
-       LOGW("watch: state: %d, focus_type : %d, reason_for_change : %s",
-               focus_state, focus_type, (reason_for_change ? reason_for_change : "N/A"));
-
-       player->sound_focus.cb_pending = TRUE;
-       player->sound_focus.by_asm_cb = TRUE;
-
-       if (focus_state == FOCUS_IS_ACQUIRED) {
-               LOGW("watch: FOCUS_IS_ACQUIRED");
-               player->sound_focus.acquired = TRUE;
-
-               if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(FALSE, reason_for_change, &msg))
-                       player->sound_focus.focus_changed_msg = (int)msg;
-
-               if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL ||
-                       player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM ||
-                       player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA) {
-                       if (!MMPLAYER_IS_RTSP_STREAMING(player)) {
-                               // hold 0.7 second to excute "fadedown mute" effect
-                               LOGW("do fade down->pause->undo fade down");
-
-                               __mmplayer_do_sound_fadedown(player, MM_PLAYER_FADEOUT_TIME_DEFAULT);
-
-                               result = _mmplayer_pause((MMHandleType)player);
-                               if (result != MM_ERROR_NONE) {
-                                       LOGW("fail to set Pause state by asm");
-                                       goto EXIT;
-                               }
-
-                               __mmplayer_undo_sound_fadedown(player);
-                       } else {
-                               /* rtsp should connect again in specific network becasue tcp session can't be kept any more */
-                               _mmplayer_unrealize((MMHandleType)player);
-                       }
-               } else {
-                       LOGW("pause immediately");
-                       result = _mmplayer_pause((MMHandleType)player);
-                       if (result != MM_ERROR_NONE) {
-                               LOGW("fail to set Pause state by asm");
-                               goto EXIT;
-                       }
-               }
-       } else if (focus_state == FOCUS_IS_RELEASED) {
-               LOGW("FOCUS_IS_RELEASED: Got msg from asm to resume");
-               player->sound_focus.acquired = FALSE;
-               player->sound_focus.antishock = TRUE;
-               player->sound_focus.by_asm_cb = FALSE;
-
-               if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(TRUE, reason_for_change, &msg))
-                       player->sound_focus.focus_changed_msg = (int)msg;
-
-               //ASM server is single thread daemon. So use g_idle_add() to post resume msg
-               player->resume_event_id = g_idle_add((GSourceFunc)_asm_postmsg, (gpointer)player);
-               goto DONE;
-       } else
-               LOGW("unknown focus state %d", focus_state);
-
-DONE:
-       player->sound_focus.by_asm_cb = FALSE;
-       player->sound_focus.cb_pending = FALSE;
-
-EXIT:
-       MMPLAYER_CMD_UNLOCK(player);
-       LOGW("dispatched");
-       return;
-
-EXIT_WITHOUT_UNLOCK:
-       LOGW("dispatched");
-       return;
-}
-
-void
-__mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
-       const char *reason_for_change, int option, const char *additional_info, void *user_data)
-{
-       mm_player_t* player = (mm_player_t*) user_data;
-       int result = MM_ERROR_NONE;
-       MMPlayerFocusChangedMsg msg = MM_PLAYER_FOCUS_CHANGED_BY_UNKNOWN;
-
-       LOGW("get focus notified");
-
-       if (!__mmplayer_can_do_interrupt(player)) {
-               LOGW("no need to interrupt, so leave");
-               goto EXIT_WITHOUT_UNLOCK;
-       }
-
-       if (player->sound_focus.session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
-               LOGW("flags is UNINTERRUPTIBLE. do nothing.");
-               goto EXIT;
-       }
-
-       LOGW("state: %d, focus_type : %d, reason_for_change : %s",
-               focus_state, focus_type, (reason_for_change ? reason_for_change : "N/A"));
-
-       player->sound_focus.cb_pending = TRUE;
-       player->sound_focus.by_asm_cb = TRUE;
-//     player->sound_focus.event_src = event_src;
-
-       if (focus_state == FOCUS_IS_RELEASED) {
-               LOGW("FOCUS_IS_RELEASED");
-               player->sound_focus.acquired = FALSE;
-
-               if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(FALSE, reason_for_change, &msg))
-                       player->sound_focus.focus_changed_msg = (int)msg;
-
-               if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL ||
-                       player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM ||
-                       player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA) {
-                       if (!MMPLAYER_IS_RTSP_STREAMING(player)) {
-                               //hold 0.7 second to excute "fadedown mute" effect
-                               LOGW("do fade down->pause->undo fade down");
-
-                               __mmplayer_do_sound_fadedown(player, MM_PLAYER_FADEOUT_TIME_DEFAULT);
-
-                               result = _mmplayer_pause((MMHandleType)player);
-                               if (result != MM_ERROR_NONE) {
-                                       LOGW("fail to set Pause state by asm");
-                                       goto EXIT;
-                               }
-                               __mmplayer_undo_sound_fadedown(player);
-                       } else {
-                               /* rtsp should connect again in specific network becasue tcp session can't be kept any more */
-                               _mmplayer_unrealize((MMHandleType)player);
-                       }
-               } else {
-                       LOGW("pause immediately");
-                       result = _mmplayer_pause((MMHandleType)player);
-                       if (result != MM_ERROR_NONE) {
-                               LOGW("fail to set Pause state by asm");
-                               goto EXIT;
-                       }
-               }
-
-               if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA &&
-                       player->sound_focus.session_type == MM_SESSION_TYPE_MEDIA &&
-                       !(player->sound_focus.session_flags & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) {
-                       result = mm_sound_set_focus_reacquisition_for_session(player->sound_focus.focus_id, false);
-                       if (result != MM_ERROR_NONE)
-                               LOGW("fail to set focus reacquisition to FALSE, skip going on..");
-               }
-       } else if (focus_state == FOCUS_IS_ACQUIRED) {
-               LOGW("FOCUS_IS_ACQUIRED: Got msg from asm to resume");
-               player->sound_focus.antishock = TRUE;
-               player->sound_focus.by_asm_cb = FALSE;
-
-               if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(TRUE, reason_for_change, &msg))
-                       player->sound_focus.focus_changed_msg = (int)msg;
-
-               //ASM server is single thread daemon. So use g_idle_add() to post resume msg
-               player->resume_event_id = g_idle_add((GSourceFunc)_asm_postmsg, (gpointer)player);
-               goto DONE;
-       } else
-               LOGW("unknown focus state %d", focus_state);
-
-DONE:
-       player->sound_focus.by_asm_cb = FALSE;
-       player->sound_focus.cb_pending = FALSE;
-
-EXIT:
-       if (mm_sound_update_focus_status(id, 0))
-               LOGE("failed to update focus status\n");
-       MMPLAYER_CMD_UNLOCK(player);
-       LOGW("dispatched");
-       return;
-
-EXIT_WITHOUT_UNLOCK:
-       LOGW("dispatched");
-       return;
-}
-
-
 int
 _mmplayer_create_player(MMHandleType handle)
 {
@@ -8783,9 +8425,6 @@ _mmplayer_create_player(MMHandleType handle)
        g_mutex_init(&player->subtitle_info_mutex);
        g_cond_init(&player->subtitle_info_cond);
 
-       /* create sound focus lock */
-       g_mutex_init(&player->sound_focus.focus_lock);
-
        player->streaming_type = STREAMING_SERVICE_NONE;
 
        /* give default value of audio effect setting */
@@ -9082,37 +8721,11 @@ _mmplayer_destroy(MMHandleType handle)
 
        _mmplayer_release_video_capture(player);
 
-       /* flush any pending asm_cb */
-       if (player->sound_focus.cb_pending) {
-               /* set a flag for make sure asm_cb to be returned immediately */
-               LOGW("asm cb has pending state");
-               player->sound_focus.exit_cb = TRUE;
-
-               /* make sure to release any pending asm_cb which locked by cmd_lock */
-               MMPLAYER_CMD_UNLOCK(player);
-               sched_yield();
-               MMPLAYER_CMD_LOCK(player);
-       }
-
-       /* withdraw asm */
-       if (MM_ERROR_NONE != _mmplayer_sound_unregister(&player->sound_focus))
-               LOGE("failed to deregister asm server\n");
-
        /* de-initialize resource manager */
        if (MM_RESOURCE_MANAGER_ERROR_NONE != mm_resource_manager_destroy(
                        player->resource_manager))
                LOGE("failed to deinitialize resource manager\n");
 
-       if (player->resume_event_id) {
-               g_source_remove(player->resume_event_id);
-               player->resume_event_id = 0;
-       }
-
-       if (player->resumable_cancel_id) {
-               g_source_remove(player->resumable_cancel_id);
-               player->resumable_cancel_id = 0;
-       }
-
        /* release pipeline */
        if (MM_ERROR_NONE != __mmplayer_gst_destroy_pipeline(player)) {
                LOGE("failed to destory pipeline\n");
@@ -9148,9 +8761,6 @@ _mmplayer_destroy(MMHandleType handle)
        /* release media stream callback lock */
        g_mutex_clear(&player->media_stream_cb_lock);
 
-       /* release sound focus lock */
-       g_mutex_clear(&player->sound_focus.focus_lock);
-
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;
@@ -9186,51 +8796,6 @@ __mmplayer_realize_streaming_ext(mm_player_t* player)
 }
 
 int
-_mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid)
-{
-       mm_player_t* player = (mm_player_t*)hplayer;
-       MMHandleType attrs = 0;
-       int ret = MM_ERROR_NONE;
-
-       attrs = MMPLAYER_GET_ATTRS(player);
-       if (!attrs) {
-               LOGE("fail to get attributes.\n");
-               return MM_ERROR_PLAYER_INTERNAL;
-       }
-
-       player->sound_focus.pid = pid;
-
-       /* register to asm */
-       if (MM_ERROR_NONE != _mmplayer_sound_register(&player->sound_focus,
-                                               (mm_sound_focus_changed_cb)__mmplayer_sound_focus_callback,
-                                               (mm_sound_focus_changed_watch_cb)__mmplayer_sound_focus_watch_callback,
-                                               (void*)player)) {
-               /* NOTE : we are dealing it as an error since we cannot expect it's behavior */
-               LOGE("failed to register asm server\n");
-               return MM_ERROR_POLICY_INTERNAL;
-       }
-       return ret;
-}
-
-int
-_mmplayer_get_client_pid(MMHandleType hplayer, int* pid)
-{
-       mm_player_t* player = (mm_player_t*) hplayer;
-
-       MMPLAYER_FENTER();
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       *pid = player->sound_focus.pid;
-
-       LOGD("registered pid[%d] %p", *pid, player);
-
-       MMPLAYER_FLEAVE();
-
-       return MM_ERROR_NONE;
-}
-
-int
 _mmplayer_realize(MMHandleType hplayer)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
@@ -9366,10 +8931,6 @@ _mmplayer_unrealize(MMHandleType hplayer)
 
        /* set asm stop if success */
        if (MM_ERROR_NONE == ret) {
-               ret = _mmplayer_sound_release_focus(&player->sound_focus);
-               if (ret != MM_ERROR_NONE)
-                       LOGE("failed to release sound focus, ret(0x%x)\n", ret);
-
                if (!player->interrupted_by_resource) {
                        if (player->video_decoder_resource != NULL) {
                                ret = mm_resource_manager_mark_for_release(player->resource_manager,
@@ -9704,12 +9265,6 @@ _mmplayer_start(MMHandleType hplayer)
        /* check current state */
        MMPLAYER_CHECK_STATE(player, MMPLAYER_COMMAND_START);
 
-       ret = _mmplayer_sound_acquire_focus(&player->sound_focus);
-       if (ret != MM_ERROR_NONE) {
-               LOGE("failed to acquire sound focus.\n");
-               return ret;
-       }
-
        /* NOTE : we should check and create pipeline again if not created as we destroy
         * whole pipeline when stopping in streamming playback
         */
@@ -9980,12 +9535,6 @@ _mmplayer_resume(MMHandleType hplayer)
        /* check current state */
        MMPLAYER_CHECK_STATE(player, MMPLAYER_COMMAND_RESUME);
 
-       ret = _mmplayer_sound_acquire_focus(&player->sound_focus);
-       if (ret != MM_ERROR_NONE) {
-               LOGE("failed to acquire sound focus.\n");
-               return ret;
-       }
-
        ret = __gst_resume(player, async);
 
        if (ret != MM_ERROR_NONE)
@@ -12092,7 +11641,6 @@ __mmplayer_release_misc(mm_player_t* player)
        player->max_audio_channels = 0;
        player->video_share_api_delta = 0;
        player->video_share_clock_delta = 0;
-       player->sound_focus.keep_last_pos = FALSE;
        player->is_subtitle_force_drop = FALSE;
        player->play_subtitle = FALSE;
        player->adjust_subtitle_pos = 0;
diff --git a/src/mm_player_sound_focus.c b/src/mm_player_sound_focus.c
deleted file mode 100644 (file)
index dcb74fa..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * libmm-player
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
- * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <sys/types.h>
-#include <unistd.h>
-#include <dlog.h>
-#include <mm_error.h>
-#include "mm_player_utils.h"
-#include "mm_player_priv.h"
-#include "mm_player_sound_focus.h"
-
-#define MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(x_player_sound_focus) \
-do { \
-       if (!x_player_sound_focus) { \
-               LOGD("no sound focus instance");\
-               return MM_ERROR_SOUND_NOT_INITIALIZED; \
-       } \
-} while (0);
-
-void __mmplayer_sound_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
-{
-       MMPlayerSoundFocus *sound_focus = (MMPlayerSoundFocus*)user_data;
-       MMPLAYER_RETURN_IF_FAIL(sound_focus);
-
-       LOGD("sound signal callback %d / %d", signal, value);
-
-       if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS && value == 1)
-               _mmplayer_sound_unregister(sound_focus);
-}
-
-static void
-__mmplayer_sound_device_connected_cb_func(MMSoundDevice_t device_h, bool is_connected, void *user_data)
-{
-       mm_player_t* player = (mm_player_t*) user_data;
-       MMPLAYER_RETURN_IF_FAIL(player);
-
-       mm_sound_device_type_e device_type;
-       int ret;
-
-       LOGW("device_connected_cb is called, device_h[0x%x], is_connected[%d]\n", device_h, is_connected);
-
-       /* get device type with device_h*/
-       ret = mm_sound_get_device_type(device_h, &device_type);
-
-       if (!is_connected && MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PLAYING
-               && (player->sound_focus.focus_id > 0 || player->sound_focus.watch_id > 0)) {
-               switch (device_type) {
-               case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
-               case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
-               case MM_SOUND_DEVICE_TYPE_HDMI:
-               case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
-               {
-                       int result = MM_ERROR_NONE;
-                       LOGW("pause immediately");
-
-                       player->sound_focus.by_asm_cb = TRUE;
-                       player->sound_focus.focus_changed_msg = MM_PLAYER_FOCUS_CHANGED_BY_EARJACK_UNPLUG;
-
-                       result = _mmplayer_pause((MMHandleType)player);
-                       if (result != MM_ERROR_NONE) {
-                               LOGE("focus_id [%d], watch_id [%d], connected_id [%d], change_state result[%d]",
-                                       player->sound_focus.focus_id, player->sound_focus.watch_id,
-                                       player->sound_focus.connected_id, ret);
-                       }
-                       player->sound_focus.by_asm_cb = FALSE;
-               }
-               break;
-
-               default:
-                       LOGD("do nothing");
-               }
-       }
-}
-
-const gchar *
-__mmplayer_sound_get_stream_type(gint type)
-{
-       switch (type) {
-       case MM_SESSION_TYPE_CALL:
-       case MM_SESSION_TYPE_VIDEOCALL:
-       case MM_SESSION_TYPE_VOIP:
-               return "ringtone-voip";
-       case MM_SESSION_TYPE_MEDIA:
-               return "media";
-       case MM_SESSION_TYPE_NOTIFY:
-               return "notification";
-       case MM_SESSION_TYPE_ALARM:
-               return "alarm";
-       case MM_SESSION_TYPE_EMERGENCY:
-               return "emergency";
-       default:
-               LOGW("unexpected case!\n");
-               return "media";
-       }
-}
-
-static bool
-__mmplayer_check_need_block(const char *focus_acquired_by)
-{
-       if (!focus_acquired_by)
-               return false;
-
-       if (!strcmp(focus_acquired_by, "alarm") ||
-               !strcmp(focus_acquired_by, "ringtone-voip") ||
-               !strcmp(focus_acquired_by, "ringtone-call") ||
-               !strcmp(focus_acquired_by, "voip") ||
-               !strcmp(focus_acquired_by, "call-voice") ||
-               !strcmp(focus_acquired_by, "call-video")) {
-               LOGW("Blocked by session policy, focus_acquired_by[%s]", focus_acquired_by);
-               return true;
-       }
-
-       return false;
-}
-
-int
-_mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus)
-{
-       int ret = MM_ERROR_NONE;
-
-       MMPLAYER_FENTER();
-       MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
-
-       if (sound_focus->acquired) {
-               LOGW("focus is already acquired. can't acquire again.");
-               return MM_ERROR_NONE;
-       }
-
-       if (_mmplayer_is_using_internal_sound_focus(sound_focus)) {
-               if (sound_focus->session_type == MM_SESSION_TYPE_MEDIA)
-                       /* option: 1 for no-resume */
-                       ret = mm_sound_acquire_focus_with_option(sound_focus->focus_id, FOCUS_FOR_BOTH, 1, "mm-player acquire focus");
-               else
-                       ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player acquire focus");
-
-               if (ret != MM_ERROR_NONE) {
-                       LOGE("failed to acquire sound focus [0x%X]", ret);
-                       return ret;
-               }
-
-               sound_focus->acquired = TRUE;
-
-               ret = mm_sound_update_focus_status(sound_focus->focus_id, 1);
-               if (ret != MM_ERROR_NONE)
-                       LOGE("failed to update focus status [0x%X]", ret);
-       } else {
-               if (sound_focus->watch_id > 0) {
-                       char *stream_type = NULL;
-                       char *ext_info = NULL;
-                       int option = 0;
-
-                       ret = mm_sound_get_stream_type_of_acquired_focus(FOCUS_FOR_BOTH, &stream_type, &option, &ext_info);
-                       if (ret == MM_ERROR_NONE) {
-                               LOGD("Focus is acquired by stream_type[%s], option[%d], ext_info[%s]", stream_type, option, ext_info);
-                               if (__mmplayer_check_need_block((const char*)stream_type)) {
-                                       LOGE("Blocked by an acquired focus[%s]", stream_type);
-                                       ret = MM_ERROR_POLICY_INTERNAL;
-                               }
-                       } else {
-                               LOGW("failed to get stream type of acquired focus [0x%X]", ret);
-                               if (ret == MM_ERROR_SOUND_NO_DATA) /* there is no acquired focus, it is normal case */
-                                       ret = MM_ERROR_NONE;
-                       }
-
-                       if (stream_type) free(stream_type);
-                       if (ext_info) free(ext_info);
-               }
-       }
-
-       MMPLAYER_FLEAVE();
-       return ret;
-}
-
-int
-_mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus)
-{
-       int ret = MM_ERROR_NONE;
-
-       MMPLAYER_FENTER();
-       MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
-
-       if (!sound_focus->acquired) {
-               LOGW("focus is not acquired. no need to release.");
-               return MM_ERROR_NONE;
-       }
-
-       if (_mmplayer_is_using_internal_sound_focus(sound_focus)) {
-               if (sound_focus->session_type == MM_SESSION_TYPE_MEDIA)
-                       /* option: 1 for no-resume */
-                       ret = mm_sound_release_focus_with_option(sound_focus->focus_id, FOCUS_FOR_BOTH, 1, "mm-player release focus");
-               else
-                       ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player release focus");
-
-               if (ret != MM_ERROR_NONE) {
-                       LOGE("failed to release sound focus\n");
-                       return ret;
-               }
-
-               sound_focus->acquired = FALSE;
-
-               ret = mm_sound_update_focus_status(sound_focus->focus_id, 0);
-               if (ret != MM_ERROR_NONE)
-                       LOGE("failed to update focus status\n");
-       }
-
-       MMPLAYER_FLEAVE();
-       return MM_ERROR_NONE;
-}
-
-gint
-_mmplayer_sound_register(MMPlayerSoundFocus* sound_focus,
-               mm_sound_focus_changed_cb focus_cb, mm_sound_focus_changed_watch_cb watch_cb, void* param)
-{
-       gint pid = -1;
-       gint ret = MM_ERROR_NONE;
-       const gchar *stream_type = NULL;
-       mm_player_t* player = MM_PLAYER_CAST(param);
-
-       MMPLAYER_FENTER();
-       MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_INVALID_ARGUMENT);
-
-       /* check if it's running on the media_server */
-       if (sound_focus->pid > 0)
-               pid = sound_focus->pid;
-       else
-               return MM_ERROR_INVALID_ARGUMENT;
-
-       LOGD("sound register focus pid[%d]", pid);
-       /* read session information */
-       ret = _mm_session_util_read_information(pid, &sound_focus->session_type, &sound_focus->session_flags);
-       LOGW("Read Session Type -> ret:0x%X \n", ret);
-
-       if (ret == MM_ERROR_INVALID_HANDLE) {
-               /* case 1. if there is no session */
-               LOGW("subscribe_id=%d\n", sound_focus->subscribe_id);
-
-               if (sound_focus->subscribe_id == 0) {
-                       ret = mm_sound_subscribe_signal_for_daemon(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, pid, &sound_focus->subscribe_id,
-                                                                       (mm_sound_signal_callback)__mmplayer_sound_signal_callback, (void*)sound_focus);
-                       if (ret != MM_ERROR_NONE) {
-                               LOGE("mm_sound_subscribe_signal is failed\n");
-                               return MM_ERROR_POLICY_BLOCKED;
-                       }
-
-                       LOGD("register focus watch callback for the value is 0, sub_cb id %d\n", sound_focus->subscribe_id);
-                       /* register watch callback */
-                       ret = mm_sound_set_focus_watch_callback_for_session(pid ,
-                                       FOCUS_FOR_BOTH, watch_cb, (void*)param, &sound_focus->watch_id);
-                       if (ret != MM_ERROR_NONE) {
-                               LOGE("mm_sound_set_focus_watch_callback is failed\n");
-                               return MM_ERROR_POLICY_BLOCKED;
-                       }
-                       /* register device connected callback */
-                       ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
-                                       (mm_sound_device_connected_cb)__mmplayer_sound_device_connected_cb_func, (void*)param, &sound_focus->connected_id);
-                       if (ret != MM_ERROR_NONE) {
-                               LOGE("mm_sound_add_device_connected_callback is failed\n");
-                               return MM_ERROR_POLICY_BLOCKED;
-                       }
-                       LOGD("register device connected callback for the value is 0, sub_cb id %d\n", sound_focus->connected_id);
-               }
-               ret = MM_ERROR_NONE;
-       } else if (ret == MM_ERROR_NONE) {
-               /* case 2. if sessoin exists */
-               /* in this case, this process is using stream info created by using sound-manager,
-                * we're going to skip working on backward compatibility of session. */
-               if (sound_focus->session_type == MM_SESSION_TYPE_REPLACED_BY_STREAM) {
-                       LOGW("this process is using stream info. skip it..");
-               } else {
-                       /* interpret session information */
-                       stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type);
-                       LOGD("fid [%d] wid [%d] type[%s], flags[0x%02X]\n",
-                               sound_focus->focus_id, sound_focus->watch_id, stream_type, sound_focus->session_flags);
-
-                       if (sound_focus->focus_id == 0) {
-                               /* get unique id */
-                               ret = mm_sound_focus_get_id(&sound_focus->focus_id);
-                               if (ret != MM_ERROR_NONE) {
-                                       LOGE("failed to get unique focus id\n");
-                                       return MM_ERROR_POLICY_BLOCKED;
-                               }
-
-                               /* register sound focus callback */
-                               ret = mm_sound_register_focus_for_session(sound_focus->focus_id, pid,
-                                               stream_type, focus_cb, (void*)param);
-                               if (ret != MM_ERROR_NONE) {
-                                       LOGE("mm_sound_register_focus is failed\n");
-                                       return MM_ERROR_POLICY_BLOCKED;
-                               }
-                       }
-
-                       if ((sound_focus->watch_id == 0) &&
-                               (strstr(stream_type, "media")) &&
-                               !(sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) &&
-                               !(sound_focus->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE)) {
-                               LOGD("register focus watch callback\n");
-                               /* register watch callback */
-                               ret = mm_sound_set_focus_watch_callback_for_session(pid,
-                                               FOCUS_FOR_BOTH, watch_cb, (void*)param, &sound_focus->watch_id);
-                               if (ret != MM_ERROR_NONE) {
-                                       LOGE("mm_sound_set_focus_watch_callback is failed\n");
-                                       return MM_ERROR_POLICY_BLOCKED;
-                               }
-                       }
-
-                       if ((strstr(stream_type, "media")) && (sound_focus->connected_id == 0)) {
-                               /* register device connected callback */
-                               ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
-                                               (mm_sound_device_connected_cb)__mmplayer_sound_device_connected_cb_func, (void*)param, &sound_focus->connected_id);
-                               if (ret != MM_ERROR_NONE) {
-                                       LOGE("mm_sound_add_device_connected_callback is failed\n");
-                                       return MM_ERROR_POLICY_BLOCKED;
-                               }
-                               LOGD("register device connected callback for the value is 0, sub_cb id %d\n", sound_focus->connected_id);
-                       }
-
-                       ret = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), (char *)NULL);
-                       if (ret != MM_ERROR_NONE) {
-                               LOGE("mm_player_set_attribute for sound_stream_type is failed\n");
-                               return ret;
-                       }
-               }
-               ret = MM_ERROR_NONE;
-       } else {
-               LOGE("_mm_session_util_read_information is failed");
-               ret =  MM_ERROR_POLICY_BLOCKED;
-       }
-
-       MMPLAYER_FLEAVE();
-       return ret;
-}
-
-gint
-_mmplayer_sound_unregister(MMPlayerSoundFocus* sound_focus)
-{
-       int ret = MM_ERROR_NONE;
-
-       MMPLAYER_FENTER();
-
-       MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
-       MMPLAYER_SOUND_FOCUS_LOCK(sound_focus);
-
-       LOGD("unregister sound focus callback\n");
-
-       if (sound_focus->focus_id > 0) {
-               ret = mm_sound_unregister_focus(sound_focus->focus_id);
-               if (ret != MM_ERROR_NONE)
-                       LOGE("failed to mm_sound_unregister_focus() %d", sound_focus->focus_id);
-               sound_focus->focus_id = 0;
-       }
-
-       if (sound_focus->watch_id > 0) {
-               ret = mm_sound_unset_focus_watch_callback(sound_focus->watch_id);
-               if (ret != MM_ERROR_NONE)
-                       LOGE("failed to mm_sound_unset_focus_watch_callback() %d", sound_focus->watch_id);
-               sound_focus->watch_id = 0;
-       }
-
-       if (sound_focus->subscribe_id > 0) {
-               mm_sound_unsubscribe_signal(sound_focus->subscribe_id);
-               sound_focus->subscribe_id = 0;
-       }
-       if (sound_focus->connected_id > 0) {
-               ret = mm_sound_remove_device_connected_callback(sound_focus->connected_id);
-               if (ret != MM_ERROR_NONE)
-                       LOGE("failed to mm_sound_remove_device_connected_callback() %d", sound_focus->connected_id);
-               sound_focus->connected_id = 0;
-       }
-
-       MMPLAYER_SOUND_FOCUS_UNLOCK(sound_focus);
-       MMPLAYER_FLEAVE();
-
-       return MM_ERROR_NONE;
-}
-
-bool _mmplayer_is_using_internal_sound_focus(MMPlayerSoundFocus* sound_focus)
-{
-       MMPLAYER_RETURN_VAL_IF_FAIL(sound_focus, false);
-
-       /* Perhaps, already got release signal or application may use stream focus directly */
-       if (sound_focus->focus_id == 0)
-               return false;
-
-       if ((sound_focus->session_type == MM_SESSION_TYPE_MEDIA && sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) ||
-               (sound_focus->session_type == MM_SESSION_TYPE_NOTIFY) ||
-               (sound_focus->session_type == MM_SESSION_TYPE_ALARM) ||
-               (sound_focus->session_type == MM_SESSION_TYPE_EMERGENCY))
-               return true;
-       else
-               return false;
-}