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

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

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_output_device.cc » ('j') | 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/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 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "media/audio/audio_manager_base.h" 17 #include "media/audio/audio_manager_base.h"
17 #include "media/base/audio_bus.h" 18 #include "media/base/audio_bus.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 CaptureCallback* capture_callback_; 50 CaptureCallback* capture_callback_;
50 51
51 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); 52 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
52 }; 53 };
53 54
54 AudioInputDevice::AudioInputDevice( 55 AudioInputDevice::AudioInputDevice(
55 scoped_ptr<AudioInputIPC> ipc, 56 scoped_ptr<AudioInputIPC> ipc,
56 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 57 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
57 : ScopedTaskRunnerObserver(io_task_runner), 58 : ScopedTaskRunnerObserver(io_task_runner),
58 callback_(NULL), 59 callback_(NULL),
59 ipc_(ipc.Pass()), 60 ipc_(std::move(ipc)),
60 state_(IDLE), 61 state_(IDLE),
61 session_id_(0), 62 session_id_(0),
62 agc_is_enabled_(false), 63 agc_is_enabled_(false),
63 stopping_hack_(false) { 64 stopping_hack_(false) {
64 CHECK(ipc_); 65 CHECK(ipc_);
65 66
66 // The correctness of the code depends on the relative values assigned in the 67 // The correctness of the code depends on the relative values assigned in the
67 // State enum. 68 // State enum.
68 static_assert(IPC_CLOSED < IDLE, "invalid enum value assignment 0"); 69 static_assert(IPC_CLOSED < IDLE, "invalid enum value assignment 0");
69 static_assert(IDLE < CREATING_STREAM, "invalid enum value assignment 1"); 70 static_assert(IDLE < CREATING_STREAM, "invalid enum value assignment 1");
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { 290 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() {
290 shared_memory_.Map(memory_length_); 291 shared_memory_.Map(memory_length_);
291 292
292 // Create vector of audio buses by wrapping existing blocks of memory. 293 // Create vector of audio buses by wrapping existing blocks of memory.
293 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); 294 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory());
294 for (int i = 0; i < total_segments_; ++i) { 295 for (int i = 0; i < total_segments_; ++i) {
295 media::AudioInputBuffer* buffer = 296 media::AudioInputBuffer* buffer =
296 reinterpret_cast<media::AudioInputBuffer*>(ptr); 297 reinterpret_cast<media::AudioInputBuffer*>(ptr);
297 scoped_ptr<media::AudioBus> audio_bus = 298 scoped_ptr<media::AudioBus> audio_bus =
298 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); 299 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio);
299 audio_buses_.push_back(audio_bus.Pass()); 300 audio_buses_.push_back(std::move(audio_bus));
300 ptr += segment_length_; 301 ptr += segment_length_;
301 } 302 }
302 } 303 }
303 304
304 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { 305 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
305 // The shared memory represents parameters, size of the data buffer and the 306 // The shared memory represents parameters, size of the data buffer and the
306 // actual data buffer containing audio data. Map the memory into this 307 // actual data buffer containing audio data. Map the memory into this
307 // structure and parse out parameters and the data area. 308 // structure and parse out parameters and the data area.
308 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); 309 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory());
309 ptr += current_segment_id_ * segment_length_; 310 ptr += current_segment_id_ * segment_length_;
(...skipping 30 matching lines...) Expand all
340 audio_bus, 341 audio_bus,
341 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 342 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
342 buffer->params.volume, 343 buffer->params.volume,
343 buffer->params.key_pressed); 344 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
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_output_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698