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

Side by Side Diff: media/audio/audio_system.h

Issue 2763383002: Switching AudioInputDeviceManager from using AudioManager interface to AudioSystem one. (Closed)
Patch Set: review comments addressed 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_AUDIO_SYSTEM_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_SYSTEM_H_
6 #define MEDIA_AUDIO_AUDIO_SYSTEM_H_ 6 #define MEDIA_AUDIO_AUDIO_SYSTEM_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "media/audio/audio_device_description.h" 9 #include "media/audio/audio_device_description.h"
10 #include "media/base/audio_parameters.h" 10 #include "media/base/audio_parameters.h"
11 #include "media/base/media_export.h" 11 #include "media/base/media_export.h"
12 12
13 namespace base { 13 namespace base {
14 class SingleThreadTaskRunner; 14 class SingleThreadTaskRunner;
15 } 15 }
16 16
17 namespace media { 17 namespace media {
18 class AudioManager; 18 class AudioManager;
19 19
20 // Work in progress: Provides asynchronous interface to AudioManager. All the 20 // Work in progress: Provides asynchronous interface to AudioManager. All the
21 // AudioManager clients will be switched to it, in preparation for moving 21 // AudioManager clients will be switched to it, in preparation for moving
22 // to Mojo audio service. 22 // to Mojo audio service.
23 class MEDIA_EXPORT AudioSystem { 23 class MEDIA_EXPORT AudioSystem {
24 public: 24 public:
25 // Replies are asynchronously sent from audio system thread to the thread the 25 // Replies are asynchronously sent from audio system thread to the thread the
26 // call is issued on. Attention! Since audio system thread may outlive all the 26 // call is issued on. Attention! Audio system thread may outlive the client
27 // others, callbacks must always be bound to weak pointers! 27 // objects; bind callbacks with care.
28 using OnAudioParamsCallback = base::Callback<void(const AudioParameters&)>; 28 using OnAudioParamsCallback = base::Callback<void(const AudioParameters&)>;
29 using OnBoolCallback = base::Callback<void(bool)>; 29 using OnBoolCallback = base::Callback<void(bool)>;
30 using OnDeviceDescriptionsCallback = 30 using OnDeviceDescriptionsCallback =
31 base::Callback<void(AudioDeviceDescriptions)>; 31 base::Callback<void(AudioDeviceDescriptions)>;
32 using OnDeviceIdCallback = base::Callback<void(const std::string&)>;
33 using OnInputDeviceInfoCallback = base::Callback<
34 void(const AudioParameters&, const AudioParameters&, const std::string&)>;
32 35
36 // Must not be called on audio system thread if it differs from the one
DaleCurtis 2017/04/06 18:37:17 I'd prefer not to land this without resolving this
o1ka 2017/04/07 12:22:17 It's just a comment describing the current situati
37 // AudioSystem is destroyed on.
33 static AudioSystem* Get(); 38 static AudioSystem* Get();
34 39
35 virtual ~AudioSystem(); 40 virtual ~AudioSystem();
36 41
37 // Callback may receive invalid parameters, it means the specified device is 42 // Callback may receive invalid parameters, it means the specified device is
38 // not found. This is best-effort: valid parameters do not guarantee existance 43 // not found. This is best-effort: valid parameters do not guarantee existance
39 // of the device. 44 // of the device.
40 // TODO(olka,tommi): fix all AudioManager implementations to return invalid 45 // TODO(olka,tommi): fix all AudioManager implementations to return invalid
41 // parameters if the device is not found. 46 // parameters if the device is not found.
42 virtual void GetInputStreamParameters( 47 virtual void GetInputStreamParameters(
43 const std::string& device_id, 48 const std::string& device_id,
44 OnAudioParamsCallback on_params_cb) const = 0; 49 OnAudioParamsCallback on_params_cb) const = 0;
45 50
46 // If media::AudioDeviceDescription::IsDefaultDevice(device_id) is true, 51 // If media::AudioDeviceDescription::IsDefaultDevice(device_id) is true,
47 // callback will receive the parameters of the default output device. 52 // callback will receive the parameters of the default output device.
48 // Callback may receive invalid parameters, it means the specified device is 53 // Callback may receive invalid parameters, it means the specified device is
49 // not found. This is best-effort: valid parameters do not guarantee existance 54 // not found. This is best-effort: valid parameters do not guarantee existance
50 // of the device. 55 // of the device.
51 // TODO(olka,tommi): fix all AudioManager implementations to return invalid 56 // TODO(olka,tommi): fix all AudioManager implementations to return invalid
52 // parameters if the device is not found. 57 // parameters if the device is not found.
53 virtual void GetOutputStreamParameters( 58 virtual void GetOutputStreamParameters(
54 const std::string& device_id, 59 const std::string& device_id,
55 OnAudioParamsCallback on_params_cb) const = 0; 60 OnAudioParamsCallback on_params_cb) const = 0;
56 61
57 virtual void HasInputDevices(OnBoolCallback on_has_devices_cb) const = 0; 62 virtual void HasInputDevices(OnBoolCallback on_has_devices_cb) const = 0;
58 63
59 // Replies with device descriptions of input audio devices if |for_input| is 64 // Replies with device descriptions of input audio devices if |for_input| is
60 // true, and of output audio devices otherwise. 65 // true, and of output audio devices otherwise.
61 virtual void GetDeviceDescriptions( 66 virtual void GetDeviceDescriptions(
62 OnDeviceDescriptionsCallback on_descriptions_cp, 67 OnDeviceDescriptionsCallback on_descriptions_cb,
63 bool for_input) = 0; 68 bool for_input) = 0;
64 69
70 // Replies with an empty string if there is no associated output device found.
71 virtual void GetAssociatedOutputDeviceID(
72 const std::string& input_device_id,
73 OnDeviceIdCallback on_device_id_cb) = 0;
74
75 // Replies with audio parameters for the specified input device and audio
76 // parameters and device ID of the associated output device, if any (otherwise
77 // it's AudioParameters() and an empty string).
78 virtual void GetInputDeviceInfo(
79 const std::string& input_device_id,
80 OnInputDeviceInfoCallback on_input_device_info_cb) = 0;
81
65 virtual base::SingleThreadTaskRunner* GetTaskRunner() const = 0; 82 virtual base::SingleThreadTaskRunner* GetTaskRunner() const = 0;
66 83
67 // Must not be used for anything but stream creation.
68 virtual AudioManager* GetAudioManager() const = 0;
69
70 protected: 84 protected:
71 // Sets the global AudioSystem pointer to the specified non-null value. 85 // Sets the global AudioSystem pointer to the specified non-null value.
72 static void SetInstance(AudioSystem* audio_system); 86 static void SetInstance(AudioSystem* audio_system);
73 87
74 // Sets the global AudioSystem pointer to null if it equals the specified one. 88 // Sets the global AudioSystem pointer to null if it equals the specified one.
75 static void ClearInstance(const AudioSystem* audio_system); 89 static void ClearInstance(const AudioSystem* audio_system);
76 }; 90 };
77 91
78 } // namespace media 92 } // namespace media
79 93
80 #endif // MEDIA_AUDIO_AUDIO_SYSTEM_H_ 94 #endif // MEDIA_AUDIO_AUDIO_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698