Merge "audio: Abort on data FMQ pointer corruption" into main

This commit is contained in:
Mikhail Naganov
2024-05-09 16:54:31 +00:00
committed by Gerrit Code Review

View File

@@ -315,7 +315,11 @@ StreamInWorkerLogic::Status StreamInWorkerLogic::cycle() {
bool StreamInWorkerLogic::read(size_t clientSize, StreamDescriptor::Reply* reply) {
ATRACE_CALL();
StreamContext::DataMQ* const dataMQ = mContext->getDataMQ();
const size_t byteCount = std::min({clientSize, dataMQ->availableToWrite(), mDataBufferSize});
StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE;
std::string fmqErrorMsg;
const size_t byteCount = std::min(
{clientSize, dataMQ->availableToWrite(&fmqError, &fmqErrorMsg), mDataBufferSize});
CHECK(fmqError == StreamContext::DataMQ::Error::NONE) << fmqErrorMsg;
const bool isConnected = mIsConnected;
const size_t frameSize = mContext->getFrameSize();
size_t actualFrameCount = 0;
@@ -587,7 +591,10 @@ StreamOutWorkerLogic::Status StreamOutWorkerLogic::cycle() {
bool StreamOutWorkerLogic::write(size_t clientSize, StreamDescriptor::Reply* reply) {
ATRACE_CALL();
StreamContext::DataMQ* const dataMQ = mContext->getDataMQ();
const size_t readByteCount = dataMQ->availableToRead();
StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE;
std::string fmqErrorMsg;
const size_t readByteCount = dataMQ->availableToRead(&fmqError, &fmqErrorMsg);
CHECK(fmqError == StreamContext::DataMQ::Error::NONE) << fmqErrorMsg;
const size_t frameSize = mContext->getFrameSize();
bool fatal = false;
int32_t latency = mContext->getNominalLatencyMs();