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

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: addressed comments 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
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
90 void AudioManagerAlsa::ShutdownOnAudioThread() {
91 AudioManagerBase::ShutdownOnAudioThread();
92 wrapper_.reset();
o1ka 2017/05/10 15:57:56 Add a comment why we must do it now?
alokp 2017/05/10 18:04:03 Actually we do not need to explicitly destroy alsa
93 }
94
82 bool AudioManagerAlsa::HasAudioOutputDevices() { 95 bool AudioManagerAlsa::HasAudioOutputDevices() {
83 return HasAnyAlsaAudioDevice(kStreamPlayback); 96 return HasAnyAlsaAudioDevice(kStreamPlayback);
84 } 97 }
85 98
86 bool AudioManagerAlsa::HasAudioInputDevices() { 99 bool AudioManagerAlsa::HasAudioInputDevices() {
87 return HasAnyAlsaAudioDevice(kStreamCapture); 100 return HasAnyAlsaAudioDevice(kStreamCapture);
88 } 101 }
89 102
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() { 103 void AudioManagerAlsa::ShowAudioInputSettings() {
106 ShowLinuxAudioInputSettings(); 104 ShowLinuxAudioInputSettings();
107 } 105 }
108 106
109 void AudioManagerAlsa::GetAudioInputDeviceNames( 107 void AudioManagerAlsa::GetAudioInputDeviceNames(
110 AudioDeviceNames* device_names) { 108 AudioDeviceNames* device_names) {
111 DCHECK(device_names->empty()); 109 DCHECK(device_names->empty());
112 GetAlsaAudioDevices(kStreamCapture, device_names); 110 GetAlsaAudioDevices(kStreamCapture, device_names);
113 } 111 }
114 112
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 365 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
368 switches::kAlsaInputDevice)) { 366 switches::kAlsaInputDevice)) {
369 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 367 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
370 switches::kAlsaInputDevice); 368 switches::kAlsaInputDevice);
371 } 369 }
372 370
373 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); 371 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get());
374 } 372 }
375 373
376 } // namespace media 374 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698