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

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: fixes content_browsertests and content_unittests Created 3 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 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.
82 bool AudioManagerAlsa::HasAudioOutputDevices() {
83 return HasAnyAlsaAudioDevice(kStreamPlayback);
84 }
85
86 bool AudioManagerAlsa::HasAudioInputDevices() {
87 return HasAnyAlsaAudioDevice(kStreamCapture);
88 }
89
90 AudioManagerAlsa::AudioManagerAlsa( 81 AudioManagerAlsa::AudioManagerAlsa(
91 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 82 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
92 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 83 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
93 AudioLogFactory* audio_log_factory) 84 AudioLogFactory* audio_log_factory)
94 : AudioManagerBase(std::move(task_runner), 85 : AudioManagerBase(std::move(task_runner),
95 std::move(worker_task_runner), 86 std::move(worker_task_runner),
96 audio_log_factory), 87 audio_log_factory),
97 wrapper_(new AlsaWrapper()) { 88 wrapper_(new AlsaWrapper()) {
98 SetMaxOutputStreamsAllowed(kMaxOutputStreams); 89 SetMaxOutputStreamsAllowed(kMaxOutputStreams);
99 } 90 }
100 91
101 AudioManagerAlsa::~AudioManagerAlsa() { 92 AudioManagerAlsa::~AudioManagerAlsa() = default;
102 Shutdown(); 93
94 void AudioManagerAlsa::Shutdown() {
95 AudioManagerBase::Shutdown();
96 wrapper_.reset();
97 }
98
99 bool AudioManagerAlsa::HasAudioOutputDevices() {
100 return HasAnyAlsaAudioDevice(kStreamPlayback);
101 }
102
103 bool AudioManagerAlsa::HasAudioInputDevices() {
104 return HasAnyAlsaAudioDevice(kStreamCapture);
103 } 105 }
104 106
105 void AudioManagerAlsa::ShowAudioInputSettings() { 107 void AudioManagerAlsa::ShowAudioInputSettings() {
106 ShowLinuxAudioInputSettings(); 108 ShowLinuxAudioInputSettings();
107 } 109 }
108 110
109 void AudioManagerAlsa::GetAudioInputDeviceNames( 111 void AudioManagerAlsa::GetAudioInputDeviceNames(
110 AudioDeviceNames* device_names) { 112 AudioDeviceNames* device_names) {
111 DCHECK(device_names->empty()); 113 DCHECK(device_names->empty());
112 GetAlsaAudioDevices(kStreamCapture, device_names); 114 GetAlsaAudioDevices(kStreamCapture, device_names);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 369 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
368 switches::kAlsaInputDevice)) { 370 switches::kAlsaInputDevice)) {
369 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 371 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
370 switches::kAlsaInputDevice); 372 switches::kAlsaInputDevice);
371 } 373 }
372 374
373 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); 375 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get());
374 } 376 }
375 377
376 } // namespace media 378 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698