Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(818)

Side by Side Diff: media/audio/pulse/pulse_input.cc

Issue 486603002: Fix the unnecessary sleep when no back to back OnData call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/pulse/pulse_input.h" 5 #include "media/audio/pulse/pulse_input.h"
6 6
7 #include <pulse/pulseaudio.h> 7 #include <pulse/pulseaudio.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/audio/pulse/audio_manager_pulse.h" 10 #include "media/audio/pulse/audio_manager_pulse.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 pa_stream_drop(handle_); 274 pa_stream_drop(handle_);
275 } while (pa_stream_readable_size(handle_) > 0); 275 } while (pa_stream_readable_size(handle_) > 0);
276 276
277 while (fifo_.available_blocks()) { 277 while (fifo_.available_blocks()) {
278 const AudioBus* audio_bus = fifo_.Consume(); 278 const AudioBus* audio_bus = fifo_.Consume();
279 279
280 // Compensate the audio delay caused by the FIFO. 280 // Compensate the audio delay caused by the FIFO.
281 hardware_delay += fifo_.GetAvailableFrames() * params_.GetBytesPerFrame(); 281 hardware_delay += fifo_.GetAvailableFrames() * params_.GetBytesPerFrame();
282 callback_->OnData(this, audio_bus, hardware_delay, normalized_volume); 282 callback_->OnData(this, audio_bus, hardware_delay, normalized_volume);
283 283
284 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5)); 284 // Sleep 5ms to wait until render consumes the data in order to avoid
285 // back to back OnData() method.
286 if (fifo_.available_blocks())
287 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5));
285 } 288 }
286 289
287 pa_threaded_mainloop_signal(pa_mainloop_, 0); 290 pa_threaded_mainloop_signal(pa_mainloop_, 0);
288 } 291 }
289 292
290 } // namespace media 293 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698