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

Unified Diff: media/audio/audio_device_thread.cc

Issue 481193003: Remove AudioBuffersState usage in Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix audio muter build buster. Created 6 years, 3 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_buffers_state.cc ('k') | media/audio/audio_io.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_device_thread.cc
diff --git a/media/audio/audio_device_thread.cc b/media/audio/audio_device_thread.cc
index 172033f46cb63a33fb9eaf79226a209804f0ba32..0c0c86cc81770108133cb36e21a4acaa014756d9 100644
--- a/media/audio/audio_device_thread.cc
+++ b/media/audio/audio_device_thread.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/memory/aligned_memory.h"
#include "base/message_loop/message_loop.h"
+#include "base/numerics/safe_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
#include "media/base/audio_bus.h"
@@ -164,15 +165,21 @@ void AudioDeviceThread::Thread::ThreadMain() {
void AudioDeviceThread::Thread::Run() {
uint32 buffer_index = 0;
while (true) {
- int pending_data = 0;
+ uint32 pending_data = 0;
size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data));
if (bytes_read != sizeof(pending_data))
break;
{
base::AutoLock auto_lock(callback_lock_);
- if (callback_)
- callback_->Process(pending_data);
+ if (callback_) {
+ // TODO(acolwell): Update downstream code to use a uint32.
+ // Under normal operation saturation should never occur here
+ // and even if it does, it would only cause a temporary loss
+ // of A/V sync which is much better than crashing or halting
+ // playback.
+ callback_->Process(base::saturated_cast<uint32>(pending_data));
+ }
}
// Let the other end know which buffer we just filled. The buffer index is
« no previous file with comments | « media/audio/audio_buffers_state.cc ('k') | media/audio/audio_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698