}
void CAudioSessionHandler::__lockFocusIdMutex() {
- if (pthread_mutex_lock(&__mFocusIdMutex) != 0) {
+ if (pthread_mutex_lock(&__mFocusIdMutex) != 0)
THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock() - FocusId Mutex");
- }
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD(COLOR_RED "LOCK - FocusId Mutex" COLOR_END);
#endif
}
void CAudioSessionHandler::__unlockFocusIdMutex() {
- if (pthread_mutex_unlock(&__mFocusIdMutex) != 0) {
+ if (pthread_mutex_unlock(&__mFocusIdMutex) != 0)
THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_unlock() - FocusId Mutex");
- }
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD(COLOR_GREEN "UNLOCK - FocusId Mutex" COLOR_END);
#endif
}
void CAudioSessionHandler::__lockFocusCBMutex() {
- if (pthread_mutex_lock(&__mFocusCBMutex) != 0) {
+ if (pthread_mutex_lock(&__mFocusCBMutex) != 0)
THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock() - FocusCB Mutex");
- }
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD(COLOR_RED "LOCK - FocusCB Mutex" COLOR_END);
#endif
}
void CAudioSessionHandler::__unlockFocusCBMutex() {
- if (pthread_mutex_unlock(&__mFocusCBMutex) != 0) {
+ if (pthread_mutex_unlock(&__mFocusCBMutex) != 0)
THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_unlock() - FocusCB Mutex");
- }
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD(COLOR_GREEN "UNLOCK - FocusCB Mutex" COLOR_END);
#endif
/* Read session information */
int ret = 0;
if ((ret = _mm_session_util_read_information(-1, (int*)¤tSession, &sessionOptions)) < 0) {
- if (ret == (int) MM_ERROR_INVALID_HANDLE) {
+ if (ret == (int) MM_ERROR_INVALID_HANDLE)
RET_ERROR_MSG(CAudioError::EError::ERROR_INVALID_HANDLE, "Failed _mm_session_util_read_information(). Invalid handle");
- } else {
+ else
RET_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed _mm_session_util_read_information(). Not exist");
- }
}
*type = currentSession;
}
void CAudioSessionHandler::getInternalVoipStreamInfo(sound_stream_info_h *stream_info) {
+#if 0
int ret;
-
if ((ret = sound_manager_get_internal_voip_stream_information(stream_info))) {
- if (ret == SOUND_MANAGER_ERROR_NO_DATA) {
+ if (ret == SOUND_MANAGER_ERROR_NO_DATA)
AUDIO_IO_LOGW("there's no internal voip stream info.");
- } else {
+ else
AUDIO_IO_LOGE("failed to sound_manager_get_internal_voip_stream_information(), ret(0x%x)", ret);
- }
}
+#endif
return;
}
void CAudioSessionHandler::initialize() {
AUDIO_IO_LOGD("");
- if (__mIsInit == true) {
+ if (__mIsInit == true)
return;
- }
MMSessionType currentSession = MM_SESSION_TYPE_MEDIA;
int sessionOptions = 0; // Mix with others by default
// Use focus watch callback with signal subscribe
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) {
+ 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);
- }
AUDIO_IO_LOGD("Subscribed mm_sound signal [id:%d]", __mSubscribeId);
__mMultimediaSession = currentSession;
__mOptions = sessionOptions;
- if (this->__mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE) {
+ if (this->__mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE)
__pcmCaptureCountInc();
- }
__mIsInit = true;
}
void CAudioSessionHandler::finalize() {
AUDIO_IO_LOGD("");
- if (__mIsInit == false) {
+ if (__mIsInit == false)
return;
- }
- if (__mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE) {
+ if (__mAudioSession == EAudioSessionType::AUDIO_SESSION_TYPE_CAPTURE)
__pcmCaptureCountDec();
- }
unregisterSound();
}
void CAudioSessionHandler::registerSound() {
- if (__mIsInit == false) {
+ if (__mIsInit == false)
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
- }
if (__mUseFocus == true) {
__lockFocusIdMutex();
}
void CAudioSessionHandler::unregisterSound() {
- if (__mIsInit == false) {
+ if (__mIsInit == false)
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
- }
__lockFocusIdMutex();
if (__mUseFocus == true && __mId >= 0) {
}
void CAudioSessionHandler::updatePlaying() {
- if (__mIsInit == false) {
+ if (__mIsInit == false)
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
- }
+
__lockFocusIdMutex();
if (!__mUseFocus || __mId < 0) {
__unlockFocusIdMutex();
}
void CAudioSessionHandler::updateStop() {
- if (__mIsInit == false) {
+ if (__mIsInit == false)
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioSessionHandler");
- }
if (__mUseFocus && __isFocusRequired(__mMultimediaSession, __mOptions)) {
__lockFocusIdMutex();