audio: Apply initial routing

We can't rely on AudioFlinger always informing us of the
initial routing using set_parameters(), so we need to apply
the routing passed when the channel was opened.

Change-Id: I683a8527b569b2b87b6b34fbf39738e37013feea
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
diff --git a/audio_hw.c b/audio_hw.c
index 12888e5..c37a1bf 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -393,7 +393,8 @@
 }
 
 static int do_init_out_common( struct stream_out_common *out,
-                                    const struct audio_config *config )
+                                    const struct audio_config *config,
+                                    audio_devices_t devices )
 {
     int ret;
 
@@ -427,6 +428,9 @@
     /* Default settings */
     out->frame_size = audio_stream_frame_size(&out->stream.common);
 
+    /* Apply initial route */
+    apply_route(out->hw, devices);
+
     return 0;
 }
 
@@ -723,7 +727,8 @@
 }
 
 static int do_init_in_common( struct stream_in_common *in,
-                                const struct audio_config *config )
+                                const struct audio_config *config,
+                                audio_devices_t devices )
 {
     in->standby = true;
 
@@ -754,6 +759,9 @@
 
     in->frame_size = audio_stream_frame_size(&in->stream.common);
 
+    /* Apply initial routing */
+    apply_route(in->hw, devices);
+
     return 0;
 }
 
@@ -1754,7 +1762,7 @@
 
     out.common->dev = adev;
     out.common->hw = hw;
-    ret = do_init_out_common( out.common, config );
+    ret = do_init_out_common( out.common, config, devices );
     if (ret < 0) {
         goto err_open;
     }
@@ -1828,7 +1836,7 @@
 
     in->common.dev = adev;
     in->common.hw = hw;
-    ret = do_init_in_common( &in->common, config );
+    ret = do_init_in_common( &in->common, config, devices );
     if (ret < 0) {
         goto fail;
     }