As following errors can't be covered by audio-io testcase itself, exclude from coverage scope
- pthread mutex errors
- sound_manager errors
- pulseaudio errors except policy restriction
- constructors which is not in use
Change-Id: I58d02dc65c16419b2c7eee95670f169327093109
/**
* class CAudioIO
*/
+//LCOV_EXCL_START
CAudioIO::CAudioIO() :
mpPulseAudioClient(NULL),
__mMutex(PTHREAD_MUTEX_INITIALIZER),
mStatePrev = CAudioInfo::EAudioIOState::AUDIO_IO_STATE_NONE;
mByPolicy = false;
}
+//LCOV_EXCL_STOP
CAudioIO::CAudioIO(CAudioInfo& audioInfo) :
mpPulseAudioClient(NULL),
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()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()"); //LCOV_EXCL_LINE
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD(COLOR_RED "%p LOCKED" COLOR_END, &__mMutex);
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()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()"); //LCOV_EXCL_LINE
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD(COLOR_GREEN "%p UNLOCKED" COLOR_END, &__mMutex);
int ret = pthread_mutex_init(&__mMutex, NULL);
if (ret != 0)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_mutex_init()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_mutex_init()"); //LCOV_EXCL_LINE
ret = pthread_cond_init(&__mCond, NULL);
if (ret != 0)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_cond_init()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_cond_init()"); //LCOV_EXCL_LINE
__mIsInit = true;
}
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);
+ AUDIO_IO_LOGE("Failed pthread_mutex_destroy(%p) errno:%d", &__mMutex, ret); //LCOV_EXCL_LINE
error_occured = true;
}
ret = pthread_mutex_destroy(&__mCondMutex);
if (ret != 0) {
+//LCOV_EXCL_START
AUDIO_IO_LOGE("Failed cond pthread_mutex_destroy(%p) errno:%d", &__mCondMutex, ret);
error_occured = true;
+//LCOV_EXCL_STOP
}
ret = pthread_cond_destroy(&__mCond);
if (ret != 0) {
+//LCOV_EXCL_START
AUDIO_IO_LOGE("Failed pthread_cond_destroy(%p) errno:%d", &__mCond, ret);
error_occured = true;
+//LCOV_EXCL_STOP
}
if (error_occured)
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);
+ 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().convertInputStreamType2AudioType(type, &audioType);
else
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);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode); //LCOV_EXCL_LINE
getAudioInfo().setAudioIndex(index);
} catch (CAudioError& e) {
mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN;
}
+//LCOV_EXCL_START
CAudioInput::CAudioInput(
unsigned int sampleRate,
CAudioInfo::EChannel channel,
mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN;
mAudioInfo = CAudioInfo(sampleRate, channel, type, audioType, -1);
}
+//LCOV_EXCL_STOP
CAudioInput::~CAudioInput() {
}
prData.paMainloop = pa_threaded_mainloop_new();
if (prData.paMainloop == NULL)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()"); //LCOV_EXCL_LINE
c = pa_context_new(pa_threaded_mainloop_get_api(prData.paMainloop), CLIENT_NAME);
if (c == NULL)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()"); //LCOV_EXCL_LINE
pa_context_set_state_callback(c, __contextStateChangeCb, prData.paMainloop);
if (pa_context_connect(c, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()"); //LCOV_EXCL_LINE
pa_threaded_mainloop_lock(prData.paMainloop);
if (pa_threaded_mainloop_start(prData.paMainloop) < 0) {
pa_threaded_mainloop_unlock(prData.paMainloop);
- THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()"); //LCOV_EXCL_LINE
}
while (true) {
break;
if (!PA_CONTEXT_IS_GOOD(state)) {
+//LCOV_EXCL_START
err = pa_context_errno(c);
pa_threaded_mainloop_unlock(prData.paMainloop);
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,
"pa_context's state is not good : err[%d]", err);
+//LCOV_EXCL_STOP
}
/* Wait until the context is ready */
o = pa_context_check_privilege(c, RECORDER_PRIVILEGE, __checkPrivilegeCb, &prData);
if (!o) {
+//LCOV_EXCL_START
pa_threaded_mainloop_unlock(prData.paMainloop);
THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed to pa_context_check_privilege()");
+//LCOV_EXCL_STOP
}
while (pa_operation_get_state(o) == PA_OPERATION_RUNNING)
pa_threaded_mainloop_wait(prData.paMainloop);
mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_OUT;
}
+//LCOV_EXCL_START
CAudioOutput::CAudioOutput(
unsigned int sampleRate,
CAudioInfo::EChannel channel,
mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_OUT;
mAudioInfo = CAudioInfo(sampleRate, channel, sampleType, audioType, -1);
}
+//LCOV_EXCL_STOP
CAudioOutput::~CAudioOutput() {
}
int ret = mpPulseAudioClient->write(buffer, l);
if (ret < 0)
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,
- "The written result is invalid ret:%d", ret);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,//LCOV_EXCL_LINE
+ "The written result is invalid ret:%d", ret); //LCOV_EXCL_LINE
buffer = static_cast<const uint8_t*>(buffer) + l;
lengthIter -= l;
break;
case PA_STREAM_FAILED:
+//LCOV_EXCL_START
AUDIO_IO_LOGD("The stream is failed");
pClient->__mpListener->onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE,
__is_microphone_restricted());
pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
break;
+//LCOV_EXCL_STOP
case PA_STREAM_TERMINATED:
AUDIO_IO_LOGD("The stream is terminated");
// Allocates PA proplist
__mpPropList = pa_proplist_new();
if (__mpPropList == NULL) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_proplist_new()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_proplist_new()"); //LCOV_EXCL_LINE
}
// Adds values on proplist for delivery to PULSEAUDIO
// Allocates PA mainloop
__mpMainloop = pa_threaded_mainloop_new();
if (__mpMainloop == NULL) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()"); //LCOV_EXCL_LINE
}
// Allocates PA context
__mpContext = pa_context_new(pa_threaded_mainloop_get_api(__mpMainloop), CLIENT_NAME);
if (__mpContext == NULL) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()"); //LCOV_EXCL_LINE
}
// Sets context state changed callback
// Connects this client with PA server
if (pa_context_connect(__mpContext, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()"); //LCOV_EXCL_LINE
}
// LOCK for synchronous connection
// Start mainloop
if (pa_threaded_mainloop_start(__mpMainloop) < 0) {
pa_threaded_mainloop_unlock(__mpMainloop);
- THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()");
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()"); //LCOV_EXCL_LINE
}
// Connection process is asynchronously
}
if (!PA_CONTEXT_IS_GOOD(state)) {
+//LCOV_EXCL_START
err = pa_context_errno(__mpContext);
pa_threaded_mainloop_unlock(__mpMainloop);
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "pa_context's state is not good : err[%d]", err);
+//LCOV_EXCL_STOP
}
/* Wait until the context is ready */
__mpStream = pa_stream_new_with_proplist(__mpContext, __mSpec.getStreamName(), &ss, &map, __mpPropList);
if (__mpStream == NULL) {
+//LCOV_EXCL_START
pa_threaded_mainloop_unlock(__mpMainloop);
THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_new_with_proplist()");
+//LCOV_EXCL_STOP
}
// Sets stream callbacks
}
if (ret != 0) {
+//LCOV_EXCL_START
err = pa_context_errno(__mpContext);
pa_threaded_mainloop_unlock(__mpMainloop);
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_connect() : err[%d]", err);
+//LCOV_EXCL_STOP
}
while (true) {
if (err == PA_ERR_ACCESS) {
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_DEVICE_POLICY_RESTRICTION, "pa_stream's state is not good : err[%d]", err);
} else {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "pa_stream's state is not good : err[%d]", err);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "pa_stream's state is not good : err[%d]", err); //LCOV_EXCL_LINE
}
}
// Data peeked, but it doesn't have any data
ret = pa_stream_drop(__mpStream);
if (ret != 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret); //LCOV_EXCL_LINE
}
} else {
__mSyncReadIndex = 0;
#endif
ret = pa_stream_drop(__mpStream);
if (ret != 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret); //LCOV_EXCL_LINE
}
// Reset the internal pointer
#endif
if (ret < 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_peek() : err[%d]", ret);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_peek() : err[%d]", ret); //LCOV_EXCL_LINE
}
return ret;
}
if (ret < 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_drop() : err[%d]", ret);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_drop() : err[%d]", ret); //LCOV_EXCL_LINE
}
return ret;
}
if (ret < 0) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_write() : err[%d]", ret);
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_write() : err[%d]", ret); //LCOV_EXCL_LINE
}
return ret;
static const char* STREAM_LATENCY_DEFAULT = "default";
static const char* STREAM_LATENCY_DEFAULT_ASYNC = "default-async";
-
+//LCOV_EXCL_START
CPulseStreamSpec::CPulseStreamSpec():
__mLatency(EStreamLatency::STREAM_LATENCY_INPUT_DEFAULT),
__mStreamName(NULL) {
__adjustSpec();
}
+//LCOV_EXCL_STOP
CPulseStreamSpec::CPulseStreamSpec(EStreamLatency latency, CAudioInfo& audioInfo) :
__mLatency(latency),
__adjustSpec();
}
+//LCOV_EXCL_START
CPulseStreamSpec::CPulseStreamSpec(EStreamLatency latency, CAudioInfo& audioInfo, int customLatency) :
__mLatency(latency),
__mAudioInfo(audioInfo),
__mStreamName(NULL) {
__adjustSpec();
}
+//LCOV_EXCL_STOP
CPulseStreamSpec::~CPulseStreamSpec() {
}