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() {
}
*/
if (__mIsUsedSyncWrite == true) {
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("Sync Write Mode! - signal! - pClient:[%p], length:[%d]", pClient, length);
+ AUDIO_IO_LOGD("Sync Write Mode! - signal! - pClient:[%p], length:[%zu]", pClient, length);
#endif
internalSignal();
return;
* Accrues callback function
*/
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("pClient:[%p], length:[%d]", pClient, length);
+ AUDIO_IO_LOGD("pClient:[%p], length:[%zu]", pClient, length);
#endif
CAudioIO::onStream(pClient, length);
}
streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_DEFAULT_ASYNC;
}
#endif
+ /* Override the default value by audio type */
+ if (audioType == CAudioInfo::EAudioType::AUDIO_OUT_TYPE_VOIP)
+ streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_VOIP;
+
CPulseStreamSpec spec(streamSpec, mAudioInfo);
internalLock();
internalUnlock();
throw;
} catch (const std::bad_alloc&) {
+//LCOV_EXCL_START
internalUnlock();
THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed to allocate CPulseAudioClient object");
+//LCOV_EXCL_STOP
}
}
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,
"The written result is invalid ret:%d", ret);
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%d)", buffer, length);
+ AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%zu)", buffer, length);
#endif
return length;
}
while ((l = mpPulseAudioClient->getWritableSize()) == 0) {
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("writableSize is [%d].. wait", l);
+ AUDIO_IO_LOGD("writableSize is [%zu].. wait", l);
#endif
internalWait();
}
l = lengthIter;
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%d)", buffer, l);
+ AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%zu)", buffer, l);
#endif
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;
}
}
+//LCOV_EXCL_START
void CPulseAudioClient::__successContextCb(pa_context* c, int success, void* user_data) {
AUDIO_IO_LOGD("pa_context[%p], success[%d], user_data[%p]", c, success, user_data);
assert(c);
#endif
return (state ? false : true);
}
+//LCOV_EXCL_STOP
void CPulseAudioClient::__streamStateChangeCb(pa_stream* s, void* user_data) {
assert(s);
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");
#ifndef DISABLE_MOBILE_BACK_COMP
if (pClient->__mIsInit == false) {
- AUDIO_IO_LOGD("Occurred this listener when an out stream is on the way to create : Write dummy, length[%d]", length);
+ AUDIO_IO_LOGD("Occurred this listener when an out stream is on the way to create : Write dummy, length[%zu]", length);
__dummy_write(s, length);
return;
}
if (pClient->isCorked()) {
- AUDIO_IO_LOGD("Occurred this listener when an out stream is CORKED : Write dummy, length[%d]", length);
+ AUDIO_IO_LOGD("Occurred this listener when an out stream is CORKED : Write dummy, length[%zu]", length);
__dummy_write(s, length);
return;
}
then write dummy data to ensure the start */
if (pClient->__mSpec.getStreamLatency() == CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_DEFAULT_ASYNC &&
pClient->__mIsFirstStream) {
- AUDIO_IO_LOGW("[async] Write dummy of length[%d] since not written in first callback during prepare", length);
+ AUDIO_IO_LOGW("[async] Write dummy of length[%zu] since not written in first callback during prepare", length);
__dummy_write(s, length);
pClient->__mIsFirstStream = false;
}
pClient->__mIsStarted = false;
}
+//LCOV_EXCL_START
void CPulseAudioClient::__streamEventCb(pa_stream* s, const char *name, pa_proplist *pl, void *user_data) {
assert(s);
assert(user_data);
pa_operation_unref(pa_stream_cork(pClient->__mpStream, 1, NULL, NULL));
}
}
-
+//LCOV_EXCL_STOP
void CPulseAudioClient::__successStreamCb(pa_stream* s, int success, void* user_data) {
AUDIO_IO_LOGD("pa_stream[%p], success[%d], user_data[%p]", s, success, user_data);
pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
}
+//LCOV_EXCL_START
void CPulseAudioClient::__successDrainCbInThread(pa_stream* s, int success, void* user_data) {
AUDIO_IO_LOGD("pa_stream[%p], success[%d], user_data[%p]", s, success, user_data);
assert(s);
pClient->__mIsOperationSuccess = static_cast<bool>(success);
pClient->__mIsDraining = false;
}
+//LCOV_EXCL_STOP
void CPulseAudioClient::__successDrainCb(pa_stream* s, int success, void* user_data) {
AUDIO_IO_LOGD("pa_stream[%p], success[%d], user_data[%p]", s, success, user_data);
// 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
}
}
if (__mSyncReadLength <= 0) {
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("readLength(%d byte) is not valid. wait...", __mSyncReadLength);
+ AUDIO_IO_LOGD("readLength(%zu byte) is not valid. wait...", __mSyncReadLength);
#endif
pa_threaded_mainloop_wait(__mpMainloop);
} else if (__mpSyncReadDataPtr == NULL) {
// 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;
// Copy partial pcm data on out parameter
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("memcpy() that a peeked buffer[0x%x], index[%d], length[%d] on out buffer", (const uint8_t*)(__mpSyncReadDataPtr) + __mSyncReadIndex, __mSyncReadIndex, l);
+ AUDIO_IO_LOGD("memcpy() that a peeked buffer[%p], index[%zu], length[%zu] on out buffer", (const uint8_t*)(__mpSyncReadDataPtr) + __mSyncReadIndex, __mSyncReadIndex, l);
#endif
memcpy(buffer, (const uint8_t*)__mpSyncReadDataPtr + __mSyncReadIndex, l);
#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
}
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("buffer[%p], length[%d]", *buffer, *length);
+ AUDIO_IO_LOGD("buffer[%p], length[%zu]", *buffer, *length);
#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;
int ret = 0;
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("data[%p], length[%d], First[%d]", data, length, __mIsFirstStream);
+ AUDIO_IO_LOGD("data[%p], length[%zu], First[%d]", data, length, __mIsFirstStream);
#endif
- if (pa_stream_is_corked(__mpStream)) {
- AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
- pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
- }
if (isInThread() == false) {
pa_threaded_mainloop_lock(__mpMainloop);
+ if (pa_stream_is_corked(__mpStream)) {
+ AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
+ pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
+ }
+
ret = pa_stream_write(__mpStream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
pa_threaded_mainloop_unlock(__mpMainloop);
} else {
+ if (pa_stream_is_corked(__mpStream)) {
+ AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
+ pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
+ }
+
if (__mIsFirstStream) {
const pa_buffer_attr* attr = pa_stream_get_buffer_attr(__mpStream);
uint32_t prebuf = attr->prebuf;
delete [] dummy;
}
__mIsFirstStream = false;
- AUDIO_IO_LOGW("FIRST STREAM CALLBACK : length[%d], prebuf[%d], dummy[%d]",
+ AUDIO_IO_LOGW("FIRST STREAM CALLBACK : length[%zu], prebuf[%d], dummy[%zu]",
length, prebuf, (length < prebuf) ? prebuf - length : 0);
}
ret = pa_stream_write(__mpStream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
}
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;
return static_cast<bool>(ret);
}
+//LCOV_EXCL_START
size_t CPulseAudioClient::getReadableSize() {
if (__mIsInit == false) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
ret = attr->tlength;
- AUDIO_IO_LOGD("PLAYBACK buffer size[%d]", ret);
+ AUDIO_IO_LOGD("PLAYBACK buffer size[%zu]", ret);
} else {
ret = attr->fragsize;
- AUDIO_IO_LOGD("RECORD buffer size[%d]", ret);
+ AUDIO_IO_LOGD("RECORD buffer size[%zu]", ret);
}
} catch (CAudioError& e) {
if (isInThread() == false) {
CPulseStreamSpec CPulseAudioClient::getStreamSpec() {
return __mSpec;
}
+//LCOV_EXCL_STOP
__handle_safe_free(handle, (void *)input, false);
return __convert_CAudioError(e);
} catch (const std::bad_alloc&) {
+//LCOV_EXCL_START
CAudioError e = CAudioError::EError::ERROR_OUT_OF_MEMORY;
AUDIO_IO_LOGE("Failed to allocate handle");
__handle_safe_free(handle, (void *)input, false);
return __convert_CAudioError(e);
+//LCOV_EXCL_STOP
}
return AUDIO_IO_ERROR_NONE;
size_t readn = inputHandle->read(buffer, static_cast<size_t>(length));
ret = static_cast<int>(readn);
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("readn:%d", readn);
+ AUDIO_IO_LOGD("readn:%zu", readn);
#endif
} catch (CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
audioIo->stream_callback.onStream(audioIo, nbytes, audioIo->stream_callback.user_data);
}
+//LCOV_EXCL_START
static void __state_changed_cb_internal(CAudioInfo::EAudioIOState state,
CAudioInfo::EAudioIOState state_prev,
bool by_policy,
__convert_state_type(state), by_policy,
audioIo->state_changed_callback.user_data);
}
+//LCOV_EXCL_STOP
int cpp_audio_in_set_stream_cb(audio_in_h input, audio_in_stream_cb callback, void* user_data) {
audio_io_s* handle = static_cast<audio_io_s*>(input);
__handle_safe_free(handle, (void *)output, true);
return __convert_CAudioError(e);
} catch (const std::bad_alloc&) {
+//LCOV_EXCL_START
CAudioError e = CAudioError::EError::ERROR_OUT_OF_MEMORY;
AUDIO_IO_LOGE("Failed to allocate handle");
__handle_safe_free(handle, (void *)output, true);
return __convert_CAudioError(e);
+//LCOV_EXCL_STOP
}
return AUDIO_IO_ERROR_NONE;
size_t written = outputHandle->write(buffer, static_cast<size_t>(length));
ret = static_cast<int>(written);
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("written:%d", written);
+ AUDIO_IO_LOGD("written:%zu", written);
#endif
} catch (CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());