summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/ipc.h3
-rw-r--r--audio/pcm_bluetooth.c20
-rw-r--r--audio/unix.c10
3 files changed, 30 insertions, 3 deletions
diff --git a/audio/ipc.h b/audio/ipc.h
index 3768dcfb..4da7d2ae 100644
--- a/audio/ipc.h
+++ b/audio/ipc.h
@@ -117,10 +117,13 @@ typedef struct {
#define BT_CAPABILITIES_ACCESS_MODE_WRITE 2
#define BT_CAPABILITIES_ACCESS_MODE_READWRITE 3
+#define BT_FLAG_AUTOCONNECT 1
+
struct bt_getcapabilities_req {
bt_audio_msg_header_t h;
char device[18]; /* Address of the remote Device */
uint8_t transport; /* Requested transport */
+ uint8_t flags; /* Requested flags */
} __attribute__ ((packed));
/* BT_GETCAPABILITIES_RSP */
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index a04f18c0..e8a524c8 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -122,6 +122,7 @@ struct bluetooth_alsa_config {
int has_block_length;
uint8_t bitpool; /* A2DP only */
int has_bitpool;
+ int autoconnect;
};
struct bluetooth_data {
@@ -1268,11 +1269,14 @@ static int bluetooth_parse_config(snd_config_t *conf,
struct bluetooth_alsa_config *bt_config)
{
snd_config_iterator_t i, next;
- const char *addr, *pref;
+ const char *addr, *pref, *autoconnect;
const char *mode, *allocation, *rate, *subbands, *blocks, *bitpool;
memset(bt_config, 0, sizeof(struct bluetooth_alsa_config));
+ /* Set defaults */
+ bt_config->autoconnect = 1;
+
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
@@ -1283,6 +1287,17 @@ static int bluetooth_parse_config(snd_config_t *conf,
if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0)
continue;
+ if (strcmp(id, "autoconnect") == 0) {
+ if (snd_config_get_string(n, &autoconnect) < 0) {
+ SNDERR("Invalid type for %s", id);
+ return -EINVAL;
+ }
+
+ if (strcmp(autoconnect, "no") == 0)
+ bt_config->autoconnect = 0;
+ continue;
+ }
+
if (strcmp(id, "device") == 0 || strcmp(id, "bdaddr") == 0) {
if (snd_config_get_string(n, &addr) < 0) {
SNDERR("Invalid type for %s", id);
@@ -1514,6 +1529,9 @@ static int bluetooth_init(struct bluetooth_data *data, snd_pcm_stream_t stream,
memset(getcaps_req, 0, BT_AUDIO_IPC_PACKET_SIZE);
getcaps_req->h.msg_type = BT_GETCAPABILITIES_REQ;
+ getcaps_req->flags = 0;
+ if (alsa_conf->autoconnect)
+ getcaps_req->flags |= BT_FLAG_AUTOCONNECT;
strncpy(getcaps_req->device, alsa_conf->device, 18);
if (alsa_conf->has_transport)
getcaps_req->transport = alsa_conf->transport;
diff --git a/audio/unix.c b/audio/unix.c
index d71c420a..f3c6e6aa 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -765,6 +765,8 @@ static void handle_getcapabilities_req(struct unix_client *client,
client->interface = g_strdup(AUDIO_SINK_INTERFACE);
if (!manager_find_device(&bdaddr, NULL, FALSE)) {
+ if (!(req->flags & BT_FLAG_AUTOCONNECT))
+ goto failed;
if (!bacmp(&bdaddr, BDADDR_ANY))
goto failed;
if (!manager_create_device(&bdaddr, create_cb, client))
@@ -773,8 +775,12 @@ static void handle_getcapabilities_req(struct unix_client *client,
}
dev = manager_find_device(&bdaddr, client->interface, TRUE);
- if (!dev)
- dev = manager_find_device(&bdaddr, client->interface, FALSE);
+ if (!dev) {
+ if (req->flags & BT_FLAG_AUTOCONNECT)
+ dev = manager_find_device(&bdaddr, client->interface, FALSE);
+ else
+ goto failed;
+ }
if (!dev)
goto failed;