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)
{
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\n");
+ LOGE("failed to acquire sound focus [0x%X]", ret);
return ret;
}
ret = mm_sound_update_focus_status(sound_focus->focus_id, 1);
if (ret != MM_ERROR_NONE)
- LOGE("failed to update focus status\n");
+ 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();