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

Unified Diff: media/audio/audio_output_controller.cc

Issue 22886005: Switch audio synchronization from sleep() based to select() based. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | media/audio/audio_output_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_controller.cc
diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc
index 81eaab9c19aba63868d476c4c27db4d1d663c624..bf64b70e381582bf43929441376e3b91d7b8ab04 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -11,7 +11,6 @@
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
-#include "media/audio/shared_memory_util.h"
#include "media/base/scoped_histogram_timer.h"
using base::Time;
@@ -221,8 +220,10 @@ void AudioOutputController::DoPause() {
if (state_ != kPaused)
return;
- // Send a special pause mark to the low-latency audio thread.
- sync_reader_->UpdatePendingBytes(kPauseMark);
+ // Let the renderer know we've stopped. Necessary to let PPAPI clients know
+ // audio has been shutdown. TODO(dalecurtis): This stinks. PPAPI should have
+ // a better way to know when it should exit PPB_Audio_Shared::Run().
+ sync_reader_->UpdatePendingBytes(-1);
#if defined(AUDIO_POWER_MONITORING)
// Paused means silence follows.
@@ -278,26 +279,9 @@ int AudioOutputController::OnMoreIOData(AudioBus* source,
DisallowEntryToOnMoreIOData();
TRACE_EVENT0("audio", "AudioOutputController::OnMoreIOData");
- // The OS level audio APIs on Linux and Windows all have problems requesting
- // data on a fixed interval. Sometimes they will issue calls back to back
- // which can cause glitching, so wait until the renderer is ready.
- //
- // We also need to wait when diverting since the virtual stream will call this
- // multiple times without waiting.
- //
- // NEVER wait on OSX unless a virtual stream is connected, otherwise we can
- // end up hanging the entire OS.
- //
- // See many bugs for context behind this decision: http://crbug.com/170498,
- // http://crbug.com/171651, http://crbug.com/174985, and more.
-#if defined(OS_WIN) || defined(OS_LINUX)
- const bool kShouldBlock = true;
-#else
- const bool kShouldBlock = diverting_to_stream_ != NULL;
-#endif
+ sync_reader_->Read(source, dest);
- const int frames = sync_reader_->Read(kShouldBlock, source, dest);
- DCHECK_LE(0, frames);
+ const int frames = dest->frames();
sync_reader_->UpdatePendingBytes(
buffers_state.total_bytes() + frames * params_.GetBytesPerFrame());
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | media/audio/audio_output_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698