[automerger skipped] Use requested sample rate when it matches device sample rate. am: 5b5e0c4552 am: 0a68f6ce13 am: f1950a452b -s ours

am skip reason: Merged-In Iebee2b269062609ff7bcd460f48714ca64980e68 with SHA-1 5b5e0c4552 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/libhardware/+/23437815

Change-Id: Iee31aee19947005e6f4f27e5a3b66b57b69733ca
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c
index d77f7ec..57f523b 100644
--- a/modules/usbaudio/audio_hal.c
+++ b/modules/usbaudio/audio_hal.c
@@ -809,6 +809,8 @@
             ALOGE("%s failed to open device(card: %d device: %d)",
                     __func__, device_info->profile.card, device_info->profile.device);
             goto exit;
+        } else {
+            out->standby = false;
         }
     }
 
@@ -835,7 +837,6 @@
         if (ret != 0) {
             goto err;
         }
-        out->standby = false;
     }
 
     struct listnode* node;
@@ -1262,7 +1263,7 @@
     return 0;
 }
 
-/* must be called with hw device and output stream mutexes locked */
+/* must be called with hw device and input stream mutexes locked */
 static int start_input_stream(struct stream_in *in)
 {
     // Only care about the first device as only one input device is allowed.
@@ -1273,7 +1274,11 @@
 
     ALOGV("start_input_stream(card:%d device:%d)",
             device_info->profile.card, device_info->profile.device);
-    return proxy_open(&device_info->proxy);
+    int ret = proxy_open(&device_info->proxy);
+    if (ret == 0) {
+        in->standby = false;
+    }
+    return ret;
 }
 
 /* TODO mutex stuff here (see out_write) */
@@ -1292,7 +1297,6 @@
         if (ret != 0) {
             goto err;
         }
-        in->standby = false;
     }
 
     // Only care about the first device as only one input device is allowed.
@@ -1858,15 +1862,9 @@
         device_lock(adev);
         if (in != NULL) {
             ret = start_input_stream(in);
-            if (!ret) {
-                in->standby = false;
-            }
         }
         if (out != NULL) {
             ret = start_output_stream(out);
-            if (!ret) {
-                out->standby = false;
-            }
         }
         device_unlock(adev);
     }