Android 5 adds audio configuration callback.
---
android/hal-ipc-api.txt | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index a5ec44b..9502a15 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1098,6 +1098,15 @@ Notifications:
0x01 = Stopped
0x02 = Started
+ Opcode 0x83 - Audio Configuration notification
+
+ Notification parameters: Remote address (6 octets)
+ Sample Rate in Hz (4 octets)
+ Channel Count (1 octet)
+
+ Valid channel count: 0x01 = Mono
+ 0x02 = Stereo
+
Bluetooth Health HAL (ID 7)
===========================
--
1.9.1
Hi,
On 11/19/2014 02:10 PM, Jakub Tyszkowski wrote:
> Android 5 adds audio configuration callback.
> ---
> android/hal-ipc-api.txt | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index a5ec44b..9502a15 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -1098,6 +1098,15 @@ Notifications:
> 0x01 = Stopped
> 0x02 = Started
>
> + Opcode 0x83 - Audio Configuration notification
> +
> + Notification parameters: Remote address (6 octets)
> + Sample Rate in Hz (4 octets)
> + Channel Count (1 octet)
> +
> + Valid channel count: 0x01 = Mono
> + 0x02 = Stereo
> +
>
> Bluetooth Health HAL (ID 7)
> ===========================
>
Please ignore this whole set as it turn out that new callback is for
sink role only and sink role is implementing the same HAL interface.
This case requires more elaborate documentation and different IPC code.
Regards,
Jakub
This is Android 5 API callback.
---
android/client/if-av.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/android/client/if-av.c b/android/client/if-av.c
index 8d1f69b..85c641b 100644
--- a/android/client/if-av.c
+++ b/android/client/if-av.c
@@ -50,10 +50,22 @@ static void audio_state(btav_audio_state_t state, bt_bdaddr_t *bd_addr)
bt_bdaddr_t2str(bd_addr, last_addr));
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static void audio_config(bt_bdaddr_t *bd_addr, uint32_t sample_rate,
+ uint8_t channel_count) {
+ haltest_info("%s: remote_addr=%s\n sample_rate=%d\n channel_count=%d\n",
+ __func__, bt_bdaddr_t2str(bd_addr, last_addr),
+ sample_rate, channel_count);
+}
+#endif
+
static btav_callbacks_t av_cbacks = {
.size = sizeof(av_cbacks),
.connection_state_cb = connection_state,
- .audio_state_cb = audio_state
+ .audio_state_cb = audio_state,
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ .audio_config_cb = audio_config,
+#endif
};
/* init */
--
1.9.1
Android 5 adds audio configuration callback.
---
android/hal-a2dp.c | 13 +++++++++++++
android/hal-msg.h | 7 +++++++
2 files changed, 20 insertions(+)
diff --git a/android/hal-a2dp.c b/android/hal-a2dp.c
index 3556218..ca92b0e 100644
--- a/android/hal-a2dp.c
+++ b/android/hal-a2dp.c
@@ -48,6 +48,17 @@ static void handle_audio_state(void *buf, uint16_t len, int fd)
cbs->audio_state_cb(ev->state, (bt_bdaddr_t *)(ev->bdaddr));
}
+static void handle_audio_config(void *buf, uint16_t len, int fd)
+{
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_a2dp_audio_config *ev = buf;
+
+ if (cbs->audio_config_cb)
+ cbs->audio_config_cb((bt_bdaddr_t *)(ev->bdaddr),
+ ev->sample_rate, ev->channel_count);
+#endif
+}
+
/*
* handlers will be called from notification thread context,
* index in table equals to 'opcode - HAL_MINIMUM_EVENT'
@@ -57,6 +68,8 @@ static const struct hal_ipc_handler ev_handlers[] = {
{ handle_conn_state, false, sizeof(struct hal_ev_a2dp_conn_state) },
/* HAL_EV_A2DP_AUDIO_STATE */
{ handle_audio_state, false, sizeof(struct hal_ev_a2dp_audio_state) },
+ /* HAL_EV_A2DP_AUDIO_CONFIG */
+ { handle_audio_config, false, sizeof(struct hal_ev_a2dp_audio_config) },
};
static bt_status_t a2dp_connect(bt_bdaddr_t *bd_addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9087571..402fc3c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1468,6 +1468,13 @@ struct hal_ev_a2dp_audio_state {
uint8_t bdaddr[6];
} __attribute__((packed));
+#define HAL_EV_A2DP_AUDIO_CONFIG 0x83
+struct hal_ev_a2dp_audio_config {
+ uint8_t bdaddr[6];
+ uint32_t sample_rate;
+ uint8_t channel_count;
+} __attribute__((packed));
+
#define HAL_EV_HANDSFREE_CONN_STATE_DISCONNECTED 0x00
#define HAL_EV_HANDSFREE_CONN_STATE_CONNECTING 0x01
#define HAL_EV_HANDSFREE_CONN_STATE_CONNECTED 0x02
--
1.9.1