Merge "audio: Abort on data FMQ pointer corruption" into main am: 2222e7d599 am: 581761fa85

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3079664

Change-Id: Ied8e9a4358ee99047e3fb0cb5fac8502eb5e7fbc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mikhail Naganov 2024-05-09 17:31:41 +00:00 committed by Automerger Merge Worker
commit d81c41d0b0

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();