audio: add functions to retrieve cras audio info

Add a function to run cras_test_client --dump_a command
and get the audio info from the cras host. And also add
another function to filter the info to get stream summary.

BUG=b:204960663
TEST=None

Change-Id: I075f68c86182405a61af29baa958e6b580cf89b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/3256638
Reviewed-by: Shuo-Peng Liao <deanliao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: John Lai <johnlai@chromium.org>
Tested-by: John Lai <johnlai@chromium.org>
Commit-Queue: John Lai <johnlai@chromium.org>
diff --git a/client/cros/audio/cras_utils.py b/client/cros/audio/cras_utils.py
index ca50456..42e6f39 100644
--- a/client/cros/audio/cras_utils.py
+++ b/client/cros/audio/cras_utils.py
@@ -20,6 +20,30 @@
     pass
 
 
+def dump_audio_thread():
+    """Dumps audio thread info.
+
+    @returns: A list of cras audio information.
+    """
+    proc = subprocess.Popen([_CRAS_TEST_CLIENT, '--dump_a'],
+                            stdout=subprocess.PIPE)
+
+    output, err = proc.communicate()
+    if err:
+        raise CrasUtilsError(err)
+    return output.splitlines()
+
+
+def get_audio_thread_summary():
+    """Gets stream summary info.
+
+    @returns: A list of stream summary information.
+    """
+
+    lines = dump_audio_thread()
+    return [l for l in lines if l.startswith('Summary:')]
+
+
 def playback(blocking=True, stdin=None, *args, **kargs):
     """A helper function to execute the playback_cmd.