diff options
author | Andre Eisenbach <eisenbach@google.com> | 2014-11-07 15:46:04 -0800 |
---|---|---|
committer | Andre Eisenbach <eisenbach@google.com> | 2014-11-17 12:37:27 -0800 |
commit | c5916e97384f07ec5a2e061e6af24f70107c74a2 (patch) | |
tree | 21c556b91deafc63df8ae26eb0dca81871381b98 /udrv | |
parent | c5cda8198541888a6f16795effa55a0d3254afdb (diff) | |
download | android_system_bt-c5916e97384f07ec5a2e061e6af24f70107c74a2.tar.gz android_system_bt-c5916e97384f07ec5a2e061e6af24f70107c74a2.tar.bz2 android_system_bt-c5916e97384f07ec5a2e061e6af24f70107c74a2.zip |
Remove overflow rate limiting when reading A2DP frames
A2DP now supports adjusting the number of A2DP frames sent per timer
tick to adjust for timer drift and missed media task ticks. When the
signal to the headset/speakers becomes interrupted, the number of
packets to be read can queue up and rate limiting will not allow for the
queue to be cleared.
The overflow mechanism introduced in commit 4aebca4 will cause the media
task to stop sending packets completely, which can underflow the jutter
buffer on the remote device and lead to audio drop-outs.
This patch removes the overflow mechanism and also adds code do discard
audio frames that could not be sent to the remote device (weak signal
etc) to allow the device to stay in sync and not build up audio delays.
Also added additional debug logging and changed the UIPC flush mechanism
to address an issue where reading byte by byte causes an endless flush
loop if remote UIPC producer writes data faster than the flush loop
consumes it.
Bug: 18326405
Change-Id: I9a424984806bb2a464877399804b3355b2c439c3
Diffstat (limited to 'udrv')
-rw-r--r-- | udrv/ulinux/uipc.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/udrv/ulinux/uipc.c b/udrv/ulinux/uipc.c index b9caa1bfe..81ca7f86e 100644 --- a/udrv/ulinux/uipc.c +++ b/udrv/ulinux/uipc.c @@ -69,6 +69,8 @@ #define SAFE_FD_ISSET(fd, set) (((fd) == -1) ? FALSE : FD_ISSET((fd), (set))) +#define UIPC_FLUSH_BUFFER_SIZE 1024 + /***************************************************************************** ** Local type definitions ******************************************************************************/ @@ -373,30 +375,40 @@ static int uipc_setup_server_locked(tUIPC_CH_ID ch_id, char *name, tUIPC_RCV_CBA static void uipc_flush_ch_locked(tUIPC_CH_ID ch_id) { - char buf; + char buf[UIPC_FLUSH_BUFFER_SIZE]; struct pollfd pfd; int ret; - pfd.events = POLLIN|POLLHUP; + pfd.events = POLLIN; pfd.fd = uipc_main.ch[ch_id].fd; if (uipc_main.ch[ch_id].fd == UIPC_DISCONNECTED) + { + BTIF_TRACE_EVENT("%s() - fd disconnected. Exiting", __FUNCTION__); return; + } while (1) { ret = poll(&pfd, 1, 1); - BTIF_TRACE_EVENT("uipc_flush_ch_locked polling : fd %d, rxev %x, ret %d", pfd.fd, pfd.revents, ret); + BTIF_TRACE_VERBOSE("%s() - polling fd %d, revents: 0x%x, ret %d", + __FUNCTION__, pfd.fd, pfd.revents, ret); if (pfd.revents & (POLLERR|POLLHUP)) + { + BTIF_TRACE_EVENT("%s() - POLLERR or POLLHUP. Exiting", __FUNCTION__); return; + } if (ret <= 0) { - BTIF_TRACE_EVENT("uipc_flush_ch_locked : error (%d)", ret); + BTIF_TRACE_EVENT("%s() - error (%d). Exiting", __FUNCTION__, ret); return; } - read(pfd.fd, &buf, 1); + + /* read sufficiently large buffer to ensure flush empties socket faster than + it is getting refilled */ + read(pfd.fd, &buf, UIPC_FLUSH_BUFFER_SIZE); } } |