From 12ea5707b561117709053ea4580d97f03b772560 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 5 Mar 2009 15:47:13 +0200 Subject: bluetooth: reset read/write index when starting to stream --- src/modules/bluetooth/module-bluetooth-device.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/modules/bluetooth/module-bluetooth-device.c') diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 495bc82f..7d601e73 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -700,6 +700,9 @@ static int start_stream_fd(struct userdata *u) { pollfd->fd = u->stream_fd; pollfd->events = pollfd->revents = 0; + u->read_index = 0; + u->write_index = 0; + return 0; } -- cgit From 362d196093309c47ab7c53bb9343adf1792c9921 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 5 Mar 2009 17:04:39 +0200 Subject: bluetooth: accept temporarily unavailable error --- src/modules/bluetooth/module-bluetooth-device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules/bluetooth/module-bluetooth-device.c') diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 7d601e73..d5c2a87c 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -876,7 +876,7 @@ static int hsp_process_render(struct userdata *u) { pa_assert(l != 0); if (l < 0) { - if (errno == EINTR) + if (errno == EINTR || errno == EAGAIN) continue; else { pa_log_error("Failed to write data to SCO socket: %s", pa_cstrerror(errno)); @@ -921,7 +921,7 @@ static int hsp_process_push(struct userdata *u) { pa_memblock_release(memchunk.memblock); if (l <= 0) { - if (l < 0 && errno == EINTR) + if (l < 0 && (errno == EINTR || errno == EAGAIN)) continue; else { pa_log_error("Failed to read data from SCO socket: %s", l < 0 ? pa_cstrerror(errno) : "EOF"); @@ -1044,7 +1044,7 @@ static int a2dp_process_render(struct userdata *u) { pa_assert(l != 0); if (l < 0) { - if (errno == EINTR) + if (errno == EINTR || errno == EAGAIN) continue; else { pa_log_error("Failed to write data to socket: %s", pa_cstrerror(errno)); -- cgit From 018cadd3375c7aa2a4e2b5b8371e87c4c83ee6b7 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 5 Mar 2009 17:20:31 +0200 Subject: bluetooth: restart timer when write begin --- src/modules/bluetooth/module-bluetooth-device.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/modules/bluetooth/module-bluetooth-device.c') diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index d5c2a87c..3e09611e 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1126,6 +1126,8 @@ static void thread_func(void *userdata) { } if (writable && do_write) { + if (u->write_index == 0) + u->started_at = pa_rtclock_usec(); if (u->profile == PROFILE_A2DP) { if (a2dp_process_render(u) < 0) -- cgit From 9e93b9ce0b4eb825d3ce434401e2ccb9ac54e779 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 5 Mar 2009 18:18:07 +0200 Subject: bluetooth: stream also when source is suspended --- src/modules/bluetooth/module-bluetooth-device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules/bluetooth/module-bluetooth-device.c') diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 3e09611e..2d9ede50 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1164,8 +1164,8 @@ static void thread_func(void *userdata) { /* Hmm, nothing to do. Let's sleep */ if (pollfd) - pollfd->events = (short) (((u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state) && !writable) ? POLLOUT : 0) | - (u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state) ? POLLIN : 0)); + pollfd->events = (short) (((u->sink && PA_SINK_IS_LINKED(u->sink->thread_info.state) && !writable) ? POLLOUT : 0) | + (u->source && PA_SOURCE_IS_LINKED(u->source->thread_info.state) ? POLLIN : 0)); if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0) goto fail; -- cgit