Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5952f4b authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6175640 from d52fb377 to rvc-release

Change-Id: I805187ecf3068de06cf6b28f02b5beb10efb3039
parents 346a7ae0 d52fb377
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -206,10 +206,23 @@ private:
    std::mutex mMutex;
    sp<ClientManager> mSenderManager;
    sp<IClientManager> mReceiverManager;
    int64_t mReceiverConnectionId;
    int64_t mSourceConnectionId;
    std::chrono::steady_clock::time_point mLastSent;
    std::chrono::steady_clock::duration mRefreshInterval;

    struct Connection {
        int64_t receiverConnectionId;
        std::chrono::steady_clock::time_point lastSent;
        Connection(int64_t receiverConnectionId,
                   std::chrono::steady_clock::time_point lastSent)
              : receiverConnectionId(receiverConnectionId),
                lastSent(lastSent) {
        }
    };

    // Map of connections.
    //
    // The key is the connection id. One sender-receiver pair may have multiple
    // connections.
    std::map<int64_t, Connection> mConnections;
};

// std::list<std::unique_ptr<C2Work>> -> WorkBundle
+35 −23
Original line number Diff line number Diff line
@@ -969,8 +969,6 @@ DefaultBufferPoolSender::DefaultBufferPoolSender(
        const sp<IClientManager>& receiverManager,
        std::chrono::steady_clock::duration refreshInterval)
    : mReceiverManager(receiverManager),
      mSourceConnectionId(0),
      mLastSent(std::chrono::steady_clock::now()),
      mRefreshInterval(refreshInterval) {
}

