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

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

Issue 1911913002: Convert //media/audio from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cast + windows build Created 4 years, 8 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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 private: 46 private:
47 int current_segment_id_; 47 int current_segment_id_;
48 uint32_t last_buffer_id_; 48 uint32_t last_buffer_id_;
49 ScopedVector<media::AudioBus> audio_buses_; 49 ScopedVector<media::AudioBus> audio_buses_;
50 CaptureCallback* capture_callback_; 50 CaptureCallback* capture_callback_;
51 51
52 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); 52 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
53 }; 53 };
54 54
55 AudioInputDevice::AudioInputDevice( 55 AudioInputDevice::AudioInputDevice(
56 scoped_ptr<AudioInputIPC> ipc, 56 std::unique_ptr<AudioInputIPC> ipc,
57 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 57 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
58 : ScopedTaskRunnerObserver(io_task_runner), 58 : ScopedTaskRunnerObserver(io_task_runner),
59 callback_(NULL), 59 callback_(NULL),
60 ipc_(std::move(ipc)), 60 ipc_(std::move(ipc)),
61 state_(IDLE), 61 state_(IDLE),
62 session_id_(0), 62 session_id_(0),
63 agc_is_enabled_(false), 63 agc_is_enabled_(false),
64 stopping_hack_(false) { 64 stopping_hack_(false) {
65 CHECK(ipc_); 65 CHECK(ipc_);
66 66
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 288 }
289 289
290 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { 290 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() {
291 shared_memory_.Map(memory_length_); 291 shared_memory_.Map(memory_length_);
292 292
293 // Create vector of audio buses by wrapping existing blocks of memory. 293 // Create vector of audio buses by wrapping existing blocks of memory.
294 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); 294 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory());
295 for (int i = 0; i < total_segments_; ++i) { 295 for (int i = 0; i < total_segments_; ++i) {
296 media::AudioInputBuffer* buffer = 296 media::AudioInputBuffer* buffer =
297 reinterpret_cast<media::AudioInputBuffer*>(ptr); 297 reinterpret_cast<media::AudioInputBuffer*>(ptr);
298 scoped_ptr<media::AudioBus> audio_bus = 298 std::unique_ptr<media::AudioBus> audio_bus =
danakj 2016/04/22 22:47:35 include memory
dcheng 2016/04/22 23:13:19 Already included in related header.
299 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); 299 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio);
300 audio_buses_.push_back(std::move(audio_bus)); 300 audio_buses_.push_back(std::move(audio_bus));
301 ptr += segment_length_; 301 ptr += segment_length_;
302 } 302 }
303 } 303 }
304 304
305 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { 305 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
306 // 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
307 // actual data buffer containing audio data. Map the memory into this 307 // actual data buffer containing audio data. Map the memory into this
308 // structure and parse out parameters and the data area. 308 // structure and parse out parameters and the data area.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 capture_callback_->Capture( 340 capture_callback_->Capture(
341 audio_bus, 341 audio_bus,
342 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 342 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
343 buffer->params.volume, buffer->params.key_pressed); 343 buffer->params.volume, buffer->params.key_pressed);
344 344
345 if (++current_segment_id_ >= total_segments_) 345 if (++current_segment_id_ >= total_segments_)
346 current_segment_id_ = 0; 346 current_segment_id_ = 0;
347 } 347 }
348 348
349 } // namespace media 349 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698