summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorwtc <wtc@chromium.org>2014-12-16 18:55:49 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-17 02:56:08 +0000
commitffbad9b6a0912b37118ed74b0dc657d2e213f00a (patch)
tree78ae668b48ce36dc0d8a9fc4b6ba65caf87a927d /media
parent914735051ba5eb98a6f69769aaadcf6735f03d5c (diff)
downloadchromium_src-ffbad9b6a0912b37118ed74b0dc657d2e213f00a.zip
chromium_src-ffbad9b6a0912b37118ed74b0dc657d2e213f00a.tar.gz
chromium_src-ffbad9b6a0912b37118ed74b0dc657d2e213f00a.tar.bz2
Remove unnecessary arithmetic operations.
It is not necessary to subtract the remainder before an integer division. Add the delay < 0 check back, so that we don't rely on the fact that static_cast<snd_pcm_uframes_t>(-1) is a huge positive value. R=dalecurtis@chromium.org BUG=none Review URL: https://codereview.chromium.org/807973003 Cr-Commit-Position: refs/heads/master@{#308735}
Diffstat (limited to 'media')
-rw-r--r--media/audio/alsa/alsa_output.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/media/audio/alsa/alsa_output.cc b/media/audio/alsa/alsa_output.cc
index 6e62d69..1fbab14 100644
--- a/media/audio/alsa/alsa_output.cc
+++ b/media/audio/alsa/alsa_output.cc
@@ -408,7 +408,6 @@ void AlsaPcmOutputStream::WritePacket() {
const uint8* buffer_data;
int buffer_size;
if (buffer_->GetCurrentChunk(&buffer_data, &buffer_size)) {
- buffer_size = buffer_size - (buffer_size % bytes_per_output_frame_);
snd_pcm_sframes_t frames = std::min(
static_cast<snd_pcm_sframes_t>(buffer_size / bytes_per_output_frame_),
GetAvailableFrames());
@@ -588,7 +587,8 @@ snd_pcm_sframes_t AlsaPcmOutputStream::GetCurrentDelay() {
// driver is PulseAudio based, certain configuration settings (e.g., tsched=1)
// will generate much larger delay values than |alsa_buffer_frames_|, so only
// clip if delay is truly crazy (> 10x expected).
- if (static_cast<snd_pcm_uframes_t>(delay) > alsa_buffer_frames_ * 10) {
+ if (delay < 0 ||
+ static_cast<snd_pcm_uframes_t>(delay) > alsa_buffer_frames_ * 10) {
delay = alsa_buffer_frames_ - GetAvailableFrames();
}