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

Side by Side Diff: remoting/host/audio_capturer_win.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: include <utility> 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 | « remoting/host/audio_capturer_linux.cc ('k') | remoting/host/audio_pump.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 "remoting/host/audio_capturer_win.h" 5 #include "remoting/host/audio_capturer_win.h"
6 6
7 #include <windows.h>
8 #include <avrt.h> 7 #include <avrt.h>
9 #include <mmreg.h> 8 #include <mmreg.h>
10 #include <mmsystem.h> 9 #include <mmsystem.h>
11
12 #include <stdint.h> 10 #include <stdint.h>
13 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <windows.h>
13
14 #include <algorithm> 14 #include <algorithm>
15 #include <utility>
15 16
16 #include "base/logging.h" 17 #include "base/logging.h"
17 18
18 namespace { 19 namespace {
19 const int kChannels = 2; 20 const int kChannels = 2;
20 const int kBytesPerSample = 2; 21 const int kBytesPerSample = 2;
21 const int kBitsPerSample = kBytesPerSample * 8; 22 const int kBitsPerSample = kBytesPerSample * 8;
22 // Conversion factor from 100ns to 1ms. 23 // Conversion factor from 100ns to 1ms.
23 const int k100nsPerMillisecond = 10000; 24 const int k100nsPerMillisecond = 10000;
24 25
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if ((flags & AUDCLNT_BUFFERFLAGS_SILENT) == 0 && 230 if ((flags & AUDCLNT_BUFFERFLAGS_SILENT) == 0 &&
230 !silence_detector_.IsSilence(reinterpret_cast<const int16_t*>(data), 231 !silence_detector_.IsSilence(reinterpret_cast<const int16_t*>(data),
231 frames * kChannels)) { 232 frames * kChannels)) {
232 scoped_ptr<AudioPacket> packet(new AudioPacket()); 233 scoped_ptr<AudioPacket> packet(new AudioPacket());
233 packet->add_data(data, frames * wave_format_ex_->nBlockAlign); 234 packet->add_data(data, frames * wave_format_ex_->nBlockAlign);
234 packet->set_encoding(AudioPacket::ENCODING_RAW); 235 packet->set_encoding(AudioPacket::ENCODING_RAW);
235 packet->set_sampling_rate(sampling_rate_); 236 packet->set_sampling_rate(sampling_rate_);
236 packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2); 237 packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2);
237 packet->set_channels(AudioPacket::CHANNELS_STEREO); 238 packet->set_channels(AudioPacket::CHANNELS_STEREO);
238 239
239 callback_.Run(packet.Pass()); 240 callback_.Run(std::move(packet));
240 } 241 }
241 242
242 hr = audio_capture_client_->ReleaseBuffer(frames); 243 hr = audio_capture_client_->ReleaseBuffer(frames);
243 if (FAILED(hr)) 244 if (FAILED(hr))
244 break; 245 break;
245 } 246 }
246 247
247 // There is nothing to capture if the audio endpoint device has been unplugged 248 // There is nothing to capture if the audio endpoint device has been unplugged
248 // or disabled. 249 // or disabled.
249 if (hr == AUDCLNT_E_DEVICE_INVALIDATED) 250 if (hr == AUDCLNT_E_DEVICE_INVALIDATED)
250 return; 251 return;
251 252
252 // Avoid reporting the same error multiple times. 253 // Avoid reporting the same error multiple times.
253 if (FAILED(hr) && hr != last_capture_error_) { 254 if (FAILED(hr) && hr != last_capture_error_) {
254 last_capture_error_ = hr; 255 last_capture_error_ = hr;
255 LOG(ERROR) << "Failed to capture an audio packet: 0x" 256 LOG(ERROR) << "Failed to capture an audio packet: 0x"
256 << std::hex << hr << std::dec << "."; 257 << std::hex << hr << std::dec << ".";
257 } 258 }
258 } 259 }
259 260
260 bool AudioCapturer::IsSupported() { 261 bool AudioCapturer::IsSupported() {
261 return true; 262 return true;
262 } 263 }
263 264
264 scoped_ptr<AudioCapturer> AudioCapturer::Create() { 265 scoped_ptr<AudioCapturer> AudioCapturer::Create() {
265 return make_scoped_ptr(new AudioCapturerWin()); 266 return make_scoped_ptr(new AudioCapturerWin());
266 } 267 }
267 268
268 } // namespace remoting 269 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/audio_capturer_linux.cc ('k') | remoting/host/audio_pump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698