Loading audio/aidl/default/Stream.cpp +21 −9 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,17 @@ using aidl::android::media::audio::common::MicrophoneInfo; namespace aidl::android::hardware::audio::core { namespace aidl::android::hardware::audio::core { namespace { template <typename MQTypeError> auto fmqErrorHandler(const char* mqName) { return [m = std::string(mqName)](MQTypeError fmqError, std::string&& errorMessage) { CHECK_EQ(fmqError, MQTypeError::NONE) << m << ": " << errorMessage; }; } } // namespace void StreamContext::fillDescriptor(StreamDescriptor* desc) { void StreamContext::fillDescriptor(StreamDescriptor* desc) { if (mCommandMQ) { if (mCommandMQ) { desc->command = mCommandMQ->dupeDesc(); desc->command = mCommandMQ->dupeDesc(); Loading Loading @@ -332,11 +343,7 @@ StreamInWorkerLogic::Status StreamInWorkerLogic::cycle() { bool StreamInWorkerLogic::read(size_t clientSize, StreamDescriptor::Reply* reply) { bool StreamInWorkerLogic::read(size_t clientSize, StreamDescriptor::Reply* reply) { ATRACE_CALL(); ATRACE_CALL(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE; const size_t byteCount = std::min({clientSize, dataMQ->availableToWrite(), mDataBufferSize}); 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 bool isConnected = mIsConnected; const size_t frameSize = mContext->getFrameSize(); const size_t frameSize = mContext->getFrameSize(); size_t actualFrameCount = 0; size_t actualFrameCount = 0; Loading Loading @@ -612,10 +619,7 @@ StreamOutWorkerLogic::Status StreamOutWorkerLogic::cycle() { bool StreamOutWorkerLogic::write(size_t clientSize, StreamDescriptor::Reply* reply) { bool StreamOutWorkerLogic::write(size_t clientSize, StreamDescriptor::Reply* reply) { ATRACE_CALL(); ATRACE_CALL(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE; const size_t readByteCount = dataMQ->availableToRead(); std::string fmqErrorMsg; const size_t readByteCount = dataMQ->availableToRead(&fmqError, &fmqErrorMsg); CHECK(fmqError == StreamContext::DataMQ::Error::NONE) << fmqErrorMsg; const size_t frameSize = mContext->getFrameSize(); const size_t frameSize = mContext->getFrameSize(); bool fatal = false; bool fatal = false; int32_t latency = mContext->getNominalLatencyMs(); int32_t latency = mContext->getNominalLatencyMs(); Loading Loading @@ -719,6 +723,14 @@ ndk::ScopedAStatus StreamCommonImpl::initInstance( LOG(WARNING) << __func__ << ": invalid worker tid: " << workerTid; LOG(WARNING) << __func__ << ": invalid worker tid: " << workerTid; } } } } getContext().getCommandMQ()->setErrorHandler( fmqErrorHandler<StreamContext::CommandMQ::Error>("CommandMQ")); getContext().getReplyMQ()->setErrorHandler( fmqErrorHandler<StreamContext::ReplyMQ::Error>("ReplyMQ")); if (getContext().getDataMQ() != nullptr) { getContext().getDataMQ()->setErrorHandler( fmqErrorHandler<StreamContext::DataMQ::Error>("DataMQ")); } return ndk::ScopedAStatus::ok(); return ndk::ScopedAStatus::ok(); } } Loading Loading
audio/aidl/default/Stream.cpp +21 −9 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,17 @@ using aidl::android::media::audio::common::MicrophoneInfo; namespace aidl::android::hardware::audio::core { namespace aidl::android::hardware::audio::core { namespace { template <typename MQTypeError> auto fmqErrorHandler(const char* mqName) { return [m = std::string(mqName)](MQTypeError fmqError, std::string&& errorMessage) { CHECK_EQ(fmqError, MQTypeError::NONE) << m << ": " << errorMessage; }; } } // namespace void StreamContext::fillDescriptor(StreamDescriptor* desc) { void StreamContext::fillDescriptor(StreamDescriptor* desc) { if (mCommandMQ) { if (mCommandMQ) { desc->command = mCommandMQ->dupeDesc(); desc->command = mCommandMQ->dupeDesc(); Loading Loading @@ -332,11 +343,7 @@ StreamInWorkerLogic::Status StreamInWorkerLogic::cycle() { bool StreamInWorkerLogic::read(size_t clientSize, StreamDescriptor::Reply* reply) { bool StreamInWorkerLogic::read(size_t clientSize, StreamDescriptor::Reply* reply) { ATRACE_CALL(); ATRACE_CALL(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE; const size_t byteCount = std::min({clientSize, dataMQ->availableToWrite(), mDataBufferSize}); 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 bool isConnected = mIsConnected; const size_t frameSize = mContext->getFrameSize(); const size_t frameSize = mContext->getFrameSize(); size_t actualFrameCount = 0; size_t actualFrameCount = 0; Loading Loading @@ -612,10 +619,7 @@ StreamOutWorkerLogic::Status StreamOutWorkerLogic::cycle() { bool StreamOutWorkerLogic::write(size_t clientSize, StreamDescriptor::Reply* reply) { bool StreamOutWorkerLogic::write(size_t clientSize, StreamDescriptor::Reply* reply) { ATRACE_CALL(); ATRACE_CALL(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ* const dataMQ = mContext->getDataMQ(); StreamContext::DataMQ::Error fmqError = StreamContext::DataMQ::Error::NONE; const size_t readByteCount = dataMQ->availableToRead(); std::string fmqErrorMsg; const size_t readByteCount = dataMQ->availableToRead(&fmqError, &fmqErrorMsg); CHECK(fmqError == StreamContext::DataMQ::Error::NONE) << fmqErrorMsg; const size_t frameSize = mContext->getFrameSize(); const size_t frameSize = mContext->getFrameSize(); bool fatal = false; bool fatal = false; int32_t latency = mContext->getNominalLatencyMs(); int32_t latency = mContext->getNominalLatencyMs(); Loading Loading @@ -719,6 +723,14 @@ ndk::ScopedAStatus StreamCommonImpl::initInstance( LOG(WARNING) << __func__ << ": invalid worker tid: " << workerTid; LOG(WARNING) << __func__ << ": invalid worker tid: " << workerTid; } } } } getContext().getCommandMQ()->setErrorHandler( fmqErrorHandler<StreamContext::CommandMQ::Error>("CommandMQ")); getContext().getReplyMQ()->setErrorHandler( fmqErrorHandler<StreamContext::ReplyMQ::Error>("ReplyMQ")); if (getContext().getDataMQ() != nullptr) { getContext().getDataMQ()->setErrorHandler( fmqErrorHandler<StreamContext::DataMQ::Error>("DataMQ")); } return ndk::ScopedAStatus::ok(); return ndk::ScopedAStatus::ok(); } } Loading