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

Side by Side Diff: media/audio/alsa/audio_manager_alsa.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/alsa/audio_manager_alsa.h" 5 #include "media/audio/alsa/audio_manager_alsa.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 static const char* kInvalidAudioInputDevices[] = { 46 static const char* kInvalidAudioInputDevices[] = {
47 "default", 47 "default",
48 "dmix", 48 "dmix",
49 "null", 49 "null",
50 "pulse", 50 "pulse",
51 "surround", 51 "surround",
52 }; 52 };
53 53
54 // static 54 // static
55 void AudioManagerAlsa::ShowLinuxAudioInputSettings() { 55 void AudioManagerAlsa::ShowLinuxAudioInputSettings() {
56 scoped_ptr<base::Environment> env(base::Environment::Create()); 56 std::unique_ptr<base::Environment> env(base::Environment::Create());
danakj 2016/04/22 22:47:35 include memory
dcheng 2016/04/22 23:13:19 Already included in corresponding .h.
57 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 57 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
58 switch (base::nix::GetDesktopEnvironment(env.get())) { 58 switch (base::nix::GetDesktopEnvironment(env.get())) {
59 case base::nix::DESKTOP_ENVIRONMENT_GNOME: 59 case base::nix::DESKTOP_ENVIRONMENT_GNOME:
60 command_line.SetProgram(base::FilePath("gnome-volume-control")); 60 command_line.SetProgram(base::FilePath("gnome-volume-control"));
61 break; 61 break;
62 case base::nix::DESKTOP_ENVIRONMENT_KDE3: 62 case base::nix::DESKTOP_ENVIRONMENT_KDE3:
63 case base::nix::DESKTOP_ENVIRONMENT_KDE4: 63 case base::nix::DESKTOP_ENVIRONMENT_KDE4:
64 case base::nix::DESKTOP_ENVIRONMENT_KDE5: 64 case base::nix::DESKTOP_ENVIRONMENT_KDE5:
65 command_line.SetProgram(base::FilePath("kmix")); 65 command_line.SetProgram(base::FilePath("kmix"));
66 break; 66 break;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 media::AudioDeviceNames* device_names) { 155 media::AudioDeviceNames* device_names) {
156 static const char kIoHintName[] = "IOID"; 156 static const char kIoHintName[] = "IOID";
157 static const char kNameHintName[] = "NAME"; 157 static const char kNameHintName[] = "NAME";
158 static const char kDescriptionHintName[] = "DESC"; 158 static const char kDescriptionHintName[] = "DESC";
159 159
160 const char* unwanted_device_type = UnwantedDeviceTypeWhenEnumerating(type); 160 const char* unwanted_device_type = UnwantedDeviceTypeWhenEnumerating(type);
161 161
162 for (void** hint_iter = hints; *hint_iter != NULL; hint_iter++) { 162 for (void** hint_iter = hints; *hint_iter != NULL; hint_iter++) {
163 // Only examine devices of the right type. Valid values are 163 // Only examine devices of the right type. Valid values are
164 // "Input", "Output", and NULL which means both input and output. 164 // "Input", "Output", and NULL which means both input and output.
165 scoped_ptr<char, base::FreeDeleter> io(wrapper_->DeviceNameGetHint( 165 std::unique_ptr<char, base::FreeDeleter> io(
166 *hint_iter, kIoHintName)); 166 wrapper_->DeviceNameGetHint(*hint_iter, kIoHintName));
167 if (io != NULL && strcmp(unwanted_device_type, io.get()) == 0) 167 if (io != NULL && strcmp(unwanted_device_type, io.get()) == 0)
168 continue; 168 continue;
169 169
170 // Found a device, prepend the default device since we always want 170 // Found a device, prepend the default device since we always want
171 // it to be on the top of the list for all platforms. And there is 171 // it to be on the top of the list for all platforms. And there is
172 // no duplicate counting here since it is only done if the list is 172 // no duplicate counting here since it is only done if the list is
173 // still empty. Note, pulse has exclusively opened the default 173 // still empty. Note, pulse has exclusively opened the default
174 // device, so we must open the device via the "default" moniker. 174 // device, so we must open the device via the "default" moniker.
175 if (device_names->empty()) { 175 if (device_names->empty()) {
176 device_names->push_front( 176 device_names->push_front(
177 media::AudioDeviceName(AudioManager::GetDefaultDeviceName(), 177 media::AudioDeviceName(AudioManager::GetDefaultDeviceName(),
178 AudioManagerBase::kDefaultDeviceId)); 178 AudioManagerBase::kDefaultDeviceId));
179 } 179 }
180 180
181 // Get the unique device name for the device. 181 // Get the unique device name for the device.
182 scoped_ptr<char, base::FreeDeleter> unique_device_name( 182 std::unique_ptr<char, base::FreeDeleter> unique_device_name(
183 wrapper_->DeviceNameGetHint(*hint_iter, kNameHintName)); 183 wrapper_->DeviceNameGetHint(*hint_iter, kNameHintName));
184 184
185 // Find out if the device is available. 185 // Find out if the device is available.
186 if (IsAlsaDeviceAvailable(type, unique_device_name.get())) { 186 if (IsAlsaDeviceAvailable(type, unique_device_name.get())) {
187 // Get the description for the device. 187 // Get the description for the device.
188 scoped_ptr<char, base::FreeDeleter> desc(wrapper_->DeviceNameGetHint( 188 std::unique_ptr<char, base::FreeDeleter> desc(
189 *hint_iter, kDescriptionHintName)); 189 wrapper_->DeviceNameGetHint(*hint_iter, kDescriptionHintName));
190 190
191 media::AudioDeviceName name; 191 media::AudioDeviceName name;
192 name.unique_id = unique_device_name.get(); 192 name.unique_id = unique_device_name.get();
193 if (desc) { 193 if (desc) {
194 // Use the more user friendly description as name. 194 // Use the more user friendly description as name.
195 // Replace '\n' with '-'. 195 // Replace '\n' with '-'.
196 char* pret = strchr(desc.get(), '\n'); 196 char* pret = strchr(desc.get(), '\n');
197 if (pret) 197 if (pret)
198 *pret = '-'; 198 *pret = '-';
199 name.device_name = desc.get(); 199 name.device_name = desc.get();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 // Loop through the sound cards. 256 // Loop through the sound cards.
257 // Don't use snd_device_name_hint(-1,..) since there is a access violation 257 // Don't use snd_device_name_hint(-1,..) since there is a access violation
258 // inside this ALSA API with libasound.so.2.0.0. 258 // inside this ALSA API with libasound.so.2.0.0.
259 while (!wrapper_->CardNext(&card) && (card >= 0) && !has_device) { 259 while (!wrapper_->CardNext(&card) && (card >= 0) && !has_device) {
260 int error = wrapper_->DeviceNameHint(card, kPcmInterfaceName, &hints); 260 int error = wrapper_->DeviceNameHint(card, kPcmInterfaceName, &hints);
261 if (!error) { 261 if (!error) {
262 for (void** hint_iter = hints; *hint_iter != NULL; hint_iter++) { 262 for (void** hint_iter = hints; *hint_iter != NULL; hint_iter++) {
263 // Only examine devices that are |stream| capable. Valid values are 263 // Only examine devices that are |stream| capable. Valid values are
264 // "Input", "Output", and NULL which means both input and output. 264 // "Input", "Output", and NULL which means both input and output.
265 scoped_ptr<char, base::FreeDeleter> io(wrapper_->DeviceNameGetHint( 265 std::unique_ptr<char, base::FreeDeleter> io(
266 *hint_iter, kIoHintName)); 266 wrapper_->DeviceNameGetHint(*hint_iter, kIoHintName));
267 const char* unwanted_type = UnwantedDeviceTypeWhenEnumerating(stream); 267 const char* unwanted_type = UnwantedDeviceTypeWhenEnumerating(stream);
268 if (io != NULL && strcmp(unwanted_type, io.get()) == 0) 268 if (io != NULL && strcmp(unwanted_type, io.get()) == 0)
269 continue; // Wrong type, skip the device. 269 continue; // Wrong type, skip the device.
270 270
271 // Found an input device. 271 // Found an input device.
272 has_device = true; 272 has_device = true;
273 break; 273 break;
274 } 274 }
275 275
276 // Destroy the hints now that we're done with it. 276 // Destroy the hints now that we're done with it.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 359 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
360 switches::kAlsaInputDevice)) { 360 switches::kAlsaInputDevice)) {
361 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 361 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
362 switches::kAlsaInputDevice); 362 switches::kAlsaInputDevice);
363 } 363 }
364 364
365 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); 365 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get());
366 } 366 }
367 367
368 } // namespace media 368 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698