Back out locking order and (over) simplification in out_write(), in_read().

Change-Id: I96954f883798f8e10adce56d9c33b70574999d1c
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c
index e583467..3163424 100644
--- a/modules/usbaudio/audio_hal.c
+++ b/modules/usbaudio/audio_hal.c
@@ -424,10 +424,12 @@
     if (out->standby) {
         ret = start_output_stream(out);
         if (ret != 0) {
+            pthread_mutex_unlock(&out->dev->lock);
             goto err;
         }
         out->standby = false;
     }
+    pthread_mutex_unlock(&out->dev->lock);
 
     alsa_device_proxy* proxy = &out->proxy;
     const void * write_buff = buffer;
@@ -458,13 +460,11 @@
     }
 
     pthread_mutex_unlock(&out->lock);
-    pthread_mutex_unlock(&out->dev->lock);
 
     return bytes;
 
 err:
     pthread_mutex_unlock(&out->lock);
-    pthread_mutex_unlock(&out->dev->lock);
     if (ret != 0) {
         usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) /
                out_get_sample_rate(&stream->common));
@@ -807,10 +807,12 @@
     pthread_mutex_lock(&in->lock);
     if (in->standby) {
         if (start_input_stream(in) != 0) {
+            pthread_mutex_unlock(&in->dev->lock);
             goto err;
         }
         in->standby = false;
     }
+    pthread_mutex_unlock(&in->dev->lock);
 
     alsa_device_profile * profile = in->profile;
 
@@ -896,7 +898,6 @@
 
 err:
     pthread_mutex_unlock(&in->lock);
-    pthread_mutex_unlock(&in->dev->lock);
 
     return num_read_buff_bytes;
 }