summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-10-18 08:32:37 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-10-18 08:32:37 +0000
commit3e1e3e3679cbe30eb8a2cf7905d709b658c4c1ad (patch)
tree48950c6a835a6c7d358f920b15ea55ff5f256354
parente7613df411ab21a28af57347f37cc3c0283bb10e (diff)
Fix poll timeout to avoid unnecessary polls
-rw-r--r--audio/pcm_bluetooth.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index 893a234c..cb440166 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -167,12 +167,17 @@ static void *playback_hw_thread(void *param)
double period_time;
struct timeval start;
struct pollfd fds[2];
+ int poll_timeout;
fds[0] = data->server;
fds[1] = data->stream;
prev_periods = 0;
period_time = 1000000.0 * data->io.period_size / data->io.rate;
+ if (period_time > (int) (MIN_PERIOD_TIME * 1000))
+ poll_timeout = (int) (period_time / 1000.0f);
+ else
+ poll_timeout = MIN_PERIOD_TIME;
gettimeofday(&start, 0);
@@ -213,7 +218,8 @@ static void *playback_hw_thread(void *param)
}
iter_sleep:
- ret = poll(fds, 2, MIN_PERIOD_TIME);
+ /* sleep up to one period interval */
+ ret = poll(fds, 2, poll_timeout);
if (ret < 0) {
SNDERR("poll error: %s (%d)", strerror(errno), errno);
if (errno != EINTR)