diff options
author | Eric Laurent <elaurent@google.com> | 2009-10-16 09:22:50 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2011-05-25 11:51:54 -0700 |
commit | 5abd6d6344fa6d196ab172f724e4b7e1a755689e (patch) | |
tree | 749d9b2b277d0a4e21774bdc780265210bc7fc04 /audio | |
parent | 31f592d952b8e7ec0af72bbbd56090d53970d728 (diff) | |
download | bluez-5abd6d6344fa6d196ab172f724e4b7e1a755689e.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-x | audio/liba2dp.c | 8 |
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) { |