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

Commit 7350b057 authored by Robert Shih's avatar Robert Shih
Browse files

Don't re-scan sources if no new ones will appear

The only scenario we might need to re-scan is when switching between
bitrate variants in HTTPLiveSources.

Bug: 23313819
Change-Id: I892033c8698f985de74801c39ac5b5417ed19e89
parent 146427dc
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -101,15 +101,20 @@ void NuPlayer::HTTPLiveSource::start() {
}

sp<AMessage> NuPlayer::HTTPLiveSource::getFormat(bool audio) {
    if (mLiveSession == NULL) {
        return NULL;
    }

    sp<AMessage> format;
    status_t err = mLiveSession->getStreamFormat(
    status_t err = -EWOULDBLOCK;
    if (mLiveSession != NULL) {
        err = mLiveSession->getStreamFormat(
                audio ? LiveSession::STREAMTYPE_AUDIO
                      : LiveSession::STREAMTYPE_VIDEO,
                &format);
    }

    if (err == -EWOULDBLOCK) {
        format = new AMessage();
        format->setInt32("err", err);
        return format;
    }

    if (err != OK) {
        return NULL;
+14 −5
Original line number Diff line number Diff line
@@ -845,16 +845,21 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {

            bool mHadAnySourcesBefore =
                (mAudioDecoder != NULL) || (mVideoDecoder != NULL);
            bool rescan = false;

            // initialize video before audio because successful initialization of
            // video may change deep buffer mode of audio.
            if (mSurface != NULL) {
                instantiateDecoder(false, &mVideoDecoder);
                if (instantiateDecoder(false, &mVideoDecoder) == -EWOULDBLOCK) {
                    rescan = true;
                }
            }

            // Don't try to re-open audio sink if there's an existing decoder.
            if (mAudioSink != NULL && mAudioDecoder == NULL) {
                instantiateDecoder(true, &mAudioDecoder);
                if (instantiateDecoder(true, &mAudioDecoder) == -EWOULDBLOCK) {
                    rescan = true;
                }
            }

            if (!mHadAnySourcesBefore
@@ -881,8 +886,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                break;
            }

            if ((mAudioDecoder == NULL && mAudioSink != NULL)
                    || (mVideoDecoder == NULL && mSurface != NULL)) {
            if (rescan) {
                msg->post(100000ll);
                mScanSourcesPending = true;
            }
@@ -1519,7 +1523,12 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) {
    sp<AMessage> format = mSource->getFormat(audio);

    if (format == NULL) {
        return -EWOULDBLOCK;
        return UNKNOWN_ERROR;
    } else {
        status_t err;
        if (format->findInt32("err", &err) && err) {
            return err;
        }
    }

    format->setInt32("priority", 0 /* realtime */);
+1 −1
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ status_t LiveSession::getStreamFormat(StreamType stream, sp<AMessage> *format) {
    sp<MetaData> meta = packetSource->getFormat();

    if (meta == NULL) {
        return -EAGAIN;
        return -EWOULDBLOCK;
    }

    if (stream == STREAMTYPE_AUDIO) {