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

Side by Side Diff: media/audio/audio_input_device.cc

Issue 2076423004: Remove calls to MessageLoop::current() in media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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/audio_input_device.h" 5 #include "media/audio/audio_input_device.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
15 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "media/audio/audio_manager_base.h" 18 #include "media/audio/audio_manager_base.h"
18 #include "media/base/audio_bus.h" 19 #include "media/base/audio_bus.h"
19 20
20 namespace media { 21 namespace media {
21 22
22 // The number of shared memory buffer segments indicated to browser process 23 // The number of shared memory buffer segments indicated to browser process
23 // in order to avoid data overwriting. This number can be any positive number, 24 // in order to avoid data overwriting. This number can be any positive number,
24 // dependent how fast the renderer process can pick up captured data from 25 // dependent how fast the renderer process can pick up captured data from
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 DVLOG(1) << "Start()"; 88 DVLOG(1) << "Start()";
88 task_runner()->PostTask(FROM_HERE, 89 task_runner()->PostTask(FROM_HERE,
89 base::Bind(&AudioInputDevice::StartUpOnIOThread, this)); 90 base::Bind(&AudioInputDevice::StartUpOnIOThread, this));
90 } 91 }
91 92
92 void AudioInputDevice::Stop() { 93 void AudioInputDevice::Stop() {
93 DVLOG(1) << "Stop()"; 94 DVLOG(1) << "Stop()";
94 95
95 { 96 {
96 base::AutoLock auto_lock(audio_thread_lock_); 97 base::AutoLock auto_lock(audio_thread_lock_);
97 audio_thread_.Stop(base::MessageLoop::current()); 98 audio_thread_.Stop(base::ThreadTaskRunnerHandle::Get());
98 stopping_hack_ = true; 99 stopping_hack_ = true;
99 } 100 }
100 101
101 task_runner()->PostTask(FROM_HERE, 102 task_runner()->PostTask(FROM_HERE,
102 base::Bind(&AudioInputDevice::ShutDownOnIOThread, this)); 103 base::Bind(&AudioInputDevice::ShutDownOnIOThread, this));
103 } 104 }
104 105
105 void AudioInputDevice::SetVolume(double volume) { 106 void AudioInputDevice::SetVolume(double volume) {
106 if (volume < 0 || volume > 1.0) { 107 if (volume < 0 || volume > 1.0) {
107 DLOG(ERROR) << "Invalid volume value specified"; 108 DLOG(ERROR) << "Invalid volume value specified";
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 capture_callback_->Capture( 341 capture_callback_->Capture(
341 audio_bus, 342 audio_bus,
342 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 343 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
343 buffer->params.volume, buffer->params.key_pressed); 344 buffer->params.volume, buffer->params.key_pressed);
344 345
345 if (++current_segment_id_ >= total_segments_) 346 if (++current_segment_id_ >= total_segments_)
346 current_segment_id_ = 0; 347 current_segment_id_ = 0;
347 } 348 }
348 349
349 } // namespace media 350 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698