Merge remote-tracking branch 'goog/ics-aah'
diff --git a/audio/android_audio_hw.c b/audio/android_audio_hw.c
index 348ad14..0746109 100644
--- a/audio/android_audio_hw.c
+++ b/audio/android_audio_hw.c
@@ -36,13 +36,17 @@
 
 #include "liba2dp.h"
 
+/* for backward compatibility with older audio framework */
+#ifndef AUDIO_PARAMETER_A2DP_SINK_ADDRESS
+    #define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address"
+#endif
+
 #define A2DP_WAKE_LOCK_NAME            "A2dpOutputStream"
 #define MAX_WRITE_RETRIES              5
 
 #define A2DP_SUSPENDED_PARM            "A2dpSuspended"
 #define BLUETOOOTH_ENABLED_PARM        "bluetooth_enabled"
 
-#define OUT_SINK_ADDR_PARM             "a2dp_sink_address"
 
 /* number of periods in pcm buffer (one period corresponds to buffer size reported to audio flinger
  * by out_get_buffer_size() */
@@ -88,7 +92,7 @@
     uint32_t                sample_rate;
     size_t                  buffer_size;
     uint32_t                channels;
-    int                     format;
+    audio_format_t          format;
 
     int                     fd;
     bool                    standby;
@@ -142,7 +146,7 @@
 {
     struct astream_out *out = (struct astream_out *)stream;
 
-    LOGE("(%s:%d) %s: Implement me!", __FILE__, __LINE__, __func__);
+    ALOGE("(%s:%d) %s: Implement me!", __FILE__, __LINE__, __func__);
     return 0;
 }
 
@@ -158,16 +162,16 @@
     return out->channels;
 }
 
-static int out_get_format(const struct audio_stream *stream)
+static audio_format_t out_get_format(const struct audio_stream *stream)
 {
     const struct astream_out *out = (const struct astream_out *)stream;
     return out->format;
 }
 
-static int out_set_format(struct audio_stream *stream, int format)
+static audio_format_t out_set_format(struct audio_stream *stream, audio_format_t format)
 {
     struct astream_out *out = (struct astream_out *)stream;
-    LOGE("(%s:%d) %s: Implement me!", __FILE__, __LINE__, __func__);
+    ALOGE("(%s:%d) %s: Implement me!", __FILE__, __LINE__, __func__);
     return 0;
 }
 
@@ -205,7 +209,7 @@
     /* XXX: shouldn't this use the sample_rate/channel_count from 'out'? */
     ret = a2dp_init(44100, 2, &out->data);
     if (ret < 0) {
-        LOGE("a2dp_init failed err: %d\n", ret);
+        ALOGE("a2dp_init failed err: %d\n", ret);
         out->data = NULL;
         return ret;
     }
@@ -218,7 +222,7 @@
     return 0;
 }
 
