| OLD | NEW |
| 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 CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/sync_socket.h" | 11 #include "base/sync_socket.h" |
| 12 #include "content/public/renderer/plugin_instance_throttler.h" |
| 12 #include "content/renderer/pepper/audio_helper.h" | 13 #include "content/renderer/pepper/audio_helper.h" |
| 13 #include "ppapi/c/pp_completion_callback.h" | 14 #include "ppapi/c/pp_completion_callback.h" |
| 14 #include "ppapi/c/ppb_audio.h" | 15 #include "ppapi/c/ppb_audio.h" |
| 15 #include "ppapi/c/ppb_audio_config.h" | 16 #include "ppapi/c/ppb_audio_config.h" |
| 16 #include "ppapi/shared_impl/ppb_audio_config_shared.h" | 17 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
| 17 #include "ppapi/shared_impl/ppb_audio_shared.h" | 18 #include "ppapi/shared_impl/ppb_audio_shared.h" |
| 18 #include "ppapi/shared_impl/resource.h" | 19 #include "ppapi/shared_impl/resource.h" |
| 19 #include "ppapi/shared_impl/scoped_pp_resource.h" | 20 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class PepperPlatformAudioOutput; | 23 class PepperPlatformAudioOutput; |
| 23 | 24 |
| 24 // Some of the backend functionality of this class is implemented by the | 25 // Some of the backend functionality of this class is implemented by the |
| 25 // PPB_Audio_Shared so it can be shared with the proxy. | 26 // PPB_Audio_Shared so it can be shared with the proxy. |
| 26 // | 27 // |
| 27 // TODO(teravest): PPB_Audio is no longer supported in-process. Clean this up | 28 // TODO(teravest): PPB_Audio is no longer supported in-process. Clean this up |
| 28 // to look more like typical HostResource implementations. | 29 // to look more like typical HostResource implementations. |
| 29 class PPB_Audio_Impl : public ppapi::Resource, | 30 class PPB_Audio_Impl : public ppapi::Resource, |
| 30 public ppapi::PPB_Audio_Shared, | 31 public ppapi::PPB_Audio_Shared, |
| 31 public AudioHelper { | 32 public AudioHelper, |
| 33 public PluginInstanceThrottler::Observer { |
| 32 public: | 34 public: |
| 33 explicit PPB_Audio_Impl(PP_Instance instance); | 35 explicit PPB_Audio_Impl(PP_Instance instance); |
| 34 | 36 |
| 35 // Resource overrides. | 37 // Resource overrides. |
| 36 ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API() override; | 38 ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API() override; |
| 37 | 39 |
| 38 // PPB_Audio_API implementation. | 40 // PPB_Audio_API implementation. |
| 39 PP_Resource GetCurrentConfig() override; | 41 PP_Resource GetCurrentConfig() override; |
| 40 PP_Bool StartPlayback() override; | 42 PP_Bool StartPlayback() override; |
| 41 PP_Bool StopPlayback() override; | 43 PP_Bool StopPlayback() override; |
| 42 int32_t Open(PP_Resource config_id, | 44 int32_t Open(PP_Resource config_id, |
| 43 scoped_refptr<ppapi::TrackedCallback> create_callback) override; | 45 scoped_refptr<ppapi::TrackedCallback> create_callback) override; |
| 44 int32_t GetSyncSocket(int* sync_socket) override; | 46 int32_t GetSyncSocket(int* sync_socket) override; |
| 45 int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) override; | 47 int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) override; |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 ~PPB_Audio_Impl() override; | 50 ~PPB_Audio_Impl() override; |
| 49 | 51 |
| 50 // AudioHelper implementation. | 52 // AudioHelper implementation. |
| 51 void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle, | 53 void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle, |
| 52 size_t shared_memory_size_, | 54 size_t shared_memory_size_, |
| 53 base::SyncSocket::Handle socket) override; | 55 base::SyncSocket::Handle socket) override; |
| 54 | 56 |
| 57 // PluginInstanceThrottler::Observer implementation. |
| 58 void OnThrottleStateChange() override; |
| 59 |
| 60 // Starts the deferred playback and unsubscribes from the throttler. |
| 61 void StartDeferredPlayback(); |
| 62 |
| 55 // AudioConfig used for creating this Audio object. We own a ref. | 63 // AudioConfig used for creating this Audio object. We own a ref. |
| 56 ppapi::ScopedPPResource config_; | 64 ppapi::ScopedPPResource config_; |
| 57 | 65 |
| 58 // PluginDelegate audio object that we delegate audio IPC through. We don't | 66 // PluginDelegate audio object that we delegate audio IPC through. We don't |
| 59 // own this pointer but are responsible for calling Shutdown on it. | 67 // own this pointer but are responsible for calling Shutdown on it. |
| 60 PepperPlatformAudioOutput* audio_; | 68 PepperPlatformAudioOutput* audio_; |
| 61 | 69 |
| 70 // Stream is playing, but throttled due to Plugin Power Saver. |
| 71 bool playback_throttled_; |
| 72 |
| 62 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl); | 73 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl); |
| 63 }; | 74 }; |
| 64 | 75 |
| 65 } // namespace content | 76 } // namespace content |
| 66 | 77 |
| 67 #endif // CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ | 78 #endif // CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ |
| OLD | NEW |