am cfca686a: Merge "Rotate fallback size" into klp-dev

* commit 'cfca686ae8e64bda44a370232f3ba367e6e520d1':
  Rotate fallback size
diff --git a/cmds/screenrecord/screenrecord.cpp b/cmds/screenrecord/screenrecord.cpp
index 68289a5..49999b5 100644
--- a/cmds/screenrecord/screenrecord.cpp
+++ b/cmds/screenrecord/screenrecord.cpp
@@ -464,12 +464,16 @@
     err = prepareEncoder(mainDpyInfo.fps, &encoder, &bufferProducer);
 
     if (err != NO_ERROR && !gSizeSpecified) {
-        if (gVideoWidth != kFallbackWidth && gVideoHeight != kFallbackHeight) {
+        // fallback is defined for landscape; swap if we're in portrait
+        bool needSwap = gVideoWidth < gVideoHeight;
+        uint32_t newWidth = needSwap ? kFallbackHeight : kFallbackWidth;
+        uint32_t newHeight = needSwap ? kFallbackWidth : kFallbackHeight;
+        if (gVideoWidth != newWidth && gVideoHeight != newHeight) {
             ALOGV("Retrying with 720p");
-            fprintf(stderr, "WARNING: failed at %dx%d, retrying at 720p\n",
-                    gVideoWidth, gVideoHeight);
-            gVideoWidth = kFallbackWidth;
-            gVideoHeight = kFallbackHeight;
+            fprintf(stderr, "WARNING: failed at %dx%d, retrying at %dx%d\n",
+                    gVideoWidth, gVideoHeight, newWidth, newHeight);
+            gVideoWidth = newWidth;
+            gVideoHeight = newHeight;
             err = prepareEncoder(mainDpyInfo.fps, &encoder, &bufferProducer);
         }
     }