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

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

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU 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
« no previous file with comments | « remoting/host/audio_capturer.h ('k') | remoting/host/audio_capturer_mac.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_linux.h" 5 #include "remoting/host/audio_capturer_linux.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h"
13 #include "remoting/proto/audio.pb.h" 15 #include "remoting/proto/audio.pb.h"
14 16
15 namespace remoting { 17 namespace remoting {
16 18
17 namespace { 19 namespace {
18 20
19 base::LazyInstance<scoped_refptr<AudioPipeReader> >::Leaky 21 base::LazyInstance<scoped_refptr<AudioPipeReader> >::Leaky
20 g_pulseaudio_pipe_sink_reader = LAZY_INSTANCE_INITIALIZER; 22 g_pulseaudio_pipe_sink_reader = LAZY_INSTANCE_INITIALIZER;
21 23
22 } // namespace 24 } // namespace
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 void AudioCapturerLinux::OnDataRead( 56 void AudioCapturerLinux::OnDataRead(
55 scoped_refptr<base::RefCountedString> data) { 57 scoped_refptr<base::RefCountedString> data) {
56 DCHECK(!callback_.is_null()); 58 DCHECK(!callback_.is_null());
57 59
58 if (silence_detector_.IsSilence( 60 if (silence_detector_.IsSilence(
59 reinterpret_cast<const int16_t*>(data->data().data()), 61 reinterpret_cast<const int16_t*>(data->data().data()),
60 data->data().size() / sizeof(int16_t))) { 62 data->data().size() / sizeof(int16_t))) {
61 return; 63 return;
62 } 64 }
63 65
64 scoped_ptr<AudioPacket> packet(new AudioPacket()); 66 std::unique_ptr<AudioPacket> packet(new AudioPacket());
65 packet->add_data(data->data()); 67 packet->add_data(data->data());
66 packet->set_encoding(AudioPacket::ENCODING_RAW); 68 packet->set_encoding(AudioPacket::ENCODING_RAW);
67 packet->set_sampling_rate(AudioPipeReader::kSamplingRate); 69 packet->set_sampling_rate(AudioPipeReader::kSamplingRate);
68 packet->set_bytes_per_sample(AudioPipeReader::kBytesPerSample); 70 packet->set_bytes_per_sample(AudioPipeReader::kBytesPerSample);
69 packet->set_channels(AudioPipeReader::kChannels); 71 packet->set_channels(AudioPipeReader::kChannels);
70 callback_.Run(std::move(packet)); 72 callback_.Run(std::move(packet));
71 } 73 }
72 74
73 bool AudioCapturer::IsSupported() { 75 bool AudioCapturer::IsSupported() {
74 return g_pulseaudio_pipe_sink_reader.Get().get() != nullptr; 76 return g_pulseaudio_pipe_sink_reader.Get().get() != nullptr;
75 } 77 }
76 78
77 scoped_ptr<AudioCapturer> AudioCapturer::Create() { 79 std::unique_ptr<AudioCapturer> AudioCapturer::Create() {
78 scoped_refptr<AudioPipeReader> reader = 80 scoped_refptr<AudioPipeReader> reader =
79 g_pulseaudio_pipe_sink_reader.Get(); 81 g_pulseaudio_pipe_sink_reader.Get();
80 if (!reader.get()) 82 if (!reader.get())
81 return nullptr; 83 return nullptr;
82 return make_scoped_ptr(new AudioCapturerLinux(reader)); 84 return base::WrapUnique(new AudioCapturerLinux(reader));
83 } 85 }
84 86
85 } // namespace remoting 87 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/audio_capturer.h ('k') | remoting/host/audio_capturer_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698