CAudioOutput::CAudioOutput(CAudioInfo& info) :
CAudioIO(info),
__mIsUsedSyncWrite(false),
- __mIsInit(false) {
+ __mIsInit(false),
+ __mTotalWrittenCount(0),
+ __mTotalWrittenBytes(0) {
mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_OUT;
}
return;
}
+ __dumpStat();
+
CAudioIO::unprepare();
if (mpPulseAudioClient && mpPulseAudioClient->isInThread())
SAFE_FINALIZE(mpPulseAudioClient);
SAFE_DELETE(mpPulseAudioClient);
+ __mTotalWrittenCount = 0;
+ __mTotalWrittenBytes = 0;
+
CAudioIO::setState(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE);
mutex.unlock();
if (mpPulseAudioClient->isInThread())
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't pause in thread"); //LCOV_EXCL_LINE
+ __dumpStat();
+
CAudioIO::pause();
CAudioIO::setState(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
if (mpPulseAudioClient->isInThread())
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't resume in thread"); //LCOV_EXCL_LINE
+ __dumpStat();
+
CAudioIO::resume();
CAudioIO::setState(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
}
}
+ if (timeouts > 0)
+ AUDIO_IO_LOGD("writableSize(%zu) is now available after (%u) timeouts!!!", l, timeouts);
+
if (l > lengthIter)
l = lengthIter;
#ifdef _AUDIO_IO_DEBUG_TIMING_
AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%zu)", buffer, l);
+ __dumpStat();
#endif
int ret = mpPulseAudioClient->write(buffer, l);
buffer = static_cast<const uint8_t*>(buffer) + l;
lengthIter -= l;
- } // End of while (length > 0)
+
+ __mTotalWrittenCount++;
+ __mTotalWrittenBytes += l;
+ } // End of while (lengthIter > 0)
__mIsUsedSyncWrite = false;
mutex.unlock();
return length;
}
+
+void CAudioOutput::__dumpStat() noexcept {
+ AUDIO_IO_LOGD("total written %llu times, %llu bytes, %llu ms",
+ __mTotalWrittenCount, __mTotalWrittenBytes,
+ __mTotalWrittenBytes * 1000 / mAudioInfo.getSampleSize() / mAudioInfo.getSampleRate());
+}
\ No newline at end of file