@@ -980,6 +978,7 @@ void DefaultBufferPoolSender::setReceiver(
    std::lock_guard<std::mutex> lock(mMutex);
    if (mReceiverManager != receiverManager) {
        mReceiverManager = receiverManager;
        mConnections.clear();
    }
    mRefreshInterval = refreshInterval;
}
@@ -987,12 +986,16 @@ void DefaultBufferPoolSender::setReceiver(
ResultStatus DefaultBufferPoolSender::send(
        const std::shared_ptr<BufferPoolData>& bpData,
        BufferStatusMessage* bpMessage) {
    int64_t connectionId = bpData->mConnectionId;
    if (connectionId == 0) {
        LOG(WARNING) << "registerSender -- invalid sender connection id (0).";
        return ResultStatus::CRITICAL_ERROR;
    }
    std::lock_guard<std::mutex> lock(mMutex);
    if (!mReceiverManager) {
        LOG(ERROR) << "No access to receiver's BufferPool.";
        return ResultStatus::NOT_FOUND;
    }
    ResultStatus rs;
    std::lock_guard<std::mutex> lock(mMutex);
    if (!mSenderManager) {
        mSenderManager = ClientManager::getInstance();
        if (!mSenderManager) {
@@ -1000,21 +1003,17 @@ ResultStatus DefaultBufferPoolSender::send(
            return ResultStatus::CRITICAL_ERROR;
        }
    }
    int64_t connectionId = bpData->mConnectionId;

    int64_t receiverConnectionId{0};
    auto foundConnection = mConnections.find(connectionId);
    bool isNewConnection = foundConnection == mConnections.end();
    std::chrono::steady_clock::time_point now =
            std::chrono::steady_clock::now();
    std::chrono::steady_clock::duration interval = now - mLastSent;
    if (mSourceConnectionId == 0 ||
            mSourceConnectionId != connectionId ||
            interval > mRefreshInterval) {
    if (isNewConnection ||
            (now - foundConnection->second.lastSent > mRefreshInterval)) {
        // Initialize the bufferpool connection.
        mSourceConnectionId = connectionId;
        if (mSourceConnectionId == 0) {
            return ResultStatus::CRITICAL_ERROR;
        }

        int64_t receiverConnectionId;
        rs = mSenderManager->registerSender(mReceiverManager,
        ResultStatus rs =
                mSenderManager->registerSender(mReceiverManager,
                                               connectionId,
                                               &receiverConnectionId);
        if ((rs != ResultStatus::OK) && (rs != ResultStatus::ALREADY_EXISTS)) {
@@ -1022,30 +1021,43 @@ ResultStatus DefaultBufferPoolSender::send(
                         << static_cast<int32_t>(rs)
                         << ".";
            return rs;
        } else if (receiverConnectionId == 0) {
            LOG(WARNING) << "registerSender -- "
                            "invalid receiver connection id (0).";
            return ResultStatus::CRITICAL_ERROR;
        } else {
            mReceiverConnectionId = receiverConnectionId;
            if (isNewConnection) {
                foundConnection = mConnections.try_emplace(
                        connectionId, receiverConnectionId, now).first;
            } else {
                foundConnection->second.receiverConnectionId = receiverConnectionId;
            }
        }
    } else {
        receiverConnectionId = foundConnection->second.receiverConnectionId;
    }

    uint64_t transactionId;
    int64_t timestampUs;
    rs = mSenderManager->postSend(
            mReceiverConnectionId, bpData, &transactionId, &timestampUs);
    ResultStatus rs = mSenderManager->postSend(
            receiverConnectionId, bpData, &transactionId, &timestampUs);
    if (rs != ResultStatus::OK) {
        LOG(ERROR) << "ClientManager::postSend -- returned error: "
                   << static_cast<int32_t>(rs)
                   << ".";
        mConnections.erase(foundConnection);
        return rs;
    }
    if (!bpMessage) {
        LOG(ERROR) << "Null output parameter for BufferStatusMessage.";
        mConnections.erase(foundConnection);
        return ResultStatus::CRITICAL_ERROR;
    }
    bpMessage->connectionId = mReceiverConnectionId;
    bpMessage->connectionId = receiverConnectionId;
    bpMessage->bufferId = bpData->mId;
    bpMessage->transactionId = transactionId;
    bpMessage->timestampUs = timestampUs;
    mLastSent = now;
    foundConnection->second.lastSent = now;
    return rs;
}

+14 −2
Original line number Diff line number Diff line
@@ -6679,6 +6679,12 @@ static bool BetterSniffMPEG4(DataSourceHelper *source, float *confidence) {
                // The smallest valid chunk is 16 bytes long in this case.
                return false;
            }
            if (chunkSize > INT64_MAX) {
                // reject overly large chunk sizes that could
                // be interpreted as negative
                ALOGE("chunk size too large");
                return false;
            }

        } else if (chunkSize < 8) {
            // The smallest valid chunk is 8 bytes long.
@@ -6734,7 +6740,10 @@ static bool BetterSniffMPEG4(DataSourceHelper *source, float *confidence) {

            case FOURCC("moov"):
            {
                moovAtomEndOffset = offset + chunkSize;
                if (__builtin_add_overflow(offset, chunkSize, &moovAtomEndOffset)) {
                    ALOGE("chunk size + offset would overflow");
                    return false;
                }

                done = true;
                break;
@@ -6744,7 +6753,10 @@ static bool BetterSniffMPEG4(DataSourceHelper *source, float *confidence) {
                break;
        }

        offset += chunkSize;
        if (__builtin_add_overflow(offset, chunkSize, &offset)) {
            ALOGE("chunk size + offset would overflow");
            return false;
        }
    }

    if (!foundGoodFileType) {
+0 −2
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ cc_test {
    cflags: ["-Wall", "-Werror"],
    shared_libs: ["libaaudio"],
    header_libs: ["libaaudio_example_utils"],
    pack_relocations: false,
}

cc_test {
@@ -15,5 +14,4 @@ cc_test {
    cflags: ["-Wall", "-Werror"],
    shared_libs: ["libaaudio"],
    header_libs: ["libaaudio_example_utils"],
    pack_relocations: false,
}
+0 −1
Original line number Diff line number Diff line
@@ -9,5 +9,4 @@ cc_test {
        "libaudioutils",
        ],
    header_libs: ["libaaudio_example_utils"],
    pack_relocations: false,
}
Loading