Merge "Merge tm-qpr-dev-plus-aosp-without-vendor@9129937" into stage-aosp-master
diff --git a/media/codec2/components/vpx/C2SoftVpxEnc.cpp b/media/codec2/components/vpx/C2SoftVpxEnc.cpp
index 2a019d4..5700e5d 100644
--- a/media/codec2/components/vpx/C2SoftVpxEnc.cpp
+++ b/media/codec2/components/vpx/C2SoftVpxEnc.cpp
@@ -264,23 +264,20 @@
     // the requirements.
     bool needsUpdate = false;
     for (const LevelLimits& limit : kLimits) {
-        if (samples > limit.samples) continue;
-        if (samplesPerSec > limit.samplesPerSec) continue;
-        if (bitrate.v.value > limit.bitrate) continue;
-        if (dimension > limit.dimension) continue;
-
-        // This is the lowest level that meets the requirements, and if
-        // we haven't seen the supplied level yet, that means we don't
-        // need the update.
-        if (needsUpdate) {
-            ALOGD("Given level %x does not cover current configuration: "
-                    "adjusting to %x",
-                    me.v.level, limit.level);
-            me.set().level = limit.level;
+        if (samples <= limit.samples && samplesPerSec <= limit.samplesPerSec &&
+            bitrate.v.value <= limit.bitrate && dimension <= limit.dimension) {
+            // This is the lowest level that meets the requirements, and if
+            // we haven't seen the supplied level yet, that means we don't
+            // need the update.
+            if (needsUpdate) {
+                ALOGD("Given level %x does not cover current configuration: "
+                        "adjusting to %x",
+                        me.v.level, limit.level);
+                me.set().level = limit.level;
+            }
+            found = true;
+            break;
         }
-        found = true;
-        break;
-
         if (me.v.level == limit.level) {
             // We break out of the loop when the lowest feasible level is
             // found. The fact that we're here means that our level doesn't
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index f15e062..d6028d9 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -5928,19 +5928,17 @@
 
         case ACodec::kWhatSetSurface:
         {
+            sp<AReplyToken> replyID;
+            CHECK(msg->senderAwaitsResponse(&replyID));
+
             sp<RefBase> obj;
             CHECK(msg->findObject("surface", &obj));
 
             status_t err = mCodec->handleSetSurface(static_cast<Surface *>(obj.get()));
 
-            sp<AReplyToken> replyID;
-            if (msg->senderAwaitsResponse(&replyID)) {
-                sp<AMessage> response = new AMessage;
-                response->setInt32("err", err);
-                response->postReply(replyID);
-            } else if (err != OK) {
-                mCodec->signalError(OMX_ErrorUndefined, err);
-            }
+            sp<AMessage> response = new AMessage;
+            response->setInt32("err", err);
+            response->postReply(replyID);
             break;
         }
 
@@ -8529,17 +8527,11 @@
 
         case kWhatSetSurface:
         {
-            ALOGV("[%s] Deferring setSurface", mCodec->mComponentName.c_str());
-
-            sp<AReplyToken> replyID;
-            CHECK(msg->senderAwaitsResponse(&replyID));
+            ALOGD("[%s] Deferring setSurface from OutputPortSettingsChangedState",
+                  mCodec->mComponentName.c_str());
 
             mCodec->deferMessage(msg);
 
-            sp<AMessage> response = new AMessage;
-            response->setInt32("err", OK);
-            response->postReply(replyID);
-
             handled = true;
             break;
         }