#include <dlog.h>
#include "CAudioIODef.h"
-
using namespace std;
using namespace tizen_media_audio;
-
/**
* class CAudioError
*/
-CAudioError::EError CAudioError::__mLastError = CAudioError::EError::ERROR_NONE;
-char CAudioError::__mLastErrorMsg[MSG_LENGTH];
-
-//LCOV_EXCL_START
-CAudioError::CAudioError(EError err) :
- __mError(err) {
- __mLastError = __mError;
+CAudioError::CAudioError(EError err, const char* msg, const char* file, const char* func, int line) :
+ __mError(err),
+ __mMsg(msg) {
+ char __mErrorMsg[MSG_LENGTH] = { 0, };
+ snprintf(__mErrorMsg, MSG_LENGTH, "[%s|%s|%s(%d)|"
+ COLOR_CYAN "%s" COLOR_END "]",
+ __convertErrorToString(__mError), file, func, line, msg);
+
+ __mFullMsg = __mErrorMsg;
}
-CAudioError::CAudioError(EError err, const char* fileName, const char* parentFunc, int lineNum) :
- __mError(err) {
- __mLastError = __mError;
-
- const char* findFileName = strrchr(fileName, '/');
- if (findFileName)
- findFileName++;
- const char* errStr = __convertErrorToString(__mError);
-
- snprintf(__mErrorMsg, MSG_LENGTH, "["
- COLOR_RED "THROW" COLOR_END ":%s|"
- COLOR_YELLOW "ERR" COLOR_END ":%s|"
- COLOR_YELLOW "FUNC" COLOR_END ":%s(%d)]", findFileName, errStr, parentFunc, lineNum);
+CAudioError::CAudioError(EError err) :
+ __mError(err),
+ __mMsg(nullptr) {
+ char __mErrorMsg[MSG_LENGTH] = { 0, };
+ snprintf(__mErrorMsg, MSG_LENGTH, "[%s]", __convertErrorToString(__mError));
- snprintf(__mLastErrorMsg, MSG_LENGTH, "LastError:%s", __mErrorMsg);
+ __mFullMsg = __mErrorMsg;
}
-//LCOV_EXCL_STOP
-
-CAudioError::CAudioError(EError err, const char* msg, const char* fileName, const char* parentFunc, int lineNum) :
- __mError(err) {
- __mLastError = __mError;
- const char* findFileName = strrchr(fileName, '/');
- if (findFileName)
- findFileName++;
- const char* errStr = __convertErrorToString(__mError);
-
- snprintf(__mErrorMsg, MSG_LENGTH, "["
- COLOR_RED "THROW" COLOR_END ":%s|"
- COLOR_YELLOW "ERR" COLOR_END ":%s|"
- COLOR_YELLOW "FUNC" COLOR_END ":%s(%d)]"
- COLOR_YELLOW "MSG" COLOR_END ":"
- COLOR_CYAN "%s" COLOR_END, findFileName, errStr, parentFunc, lineNum, msg);
-
- snprintf(__mLastErrorMsg, MSG_LENGTH, "LastError:%s", __mErrorMsg);
+const char* CAudioError::getErrorMsg() const noexcept {
+ return __mFullMsg.c_str();
}
-//LCOV_EXCL_START
-CAudioError::CAudioError(const CAudioError& err) {
- __mError = err.__mError;
- memcpy(__mErrorMsg, err.__mErrorMsg, MSG_LENGTH);
+const CAudioError::EError CAudioError::getError() const noexcept {
+ return __mError;
}
-//LCOV_EXCL_STOP
-const char* CAudioError::__convertErrorToString(EError err) {
+const char* CAudioError::__convertErrorToString(EError err) noexcept {
switch (err) {
default:
case EError::ERROR_NONE: return COLOR_GREEN "ERROR_NONE" COLOR_END;
//LCOV_EXCL_STOP
}
}
-
-//LCOV_EXCL_START
-CAudioError::EError CAudioError::getLastError() {
- return __mLastError;
-}
-
-const char* CAudioError::getLastErrorMsg() {
- return __mLastErrorMsg;
-}
-//LCOV_EXCL_STOP
-
-CAudioError::EError CAudioError::getError() {
- return __mError;
-}
-
-const char* CAudioError::getErrorMsg() {
- return __mErrorMsg;
-}
-
-//LCOV_EXCL_START
-CAudioError& CAudioError::operator = (const EError err) {
- __mError = err;
- __mLastError = __mError;
- return *this;
-}
-
-CAudioError& CAudioError::operator = (const CAudioError& err) {
- __mError = err.__mError;
- __mLastError = __mError;
- memcpy(__mErrorMsg, err.__mErrorMsg, MSG_LENGTH);
- memcpy(__mLastErrorMsg, __mErrorMsg, MSG_LENGTH);
- return *this;
-}
-
-bool CAudioError::operator != (const EError err) {
- return (__mError != err);
-}
-
-bool CAudioError::operator == (const EError err) {
- return (__mError == err);
-}
-//LCOV_EXCL_STOP
-
-//bool operator == (const CAudioError& src, const CAudioError::EError& err) {
-// //return (src.__mLastError == err);
-// return true;
-//}
#include "CAudioIODef.h"
#include <system_info.h>
+#include <cassert>
#define FEATURE_MICROPHONE "http://tizen.org/feature/microphone"
/**
* Internal functions
*/
-static audio_io_error_e __convert_CAudioError(CAudioError& error) {
- switch (error.getError()) {
+static audio_io_error_e __convert_audio_io_error(CAudioError::EError error) {
+ switch (error) {
case CAudioError::EError::ERROR_NONE:
return AUDIO_IO_ERROR_NONE;
case CAudioError::EError::ERROR_INVALID_ARGUMENT:
AUDIO_IO_LOGD("[%p] created", handle);
*input = handle;
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
__handle_safe_free(handle, (void *)input, false);
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
} catch (const std::bad_alloc&) {
- CAudioError e(CAudioError::EError::ERROR_OUT_OF_MEMORY);
+//LCOV_EXCL_START
AUDIO_IO_LOGE("Failed to allocate handle");
__handle_safe_free(handle, (void *)input, false);
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(CAudioError::EError::ERROR_OUT_OF_MEMORY);
//LCOV_EXCL_STOP
}
SAFE_FINALIZE(handle->audioIoHandle);
SAFE_DELETE(handle->audioIoHandle);
SAFE_DELETE(handle);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("destroyed");
AUDIO_IO_LOGD("[%p], stream_info:[%p]", handle, stream_info);
handle->audioIoHandle->setStreamInfo(stream_info);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->prepare();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] prepared", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->unprepare();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] unprepared", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->pause();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] paused", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->resume();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] resumed", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->flush();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] flushed", handle);
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD("readn:%zu", readn);
#endif
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return ret;
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
*size = inputHandle->getBufferSize();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
assert(handle->audioIoHandle);
*sample_rate = handle->audioIoHandle->getAudioInfo().getSampleRate();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
assert(handle->audioIoHandle);
*channel = __convert_audio_info_channel_to_channel(handle->audioIoHandle->getAudioInfo().getChannel());
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
assert(handle->audioIoHandle);
*type = __convert_audio_info_sample_type_to_sample_type(handle->audioIoHandle->getAudioInfo().getSampleType());
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
cb.set(__stream_cb_internal, static_cast<void*>(handle));
handle->audioIoHandle->setStreamCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
cb.unset();
handle->audioIoHandle->setStreamCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
inputHandle->peek(buffer, &_length);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
*length = (unsigned int)_length;
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
inputHandle->drop();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
cb.set(__state_changed_cb_internal, static_cast<void*>(handle));
handle->audioIoHandle->setStateChangedCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
cb.unset();
handle->audioIoHandle->setStateChangedCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
AUDIO_IO_LOGD("[%p] created", handle);
*output = handle;
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
__handle_safe_free(handle, (void *)output, true);
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
} catch (const std::bad_alloc&) {
- CAudioError e(CAudioError::EError::ERROR_OUT_OF_MEMORY);
+//LCOV_EXCL_START
AUDIO_IO_LOGE("Failed to allocate handle");
__handle_safe_free(handle, (void *)output, true);
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(CAudioError::EError::ERROR_OUT_OF_MEMORY);
//LCOV_EXCL_STOP
}
SAFE_FINALIZE(handle->audioIoHandle);
SAFE_DELETE(handle->audioIoHandle);
SAFE_DELETE(handle);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] destroyed", handle);
AUDIO_IO_LOGD("[%p], stream_info:[%p]", handle, stream_info);
handle->audioIoHandle->setStreamInfo(stream_info);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->prepare();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] prepared", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->unprepare();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] unprepared", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->pause();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] paused", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->resume();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] resumed", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->drain();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] drained", handle);
AUDIO_IO_LOGD("[%p]", handle);
handle->audioIoHandle->flush();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] flushed", handle);
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD("written:%zu", written);
#endif
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return ret;
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
*size = outputHandle->getBufferSize();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
assert(handle->audioIoHandle);
*sample_rate = handle->audioIoHandle->getAudioInfo().getSampleRate();
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
assert(handle->audioIoHandle);
*channel = __convert_audio_info_channel_to_channel(handle->audioIoHandle->getAudioInfo().getChannel());
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
assert(handle->audioIoHandle);
*type = __convert_audio_info_sample_type_to_sample_type(handle->audioIoHandle->getAudioInfo().getSampleType());
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
assert(handle->audioIoHandle);
*type = __convert_audio_info_audio_type_to_sound_type(handle->audioIoHandle->getAudioInfo().getAudioType());
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
return AUDIO_IO_ERROR_NONE;
cb.set(__stream_cb_internal, static_cast<void*>(handle));
handle->audioIoHandle->setStreamCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
cb.unset();
handle->audioIoHandle->setStreamCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
cb.set(__state_changed_cb_internal, static_cast<void*>(handle));
handle->audioIoHandle->setStateChangedCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);
cb.unset();
handle->audioIoHandle->setStateChangedCallback(cb);
- } catch (CAudioError& e) {
+ } catch (const CAudioError& e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
+ return __convert_audio_io_error(e.getError());
}
AUDIO_IO_LOGD("[%p] done", handle);