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

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

Issue 2763383002: Switching AudioInputDeviceManager from using AudioManager interface to AudioSystem one. (Closed)
Patch Set: rebase 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
« no previous file with comments | « media/audio/audio_manager.cc ('k') | media/audio/audio_system_impl.h » ('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 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
37 // AudioSystem is destroyed on. See http://crbug.com/705455.
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(
(...skipping 11 matching lines...) Expand all
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 virtual void HasOutputDevices(OnBoolCallback on_has_devices_cb) const = 0; 64 virtual void HasOutputDevices(OnBoolCallback on_has_devices_cb) const = 0;
60 65
61 // Replies with device descriptions of input audio devices if |for_input| is 66 // Replies with device descriptions of input audio devices if |for_input| is
62 // true, and of output audio devices otherwise. 67 // true, and of output audio devices otherwise.
63 virtual void GetDeviceDescriptions( 68 virtual void GetDeviceDescriptions(
64 OnDeviceDescriptionsCallback on_descriptions_cp, 69 OnDeviceDescriptionsCallback on_descriptions_cb,
65 bool for_input) = 0; 70 bool for_input) = 0;
66 71
72 // Replies with an empty string if there is no associated output device found.
73 virtual void GetAssociatedOutputDeviceID(
74 const std::string& input_device_id,
75 OnDeviceIdCallback on_device_id_cb) = 0;
76
77 // Replies with audio parameters for the specified input device and audio
78 // parameters and device ID of the associated output device, if any (otherwise
79 // it's AudioParameters() and an empty string).
80 virtual void GetInputDeviceInfo(
81 const std::string& input_device_id,
82 OnInputDeviceInfoCallback on_input_device_info_cb) = 0;
83
67 virtual base::SingleThreadTaskRunner* GetTaskRunner() const = 0; 84 virtual base::SingleThreadTaskRunner* GetTaskRunner() const = 0;
68 85
69 // Must not be used for anything but stream creation.
70 virtual AudioManager* GetAudioManager() const = 0;
71
72 protected: 86 protected:
73 // Sets the global AudioSystem pointer to the specified non-null value. 87 // Sets the global AudioSystem pointer to the specified non-null value.
74 static void SetInstance(AudioSystem* audio_system); 88 static void SetInstance(AudioSystem* audio_system);
75 89
76 // Sets the global AudioSystem pointer to null if it equals the specified one. 90 // Sets the global AudioSystem pointer to null if it equals the specified one.
77 static void ClearInstance(const AudioSystem* audio_system); 91 static void ClearInstance(const AudioSystem* audio_system);
78 }; 92 };
79 93
80 } // namespace media 94 } // namespace media
81 95
82 #endif // MEDIA_AUDIO_AUDIO_SYSTEM_H_ 96 #endif // MEDIA_AUDIO_AUDIO_SYSTEM_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager.cc ('k') | media/audio/audio_system_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698