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

Commit 075d77dd authored by Dave Burke's avatar Dave Burke Committed by Android Git Automerger
Browse files

am 4769f0b8: Merge "Even cleaner shutdown." into jb-mr1-dev

* commit '4769f0b8':
  Even cleaner shutdown.
parents 7fff6091 4769f0b8
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -301,8 +301,6 @@ status_t Converter::feedEncoderInputBuffers() {
        if (buffer != NULL) {
            CHECK(buffer->meta()->findInt64("timeUs", &timeUs));

            ALOGV("in: %s timeUs = %lld us", mIsVideo ? "video" : "audio", timeUs);

            memcpy(mEncoderInputBuffers.itemAt(bufferIndex)->data(),
                   buffer->data(),
                   buffer->size());
@@ -353,8 +351,6 @@ status_t Converter::doMoreWork() {
            notify->setInt32("what", kWhatEOS);
            notify->post();
        } else {
            ALOGV("out: %s timeUs = %lld us", mIsVideo ? "video" : "audio", timeUs);

            sp<ABuffer> buffer = new ABuffer(size);
            buffer->meta()->setInt64("timeUs", timeUs);

+21 −17
Original line number Diff line number Diff line
@@ -75,8 +75,6 @@ struct WifiDisplaySource::PlaybackSession::Track : public AHandler {
    status_t start();
    void stopAsync();

    bool isStopped() const { return !mStarted; }

    void queueAccessUnit(const sp<ABuffer> &accessUnit);
    sp<ABuffer> dequeueAccessUnit();

@@ -200,6 +198,8 @@ void WifiDisplaySource::PlaybackSession::Track::onMessageReceived(
            sp<AMessage> notify = mNotify->dup();
            notify->setInt32("what", kWhatStopped);
            notify->post();

            ALOGI("kWhatStopped %s posted", mIsAudio ? "audio" : "video");
            break;
        }

@@ -267,9 +267,11 @@ WifiDisplaySource::PlaybackSession::PlaybackSession(
      mNumRTPOctetsSent(0),
      mNumSRsSent(0),
      mSendSRPending(false),
      mFirstPacketTimeUs(-1ll),
      mHistoryLength(0),
      mTotalBytesSent(0ll)
      mHistoryLength(0)
#if TRACK_BANDWIDTH
      ,mFirstPacketTimeUs(-1ll),
      ,mTotalBytesSent(0ll)
#endif
#if LOG_TRANSPORT_STREAM
      ,mLogFile(NULL)
#endif
@@ -747,21 +749,18 @@ void WifiDisplaySource::PlaybackSession::onMessageReceived(
            CHECK(msg->findSize("trackIndex", &trackIndex));

            if (what == Track::kWhatStopped) {
                bool allTracksAreStopped = true;
                for (size_t i = 0; i < mTracks.size(); ++i) {
                    const sp<Track> &track = mTracks.valueAt(i);
                    if (!track->isStopped()) {
                        allTracksAreStopped = false;
                        break;
                    }
                }
                ALOGI("Track %d stopped", trackIndex);

                sp<Track> track = mTracks.valueFor(trackIndex);
                looper()->unregisterHandler(track->id());
                mTracks.removeItem(trackIndex);
                track.clear();

                if (!allTracksAreStopped) {
                if (!mTracks.isEmpty()) {
                    ALOGI("not all tracks are stopped yet");
                    break;
                }

                mTracks.clear();

                mPacketizer.clear();

#if ENABLE_RETRANSMISSION
@@ -1074,12 +1073,15 @@ ssize_t WifiDisplaySource::PlaybackSession::appendTSData(
        // flush

        int64_t nowUs = ALooper::GetNowUs();

#if TRACK_BANDWIDTH
        if (mFirstPacketTimeUs < 0ll) {
            mFirstPacketTimeUs = nowUs;
        }
#endif

        // 90kHz time scale
        uint32_t rtpTime = ((nowUs - mFirstPacketTimeUs) * 9ll) / 100ll;
        uint32_t rtpTime = (nowUs * 9ll) / 100ll;

        uint8_t *rtp = mTSQueue->data();
        rtp[0] = 0x80;
@@ -1115,6 +1117,7 @@ ssize_t WifiDisplaySource::PlaybackSession::appendTSData(
        } else {
            sendPacket(mRTPSessionID, rtp, mTSQueue->size());

#if TRACK_BANDWIDTH
            mTotalBytesSent += mTSQueue->size();
            int64_t delayUs = ALooper::GetNowUs() - mFirstPacketTimeUs;

@@ -1122,6 +1125,7 @@ ssize_t WifiDisplaySource::PlaybackSession::appendTSData(
                ALOGV("approx. net bandwidth used: %.2f Mbit/sec",
                        mTotalBytesSent * 8.0 / delayUs);
            }
#endif
        }

        mTSQueue->setInt32Data(mRTPSeqNo - 1);
+4 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ struct TSPacketizer;

#define LOG_TRANSPORT_STREAM            0
#define ENABLE_RETRANSMISSION           0
#define TRACK_BANDWIDTH                 0

// Encapsulates the state of an RTP/RTCP session in the context of wifi
// display.
@@ -160,12 +161,13 @@ private:

    bool mSendSRPending;

    int64_t mFirstPacketTimeUs;

    List<sp<ABuffer> > mHistory;
    size_t mHistoryLength;

#if TRACK_BANDWIDTH
    int64_t mFirstPacketTimeUs;
    uint64_t mTotalBytesSent;
#endif

#if LOG_TRANSPORT_STREAM
    FILE *mLogFile;
+11 −2
Original line number Diff line number Diff line
@@ -13,7 +13,8 @@
namespace android {

RepeaterSource::RepeaterSource(const sp<MediaSource> &source, double rateHz)
    : mSource(source),
    : mStarted(false),
      mSource(source),
      mRateHz(rateHz),
      mBuffer(NULL),
      mResult(OK),
@@ -22,10 +23,12 @@ RepeaterSource::RepeaterSource(const sp<MediaSource> &source, double rateHz)
}

RepeaterSource::~RepeaterSource() {
    stop();
    CHECK(!mStarted);
}

status_t RepeaterSource::start(MetaData *params) {
    CHECK(!mStarted);

    status_t err = mSource->start(params);

    if (err != OK) {
@@ -46,10 +49,14 @@ status_t RepeaterSource::start(MetaData *params) {

    postRead();

    mStarted = true;

    return OK;
}

status_t RepeaterSource::stop() {
    CHECK(mStarted);

    ALOGV("stopping");

    if (mLooper != NULL) {
@@ -69,6 +76,8 @@ status_t RepeaterSource::stop() {

    ALOGV("stopped");

    mStarted = false;

    return err;
}

+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ private:
    Mutex mLock;
    Condition mCondition;

    bool mStarted;

    sp<MediaSource> mSource;
    double mRateHz;