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

Commit 547b467b authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am 5895c5db: Merge "Make sure we only release the HDCP module once shutdown...

am 5895c5db: Merge "Make sure we only release the HDCP module once shutdown has completed." into jb-mr1-dev

* commit '5895c5db':
  Make sure we only release the HDCP module once shutdown has completed.
parents 23520044 5895c5db
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -1297,6 +1297,10 @@ bool WifiDisplaySource::PlaybackSession::allTracksHavePacketizerIndex() {
    return true;
}

static inline size_t MIN(size_t a, size_t b) {
    return (a < b) ? a : b;
}

status_t WifiDisplaySource::PlaybackSession::packetizeAccessUnit(
        size_t trackIndex, const sp<ABuffer> &accessUnit) {
    const sp<Track> &track = mTracks.valueFor(trackIndex);
@@ -1309,8 +1313,20 @@ status_t WifiDisplaySource::PlaybackSession::packetizeAccessUnit(
    if (mHDCP != NULL && !track->isAudio()) {
        isHDCPEncrypted = true;

#if 0
        ALOGI("in:");
        hexdump(accessUnit->data(), MIN(64, accessUnit->size()));
#endif

        if (mTempAccessUnit == NULL
                || mTempAccessUnit->capacity() < accessUnit->size()) {
            mTempAccessUnit = new ABuffer(accessUnit->size());
        }

        memcpy(mTempAccessUnit->data(), accessUnit->data(), accessUnit->size());

        status_t err = mHDCP->encrypt(
                accessUnit->data(), accessUnit->size(),
                mTempAccessUnit->data(), mTempAccessUnit->size(),
                trackIndex  /* streamCTR */,
                &inputCTR,
                accessUnit->data());
@@ -1320,6 +1336,12 @@ status_t WifiDisplaySource::PlaybackSession::packetizeAccessUnit(
                  err);

            return err;
        } else {
#if 0
            ALOGI("out:");
            hexdump(accessUnit->data(), MIN(64, accessUnit->size()));
            ALOGI("inputCTR: 0x%016llx", inputCTR);
#endif
        }

        HDCP_private_data[0] = 0x00;
+2 −0
Original line number Diff line number Diff line
@@ -164,6 +164,8 @@ private:

    uint64_t mTotalBytesSent;

    sp<ABuffer> mTempAccessUnit;

#if LOG_TRANSPORT_STREAM
    FILE *mLogFile;
#endif
+22 −12
Original line number Diff line number Diff line
@@ -230,20 +230,18 @@ void WifiDisplaySource::onMessageReceived(const sp<AMessage> &msg) {

        case kWhatStop:
        {
            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));
            CHECK(msg->senderAwaitsResponse(&mStopReplyID));

            if (mSessionID != 0 && mClientSessionID != 0) {
                status_t err = sendM5(
                        mClientSessionID, true /* requestShutdown */);

                if (err == OK) {
                    mStopReplyID = replyID;
                    break;
                }
            }

            finishStop(replyID);
            finishStop();
            break;
        }

@@ -339,7 +337,7 @@ void WifiDisplaySource::onMessageReceived(const sp<AMessage> &msg) {
            CHECK(msg->findInt32("ext1", &ext1));
            CHECK(msg->findInt32("ext2", &ext2));

            ALOGV("Saw HDCP notification code %d, ext1 %d, ext2 %d",
            ALOGI("Saw HDCP notification code %d, ext1 %d, ext2 %d",
                    msgCode, ext1, ext2);

            switch (msgCode) {
@@ -355,6 +353,12 @@ void WifiDisplaySource::onMessageReceived(const sp<AMessage> &msg) {
                    break;
                }

                case HDCPModule::HDCP_SHUTDOWN_COMPLETE:
                {
                    finishStop2();
                    break;
                }

                default:
                {
                    ALOGE("HDCP failure, shutting down.");
@@ -1080,8 +1084,7 @@ status_t WifiDisplaySource::onTeardownRequest(
    }

    if (mStopReplyID != 0) {
        finishStop(mStopReplyID);
        mStopReplyID = 0;
        finishStop();
    } else {
        disconnectClient(UNKNOWN_ERROR);
    }
@@ -1089,21 +1092,29 @@ status_t WifiDisplaySource::onTeardownRequest(
    return OK;
}

void WifiDisplaySource::finishStop(uint32_t replyID) {
void WifiDisplaySource::finishStop() {
    disconnectClient(OK);

#if REQUIRE_HDCP
    if (mHDCP != NULL) {
        mHDCP->shutdownAsync();
        mHDCP.clear();
        return;
    }
#endif

    finishStop2();
}

void WifiDisplaySource::finishStop2() {
#if REQUIRE_HDCP
    mHDCP.clear();
#endif

    status_t err = OK;

    sp<AMessage> response = new AMessage;
    response->setInt32("err", err);
    response->postReply(replyID);
    response->postReply(mStopReplyID);
}

status_t WifiDisplaySource::onGetParameterRequest(
@@ -1195,8 +1206,7 @@ void WifiDisplaySource::sendErrorResponse(

    response.append("\r\n");

    status_t err = mNetSession->sendRequest(sessionID, response.c_str());
    CHECK_EQ(err, (status_t)OK);
    mNetSession->sendRequest(sessionID, response.c_str());
}

int32_t WifiDisplaySource::makeUniquePlaybackSessionID() const {
+2 −1
Original line number Diff line number Diff line
@@ -205,7 +205,8 @@ private:
    // A listener is notified accordingly.
    void disconnectClient(status_t err);

    void finishStop(uint32_t replyID);
    void finishStop();
    void finishStop2();

    DISALLOW_EVIL_CONSTRUCTORS(WifiDisplaySource);
};