diff options
author | Mike Lockwood <lockwood@android.com> | 2009-06-19 11:50:02 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-06-19 11:50:02 -0400 |
commit | cb75ad7a5a708a6a1f593cddb745f1c0460676c6 (patch) | |
tree | a963f42c5fcad731db10033f7e434a0e2cf664d7 | |
parent | 5c4a7a53067d815f515ba8b079244c17a2fc4f4c (diff) | |
download | bluez-donut-release2.tar.gz |
liba2dp: Fix timeout computation in wait_for_start()HEADandroid-sdk-tools_r2android-sdk-1.6_r2android-sdk-1.6_r1android-sdk-1.6-docs_r1android-1.6_r2android-1.6_r1.5android-1.6_r1.4android-1.6_r1.3android-1.6_r1.2android-1.6_r1.1android-1.6_r1mastermaindonut-release2donut-releasedonut
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.c | 15 |
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) |