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

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

Issue 2784433002: Ensures that audio tasks cannot run after AudioManager is deleted. (Closed)
Patch Set: rebase Created 3 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/alsa/audio_manager_alsa.h ('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"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 command_line.AppendArg("input"); 71 command_line.AppendArg("input");
72 break; 72 break;
73 default: 73 default:
74 LOG(ERROR) << "Failed to show audio input settings: we don't know " 74 LOG(ERROR) << "Failed to show audio input settings: we don't know "
75 << "what command to use for your desktop environment."; 75 << "what command to use for your desktop environment.";
76 return; 76 return;
77 } 77 }
78 base::LaunchProcess(command_line, base::LaunchOptions()); 78 base::LaunchProcess(command_line, base::LaunchOptions());
79 } 79 }
80 80
81 // Implementation of AudioManager. 81 AudioManagerAlsa::AudioManagerAlsa(std::unique_ptr<AudioThread> audio_thread,
82 AudioLogFactory* audio_log_factory)
83 : AudioManagerBase(std::move(audio_thread), audio_log_factory),
84 wrapper_(new AlsaWrapper()) {
85 SetMaxOutputStreamsAllowed(kMaxOutputStreams);
86 }
87
88 AudioManagerAlsa::~AudioManagerAlsa() = default;
89
82 bool AudioManagerAlsa::HasAudioOutputDevices() { 90 bool AudioManagerAlsa::HasAudioOutputDevices() {
83 return HasAnyAlsaAudioDevice(kStreamPlayback); 91 return HasAnyAlsaAudioDevice(kStreamPlayback);
84 } 92 }
85 93
86 bool AudioManagerAlsa::HasAudioInputDevices() { 94 bool AudioManagerAlsa::HasAudioInputDevices() {
87 return HasAnyAlsaAudioDevice(kStreamCapture); 95 return HasAnyAlsaAudioDevice(kStreamCapture);
88 } 96 }
89 97
90 AudioManagerAlsa::AudioManagerAlsa(
91 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
92 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
93 AudioLogFactory* audio_log_factory)
94 : AudioManagerBase(std::move(task_runner),
95 std::move(worker_task_runner),
96 audio_log_factory),
97 wrapper_(new AlsaWrapper()) {
98 SetMaxOutputStreamsAllowed(kMaxOutputStreams);
99 }
100
101 AudioManagerAlsa::~AudioManagerAlsa() {
102 Shutdown();
103 }
104
105 void AudioManagerAlsa::ShowAudioInputSettings() { 98 void AudioManagerAlsa::ShowAudioInputSettings() {
106 ShowLinuxAudioInputSettings(); 99 ShowLinuxAudioInputSettings();
107 } 100 }
108 101
109 void AudioManagerAlsa::GetAudioInputDeviceNames( 102 void AudioManagerAlsa::GetAudioInputDeviceNames(
110 AudioDeviceNames* device_names) { 103 AudioDeviceNames* device_names) {
111 DCHECK(device_names->empty()); 104 DCHECK(device_names->empty());
112 GetAlsaAudioDevices(kStreamCapture, device_names); 105 GetAlsaAudioDevices(kStreamCapture, device_names);
113 } 106 }
114 107
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 360 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
368 switches::kAlsaInputDevice)) { 361 switches::kAlsaInputDevice)) {
369 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 362 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
370 switches::kAlsaInputDevice); 363 switches::kAlsaInputDevice);
371 } 364 }
372 365
373 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); 366 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get());
374 } 367 }
375 368
376 } // namespace media 369 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/alsa/audio_manager_alsa.h ('k') | media/audio/android/audio_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698