summaryrefslogtreecommitdiffstats
path: root/audio_a2dp_hw
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@google.com>2014-07-11 12:05:04 -0700
committerMike Lockwood <lockwood@google.com>2014-07-11 12:05:04 -0700
commitb1c8fccbca8573555d6db07a2e44685f335800aa (patch)
treecbb199bb1645eda0222c162e1ac5b055e20c2a17 /audio_a2dp_hw
parent3b4d3fb7f1b0fa51400cc6531e1e693471949486 (diff)
downloadandroid_system_bt-b1c8fccbca8573555d6db07a2e44685f335800aa.tar.gz
android_system_bt-b1c8fccbca8573555d6db07a2e44685f335800aa.tar.bz2
android_system_bt-b1c8fccbca8573555d6db07a2e44685f335800aa.zip
A2DP: Fix audio stuttering in A2DP sink mode
Change-Id: Ied821aeb14f83e3fd1daa6e175ac995abbfbb198
Diffstat (limited to 'audio_a2dp_hw')
-rw-r--r--audio_a2dp_hw/audio_a2dp_hw.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/audio_a2dp_hw/audio_a2dp_hw.c b/audio_a2dp_hw/audio_a2dp_hw.c
index 14a923516..beedb3b00 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.c
+++ b/audio_a2dp_hw/audio_a2dp_hw.c
@@ -222,12 +222,18 @@ static int skt_connect(char *path, size_t buffer_sz)
if (ret < 0)
ERROR("setsockopt failed (%s)", strerror(errno));
+ ret = setsockopt(skt_fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, (int)sizeof(len));
+
+ /* only issue warning if failed */
+ if (ret < 0)
+ ERROR("setsockopt failed (%s)", strerror(errno));
+
INFO("connected to stack fd = %d", skt_fd);
return skt_fd;
}
-static int skt_read(int fd, void *p, size_t len, int us_timeout)
+static int skt_read(int fd, void *p, size_t len)
{
int read;
struct pollfd pfd;
@@ -235,19 +241,6 @@ static int skt_read(int fd, void *p, size_t len, int us_timeout)
FNLOG();
- pfd.fd = fd;
- pfd.events = POLLIN;
-
- ts.tv_sec = us_timeout / 1000000;
- ts.tv_nsec = (us_timeout % 1000000) * 1000;
-
- ts_log("skt_read ppoll", len, NULL);
-
- /* read time out */
- if (ppoll(&pfd, 1, &ts, NULL) == 0) {
- return 0;
- }
-
ts_log("skt_read recv", len, NULL);
if ((read = recv(fd, p, len, MSG_NOSIGNAL)) == -1)
@@ -933,8 +926,6 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
return -1;
}
- int us_delay = calc_audiotime(in->common.cfg, bytes);
-
/* only allow autostarting if we are in stopped or standby */
if ((in->common.state == AUDIO_A2DP_STATE_STOPPED) ||
(in->common.state == AUDIO_A2DP_STATE_STANDBY))
@@ -946,6 +937,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
/* emulate time this write represents to avoid very fast write
failures during transition periods or remote suspend */
+ int us_delay = calc_audiotime(in->common.cfg, bytes);
+
DEBUG("emulate a2dp read delay (%d us)", us_delay);
usleep(us_delay);
@@ -961,7 +954,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
return -1;
}
- read = skt_read(in->common.audio_fd, buffer, bytes, us_delay);
+ read = skt_read(in->common.audio_fd, buffer, bytes);
if (read == -1)
{