From: Sangchul Lee Date: Fri, 17 Mar 2017 04:02:43 +0000 (+0900) Subject: Enhance backward compatibility for media session X-Git-Tag: accepted/tizen/3.0/common/20170330.125039^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F32%2F119432%2F2;p=platform%2Fcore%2Fapi%2Faudio-io.git Enhance backward compatibility for media session Pass no-resume option when acquiring/releasing focus internally in case of media session type. Set reacquisition to false in case of media session type without resume setting. Those are added to meet the previous media session behavior. [Version] 0.3.72 [Profile] Common [Issue Type] Backward compatibility Change-Id: I0b3d34c3b72b6c7365cfe383316bcd3540273d05 Signed-off-by: Sangchul Lee --- diff --git a/include/CAudioSessionHandler.h b/include/CAudioSessionHandler.h index 3d360a8..06a3619 100644 --- a/include/CAudioSessionHandler.h +++ b/include/CAudioSessionHandler.h @@ -115,6 +115,7 @@ namespace tizen_media_audio { CAudioError __convertStreamType(EAudioSessionType type1, MMSessionType type2, int *index); CAudioError __getAsmInformation(MMSessionType *type, int *options); bool __isFocusRequired(MMSessionType type, int options); + bool __isFocusDisableReacquisitionRequired(MMSessionType type, int options); /* Static Member */ static int __sCaptureRef; diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec index 85abd03..144b3d6 100644 --- a/packaging/capi-media-audio-io.spec +++ b/packaging/capi-media-audio-io.spec @@ -1,6 +1,6 @@ Name: capi-media-audio-io Summary: An Audio Input & Audio Output library in Tizen Native API -Version: 0.3.71 +Version: 0.3.72 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/cpp/CAudioSessionHandler.cpp b/src/cpp/CAudioSessionHandler.cpp index 1f2e04b..f31675d 100644 --- a/src/cpp/CAudioSessionHandler.cpp +++ b/src/cpp/CAudioSessionHandler.cpp @@ -160,6 +160,14 @@ bool CAudioSessionHandler::__isFocusRequired(MMSessionType type, int options) { return false; } +bool CAudioSessionHandler::__isFocusDisableReacquisitionRequired(MMSessionType type, int options) { + if ((type == MM_SESSION_TYPE_MEDIA) && + !(options & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) + return true; + + return false; +} + int CAudioSessionHandler::getId() { return __mId; } @@ -362,6 +370,13 @@ void CAudioSessionHandler::registerSound() throw(CAudioError) { THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_register_focus_for_session() err:0x%x", errorCode); } + if (__isFocusDisableReacquisitionRequired(__mMultimediaSession, __mOptions)) { + errorCode = mm_sound_set_focus_reacquisition_for_session(__mId, false); + if (errorCode != MM_ERROR_NONE) { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_set_focus_reacquisition() err:0x%x", errorCode); + } + } + __focusIdCountInc(); AUDIO_IO_LOGD("Focus callback registered successfully [id:%d]", __mId); @@ -420,7 +435,11 @@ void CAudioSessionHandler::updatePlaying() throw(CAudioError) { if (__mUseFocus && __isFocusRequired(__mMultimediaSession, __mOptions)) { if (__mId >= 0) { - int ret = mm_sound_acquire_focus(__mId, FOCUS_FOR_BOTH, "audio-io acquire focus"); + int ret = MM_ERROR_NONE; + if (__mMultimediaSession == MM_SESSION_TYPE_MEDIA) + ret = mm_sound_acquire_focus_with_option(__mId, FOCUS_FOR_BOTH, 1, "audio-io acquire focus"); /* option: 1 for no-resume */ + else + ret = mm_sound_acquire_focus(__mId, FOCUS_FOR_BOTH, "audio-io acquire focus"); if (ret != MM_ERROR_NONE) { THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_acquire_focus() err:0x%x", ret); } @@ -436,7 +455,11 @@ void CAudioSessionHandler::updateStop() throw(CAudioError) { if (__mUseFocus && __isFocusRequired(__mMultimediaSession, __mOptions)) { if (__mId >= 0) { - int ret = mm_sound_release_focus(__mId, FOCUS_FOR_BOTH, "audio-io release focus"); + int ret = MM_ERROR_NONE; + if (__mMultimediaSession == MM_SESSION_TYPE_MEDIA) + ret = mm_sound_release_focus_with_option(__mId, FOCUS_FOR_BOTH, 1, "audio-io release focus"); /* option: 1 for no-resume */ + else + ret = mm_sound_release_focus(__mId, FOCUS_FOR_BOTH, "audio-io release focus"); if (ret != MM_ERROR_NONE) { THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_release_focus() err:0x%x", ret); }