-void CAudioIO::internalLock() {
- if (!__mIsInit)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
-
- if (pthread_mutex_lock(&__mMutex) != 0)
- 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);
-#endif
-}
-
-void CAudioIO::internalUnlock() {
- if (!__mIsInit)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
-
- if (pthread_mutex_unlock(&__mMutex) != 0)
- 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);
-#endif
-}
-
-void CAudioIO::internalWait() {
- if (!__mIsInit)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
-
-#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD(COLOR_RED "WAIT" COLOR_END);
-#endif
- pthread_mutex_lock(&__mCondMutex);
-
- struct timeval now = { 0, };
- struct timeval to_wait = { 0, };
- struct timeval until = { 0, };
- struct timespec until_ts = { 0, };
-
- constexpr int COND_TIMEOUT_MS = 200;
-
- gettimeofday(&now, nullptr);
- to_wait.tv_sec = COND_TIMEOUT_MS / 1000UL;
- to_wait.tv_usec = (COND_TIMEOUT_MS % 1000UL) * 1000UL;
- timeradd(&now, &to_wait, &until);
- until_ts.tv_sec = until.tv_sec;
- until_ts.tv_nsec = until.tv_usec * 1000UL;
-
- int ret = pthread_cond_timedwait(&__mCond, &__mCondMutex, &until_ts);
- if (ret != 0) {
- char str_error[256];
- AUDIO_IO_LOGE("pthread_cond_timedwait error=[%d][%s]", ret, strerror_r(ret, str_error, sizeof(str_error)));
- }
-
- pthread_mutex_unlock(&__mCondMutex);
-}
-
-void CAudioIO::internalSignal() {
- if (!__mIsInit)
- THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); //LCOV_EXCL_LINE
-
-#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);
-}
-