Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bluetooth: Making 48K as the default sampling rate for SBC encoding.

Audio HAL default sample rate is updated to 48K, so updating A2dp
sampling even to 48K in order to avoid delays in updating frames
consumed.

CRs-Fixed: 350360

Change-Id: Ia7af9870fe44155a8d5c608bc67da3c0a4c4e087
  • Loading branch information...
commit e3a9481f9efd7b86e68a68fc9c0d62cd7abfaf3a 1 parent d292ef2
Srinivas Krovvidi authored BMc08GT committed
Showing with 34 additions and 6 deletions.
  1. +11 −0 audio/Android.mk
  2. +15 −4 audio/a2dp.c
  3. +8 −2 audio/android_audio_hw.c
View
11 audio/Android.mk
@@ -44,6 +44,11 @@ LOCAL_SHARED_LIBRARIES := \
libdbus \
libglib
+ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
+ifeq ($(BOARD_USES_ALSA_AUDIO),true)
+LOCAL_CFLAGS += -DA2DP_48000_SAMPLE_RATE
+endif
+endif
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/bluez-plugin
LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/bluez-plugin
@@ -85,6 +90,12 @@ LOCAL_C_INCLUDES:= \
LOCAL_SHARED_LIBRARIES := \
libcutils
+ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
+ifeq ($(BOARD_USES_ALSA_AUDIO),true)
+LOCAL_CFLAGS += -DA2DP_48000_SAMPLE_RATE
+endif
+endif
+
ifneq ($(wildcard system/bluetooth/legacy.mk),)
LOCAL_STATIC_LIBRARIES := \
libpower
View
19 audio/a2dp.c
@@ -505,7 +505,11 @@ static gboolean sbc_getcap_ind(struct avdtp *session, struct avdtp_local_sep *se
sbc_cap.cap.media_codec_type = A2DP_CODEC_SBC;
#ifdef ANDROID
- sbc_cap.frequency = SBC_SAMPLING_FREQ_44100;
+#ifdef A2DP_48000_SAMPLE_RATE
+ sbc_cap.frequency = SBC_SAMPLING_FREQ_48000;
+#else
+ sbc_cap.frequency = SBC_SAMPLING_FREQ_44100;
+#endif
#else
sbc_cap.frequency = ( SBC_SAMPLING_FREQ_48000 |
SBC_SAMPLING_FREQ_44100 |
@@ -1782,10 +1786,17 @@ static gboolean select_sbc_params(struct sbc_codec_cap *cap,
cap->cap.media_type = AVDTP_MEDIA_TYPE_AUDIO;
cap->cap.media_codec_type = A2DP_CODEC_SBC;
- if (supported->frequency & SBC_SAMPLING_FREQ_44100)
- cap->frequency = SBC_SAMPLING_FREQ_44100;
- else if (supported->frequency & SBC_SAMPLING_FREQ_48000)
+#ifdef A2DP_48000_SAMPLE_RATE
+ if (supported->frequency & SBC_SAMPLING_FREQ_48000)
cap->frequency = SBC_SAMPLING_FREQ_48000;
+ else if (supported->frequency & SBC_SAMPLING_FREQ_44100)
+ cap->frequency = SBC_SAMPLING_FREQ_44100;
+#else
+ if (supported->frequency & SBC_SAMPLING_FREQ_44100)
+ cap->frequency = SBC_SAMPLING_FREQ_44100;
+ else if (supported->frequency & SBC_SAMPLING_FREQ_48000)
+ cap->frequency = SBC_SAMPLING_FREQ_48000;
+#endif
else if (supported->frequency & SBC_SAMPLING_FREQ_32000)
cap->frequency = SBC_SAMPLING_FREQ_32000;
else if (supported->frequency & SBC_SAMPLING_FREQ_16000)
View
10 audio/android_audio_hw.c
@@ -36,6 +36,12 @@
#include "liba2dp.h"
+#ifdef A2DP_48000_SAMPLE_RATE
+#define A2DP_SAMPLE_RATE 48000
+#else
+#define A2DP_SAMPLE_RATE 44100
+#endif
+
/* for backward compatibility with older audio framework */
#ifndef AUDIO_PARAMETER_A2DP_SINK_ADDRESS
#define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address"
@@ -207,7 +213,7 @@ static int _out_init_locked(struct astream_out *out, const char *addr)
return 0;
/* XXX: shouldn't this use the sample_rate/channel_count from 'out'? */
- ret = a2dp_init(44100, 2, &out->data);
+ ret = a2dp_init(A2DP_SAMPLE_RATE, 2, &out->data);
if (ret < 0) {
ALOGE("a2dp_init failed err: %d\n", ret);
out->data = NULL;
@@ -655,7 +661,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->stream.write = out_write;
out->stream.get_render_position = out_get_render_position;
- out->sample_rate = 44100;
+ out->sample_rate = A2DP_SAMPLE_RATE;
out->buffer_size = 512 * 20;
out->channels = AUDIO_CHANNEL_OUT_STEREO;
out->format = AUDIO_FORMAT_PCM_16_BIT;
Please sign in to comment.
Something went wrong with that request. Please try again.