hal: enable routing based on bus addresses
Choose the snd_device based on streams.
This ensures that usecases such as mmap
play out of their intended bus device instead
of always defaulting to the media bus.
Change-Id: Id96742e0a65d3e4c337bcb72baf5a0fd2c8eb469
diff --git a/hal/audio_extn/auto_hal.c b/hal/audio_extn/auto_hal.c
index ca3cd6b..9276c9c 100755
--- a/hal/audio_extn/auto_hal.c
+++ b/hal/audio_extn/auto_hal.c
@@ -841,6 +841,8 @@
snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
break;
case USECASE_AUDIO_PLAYBACK_MEDIA:
+ snd_device = SND_DEVICE_OUT_BUS_MEDIA;
+ break;
case USECASE_AUDIO_PLAYBACK_OFFLOAD:
case USECASE_AUDIO_PLAYBACK_OFFLOAD2:
case USECASE_AUDIO_PLAYBACK_OFFLOAD3:
@@ -854,6 +856,33 @@
case USECASE_AUDIO_PLAYBACK_MMAP:
case USECASE_AUDIO_PLAYBACK_VOIP:
snd_device = SND_DEVICE_OUT_BUS_MEDIA;
+ /* Override the snd_device based on the bus address if available */
+ if (usecase->stream.out->car_audio_stream) {
+ switch (usecase->stream.out->car_audio_stream) {
+ case CAR_AUDIO_STREAM_MEDIA:
+ snd_device = SND_DEVICE_OUT_BUS_MEDIA;
+ break;
+ case CAR_AUDIO_STREAM_SYS_NOTIFICATION:
+ snd_device = SND_DEVICE_OUT_BUS_SYS;
+ break;
+ case CAR_AUDIO_STREAM_NAV_GUIDANCE:
+ snd_device = SND_DEVICE_OUT_BUS_NAV;
+ break;
+ case CAR_AUDIO_STREAM_PHONE:
+ snd_device = SND_DEVICE_OUT_BUS_PHN;
+ break;
+ case CAR_AUDIO_STREAM_FRONT_PASSENGER:
+ snd_device = SND_DEVICE_OUT_BUS_PAX;
+ break;
+ case CAR_AUDIO_STREAM_REAR_SEAT:
+ snd_device = SND_DEVICE_OUT_BUS_RSE;
+ break;
+ default:
+ ALOGE("%s: Car audio stream %x not supported", __func__,
+ usecase->stream.out->car_audio_stream);
+ return -EINVAL;
+ }
+ }
break;
case USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION:
snd_device = SND_DEVICE_OUT_BUS_SYS;