diff options
author | Nicolas Boichat <nicolas@boichat.ch> | 2014-01-04 15:27:56 +0800 |
---|---|---|
committer | David James <davidjames@chromium.org> | 2014-01-09 03:18:31 +0000 |
commit | a44ca59057b11c67482bab775d795a813ea1a0e9 (patch) | |
tree | dbcaddb2d1204ab6693a13d15ea42cade5745695 | |
parent | 49580e823b11ccbb08155374b2bb48906632968e (diff) | |
download | adhd-a44ca59057b11c67482bab775d795a813ea1a0e9.tar.gz |
CRAS: alsa_plugin - Fix tv_nsec divisions.
Dividing long by unsigned int results in a signed operation on x86-64,
but unsigned on x86 and ARM, cast io->rate to make sure the division is
signed.
BUG=chromium:331637
TEST=aplay/arecord and gtalk plugin on peppy.
Change-Id: I13544050b4179a63560d64e8cfdb75ce48f480d2
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/181713
-rw-r--r-- | cras/src/alsa_plugin/pcm_cras.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cras/src/alsa_plugin/pcm_cras.c b/cras/src/alsa_plugin/pcm_cras.c index 94fc6757..f95179f9 100644 --- a/cras/src/alsa_plugin/pcm_cras.c +++ b/cras/src/alsa_plugin/pcm_cras.c @@ -332,9 +332,11 @@ static int snd_pcm_cras_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp) &latency); } - *delayp = limit + io->appl_ptr - pcm_cras->playback_sample_index + - latency.tv_sec * io->rate + - latency.tv_nsec / (1000000000L / io->rate); + *delayp = limit + + io->appl_ptr - + pcm_cras->playback_sample_index + + latency.tv_sec * io->rate + + latency.tv_nsec / (1000000000L / (long)io->rate); } else { /* Do not compute latency if capture_sample_time is not set */ if (pcm_cras->capture_sample_time.tv_sec == 0 && @@ -347,9 +349,11 @@ static int snd_pcm_cras_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp) &latency); } - *delayp = limit + pcm_cras->capture_sample_index - io->appl_ptr + - latency.tv_sec * io->rate + - latency.tv_nsec / (1000000000L / io->rate); + *delayp = limit + + pcm_cras->capture_sample_index - + io->appl_ptr + + latency.tv_sec * io->rate + + latency.tv_nsec / (1000000000L / (long)io->rate); } /* Both appl and hw pointers wrap at the pcm boundary. */ |