*/
-#include <mm.h>
-#include <pthread.h>
#include <assert.h>
-#include <glib.h>
#include "CAudioIODef.h"
+#include <sound_manager_internal.h>
+#include <sys/time.h>
+#include <string.h>
using namespace std;
using namespace tizen_media_audio;
/**
* class CAudioIO
*/
-CAudioIO::CAudioIO() :
- mpAudioSessionHandler(NULL),
- mpPulseAudioClient(NULL),
- __mMutex(PTHREAD_MUTEX_INITIALIZER),
- __mCondMutex(PTHREAD_MUTEX_INITIALIZER),
- __mCond(PTHREAD_COND_INITIALIZER),
- __mIsInit(false),
- __mForceIgnore(false) {
- mInterruptCode = IAudioSessionEventListener::EInterruptCode::INTERRUPT_MAX;
- mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_MAX;
- mState = CAudioInfo::EAudioIOState::AUDIO_IO_STATE_NONE;
- mStatePrev = CAudioInfo::EAudioIOState::AUDIO_IO_STATE_NONE;
- mByPolicy = false;
- mIsInterrupted = false;
-}
CAudioIO::CAudioIO(CAudioInfo& audioInfo) :
- mpAudioSessionHandler(NULL),
- mpPulseAudioClient(NULL),
- __mMutex(PTHREAD_MUTEX_INITIALIZER),
- __mCondMutex(PTHREAD_MUTEX_INITIALIZER),
- __mCond(PTHREAD_COND_INITIALIZER),
- __mIsInit(false),
- __mForceIgnore(false) {
- mAudioInfo = audioInfo;
- mInterruptCode = IAudioSessionEventListener::EInterruptCode::INTERRUPT_MAX;
- mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_MAX;
- mState = CAudioInfo::EAudioIOState::AUDIO_IO_STATE_NONE;
- mStatePrev = CAudioInfo::EAudioIOState::AUDIO_IO_STATE_NONE;
- mByPolicy = false;
- mIsInterrupted = false;
-}
-
-CAudioIO::~CAudioIO() {
+ mAudioInfo(audioInfo) {
}
void CAudioIO::setInit(bool flag) {
}
bool CAudioIO::IsReady() {
- return ((mState == CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING || mState == CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED)? true : false);
-}
-
-void CAudioIO::internalLock() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
-
- if (pthread_mutex_lock(&__mMutex) != 0) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()");
- }
-
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_RED "%p LOCKED" COLOR_END, &__mMutex);
-#endif
-}
-
-void CAudioIO::internalUnlock() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
-
- if (pthread_mutex_unlock(&__mMutex) != 0) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()");
- }
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_GREEN "%p UNLOCKED" COLOR_END, &__mMutex);
-#endif
-}
-
-void CAudioIO::internalWait() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
-
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_RED "WAIT" COLOR_END);
-#endif
-
- pthread_mutex_lock(&__mCondMutex);
- pthread_cond_wait(&__mCond, &__mCondMutex);
- pthread_mutex_unlock(&__mCondMutex);
-}
-
-void CAudioIO::internalSignal() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
-
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_GREEN "SIGNAL" COLOR_END);
-#endif
-
- pthread_mutex_lock(&__mCondMutex);
- pthread_cond_signal(&__mCond);
- pthread_mutex_unlock(&__mCondMutex);
-}
-
-bool CAudioIO::isForceIgnore() {
- return __mForceIgnore;
+ return ((mState == CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING ||
+ mState == CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED));
}
void CAudioIO::initialize() {
- if (__mIsInit == true) {
+ if (__mIsInit)
return;
- }
AUDIO_IO_LOGD("initialize");
-
- int ret = pthread_mutex_init(&__mMutex, NULL);
- if (ret != 0) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_mutex_init()");
- }
-
- ret = pthread_cond_init(&__mCond, NULL);
- if (ret != 0) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_cond_init()");
- }
-
__mIsInit = true;
}
void CAudioIO::finalize() {
- if (__mIsInit == false) {
+ if (!__mIsInit)
return;
- }
AUDIO_IO_LOGD("finalize");
-
- bool error_occured = false;
- int ret = pthread_mutex_destroy(&__mMutex);
- if (ret != 0) {
- AUDIO_IO_LOGE("Failed pthread_mutex_destroy(%p) errno:%d", &__mMutex, ret);
- error_occured = true;
- }
- ret = pthread_mutex_destroy(&__mCondMutex);
- if (ret != 0) {
- AUDIO_IO_LOGE("Failed pthread_mutex_destroy(%p) errno:%d", &__mCondMutex, ret);
- error_occured = true;
- }
-
-
- ret = pthread_cond_destroy(&__mCond);
- if (ret != 0) {
- AUDIO_IO_LOGE("Failed pthread_cond_destroy(%p) errno:%d", &__mCond, ret);
- error_occured = true;
- }
-
- if (error_occured)
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Finalize Failed");
-
__mIsInit = false;
}
void CAudioIO::onStream(CPulseAudioClient* pClient, size_t length) {
- assert(__mIsInit == true);
- assert(pClient != NULL);
+ assert(__mIsInit);
+ assert(pClient);
assert(length > 0);
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD("mStreamCallback.onStream(%p), pClient(%p), length(%zu)", mStreamCallback.onStream, pClient, length);
#endif
- if (mStreamCallback.onStream != NULL) {
+ if (mStreamCallback.onStream)
mStreamCallback.onStream(length, mStreamCallback.mUserData);
- }
}
void CAudioIO::onStateChanged(CAudioInfo::EAudioIOState state, bool byPolicy) {
- assert(__mIsInit == true);
+ assert(__mIsInit);
assert(state >= CAudioInfo::EAudioIOState::AUDIO_IO_STATE_NONE && state < CAudioInfo::EAudioIOState::AUDIO_IO_STATE_MAX);
- mStatePrev = mState;
- mState = state;
- mByPolicy = byPolicy;
+ mByPolicy = byPolicy;
if (mState == mStatePrev)
return;
- const char* state_string[] = { "NONE", "IDLE", "RUNNING", "PAUSED" };
+ static const char* state_string[] = { "NONE", "IDLE", "RUNNING", "PAUSED" };
AUDIO_IO_LOGD("previous(%s,%d) ===> current(%s,%d), by_policy(%d)",
state_string[static_cast<int>(mStatePrev)],
static_cast<int>(mState),
mByPolicy);
- if (mStateChangedCallback.onStateChanged != NULL) {
+ if (mStateChangedCallback.onStateChanged)
mStateChangedCallback.onStateChanged(mState, mStatePrev, mByPolicy, mStateChangedCallback.mUserData);
- }
+}
+
+void CAudioIO::setState(CAudioInfo::EAudioIOState state) {
+ mStatePrev = mState;
+ mState = state;
}
void CAudioIO::onStateChanged(CAudioInfo::EAudioIOState state) {
onStateChanged(state, false);
}
-CAudioInfo::EAudioIOState CAudioIO::getState() {
+CAudioInfo::EAudioIOState CAudioIO::getState() noexcept {
return mState;
}
-int CAudioIO::sendInterrupt(void* user_data) {
- CAudioIO *pCaudioIo = (CAudioIO *)user_data;
-
- if (pCaudioIo && pCaudioIo->mInterruptCallback.onInterrupt) {
- AUDIO_IO_LOGD("sending interrupt [%d]", pCaudioIo->mInterruptCode);
- pCaudioIo->mInterruptCallback.onInterrupt(pCaudioIo->mInterruptCode, pCaudioIo->mInterruptCallback.mUserData);
- }
- return 0;
-}
-
-int caudio_gsource_callback(void *user_data) {
- CAudioIO::sendInterrupt(user_data);
- return 0;
-}
-
-void CAudioIO::onInterrupt(CAudioSessionHandler* pHandler, int id, mm_sound_focus_type_e focus_type,
- mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info) {
- assert(pHandler);
-
- int session_option = pHandler->getOptions();
-
- if (id == -1) {
- ///////////////////////////////////////
- // Triggered by 'focus watch callback'
- ///////////////////////////////////////
-
- if (session_option & (MM_SESSION_OPTION_PAUSE_OTHERS | MM_SESSION_OPTION_UNINTERRUPTIBLE)) {
- AUDIO_IO_LOGD("Session option is pausing others or uninterruptible, skip...");
- return;
- }
-
- if (state == FOCUS_IS_RELEASED) {
- // Focus handle(id) of the other application was released, notify resume
- // Focus watch callback doesn't have focus handle, but it need to convert & report to application for convenience
- state = FOCUS_IS_ACQUIRED;
- } else if (state == FOCUS_IS_ACQUIRED) {
- // Focus handle(id) of the other application was acquired, do pause if possible
- internalLock();
- if (mpPulseAudioClient) {
- mpPulseAudioClient->cork(true);
- }
- mIsInterrupted = true;
- internalUnlock();
-
- // Focus watch callback doesn't have focus handle, but it need to convert & report to application for convenience
- state = FOCUS_IS_RELEASED;
- }
- } else {
- ///////////////////////////////////////
- // Triggered by 'focus callback'
- ///////////////////////////////////////
-
- if (pHandler->getId() != id) {
- AUDIO_IO_LOGW("Id is different, why? [mId : %d]", pHandler->getId());
- }
-
- if (session_option & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
- AUDIO_IO_LOGD("Session option is uninterruptible, skip...");
- return;
- }
-
- if (state == FOCUS_IS_RELEASED) {
- // Focus handle(id) was released, do pause here
- internalLock();
- if (mpPulseAudioClient) {
- mpPulseAudioClient->cork(true);
- }
-
- mIsInterrupted = true;
- internalUnlock();
- } else if (state == FOCUS_IS_ACQUIRED) {
- // Focus handle(id) was acquired again,
- // check reason_for_change ("call-voice","call-video","voip","alarm","notification", ...)
- // do resume here and call interrupt completed callback to application.
- }
- }
-
- if (mInterruptCallback.onInterrupt != NULL) {
- IAudioSessionEventListener::EInterruptCode e = IAudioSessionEventListener::EInterruptCode::INTERRUPT_COMPLETED;
- e = IAudioSessionEventListener::convertInterruptedCode(state, reason_for_change);
-
- if (EInterruptCode::INTERRUPT_COMPLETED == e) {
- mInterruptCode = e;
- g_idle_add(caudio_gsource_callback, this);
- } else {
- mInterruptCallback.onInterrupt(e, mInterruptCallback.mUserData);
- }
- }
-}
-
-void CAudioIO::onSignal(CAudioSessionHandler* pHandler, mm_sound_signal_name_t signal, int value) {
- assert(pHandler);
-
- if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
- if (value == 1 && pHandler->getSubscribeId() > 0) {
- // Unregister focus watch callback & disable session handler
- pHandler->disableSessionHandler();
- AUDIO_IO_LOGD("Session handler disabled by signal");
- } else if (value == 0) {
- // Currently do nothing...
- }
- }
-}
-
void CAudioIO::prepare() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
- if (mDirection == CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN) {
- AUDIO_IO_LOGD("Prepare for Audio in");
- } else if (mDirection == CAudioInfo::EAudioDirection::AUDIO_DIRECTION_OUT) {
- AUDIO_IO_LOGD("Prepare for Audio Out");
- }
- try {
- if (mIsInterrupted) {
- AUDIO_IO_LOGE("This is preparing during interrupted!!!");
- bool isSkip = mpAudioSessionHandler->isSkipSession();
- if (__mForceIgnore == false && isSkip == false && mpAudioSessionHandler->getId() >= 0) {
- AUDIO_IO_LOGE("Session updatePlaying!!!");
- mpAudioSessionHandler->updatePlaying();
- }
-
- if (mpPulseAudioClient && mpPulseAudioClient->isCorked()) {
- AUDIO_IO_LOGE("Uncork!");
- mpPulseAudioClient->cork(false);
- }
- mIsInterrupted = false;
- }
-
- AUDIO_IO_LOGD("------> prepare done");
- /* Do nothing */
- } catch (CAudioError& e) {
- throw;
- }
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
}
void CAudioIO::unprepare() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
-
- try {
- AUDIO_IO_LOGD("unprepare ----->");
- /* Do nothing */
- } catch (CAudioError& e) {
- throw;
- }
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
}
void CAudioIO::pause() {
- if (__mIsInit == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioIO");
- }
+ if (!__mIsInit || !IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioIO"); //LCOV_EXCL_LINE
- try {
- internalLock();
- AUDIO_IO_LOGD("pause");
- mpPulseAudioClient->cork(true);
- internalUnlock();
- } catch (CAudioError& e) {
- internalUnlock();
- throw;
- }
+ AUDIO_IO_LOGD("pause");
+ mpPulseAudioClient->cork(true);
}
void CAudioIO::resume() {
- if (__mIsInit == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioIO");
- }
+ if (!__mIsInit || !IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioIO"); //LCOV_EXCL_LINE
- try {
- internalLock();
- AUDIO_IO_LOGD("resume");
- mpPulseAudioClient->cork(false);
- internalUnlock();
- } catch (CAudioError& e) {
- internalUnlock();
- throw;
- }
-}
-
-void CAudioIO::drain() {
- if (__mIsInit == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioIO");
- }
-
- try {
- if (mpPulseAudioClient->isInThread()) {
- mpPulseAudioClient->drain();
- } else {
- internalLock();
- mpPulseAudioClient->drain();
- internalUnlock();
- }
- } catch (CAudioError& e) {
- if (!mpPulseAudioClient->isInThread()) {
- internalUnlock();
- }
- throw;
- }
+ mpPulseAudioClient->cork(false);
}
void CAudioIO::flush() {
- if (__mIsInit == false || IsReady() == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioIO");
- }
+ if (!__mIsInit || !IsReady())
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioIO"); //LCOV_EXCL_LINE
- try {
- if (mpPulseAudioClient->isInThread()) {
- mpPulseAudioClient->flush();
- } else {
- internalLock();
- mpPulseAudioClient->flush();
- internalUnlock();
- }
- } catch (CAudioError& e) {
- if (!mpPulseAudioClient->isInThread()) {
- internalUnlock();
- }
- throw;
- }
+ mpPulseAudioClient->flush();
}
CAudioInfo& CAudioIO::getAudioInfo() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
return mAudioInfo;
}
void CAudioIO::setStreamCallback(SStreamCallback callback) {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
mStreamCallback = callback;
}
CAudioIO::SStreamCallback CAudioIO::getStreamCallback() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
return mStreamCallback;
}
void CAudioIO::setStateChangedCallback(SStateChangedCallback callback) {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
mStateChangedCallback = callback;
}
CAudioIO::SStateChangedCallback CAudioIO::getStateChangedCallback() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
return mStateChangedCallback;
}
-void CAudioIO::setInterruptCallback(SInterruptCallback callback) {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
-
- mInterruptCallback = callback;
-}
-
-CAudioIO::SInterruptCallback CAudioIO::getInterruptCallback() {
- if (__mIsInit == false) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
- }
-
- return mInterruptCallback;
-}
-
-void CAudioIO::ignoreSession() {
- if (__mIsInit == false)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
-
- try {
- internalLock();
-
- if (mpPulseAudioClient != NULL && mState == CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION, "An Operation is not permitted while started");
-
- abandonInternalFocus();
-
- internalUnlock();
- } catch (CAudioError& e) {
- internalUnlock();
- throw;
- }
-}
-
void CAudioIO::setStreamInfo(sound_stream_info_h stream_info) {
- if (stream_info == NULL)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_ARGUMENT, "stream_info is NULL");
-
- if (__mIsInit == false)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
+ if (!stream_info)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_ARGUMENT, "stream_info is NULL"); //LCOV_EXCL_LINE
- try {
- if (mState != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE, "it is not permitted while started");
+ if (!__mIsInit)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
- abandonInternalFocus();
+ if (mState != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE, "it is not permitted while started"); //LCOV_EXCL_LINE
- int errorCode = SOUND_MANAGER_ERROR_NONE;
- CAudioInfo::EAudioType audioType = CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA;
- char *type = NULL;
- int index = -1;
- bool avail = false;
+ int errorCode = SOUND_MANAGER_ERROR_NONE;
+ char *type = nullptr;
+ int index = -1;
+ bool avail = false;
- if ((errorCode = sound_manager_is_available_stream_information(stream_info, NATIVE_API_AUDIO_IO, &avail)) != SOUND_MANAGER_ERROR_NONE)
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info is invalid [ret:%d]", errorCode);
+ if ((errorCode = sound_manager_is_available_stream_information(stream_info, NATIVE_API_AUDIO_IO, &avail)) != SOUND_MANAGER_ERROR_NONE)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info is invalid [ret:%d]", errorCode); //LCOV_EXCL_LINE
+ if (!avail)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "Input stream is not supported"); //LCOV_EXCL_LINE
- if (!avail)
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "Input stream is not supported");
+ if ((errorCode = sound_manager_get_type_from_stream_information(stream_info, &type)) != SOUND_MANAGER_ERROR_NONE)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); //LCOV_EXCL_LINE
+ if (mDirection == CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN)
+ getAudioInfo().setAudioTypeByInputStreamType(type);
+ else
+ getAudioInfo().setAudioTypeByOutputStreamType(type);
- if ((errorCode = sound_manager_get_type_from_stream_information(stream_info, &type)) != SOUND_MANAGER_ERROR_NONE)
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode);
+ if ((errorCode = sound_manager_get_index_from_stream_information(stream_info, &index)) != SOUND_MANAGER_ERROR_NONE)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode); //LCOV_EXCL_LINE
+ getAudioInfo().setAudioIndex(index);
- if (mDirection == CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN)
- getAudioInfo().convertInputStreamType2AudioType(type, &audioType);
- else
- getAudioInfo().convertOutputStreamType2AudioType(type, &audioType);
- getAudioInfo().setAudioType(audioType);
-
- if ((errorCode = sound_manager_get_index_from_stream_information(stream_info, &index)) != SOUND_MANAGER_ERROR_NONE)
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode);
+ if (mDirection == CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN) {
+ int device_id;
+ int method;
+ sound_effect_method_with_reference_e method_reference;
- getAudioInfo().setAudioIndex(index);
+ if (sound_manager_get_effect_method(stream_info, &method) == SOUND_MANAGER_ERROR_NONE)
+ getAudioInfo().setEffectMethod(method);
- AUDIO_IO_LOGD("stream info(%p) is set", stream_info);
- } catch (CAudioError& e) {
- throw;
+ if (sound_manager_get_effect_method_with_reference(stream_info, &method_reference, &device_id) == SOUND_MANAGER_ERROR_NONE)
+ getAudioInfo().setEffectMethodWithReference(method_reference, device_id);
}
}
-void CAudioIO::setInternalStreamInfo() {
- if (__mIsInit == false)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
-
- try {
- if (mState != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE, "it is not permitted while started");
-
- if (mpAudioSessionHandler &&
- mpAudioSessionHandler->getMultimediaSession() == MM_SESSION_TYPE_VOIP) {
- sound_stream_info_h stream_info = NULL;
- mpAudioSessionHandler->getInternalVoipStreamInfo(&stream_info);
- AUDIO_IO_LOGD("get internal VOIP stream info(%p)", stream_info);
- setStreamInfo(stream_info);
- }
- } catch (CAudioError& e) {
- throw;
- }
-}
+void CAudioIO::onCorked(CPulseAudioClient* pClient, bool corked) {
+ assert(__mIsInit);
+ assert(pClient);
-void CAudioIO::abandonInternalFocus() {
- bool isSkip = mpAudioSessionHandler->isSkipSession();
- int id = mpAudioSessionHandler->getId();
-
- try {
- if (isSkip == false && id >= 0)
- mpAudioSessionHandler->unregisterSound();
-
- mpAudioSessionHandler->finalize();
- __mForceIgnore = true;
- } catch (CAudioError& e) {
- throw;
- }
+ AUDIO_IO_LOGD("pClient(%p), corked(%d)", pClient, corked);
}