summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2009-06-19 11:50:02 -0400
committerMike Lockwood <lockwood@android.com>2009-06-19 11:50:02 -0400
commitcb75ad7a5a708a6a1f593cddb745f1c0460676c6 (patch)
treea963f42c5fcad731db10033f7e434a0e2cf664d7
parent5c4a7a53067d815f515ba8b079244c17a2fc4f4c (diff)
downloadbluez-donut-release.tar.gz
Also increase a2dp_write timeout from 100ms to 500 ms to avoid losing the first fraction of a second of a song when streaming starts. Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--utils/audio/liba2dp.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/utils/audio/liba2dp.c b/utils/audio/liba2dp.c
index 943f542f..feb42027 100644
--- a/utils/audio/liba2dp.c
+++ b/utils/audio/liba2dp.c
@@ -86,7 +86,7 @@
#define POLL_TIMEOUT 1000
/* timeout in milliseconds for a2dp_write */
-#define WRITE_TIMEOUT 100
+#define WRITE_TIMEOUT 500
typedef enum {
@@ -831,17 +831,22 @@ static void set_command(struct bluetooth_data *data, a2dp_command_t command)
pthread_mutex_unlock(&data->mutex);
}
+/* timeout is in milliseconds */
static int wait_for_start(struct bluetooth_data *data, int timeout)
{
a2dp_state_t state = data->state;
+ struct timeval tv;
struct timespec ts;
- uint64_t begin, end;
int err = 0;
+#ifdef ENABLE_TIMING
+ uint64_t begin, end;
begin = get_microseconds();
- end = begin + (timeout * 1000);
- ts.tv_sec = end / (1000 * 1000);
- ts.tv_nsec = (end % (1000 * 1000)) * 1000;
+#endif
+
+ gettimeofday(&tv, (struct timezone *) NULL);
+ ts.tv_sec = tv.tv_sec + (timeout / 1000);
+ ts.tv_nsec = (tv.tv_usec + (timeout % 1000) * 1000L ) * 1000L;
while (state != A2DP_STATE_STARTED && !err) {
if (state == A2DP_STATE_NONE)