__mMultimediaSession(MM_SESSION_TYPE_MEDIA),
__mpEventListener(listener),
__mIsInit(false),
- __mSubscribeId(-1),
+ __mSubscribeId(0),
__mUseFocus(false),
__mFocusType(FOCUS_NONE),
__mState(FOCUS_IS_RELEASED),
return __mMultimediaSession;
}
-int CAudioSessionHandler::getSubscribeId() {
+unsigned int CAudioSessionHandler::getSubscribeId() {
return __mSubscribeId;
}
AUDIO_IO_LOGD("[signal:%d], [value:%d], [user_data:0x%x]", signal, value, user_data);
CAudioSessionHandler* pHandler = static_cast<CAudioSessionHandler*>(user_data);
- if (pHandler->__mpEventListener != NULL) {
+ if (pHandler->__mpEventListener != NULL)
pHandler->__mpEventListener->onSignal(pHandler, signal, value);
- }
}
-void CAudioSessionHandler::initialize() throw (CAudioError) {
+void CAudioSessionHandler::initialize() throw(CAudioError) {
AUDIO_IO_LOGD("");
if (__mIsInit == true) {
return;
CAudioError err = __getAsmInformation(¤tSession, &sessionOptions);
if (err == CAudioError::EError::ERROR_NONE) {
- // Session was configured before, use focus callback
- __mUseFocus = true;
- AUDIO_IO_LOGD("Use audio focus concept internally!");
+ if (currentSession == MM_SESSION_TYPE_REPLACED_BY_STREAM) {
+ __mUseFocus = false;
+ AUDIO_IO_LOGD("Stream info. was created outside, skip audio focus concept internally!");
+ } else {
+ // Session was configured before, use focus callback
+ __mUseFocus = true;
+ AUDIO_IO_LOGD("Use audio focus concept internally!");
+ }
} else {
if (err == CAudioError::EError::ERROR_INVALID_HANDLE) {
- int value = 0;
- unsigned int subscribe_id;
+ // No session, No stream_info, No focus watch callback before
+ // Use focus watch callback with signal subscribe
- int errorCode = mm_sound_get_signal_value(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &value);
- if (errorCode != MM_ERROR_NONE) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_get_signal_value() err:0x%x", errorCode);
+ int errorCode = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &__mSubscribeId, __sound_pcm_signal_cb, static_cast<void*>(this));
+ if (errorCode != MM_ERROR_NONE || __mSubscribeId == 0) {
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_subscribe_signal() err:0x%x, __mSubscribeId:%u",
+ errorCode, __mSubscribeId);
}
- if (value == 1) {
- // stream_info was created or focus watch callback was configured before
- __mUseFocus = false;
- AUDIO_IO_LOGD("Skip audio focus concept!");
- } else if (value == 0) {
- // No session, No stream_info, No focus watch callback before
- // Use focus watch callback with signal subscribe
- errorCode = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &subscribe_id, __sound_pcm_signal_cb, static_cast<void*>(this));
- if (errorCode != MM_ERROR_NONE) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_get_signal_value() err:0x%x", errorCode);
- }
-
- __mSubscribeId = (int)subscribe_id;
- AUDIO_IO_LOGD("Subscribed mm_sound signal");
+ AUDIO_IO_LOGD("Subscribed mm_sound signal");
- sessionOptions = 0; // Mix with others by default
- __mUseFocus = true;
- AUDIO_IO_LOGD("Use audio focus(watch) concept internally!");
- }
+ sessionOptions = 0; // Mix with others by default
+ __mUseFocus = true;
+ AUDIO_IO_LOGD("Use audio focus(watch) concept internally!");
} else {
__mUseFocus = false;
AUDIO_IO_LOGD("Skip audio focus concept!");
__pcmCaptureCountDec();
}
- if (__mSubscribeId >= 0) {
+ if (__mSubscribeId > 0) {
mm_sound_unsubscribe_signal(__mSubscribeId);
+ __mSubscribeId = 0;
}
+ __mpEventListener = NULL;
+
__mIsInit = false;
}
-bool CAudioSessionHandler::isSkipSessionEvent() throw (CAudioError) {
+bool CAudioSessionHandler::isSkipSessionEvent() throw(CAudioError) {
bool ret = false;
// To be regarded...
if (mEvent != ASM_EVENT_CALL && mEvent != ASM_EVENT_VOIP &&
mEvent != ASM_EVENT_VIDEOCALL && mEvent != ASM_EVENT_VOICE_RECOGNITION &&
mEvent != ASM_EVENT_MMCAMCORDER_AUDIO && mEvent != ASM_EVENT_MMCAMCORDER_VIDEO) {
-
// Check AudioType
switch (__mAudioInfo.getAudioType()) {
case CAudioInfo::AUDIO_IN_TYPE_MEDIA:
return ret;
}
-void CAudioSessionHandler::__sound_pcm_focus_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data) {
+void CAudioSessionHandler::__sound_pcm_focus_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *additional_info, void *user_data) {
assert(user_data);
AUDIO_IO_LOGD("[id:%d], [focus_type:%d], [state:%d], [reason_for_change:%s], [additional_info:%s], [user_data:0x%x]", id, focus_type, state, reason_for_change, additional_info, user_data);
+/* FIXME: disable it temporarily */
+#ifndef DISABLE_SESSION_BACK_COMP
+
CAudioSessionHandler* pHandler = static_cast<CAudioSessionHandler*>(user_data);
pHandler->__mFocusType = focus_type;
pHandler->__mState = state;
pHandler->__mReasonForChange = (char *)reason_for_change;
pHandler->__mAdditionalInfo = (char *)additional_info;
- if (pHandler->__mpEventListener != NULL) {
+ if (pHandler->__mpEventListener != NULL)
pHandler->__mpEventListener->onInterrupt(pHandler, id, focus_type, state, reason_for_change, additional_info);
- }
-
+#endif
return;
}
void CAudioSessionHandler::__sound_pcm_focus_watch_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data) {
AUDIO_IO_LOGD("[id:%d], [focus_type:%d], [state:%d], [reason_for_change:%s], [additional_info:%s], [user_data:0x%x]", id, focus_type, state, reason_for_change, additional_info, user_data);
- CAudioSessionHandler::__sound_pcm_focus_cb(-1, focus_type, state, reason_for_change, additional_info, user_data);
+ CAudioSessionHandler::__sound_pcm_focus_cb(-1, focus_type, state, reason_for_change, 0, additional_info, user_data);
return;
}
-void CAudioSessionHandler::registerSound() throw (CAudioError) {
+void CAudioSessionHandler::registerSound() throw(CAudioError) {
if (__mIsInit == false) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
}
errorCode = mm_sound_focus_get_id(&__mId);
if (errorCode != MM_ERROR_NONE) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_focus_get_id() err:0x%x", errorCode);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_focus_get_id() err:0x%x", errorCode);
}
// Register focus callback
__sound_pcm_focus_cb,
static_cast<void*>(this));
if (errorCode != MM_ERROR_NONE) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_register_focus_for_session() err:0x%x", errorCode);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_register_focus_for_session() err:0x%x", errorCode);
}
__focusIdCountInc();
// Register focus watch callback
errorCode = mm_sound_set_focus_watch_callback_for_session(getpid(), FOCUS_FOR_BOTH, __sound_pcm_focus_watch_cb, static_cast<void*>(this), &__mId);
if (errorCode < 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_set_focus_watch_callback_for_session() err:0x%x", errorCode);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_set_focus_watch_callback_for_session() err:0x%x", errorCode);
}
__focusIdCountInc();
}
}
-void CAudioSessionHandler::unregisterSound() throw (CAudioError) {
+void CAudioSessionHandler::unregisterSound() throw(CAudioError) {
if (__mIsInit == false) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
}
- if (__mUseFocus == true) {
- if (__mId < 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Did not register [id:%d]", __mId);
- }
-
+ if (__mUseFocus == true && __mId >= 0) {
int errorCode = 0;
if (__isFocusRequired(__mMultimediaSession, __mOptions)) {
// Unregister focus callback
errorCode = mm_sound_unregister_focus(__mId);
if (errorCode != MM_ERROR_NONE) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_unregister_focus() err:0x%x", errorCode);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_unregister_focus() err:0x%x", errorCode);
}
__focusIdCountDec();
// Unregister focus watch callback.
errorCode = mm_sound_unset_focus_watch_callback(__mId);
if (errorCode < 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Failed mm_sound_unset_focus_watch_callback() err:0x%x", errorCode);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_unset_focus_watch_callback() err:0x%x", errorCode);
}
__focusIdCountDec();
}
}
-void CAudioSessionHandler::updatePlaying() throw (CAudioError) {
+void CAudioSessionHandler::updatePlaying() throw(CAudioError) {
if (__mIsInit == false) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
}
}
}
-void CAudioSessionHandler::updateStop() throw (CAudioError) {
+void CAudioSessionHandler::updateStop() throw(CAudioError) {
if (__mIsInit == false) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
}
if (__mId >= 0) {
int 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_POLICY_BLOCKED, "Failed mm_sound_release_focus() err:0x%x", ret);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed mm_sound_release_focus() err:0x%x", ret);
}
AUDIO_IO_LOGD("Focus released successfully [id:%d]", __mId);
}
}
}
-void CAudioSessionHandler::disableSessionHandler() throw (CAudioError) {
+void CAudioSessionHandler::disableSessionHandler() throw(CAudioError) {
CAudioSessionHandler::updateStop();
CAudioSessionHandler::unregisterSound();
IAudioSessionEventListener::EInterruptCode IAudioSessionEventListener::convertInterruptedCode(int code, const char *reason_for_change) {
EInterruptCode e = EInterruptCode::INTERRUPT_COMPLETED;
- switch (code)
- {
+ switch (code) {
case FOCUS_IS_ACQUIRED:
e = EInterruptCode::INTERRUPT_COMPLETED;
break;