void* user_data;
audio_in_stream_cb onStream;
- audio_io_stream_cb_s() : user_data(NULL), onStream(NULL)
+ audio_io_stream_cb_s() : user_data(nullptr), onStream(nullptr)
{/* Empty Body */}
} audio_io_stream_cb_s;
void* user_data;
audio_in_state_changed_cb onStateChanged;
- audio_io_state_changed_cb_s() : user_data(NULL), onStateChanged(NULL)
+ audio_io_state_changed_cb_s() : user_data(nullptr), onStateChanged(nullptr)
{/* Empty Body */}
} audio_io_state_changed_cb_s;
audio_io_stream_cb_s stream_callback;
audio_io_state_changed_cb_s state_changed_callback;
- audio_io_s() : audioIoHandle(NULL)
+ audio_io_s() : audioIoHandle(nullptr)
{/* Empty Body */}
} audio_io_s;
VALID_POINTER_START(obj)
if (is_output)
- *(audio_out_h *)obj = NULL;
+ *(audio_out_h *)obj = nullptr;
else
- *(audio_in_h *)obj = NULL;
+ *(audio_in_h *)obj = nullptr;
VALID_POINTER_END
}
* Implements CAPI functions
*/
int cpp_audio_in_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_in_h *input) {
- audio_io_s* handle = NULL;
+ audio_io_s* handle = nullptr;
bool mic_enable = false;
- int ret = 0;
+
try {
- if (input == NULL) {
+ if (!input)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
- }
__check_audio_param(sample_rate, channel, type, false);
AUDIO_IO_LOGD("samplerate:[%d] channel:[0x%x] sample_type:[0x%x]", sample_rate, channel, type);
/* If MIC is not supported, return NOT_SUPPORTED error */
- ret = system_info_get_platform_bool(FEATURE_MICROPHONE, &mic_enable);
+ int ret = system_info_get_platform_bool(FEATURE_MICROPHONE, &mic_enable);
AUDIO_IO_LOGD("system_info_platform [%s]=[%d], ret[%d]", FEATURE_MICROPHONE, mic_enable, ret);
- if (ret != SYSTEM_INFO_ERROR_NONE || !mic_enable) {
+ if (ret != SYSTEM_INFO_ERROR_NONE || !mic_enable)
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "System doesn't support microphone!");
- }
CAudioInfo audioInfo = __generate_audio_input_info(sample_rate, channel, type);
__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;
+ 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);
}
int cpp_audio_in_destroy(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
assert(handle->audioIoHandle);
}
int cpp_audio_in_set_sound_stream_info(audio_in_h input, sound_stream_info_h stream_info) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL || stream_info == NULL)
+ if (!handle || !stream_info)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, stream_info:%p", input, stream_info);
assert(handle->audioIoHandle);
}
int cpp_audio_in_prepare(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
assert(handle->audioIoHandle);
}
int cpp_audio_in_unprepare(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
assert(handle->audioIoHandle);
}
int cpp_audio_in_pause(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
assert(handle->audioIoHandle);
}
int cpp_audio_in_resume(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
assert(handle->audioIoHandle);
}
int cpp_audio_in_flush(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
assert(handle->audioIoHandle);
}
int cpp_audio_in_read(audio_in_h input, void *buffer, unsigned int length) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
int ret = 0;
try {
- if (handle == NULL || buffer == NULL)
+ auto handle = static_cast<audio_io_s*>(input);
+ if (!handle || !buffer)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, buffer:%p", input, buffer);
assert(handle->audioIoHandle);
- CAudioInput* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
- if (inputHandle == NULL) {
+ auto inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
+ if (!inputHandle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
- }
- size_t readn = inputHandle->read(buffer, static_cast<size_t>(length));
+ auto readn = inputHandle->read(buffer, static_cast<size_t>(length));
ret = static_cast<int>(readn);
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD("readn:%zu", readn);
}
int cpp_audio_in_get_buffer_size(audio_in_h input, int *size) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
try {
- if (handle == NULL || size == NULL)
+ auto handle = static_cast<audio_io_s*>(input);
+ if (!handle || !size)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, size:%p", input, size);
assert(handle->audioIoHandle);
- CAudioIO* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
- if (inputHandle == NULL) {
+ auto inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
+ if (!inputHandle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
- }
+
*size = inputHandle->getBufferSize();
} catch (CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
}
int cpp_audio_in_get_sample_rate(audio_in_h input, int *sample_rate) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
try {
- if (handle == NULL || sample_rate == NULL)
+ auto handle = static_cast<audio_io_s*>(input);
+ if (!handle || !sample_rate)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, sample_rate:%p", input, sample_rate);
assert(handle->audioIoHandle);
}
int cpp_audio_in_get_channel(audio_in_h input, audio_channel_e *channel) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
try {
- if (handle == NULL || channel == NULL)
+ auto handle = static_cast<audio_io_s*>(input);
+ if (!handle || !channel)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, channel:%p", input, channel);
assert(handle->audioIoHandle);
- const CAudioInfo::EChannel srcChannel = handle->audioIoHandle->getAudioInfo().getChannel();
- audio_channel_e dstChannel = AUDIO_CHANNEL_MONO;
+ auto srcChannel = handle->audioIoHandle->getAudioInfo().getChannel();
+ auto dstChannel = AUDIO_CHANNEL_MONO;
__convert_audio_info_channel_2_channel(srcChannel, dstChannel);
*channel = dstChannel;
}
int cpp_audio_in_get_sample_type(audio_in_h input, audio_sample_type_e *type) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
try {
- if (handle == NULL || type == NULL)
+ auto handle = static_cast<audio_io_s*>(input);
+ if (!handle || !type)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, type:%p", input, type);
assert(handle->audioIoHandle);
- const CAudioInfo::ESampleType srcSampleType = handle->audioIoHandle->getAudioInfo().getSampleType();
- audio_sample_type_e dstSampleType = AUDIO_SAMPLE_TYPE_U8;
+ auto srcSampleType = handle->audioIoHandle->getAudioInfo().getSampleType();
+ auto dstSampleType = AUDIO_SAMPLE_TYPE_U8;
__convert_audio_info_sample_type_2_sample_type(srcSampleType, dstSampleType);
*type = dstSampleType;
}
static void __stream_cb_internal(size_t nbytes, void *user_data) {
- audio_io_s* audioIo = static_cast<audio_io_s*>(user_data);
+ auto audioIo = static_cast<audio_io_s*>(user_data);
assert(audioIo);
if (audioIo->stream_callback.onStream)
CAudioInfo::EAudioIOState state_prev,
bool by_policy,
void *user_data) {
- audio_io_s* audioIo = static_cast<audio_io_s*>(user_data);
+ auto audioIo = static_cast<audio_io_s*>(user_data);
assert(audioIo);
if (audioIo->state_changed_callback.onStateChanged)
//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);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL || callback == NULL)
+ if (!handle || !callback)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, callback:%p", input, callback);
assert(handle->audioIoHandle);
handle->stream_callback.onStream = callback;
handle->stream_callback.user_data = user_data;
- CAudioIO::SStreamCallback cb = handle->audioIoHandle->getStreamCallback();
+ auto cb = handle->audioIoHandle->getStreamCallback();
cb.mUserData = static_cast<void*>(handle);
cb.onStream = __stream_cb_internal;
}
int cpp_audio_in_unset_stream_cb(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
assert(handle->audioIoHandle);
AUDIO_IO_LOGD("[%p]", handle);
- handle->stream_callback.onStream = NULL;
- handle->stream_callback.user_data = NULL;
+ handle->stream_callback.onStream = nullptr;
+ handle->stream_callback.user_data = nullptr;
- CAudioIO::SStreamCallback cb = handle->audioIoHandle->getStreamCallback();
- cb.mUserData = NULL;
- cb.onStream = NULL;
+ auto cb = handle->audioIoHandle->getStreamCallback();
+ cb.mUserData = nullptr;
+ cb.onStream = nullptr;
handle->audioIoHandle->setStreamCallback(cb);
} catch (CAudioError& e) {
}
int cpp_audio_in_peek(audio_in_h input, const void **buffer, unsigned int *length) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
size_t _length = 0;
try {
- if (handle == NULL || buffer == NULL)
+ auto handle = static_cast<audio_io_s*>(input);
+ if (!handle || !buffer)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, buffer:%p", input, buffer);
- CAudioInput* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
- if (inputHandle == NULL)
+ auto inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
+ if (!inputHandle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
inputHandle->peek(buffer, &_length);
}
int cpp_audio_in_drop(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
try {
- if (handle == NULL)
+ auto handle = static_cast<audio_io_s*>(input);
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p", input);
- CAudioInput* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
- if (inputHandle == NULL)
+ auto inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
+ if (!inputHandle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
inputHandle->drop();
}
int cpp_audio_in_set_state_changed_cb(audio_in_h input, audio_in_state_changed_cb callback, void* user_data) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL || callback == NULL)
+ if (!handle || !callback)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL input:%p, callback:%p", input, callback);
assert(handle->audioIoHandle);
handle->state_changed_callback.onStateChanged = callback;
handle->state_changed_callback.user_data = user_data;
- CAudioIO::SStateChangedCallback cb = handle->audioIoHandle->getStateChangedCallback();
+ auto cb = handle->audioIoHandle->getStateChangedCallback();
cb.mUserData = static_cast<void*>(handle);
cb.onStateChanged = __state_changed_cb_internal;
}
int cpp_audio_in_unset_state_changed_cb(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
+ auto handle = static_cast<audio_io_s*>(input);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p", input);
assert(handle->audioIoHandle);
AUDIO_IO_LOGD("[%p]", handle);
- handle->state_changed_callback.onStateChanged = NULL;
- handle->state_changed_callback.user_data = NULL;
+ handle->state_changed_callback.onStateChanged = nullptr;
+ handle->state_changed_callback.user_data = nullptr;
- CAudioIO::SStateChangedCallback cb = handle->audioIoHandle->getStateChangedCallback();
- cb.mUserData = NULL;
- cb.onStateChanged = NULL;
+ auto cb = handle->audioIoHandle->getStateChangedCallback();
+ cb.mUserData = nullptr;
+ cb.onStateChanged = nullptr;
handle->audioIoHandle->setStateChangedCallback(cb);
} catch (CAudioError& e) {
* Audio Out
*/
int cpp_audio_out_create_new(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_out_h *output) {
- audio_io_s* handle = NULL;
+ audio_io_s* handle = nullptr;
try {
- if (output == NULL)
+ if (!output)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p", output);
__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;
+ 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);
}
int cpp_audio_out_destroy(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p", output);
assert(handle->audioIoHandle);
return __convert_CAudioError(e);
}
- AUDIO_IO_LOGD("destroyed");
+ AUDIO_IO_LOGD("[%p] destroyed", handle);
return AUDIO_IO_ERROR_NONE;
}
int cpp_audio_out_set_sound_stream_info(audio_out_h output, sound_stream_info_h stream_info) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL || stream_info == NULL)
+ if (!handle || !stream_info)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, stream_info:%p", output, stream_info);
assert(handle->audioIoHandle);
}
int cpp_audio_out_prepare(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p", output);
assert(handle->audioIoHandle);
}
int cpp_audio_out_unprepare(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p", output);
assert(handle->audioIoHandle);
}
int cpp_audio_out_pause(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p", output);
assert(handle->audioIoHandle);
}
int cpp_audio_out_resume(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p", output);
assert(handle->audioIoHandle);
}
int cpp_audio_out_drain(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p", output);
assert(handle->audioIoHandle);
}
int cpp_audio_out_flush(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p", output);
assert(handle->audioIoHandle);
}
int cpp_audio_out_write(audio_out_h output, void *buffer, unsigned int length) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
int ret = 0;
try {
- if (handle == NULL || buffer == NULL)
+ auto handle = static_cast<audio_io_s*>(output);
+ if (!handle || !buffer)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameter is NULL output:%p, buffer:%p", output, buffer);
assert(handle->audioIoHandle);
- CAudioOutput* outputHandle = static_cast<CAudioOutput*>(handle->audioIoHandle);
- if (outputHandle == NULL)
+ auto outputHandle = static_cast<CAudioOutput*>(handle->audioIoHandle);
+ if (!outputHandle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
- size_t written = outputHandle->write(buffer, static_cast<size_t>(length));
+ auto written = outputHandle->write(buffer, static_cast<size_t>(length));
ret = static_cast<int>(written);
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD("written:%zu", written);
}
int cpp_audio_out_get_buffer_size(audio_out_h output, int *size) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
-
try {
- if (handle == NULL || size == NULL)
+ auto handle = static_cast<audio_io_s*>(output);
+ if (!handle || !size)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, size:%p", output, size);
assert(handle->audioIoHandle);
- CAudioOutput* outputHandle = static_cast<CAudioOutput*>(handle->audioIoHandle);
- if (outputHandle == NULL)
+ auto outputHandle = static_cast<CAudioOutput*>(handle->audioIoHandle);
+ if (!outputHandle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
*size = outputHandle->getBufferSize();
}
int cpp_audio_out_get_sample_rate(audio_out_h output, int *sample_rate) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
-
try {
- if (handle == NULL || sample_rate == NULL)
+ auto handle = static_cast<audio_io_s*>(output);
+ if (!handle || !sample_rate)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, sample_rate:%p", output, sample_rate);
assert(handle->audioIoHandle);
}
int cpp_audio_out_get_channel(audio_out_h output, audio_channel_e *channel) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
-
try {
- if (handle == NULL || channel == NULL)
+ auto handle = static_cast<audio_io_s*>(output);
+ if (!handle || !channel)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, channel:%p", output, channel);
assert(handle->audioIoHandle);
- const CAudioInfo::EChannel srcChannel = handle->audioIoHandle->getAudioInfo().getChannel();
- audio_channel_e dstChannel = AUDIO_CHANNEL_MONO;
+ auto srcChannel = handle->audioIoHandle->getAudioInfo().getChannel();
+ auto dstChannel = AUDIO_CHANNEL_MONO;
__convert_audio_info_channel_2_channel(srcChannel, dstChannel);
*channel = dstChannel;
}
int cpp_audio_out_get_sample_type(audio_out_h output, audio_sample_type_e *type) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
-
try {
- if (handle == NULL || type == NULL)
+ auto handle = static_cast<audio_io_s*>(output);
+ if (!handle || !type)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, type:%p", output, type);
assert(handle->audioIoHandle);
- const CAudioInfo::ESampleType srcSampleType = handle->audioIoHandle->getAudioInfo().getSampleType();
- audio_sample_type_e dstSampleType = AUDIO_SAMPLE_TYPE_U8;
+ auto srcSampleType = handle->audioIoHandle->getAudioInfo().getSampleType();
+ auto dstSampleType = AUDIO_SAMPLE_TYPE_U8;
__convert_audio_info_sample_type_2_sample_type(srcSampleType, dstSampleType);
*type = dstSampleType;
}
int cpp_audio_out_get_sound_type(audio_out_h output, sound_type_e *type) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL || type == NULL)
+ if (!handle || !type)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, type:%p", output, type);
assert(handle->audioIoHandle);
- const CAudioInfo::EAudioType srcAudioType = handle->audioIoHandle->getAudioInfo().getAudioType();
- sound_type_e dstSoundType = SOUND_TYPE_MEDIA;
+ auto srcAudioType = handle->audioIoHandle->getAudioInfo().getAudioType();
+ auto dstSoundType = SOUND_TYPE_MEDIA;
__convert_audio_info_audio_type_2_sound_type(srcAudioType, dstSoundType);
*type = dstSoundType;
}
int cpp_audio_out_set_stream_cb(audio_out_h output, audio_out_stream_cb callback, void* user_data) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL || callback == NULL)
+ if (!handle || !callback)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, callback:%p", output, callback);
assert(handle->audioIoHandle);
handle->stream_callback.onStream = callback;
handle->stream_callback.user_data = user_data;
- CAudioIO::SStreamCallback cb = handle->audioIoHandle->getStreamCallback();
+ auto cb = handle->audioIoHandle->getStreamCallback();
cb.mUserData = static_cast<void*>(handle);
cb.onStream = __stream_cb_internal;
}
int cpp_audio_out_unset_stream_cb(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p", output);
assert(handle->audioIoHandle);
AUDIO_IO_LOGD("[%p]", handle);
- handle->stream_callback.onStream = NULL;
- handle->stream_callback.user_data = NULL;
+ handle->stream_callback.onStream = nullptr;
+ handle->stream_callback.user_data = nullptr;
- CAudioIO::SStreamCallback cb = handle->audioIoHandle->getStreamCallback();
- cb.mUserData = NULL;
- cb.onStream = NULL;
+ auto cb = handle->audioIoHandle->getStreamCallback();
+ cb.mUserData = nullptr;
+ cb.onStream = nullptr;
handle->audioIoHandle->setStreamCallback(cb);
} catch (CAudioError& e) {
}
int cpp_audio_out_set_state_changed_cb(audio_out_h output, audio_in_state_changed_cb callback, void* user_data) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL || callback == NULL)
+ if (!handle || !callback)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p, callback:%p", output, callback);
assert(handle->audioIoHandle);
handle->state_changed_callback.onStateChanged = callback;
handle->state_changed_callback.user_data = user_data;
- CAudioIO::SStateChangedCallback cb = handle->audioIoHandle->getStateChangedCallback();
+ auto cb = handle->audioIoHandle->getStateChangedCallback();
cb.mUserData = static_cast<void*>(handle);
cb.onStateChanged = __state_changed_cb_internal;
}
int cpp_audio_out_unset_state_changed_cb(audio_out_h output) {
- audio_io_s* handle = static_cast<audio_io_s*>(output);
+ auto handle = static_cast<audio_io_s*>(output);
try {
- if (handle == NULL)
+ if (!handle)
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,
"Parameters are NULL output:%p", output);
assert(handle->audioIoHandle);
AUDIO_IO_LOGD("[%p]", handle);
- handle->state_changed_callback.onStateChanged = NULL;
- handle->state_changed_callback.user_data = NULL;
+ handle->state_changed_callback.onStateChanged = nullptr;
+ handle->state_changed_callback.user_data = nullptr;
- CAudioIO::SStateChangedCallback cb = handle->audioIoHandle->getStateChangedCallback();
- cb.mUserData = NULL;
- cb.onStateChanged = NULL;
+ auto cb = handle->audioIoHandle->getStateChangedCallback();
+ cb.mUserData = nullptr;
+ cb.onStateChanged = nullptr;
handle->audioIoHandle->setStateChangedCallback(cb);
} catch (CAudioError& e) {