OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_CONTROLLER_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_CONTROLLER_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_CONTROLLER_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_CONTROLLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
| 14 class PepperAudioOutputHost; |
14 class PepperPluginInstanceImpl; | 15 class PepperPluginInstanceImpl; |
15 class PPB_Audio_Impl; | 16 class PPB_Audio_Impl; |
16 | 17 |
17 /** | 18 /** |
18 * This class controls all the active audio instances of a Pepper instance. | 19 * This class controls all the active audio instances of a Pepper instance. |
19 * This class can only be a non-shareable member of PepperPluginInstanceImpl. | 20 * This class can only be a non-shareable member of PepperPluginInstanceImpl. |
20 */ | 21 */ |
21 class PepperAudioController { | 22 class PepperAudioController { |
22 public: | 23 public: |
23 explicit PepperAudioController(PepperPluginInstanceImpl* instance); | 24 explicit PepperAudioController(PepperPluginInstanceImpl* instance); |
24 virtual ~PepperAudioController(); | 25 virtual ~PepperAudioController(); |
25 | 26 |
26 // Adds an audio instance to the controller. | 27 // Adds an audio instance to the controller. |
27 void AddInstance(PPB_Audio_Impl* audio); | 28 void AddInstance(PPB_Audio_Impl* audio); |
| 29 void AddInstance(PepperAudioOutputHost* audio_output); |
28 | 30 |
29 // Removes an audio instance from the controller. | 31 // Removes an audio instance from the controller. |
30 void RemoveInstance(PPB_Audio_Impl* audio); | 32 void RemoveInstance(PPB_Audio_Impl* audio); |
| 33 void RemoveInstance(PepperAudioOutputHost* audio_output); |
31 | 34 |
32 // Sets the volume of all audio instances. | 35 // Sets the volume of all audio instances. |
33 void SetVolume(double volume); | 36 void SetVolume(double volume); |
34 | 37 |
35 // The pepper instance has been deleted. This method can only be called | 38 // The pepper instance has been deleted. This method can only be called |
36 // once. The controller will be invalidated after this call, and then all | 39 // once. The controller will be invalidated after this call, and then all |
37 // other methods will be no-op. | 40 // other methods will be no-op. |
38 void OnPepperInstanceDeleted(); | 41 void OnPepperInstanceDeleted(); |
39 | 42 |
40 private: | 43 private: |
41 // Notifies the RenderFrame that the playback has stopped. This method should | 44 // Notifies the RenderFrame that the playback has stopped. This method should |
42 // only be called when |ppb_audios_| turns from non-empty to empty. | 45 // only be called when |ppb_audios_| turns from non-empty to empty. |
43 void NotifyPlaybackStopsOnEmpty(); | 46 void NotifyPlaybackStopsOnEmpty(); |
44 | 47 |
45 // All active audio instances. | 48 // Helper functions to deal with the first and last audio instance. |
| 49 void StartPlaybackIfFirstInstance(); |
| 50 void StopPlaybackIfLastInstance(); |
| 51 |
| 52 // All active audio instances that are using the old |
| 53 // PPB_Audio interface. |
46 std::set<PPB_Audio_Impl*> ppb_audios_; | 54 std::set<PPB_Audio_Impl*> ppb_audios_; |
47 | 55 |
| 56 // All active audio output instances that are using the new |
| 57 // PPB_AudioOutput interface. |
| 58 std::set<PepperAudioOutputHost*> audio_output_hosts_; |
| 59 |
48 // The Pepper instance which this controller is for. Will be null after | 60 // The Pepper instance which this controller is for. Will be null after |
49 // OnPepperInstanceDeleted() is called. | 61 // OnPepperInstanceDeleted() is called. |
50 PepperPluginInstanceImpl* instance_; | 62 PepperPluginInstanceImpl* instance_; |
51 | 63 |
52 DISALLOW_COPY_AND_ASSIGN(PepperAudioController); | 64 DISALLOW_COPY_AND_ASSIGN(PepperAudioController); |
53 }; | 65 }; |
54 | 66 |
55 } // namespace content | 67 } // namespace content |
56 | 68 |
57 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_CONTROLLER_H_ | 69 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_CONTROLLER_H_ |
OLD | NEW |