-static bool _out_validate_parms(struct astream_out *out, int format,
+static bool _out_validate_parms(struct astream_out *out, audio_format_t format,
                                 uint32_t chans, uint32_t rate)
 {
     if ((format && (format != out->format)) ||
@@ -242,11 +246,11 @@
         ret = pthread_cond_timeout_np(&out->write_cond,
                                 &out->lock,
                                 BUF_WRITE_COMPLETION_TIMEOUT_MS);
-        LOGE_IF(ret != 0, "out_standby_stream_locked() wait cond error %d", ret);
+        ALOGE_IF(ret != 0, "out_standby_stream_locked() wait cond error %d", ret);
     }
-    LOGE_IF(attempts == 0, "out_standby_stream_locked() a2dp_write() would not stop!!!");
+    ALOGE_IF(attempts == 0, "out_standby_stream_locked() a2dp_write() would not stop!!!");
 
-    LOGV_IF(!out->bt_enabled, "Standby skip stop: enabled %d", out->bt_enabled);
+    ALOGV_IF(!out->bt_enabled, "Standby skip stop: enabled %d", out->bt_enabled);
     if (out->bt_enabled) {
         ret = a2dp_stop(out->data);
     }
@@ -260,7 +264,7 @@
     out_standby_stream_locked(out);
 
     if (out->data) {
-        LOGV("%s: calling a2dp_cleanup()", __func__);
+        ALOGV("%s: calling a2dp_cleanup()", __func__);
         a2dp_cleanup(out->data);
         out->data = NULL;
     }
@@ -291,7 +295,7 @@
 
     pthread_mutex_lock(&out->lock);
 
-    ret = str_parms_get_str(parms, OUT_SINK_ADDR_PARM, value, sizeof(value));
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_A2DP_SINK_ADDRESS, value, sizeof(value));
     if (ret >= 0) {
         /* strlen(00:00:00:00:00:00) == 17 */
         if (strlen(value) == 17) {
@@ -342,9 +346,9 @@
 
     pthread_mutex_lock(&out->lock);
 
-    ret = str_parms_get_str(parms, OUT_SINK_ADDR_PARM, value, sizeof(value));
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_A2DP_SINK_ADDRESS, value, sizeof(value));
     if (ret >= 0)
-        str_parms_add_str(out_parms, OUT_SINK_ADDR_PARM, out->a2dp_addr);
+        str_parms_add_str(out_parms, AUDIO_PARAMETER_A2DP_SINK_ADDRESS, out->a2dp_addr);
 
     pthread_mutex_unlock(&out->lock);
 
@@ -407,7 +411,7 @@
     pthread_mutex_lock(&out->buf_lock);
     pthread_mutex_lock(&out->lock);
     if (!out->bt_enabled || out->suspended) {
-        LOGV("a2dp write: bluetooth disabled bt_en %d, suspended %d",
+        ALOGV("a2dp %s: bluetooth disabled bt_en %d, suspended %d",
              out->bt_enabled, out->suspended);
         ret = -1;
         goto err_bt_disabled;
@@ -462,7 +466,7 @@
 err_init:
 err_bt_disabled:
     pthread_mutex_unlock(&out->buf_lock);
-    LOGV("!!!! write error");
+    ALOGV("!!!! write error");
     out_standby_stream_locked(out);
     pthread_mutex_unlock(&out->lock);
 
@@ -519,7 +523,7 @@
                 pthread_mutex_unlock(&out->lock);
 
                 if (ret < 0) {
-                    LOGE("%s: a2dp_write failed (%d)\n", __func__, ret);
+                    ALOGE("%s: a2dp_write failed (%d)\n", __func__, ret);
                     /* skip pending frames in case of write error */
                     _out_inc_rd_idx_locked(out, frames);
                     break;
@@ -545,7 +549,7 @@
                 buffer_duration_us = ((ret * 1000) / out->sample_rate) * 1000;
 
                 if (elapsed_us < (buffer_duration_us / 4)) {
-                    LOGV("A2DP sink runs too fast");
+                    ALOGV("A2DP sink runs too fast");
                     usleep(buffer_duration_us - elapsed_us);
                 }
                 out->last_write_time = now;
@@ -598,7 +602,7 @@
 }
 
 static int adev_open_output_stream(struct audio_hw_device *dev,
-                                   uint32_t devices, int *format,
+                                   uint32_t devices, audio_format_t *format,
                                    uint32_t *channels, uint32_t *sample_rate,
                                    struct audio_stream_out **stream_out)
 {
@@ -610,7 +614,7 @@
 
     /* one output stream at a time */
     if (adev->output) {
-        LOGV("output exists");
+        ALOGV("output exists");
         ret = -EBUSY;
         goto err_output_exists;
     }
@@ -661,7 +665,7 @@
     if (!_out_validate_parms(out, format ? *format : 0,
                              channels ? *channels : 0,
                              sample_rate ? *sample_rate : 0)) {
-        LOGV("invalid parameters");
+        ALOGV("invalid parameters");
         ret = -EINVAL;
         goto err_validate_parms;
     }
@@ -715,7 +719,7 @@
 
     /* invalid stream? */
     if (!adev->output || adev->output != out) {
-        LOGE("%s: unknown stream %p (ours is %p)", __func__, out, adev->output);
+        ALOGE("%s: unknown stream %p (ours is %p)", __func__, out, adev->output);
         return;
     }
 
@@ -836,7 +840,7 @@
     return -ENOSYS;
 }
 
-static int adev_set_mode(struct audio_hw_device *dev, int mode)
+static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
 {
     /* TODO: do we care for the mode? */
     return 0;
@@ -853,7 +857,7 @@
 }
 
 static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
-                                         uint32_t sample_rate, int format,
+                                         uint32_t sample_rate, audio_format_t format,
                                          int channel_count)
 {
     /* no input */
@@ -861,7 +865,7 @@
 }
 
 static int adev_open_input_stream(struct audio_hw_device *dev, uint32_t devices,
-                                  int *format, uint32_t *channels,
+                                  audio_format_t *format, uint32_t *channels,
                                   uint32_t *sample_rate,
                                   audio_in_acoustics_t acoustics,
                                   struct audio_stream_in **stream_in)
diff --git a/audio/liba2dp.c b/audio/liba2dp.c
index 62f52d4..aba24e4 100755
--- a/audio/liba2dp.c
+++ b/audio/liba2dp.c
@@ -58,13 +58,13 @@
 #define BUFFER_SIZE 2048
 
 #ifdef ENABLE_DEBUG
-#define DBG LOGD
+#define DBG ALOGD
 #else
 #define DBG(fmt, arg...)
 #endif
 
 #ifdef ENABLE_VERBOSE
-#define VDBG LOGV
+#define VDBG ALOGV
 #else
 #define VDBG(fmt, arg...)
 #endif
@@ -80,7 +80,7 @@
 #define MAX_BITPOOL 64
 #define MIN_BITPOOL 2
 
-#define ERR LOGE
+#define ERR ALOGE
 
 /* Number of packets to buffer in the stream socket */
 #define PACKET_BUFFER_COUNT		10
diff --git a/tools/Android.mk b/tools/Android.mk
index ac4c2e7..47343e7 100755
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -211,6 +211,8 @@
 LOCAL_SHARED_LIBRARIES := \
 	libbluetooth libbluetoothd
 
+LOCAL_MODULE_TAGS := optional
+
 LOCAL_MODULE:=bccmd
 
 include $(BUILD_EXECUTABLE)