If audio io handle uses media session with MIX_WITH_OTHERS option and other process
has already acquired a focus which has more higher priority than media, policy error
will be returned from prepare() functions.
- audio_out_prepare(), audio_in_prepare()
Unnecessary session backward compatibility codes are also removed in some functions
exported since tizen 3.0.
- audio_out_pause(), audio_in_pause()
- audio_out_resume(), audio_in_resume()
Original patch is
: https://review.tizen.org/gerrit/#/c/125413/
[Version] 0.4.1
[Profile] Common
[Issue Type] Backward compatibility
Change-Id: Id0710c2847903cf96cdce38eab909b5c2e103c5f
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
(cherry picked from commit
6035bcf1a578fa1c0533a7d850e0e9f2794a46ab)
bool __isFocusDisableReacquisitionRequired(MMSessionType type, int options);
void __lockFocusCBMutex();
void __unlockFocusCBMutex();
+ bool __checkNeedBlock(const char *focus_acquired_by);
/* Static Member */
static int __sCaptureRef;
Name: capi-media-audio-io
Summary: An Audio Input & Audio Output library in Tizen Native API
-Version: 0.4.0
+Version: 0.4.1
Release: 0
Group: Multimedia/API
License: Apache-2.0
// Create PulseAudio Handler
mpPulseAudioClient = new CPulseAudioClient(CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_RECORD, spec, this);
- // Initialize PulseAudio Handler
- mpPulseAudioClient->initialize();
-
if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
mpAudioSessionHandler->updatePlaying();
+ // Initialize PulseAudio Handler
+ mpPulseAudioClient->initialize();
#ifndef DISABLE_MOBILE_BACK_COMP
// Uncork stream which is created with CORKED flag */
mpPulseAudioClient->cork(false);
try {
CAudioIO::pause();
- internalLock();
-
- /* Updates ASM to STOP */
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false) {
- mpAudioSessionHandler->updateStop();
- }
-
- internalUnlock();
-
CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
} catch (CAudioError& e) {
- internalUnlock();
throw;
}
}
}
try {
- internalLock();
-
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
- mpAudioSessionHandler->updatePlaying();
-
- internalUnlock();
-
CAudioIO::resume();
CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
} catch (CAudioError& e) {
- internalUnlock();
throw;
}
}
// Create PulseAudio Handler
mpPulseAudioClient = new CPulseAudioClient(CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_PLAYBACK, spec, this);
- // Initialize PulseAudio Handler
- mpPulseAudioClient->initialize();
-
if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
mpAudioSessionHandler->updatePlaying();
+ // Initialize PulseAudio Handler
+ mpPulseAudioClient->initialize();
#ifndef DISABLE_MOBILE_BACK_COMP
// Uncork stream which is created with CORKED flag */
mpPulseAudioClient->cork(false);
try {
CAudioIO::pause();
- internalLock();
-
- /* Updates ASM to STOP */
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
- mpAudioSessionHandler->updateStop();
-
- internalUnlock();
-
CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
} catch (CAudioError& e) {
- internalUnlock();
throw;
}
}
}
try {
- internalLock();
-
- if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
- mpAudioSessionHandler->updatePlaying();
-
- internalUnlock();
-
CAudioIO::resume();
CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
} catch (CAudioError& e) {
- internalUnlock();
throw;
}
}
return false;
}
+bool CAudioSessionHandler::__checkNeedBlock(const char *focus_acquired_by) {
+ assert(focus_acquired_by != NULL);
+
+ 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")) {
+ AUDIO_IO_LOGW("Blocked by session policy, focus_acquired_by[%s]", focus_acquired_by);
+ return true;
+ }
+
+ return false;
+}
+
int CAudioSessionHandler::getId() {
return __mId;
}
if (__mIsInit == false) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
}
+ if (!__mUseFocus || __mId < 0)
+ return;
if (__mUseFocus && __isFocusRequired(__mMultimediaSession, __mOptions)) {
if (__mId >= 0) {
if (!is_focus_cb_thread)
__unlockFocusCBMutex();
}
+ } else {
+ int ret = MM_ERROR_NONE;
+ char *stream_type = NULL;
+ char *ext_info = NULL;
+ int option = 0;
+
+ if ((ret = mm_sound_get_stream_type_of_acquired_focus(FOCUS_FOR_BOTH, &stream_type, &option, &ext_info)))
+ return;
+
+ AUDIO_IO_LOGD("Focus is acquired by stream_type[%s], option[%d], ext_info[%s]", stream_type, option, ext_info);
+
+ if (__checkNeedBlock((const char*)stream_type)) {
+ free(stream_type);
+ free(ext_info);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_POLICY_BLOCKED, "Blocked by an acquired focus");
+ }
+ free(stream_type);
+ free(ext_info);
}
}