aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2009-10-16 09:22:50 -0700
committerJaikumar Ganesh <jaikumar@google.com>2011-03-30 13:57:03 -0700
commit56bab6784afe7dda773aaed58c68316228ab09c0 (patch)
treebecad4fbd112cbc3bbf1fb8bf4b5bdfd1edb369e /audio
parentea90ad8ad019d6c613ac548bba396da79ed3f9d5 (diff)
downloadbluez-56bab6784afe7dda773aaed58c68316228ab09c0.tar.gz
Bluetooth A2DP suspend-resume improvements.
This change will reduce the occurence rate of A2DP sink suspend resume failures observed in issues 2184627, 2181005 and possibly 2189628. Avoid lockups in case of BT device disconnection during the A2DP start process by using a timeout when reading from bluetooth command socket. Correct a typo causing potential deadlock in wait_for_start().
Diffstat (limited to 'audio')
-rwxr-xr-xaudio/liba2dp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/audio/liba2dp.c b/audio/liba2dp.c
index d8f5bc8d..7dcfc9dc 100755
--- a/audio/liba2dp.c
+++ b/audio/liba2dp.c
@@ -88,6 +88,9 @@
/* timeout in milliseconds for a2dp_write */
#define WRITE_TIMEOUT 1000
+/* timeout in seconds for command socket recv() */
+#define RECV_TIMEOUT 5
+
typedef enum {
A2DP_STATE_NONE = 0,
@@ -786,6 +789,7 @@ static int audioservice_expect(struct bluetooth_data *data,
static int bluetooth_init(struct bluetooth_data *data)
{
int sk, err;
+ struct timeval tv = {.tv_sec = RECV_TIMEOUT};
DBG("bluetooth_init");
@@ -795,6 +799,8 @@ static int bluetooth_init(struct bluetooth_data *data)
return -errno;
}
+ setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+
data->server.fd = sk;
data->server.events = POLLIN;
data->state = A2DP_STATE_INITIALIZED;
@@ -919,7 +925,7 @@ static int wait_for_start(struct bluetooth_data *data, int timeout)
pthread_mutex_lock(&data->mutex);
while (state != A2DP_STATE_STARTED) {
if (state == A2DP_STATE_NONE)
- set_command(data, A2DP_CMD_INIT);
+ __set_command(data, A2DP_CMD_INIT);
else if (state == A2DP_STATE_INITIALIZED)
__set_command(data, A2DP_CMD_CONFIGURE);
else if (state == A2DP_STATE_CONFIGURED) {