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

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

Issue 2697033006: Switching MediaStreamManager from using AudioManager to AudioSystem (Closed)
Patch Set: weak pointers removed Created 3 years, 9 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/base/audio_parameters.h" 9 #include "media/base/audio_parameters.h"
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
11 11
12 namespace base {
13 class SingleThreadTaskRunner;
14 }
15
12 namespace media { 16 namespace media {
13 class AudioManager; 17 class AudioManager;
14 18
15 // Work in progress: Provides asynchronous interface to AudioManager. All the 19 // Work in progress: Provides asynchronous interface to AudioManager. All the
16 // AudioManager clients will be switched to it, in preparation for moving 20 // AudioManager clients will be switched to it, in preparation for moving
17 // to Mojo audio service. 21 // to Mojo audio service.
18 class MEDIA_EXPORT AudioSystem { 22 class MEDIA_EXPORT AudioSystem {
19 public: 23 public:
20 // Replies are asynchronously sent to the thread the call is issued on. 24 // Replies are asynchronously sent from audio system thread to the thread the
25 // call is issued on. Attention! Since audio system thread may outlive all the
26 // others, callbacks must always be bound to weak pointers!
21 using OnAudioParamsCallback = base::Callback<void(const AudioParameters&)>; 27 using OnAudioParamsCallback = base::Callback<void(const AudioParameters&)>;
22 using OnBoolCallback = base::Callback<void(bool)>; 28 using OnBoolCallback = base::Callback<void(bool)>;
23 29
24 static AudioSystem* Get(); 30 static AudioSystem* Get();
25 31
26 virtual ~AudioSystem(); 32 virtual ~AudioSystem();
27 33
28 // Callback may receive invalid parameters, it means the specified device is 34 // Callback may receive invalid parameters, it means the specified device is
29 // not found. This is best-effort: valid parameters do not guarantee existance 35 // not found. This is best-effort: valid parameters do not guarantee existance
30 // of the device. 36 // of the device.
31 // TODO(olka,tommi): fix all AudioManager implementations to return invalid 37 // TODO(olka,tommi): fix all AudioManager implementations to return invalid
32 // parameters if the device is not found. 38 // parameters if the device is not found.
33 virtual void GetInputStreamParameters( 39 virtual void GetInputStreamParameters(
34 const std::string& device_id, 40 const std::string& device_id,
35 OnAudioParamsCallback on_params_cb) const = 0; 41 OnAudioParamsCallback on_params_cb) const = 0;
36 42
37 // If media::AudioDeviceDescription::IsDefaultDevice(device_id) is true, 43 // If media::AudioDeviceDescription::IsDefaultDevice(device_id) is true,
38 // callback will receive the parameters of the default output device. 44 // callback will receive the parameters of the default output device.
39 // Callback may receive invalid parameters, it means the specified device is 45 // Callback may receive invalid parameters, it means the specified device is
40 // not found. This is best-effort: valid parameters do not guarantee existance 46 // not found. This is best-effort: valid parameters do not guarantee existance
41 // of the device. 47 // of the device.
42 // TODO(olka,tommi): fix all AudioManager implementations to return invalid 48 // TODO(olka,tommi): fix all AudioManager implementations to return invalid
43 // parameters if the device is not found. 49 // parameters if the device is not found.
44 virtual void GetOutputStreamParameters( 50 virtual void GetOutputStreamParameters(
45 const std::string& device_id, 51 const std::string& device_id,
46 OnAudioParamsCallback on_params_cb) const = 0; 52 OnAudioParamsCallback on_params_cb) const = 0;
47 53
48 virtual void HasInputDevices(OnBoolCallback on_has_devices_cb) const = 0; 54 virtual void HasInputDevices(OnBoolCallback on_has_devices_cb) const = 0;
49 55
56 virtual base::SingleThreadTaskRunner* GetTaskRunner() const = 0;
57
50 // Must not be used for anything but stream creation. 58 // Must not be used for anything but stream creation.
51 virtual AudioManager* GetAudioManager() const = 0; 59 virtual AudioManager* GetAudioManager() const = 0;
52 60
53 protected: 61 protected:
54 // Sets the global AudioSystem pointer to the specified non-null value. 62 // Sets the global AudioSystem pointer to the specified non-null value.
55 static void SetInstance(AudioSystem* audio_system); 63 static void SetInstance(AudioSystem* audio_system);
56 64
57 // Sets the global AudioSystem pointer to null if it equals the specified one. 65 // Sets the global AudioSystem pointer to null if it equals the specified one.
58 static void ClearInstance(const AudioSystem* audio_system); 66 static void ClearInstance(const AudioSystem* audio_system);
59 }; 67 };
60 68
61 } // namespace media 69 } // namespace media
62 70
63 #endif // MEDIA_AUDIO_AUDIO_SYSTEM_H_ 71 #endif // MEDIA_AUDIO_AUDIO_SYSTEM_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_unittest.cc ('k') | media/audio/audio_system_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698