audio: Fix device table access in get_snd_device_name()
authorAndreas Schneider <asn@cryptomilk.org>
Mon, 13 Feb 2017 14:19:36 +0000 (15:19 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 14 Feb 2017 16:42:14 +0000 (17:42 +0100)
We have a value for SND_DEVICE_NONE so we should use that. There is no
field for SND_DEVICE_MIN so we need to check it is bigger.

Change-Id: I041930c8c4b552d45804a178aeb1aa981ae7c13f

audio/audio_hw.c

index ea69f255734b2431e8736b889481e532a98b63e1..61b28e2d36265d46b5a9626bbb920ad06d2319cf 100644 (file)
@@ -440,7 +440,8 @@ static const char *get_snd_device_name(snd_device_t snd_device)
 {
     const char *name = NULL;
 
-    if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX)
+    if (snd_device == SND_DEVICE_NONE ||
+        (snd_device > SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX))
         name = device_table[snd_device];
 
     ALOGE_IF(name == NULL, "%s: invalid snd device %d", __func__, snd_device);