aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/android_audio_hw.c56
-rwxr-xr-xaudio/liba2dp.c6
2 files changed, 33 insertions, 29 deletions
diff --git a/audio/android_audio_hw.c b/audio/android_audio_hw.c
index 348ad14d..07461096 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 @@ struct astream_out {
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 @@ static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
{
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 @@ static uint32_t out_get_channels(const struct audio_stream *stream)
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 @@ static int _out_init_locked(struct astream_out *out, const char *addr)
/* 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 @@ static int _out_init_locked(struct astream_out *out, const char *addr)
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 @@ static int out_standby_stream_locked(struct astream_out *out)
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 @@ static int out_close_stream_locked(struct astream_out *out)
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 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
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 @@ static char * out_get_parameters(const struct audio_stream *stream,
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 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
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_write:
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 @@ static void *_out_buf_thread_func(void *context)
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 @@ static void *_out_buf_thread_func(void *context)
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 _out_a2dp_suspend(struct astream_out *out, bool suspend)
}
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 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
/* 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 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
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 @@ static void adev_close_output_stream_locked(struct adev_a2dp *dev,
/* 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 @@ static int adev_set_master_volume(struct audio_hw_device *dev, float volume)
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 int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
}
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 size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
}
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 62f52d49..aba24e4d 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