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

Side by Side Diff: media/audio/alsa/audio_manager_alsa.cc

Issue 1892433002: Moving device description utils from AudioManager[Base] into AudioDeviceDescription; to be shared b… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 4 years, 7 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/BUILD.gn ('k') | media/audio/android/audio_android_unittest.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 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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/free_deleter.h" 14 #include "base/memory/free_deleter.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/nix/xdg_util.h" 16 #include "base/nix/xdg_util.h"
17 #include "base/process/launch.h" 17 #include "base/process/launch.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "media/audio/audio_device_description.h"
19 #include "media/audio/audio_output_dispatcher.h" 20 #include "media/audio/audio_output_dispatcher.h"
20 #if defined(USE_CRAS) 21 #if defined(USE_CRAS)
21 #include "media/audio/cras/audio_manager_cras.h" 22 #include "media/audio/cras/audio_manager_cras.h"
22 #endif 23 #endif
23 #include "media/audio/alsa/alsa_input.h" 24 #include "media/audio/alsa/alsa_input.h"
24 #include "media/audio/alsa/alsa_output.h" 25 #include "media/audio/alsa/alsa_output.h"
25 #include "media/audio/alsa/alsa_wrapper.h" 26 #include "media/audio/alsa/alsa_wrapper.h"
26 #if defined(USE_PULSEAUDIO) 27 #if defined(USE_PULSEAUDIO)
27 #include "media/audio/pulse/audio_manager_pulse.h" 28 #include "media/audio/pulse/audio_manager_pulse.h"
28 #endif 29 #endif
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 std::unique_ptr<char, base::FreeDeleter> io( 166 std::unique_ptr<char, base::FreeDeleter> io(
166 wrapper_->DeviceNameGetHint(*hint_iter, kIoHintName)); 167 wrapper_->DeviceNameGetHint(*hint_iter, kIoHintName));
167 if (io != NULL && strcmp(unwanted_device_type, io.get()) == 0) 168 if (io != NULL && strcmp(unwanted_device_type, io.get()) == 0)
168 continue; 169 continue;
169 170
170 // Found a device, prepend the default device since we always want 171 // 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 172 // 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 173 // no duplicate counting here since it is only done if the list is
173 // still empty. Note, pulse has exclusively opened the default 174 // still empty. Note, pulse has exclusively opened the default
174 // device, so we must open the device via the "default" moniker. 175 // device, so we must open the device via the "default" moniker.
175 if (device_names->empty()) { 176 if (device_names->empty())
176 device_names->push_front( 177 device_names->push_front(media::AudioDeviceName::CreateDefault());
177 media::AudioDeviceName(AudioManager::GetDefaultDeviceName(),
178 AudioManagerBase::kDefaultDeviceId));
179 }
180 178
181 // Get the unique device name for the device. 179 // Get the unique device name for the device.
182 std::unique_ptr<char, base::FreeDeleter> unique_device_name( 180 std::unique_ptr<char, base::FreeDeleter> unique_device_name(
183 wrapper_->DeviceNameGetHint(*hint_iter, kNameHintName)); 181 wrapper_->DeviceNameGetHint(*hint_iter, kNameHintName));
184 182
185 // Find out if the device is available. 183 // Find out if the device is available.
186 if (IsAlsaDeviceAvailable(type, unique_device_name.get())) { 184 if (IsAlsaDeviceAvailable(type, unique_device_name.get())) {
187 // Get the description for the device. 185 // Get the description for the device.
188 std::unique_ptr<char, base::FreeDeleter> desc( 186 std::unique_ptr<char, base::FreeDeleter> desc(
189 wrapper_->DeviceNameGetHint(*hint_iter, kDescriptionHintName)); 187 wrapper_->DeviceNameGetHint(*hint_iter, kDescriptionHintName));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 345 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
348 switches::kAlsaOutputDevice)) { 346 switches::kAlsaOutputDevice)) {
349 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 347 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
350 switches::kAlsaOutputDevice); 348 switches::kAlsaOutputDevice);
351 } 349 }
352 return new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this); 350 return new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this);
353 } 351 }
354 352
355 AudioInputStream* AudioManagerAlsa::MakeInputStream( 353 AudioInputStream* AudioManagerAlsa::MakeInputStream(
356 const AudioParameters& params, const std::string& device_id) { 354 const AudioParameters& params, const std::string& device_id) {
357 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? 355 std::string device_name =
358 AlsaPcmInputStream::kAutoSelectDevice : device_id; 356 (device_id == AudioDeviceDescription::kDefaultDeviceId)
357 ? AlsaPcmInputStream::kAutoSelectDevice
358 : device_id;
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
« no previous file with comments | « media/audio/BUILD.gn ('k') | media/audio/android/audio_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698