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

Side by Side Diff: media/audio/win/audio_manager_win.h

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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ 5 #ifndef MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
6 #define MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ 6 #define MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "media/audio/audio_manager_base.h" 12 #include "media/audio/audio_manager_base.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 class AudioDeviceListenerWin; 16 class AudioDeviceListenerWin;
17 17
18 // Windows implementation of the AudioManager singleton. This class is internal 18 // Windows implementation of the AudioManager singleton. This class is internal
19 // to the audio output and only internal users can call methods not exposed by 19 // to the audio output and only internal users can call methods not exposed by
20 // the AudioManager class. 20 // the AudioManager class.
21 class MEDIA_EXPORT AudioManagerWin : public AudioManagerBase { 21 class MEDIA_EXPORT AudioManagerWin : public AudioManagerBase {
22 public: 22 public:
23 AudioManagerWin( 23 AudioManagerWin(std::unique_ptr<AudioThread> audio_thread,
24 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 24 AudioLogFactory* audio_log_factory);
25 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 25 ~AudioManagerWin() override;
26 AudioLogFactory* audio_log_factory);
27 26
28 // Implementation of AudioManager. 27 // Implementation of AudioManager.
29 bool HasAudioOutputDevices() override; 28 bool HasAudioOutputDevices() override;
30 bool HasAudioInputDevices() override; 29 bool HasAudioInputDevices() override;
31 base::string16 GetAudioInputDeviceModel() override; 30 base::string16 GetAudioInputDeviceModel() override;
32 void ShowAudioInputSettings() override; 31 void ShowAudioInputSettings() override;
33 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; 32 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override;
34 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; 33 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override;
35 AudioParameters GetInputStreamParameters( 34 AudioParameters GetInputStreamParameters(
36 const std::string& device_id) override; 35 const std::string& device_id) override;
(...skipping 13 matching lines...) Expand all
50 const AudioParameters& params, 49 const AudioParameters& params,
51 const std::string& device_id, 50 const std::string& device_id,
52 const LogCallback& log_callback) override; 51 const LogCallback& log_callback) override;
53 AudioInputStream* MakeLowLatencyInputStream( 52 AudioInputStream* MakeLowLatencyInputStream(
54 const AudioParameters& params, 53 const AudioParameters& params,
55 const std::string& device_id, 54 const std::string& device_id,
56 const LogCallback& log_callback) override; 55 const LogCallback& log_callback) override;
57 std::string GetDefaultOutputDeviceID() override; 56 std::string GetDefaultOutputDeviceID() override;
58 57
59 protected: 58 protected:
60 ~AudioManagerWin() override; 59 void ShutdownOnAudioThread() override;
61
62 AudioParameters GetPreferredOutputStreamParameters( 60 AudioParameters GetPreferredOutputStreamParameters(
63 const std::string& output_device_id, 61 const std::string& output_device_id,
64 const AudioParameters& input_params) override; 62 const AudioParameters& input_params) override;
65 63
66 private: 64 private:
67 // Allow unit test to modify the utilized enumeration API. 65 // Allow unit test to modify the utilized enumeration API.
68 friend class AudioManagerTest; 66 friend class AudioManagerTest;
69 67
70 // Helper methods for performing expensive initialization tasks on the audio 68 // Helper methods for performing expensive initialization tasks on the audio
71 // thread instead of on the UI thread which AudioManager is constructed on. 69 // thread instead of on the UI thread which AudioManager is constructed on.
72 void InitializeOnAudioThread(); 70 void InitializeOnAudioThread();
73 71
74 void GetAudioDeviceNamesImpl(bool input, AudioDeviceNames* device_names); 72 void GetAudioDeviceNamesImpl(bool input, AudioDeviceNames* device_names);
75 73
76 // Listen for output device changes. 74 // Listen for output device changes.
77 std::unique_ptr<AudioDeviceListenerWin> output_device_listener_; 75 std::unique_ptr<AudioDeviceListenerWin> output_device_listener_;
78 76
79 DISALLOW_COPY_AND_ASSIGN(AudioManagerWin); 77 DISALLOW_COPY_AND_ASSIGN(AudioManagerWin);
80 }; 78 };
81 79
82 } // namespace media 80 } // namespace media
83 81
84 #endif // MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ 82 #endif // MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
OLDNEW
« no previous file with comments | « media/audio/win/audio_low_latency_output_win_unittest.cc ('k') | media/audio/win/audio_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698