audio: Extend platform parser to allow device name aliasing

Author: Ethan Chen <intervigil@gmail.com>
Date:   Fri Sep 5 13:01:26 2014 -0700

    audio: Extend platform parser to allow device name aliasing

    * Supported sections now include device names
    * This allows for aliasing device names to a custom name

    Change-Id: I880e90a7e887f020517d89ba276199c700c0eeae

Author: Nicholas Flintham <nick@flinny.org>
Date:   Fri Oct 19 21:56:28 2018 +0100

    Fix mismerge of audio: Extend platform parser to allow device name aliasing

        * device name aliases were not being applied.

    Change-Id: I20493069d2e4cb59250006ac8b14fbb086c297fa

Change-Id: I23319cb7c1fa2ce0c345f96e59455cb64d47988c
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 64e9383..f3cd987 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -421,7 +421,7 @@
 };
 
 /* Array to store sound devices */
-static const char * const device_table[SND_DEVICE_MAX] = {
+static const char * device_table[SND_DEVICE_MAX] = {
     [SND_DEVICE_NONE] = "none",
     /* Playback sound devices */
     [SND_DEVICE_OUT_HANDSET] = "handset",
@@ -8029,6 +8029,21 @@
     return snd_device;
 }
 
+int platform_set_snd_device_name(snd_device_t device, const char *name)
+{
+    int ret = 0;
+
+    if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) {
+        ALOGE("%s:: Invalid snd_device = %d", __func__, device);
+        ret = -EINVAL;
+        goto done;
+    }
+
+    device_table[device] = strdup(name);
+done:
+    return ret;
+}
+
 int platform_set_sidetone(struct audio_device *adev,
                           snd_device_t out_snd_device,
                           bool enable,