summaryrefslogtreecommitdiffstats
path: root/audio_a2dp_hw
diff options
context:
space:
mode:
authorAyan Ghosh <abghosh@codeaurora.org>2015-10-07 18:34:50 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2015-12-01 04:19:55 -0800
commitcc034991d31c3ad1cf9b9d44655dc256c6b68228 (patch)
treea800674f064d564f31b55c0d761bc6f1e991fd99 /audio_a2dp_hw
parentf80b682e088ea0c49b5b4d1371eedda63bc5d96b (diff)
downloadandroid_system_bt-cc034991d31c3ad1cf9b9d44655dc256c6b68228.tar.gz
android_system_bt-cc034991d31c3ad1cf9b9d44655dc256c6b68228.tar.bz2
android_system_bt-cc034991d31c3ad1cf9b9d44655dc256c6b68228.zip
Split A2dp implementation
Implement Split A2dp to process AVDTP Signalling commands from host and media packet handling from Controller. Host uses vendor specific commands to let controller know the media channel configurations for controller to form the media packets accordingly. Change-Id: I7a98177a8125fd70b057bb514f0d870971a45bcf
Diffstat (limited to 'audio_a2dp_hw')
-rw-r--r--audio_a2dp_hw/audio_a2dp_hw.c58
-rw-r--r--audio_a2dp_hw/audio_a2dp_hw.h4
2 files changed, 61 insertions, 1 deletions
diff --git a/audio_a2dp_hw/audio_a2dp_hw.c b/audio_a2dp_hw/audio_a2dp_hw.c
index 5b93992a8..3e2bc2dde 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.c
+++ b/audio_a2dp_hw/audio_a2dp_hw.c
@@ -543,6 +543,7 @@ static int start_audio_datapath(struct a2dp_stream_common *common)
return -1;
}
+#ifndef BTA_AV_SPLIT_A2DP_ENABLED
/* connect socket if not yet connected */
if (common->audio_fd == AUDIO_SKT_DISCONNECTED)
{
@@ -555,6 +556,9 @@ static int start_audio_datapath(struct a2dp_stream_common *common)
common->state = AUDIO_A2DP_STATE_STARTED;
}
+#else
+ common->state = AUDIO_A2DP_STATE_STARTED;
+#endif
return 0;
}
@@ -581,9 +585,11 @@ static int stop_audio_datapath(struct a2dp_stream_common *common)
common->state = AUDIO_A2DP_STATE_STOPPED;
+#ifndef BTA_AV_SPLIT_A2DP_ENABLED
/* disconnect audio path */
skt_disconnect(common->audio_fd);
common->audio_fd = AUDIO_SKT_DISCONNECTED;
+#endif
return 0;
}
@@ -606,10 +612,12 @@ static int suspend_audio_datapath(struct a2dp_stream_common *common, bool standb
else
common->state = AUDIO_A2DP_STATE_SUSPENDED;
+#ifndef BTA_AV_SPLIT_A2DP_ENABLED
/* disconnect audio path */
skt_disconnect(common->audio_fd);
common->audio_fd = AUDIO_SKT_DISCONNECTED;
+#endif
return 0;
}
@@ -715,6 +723,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
}
DEBUG("wrote %d bytes out of %zu bytes", sent, bytes);
+
return sent;
}
@@ -815,13 +824,60 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
int retval;
int status = 0;
- INFO("state %d", out->common.state);
+ INFO("out_set_parameters: state %d", out->common.state);
parms = str_parms_create_str(kvpairs);
/* dump params */
str_parms_dump(parms);
+#ifdef BTA_AV_SPLIT_A2DP_ENABLED
+ retval = str_parms_get_str(parms, "A2dpStarted", keyval, sizeof(keyval));
+ if (retval >= 0)
+ {
+ INFO("out_set_parameters, param: A2dpStarted");
+ if (strcmp(keyval, "true") == 0)
+ {
+ INFO("out_set_parameters, value: true");
+ pthread_mutex_lock(&out->common.lock);
+ if (out->common.state == AUDIO_A2DP_STATE_SUSPENDED)
+ {
+ INFO("stream suspended");
+ status = -1;
+ }
+ else if ((out->common.state == AUDIO_A2DP_STATE_STOPPED) ||
+ (out->common.state == AUDIO_A2DP_STATE_STANDBY))
+ {
+ if (start_audio_datapath(&out->common) < 0)
+ {
+ INFO("stream start failed");
+ status = -1;
+ }
+ }
+ else if (out->common.state != AUDIO_A2DP_STATE_STARTED)
+ {
+ ERROR("stream not in stopped or standby");
+ status = -1;
+ }
+ pthread_mutex_unlock(&out->common.lock);
+ INFO("stream start completes with status: %d", status);
+ }
+ else if (strcmp(keyval, "false") == 0)
+ {
+ INFO("out_set_parameters, value: false");
+ pthread_mutex_lock(&out->common.lock);
+ if (out->common.state != AUDIO_A2DP_STATE_SUSPENDED)
+ status = suspend_audio_datapath(&out->common, true);
+ else
+ {
+ ERROR("stream alreday suspended");
+ }
+ pthread_mutex_unlock(&out->common.lock);
+ INFO("stream stop completes with status: %d", status);
+ }
+ }
+#endif
+
retval = str_parms_get_str(parms, "closing", keyval, sizeof(keyval));
if (retval >= 0)
diff --git a/audio_a2dp_hw/audio_a2dp_hw.h b/audio_a2dp_hw/audio_a2dp_hw.h
index e49cbdb32..a97b4c855 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.h
+++ b/audio_a2dp_hw/audio_a2dp_hw.h
@@ -35,7 +35,11 @@
#define A2DP_CTRL_PATH "/data/misc/bluedroid/.a2dp_ctrl"
#define A2DP_DATA_PATH "/data/misc/bluedroid/.a2dp_data"
+#ifndef BTA_AV_SPLIT_A2DP_DEF_FREQ_48KHZ
#define AUDIO_STREAM_DEFAULT_RATE 44100
+#else
+#define AUDIO_STREAM_DEFAULT_RATE 48000
+#endif
#define AUDIO_STREAM_DEFAULT_FORMAT AUDIO_FORMAT_PCM_16_BIT
#define AUDIO_STREAM_DEFAULT_CHANNEL_FLAG AUDIO_CHANNEL_OUT_STEREO
#define AUDIO_STREAM_OUTPUT_BUFFER_SZ (20*512)