diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 19:22:53 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 19:22:53 +0000 |
commit | 55cdf605cda8900f0c6c4d8098fb1ba951767fd2 (patch) | |
tree | 05f1d89fdf3f46d1cfd4350ee169ca9c282ae5e0 /ppapi/shared_impl | |
parent | e1873b977ecb681d9261d9ce9fbe606e036b7d5b (diff) | |
download | chromium_src-55cdf605cda8900f0c6c4d8098fb1ba951767fd2.zip chromium_src-55cdf605cda8900f0c6c4d8098fb1ba951767fd2.tar.gz chromium_src-55cdf605cda8900f0c6c4d8098fb1ba951767fd2.tar.bz2 |
Convert audio-related messages to the new thunk/API system for Pepper.
This has a bit of a change from the previous couple of resources that were
converted in that the ResourceCreationProxy now calls a static proxy function
for actually doing the work. It became too complicated and required that the
ResourceCreationProxy know a lot about the internals of the objects.
Did a little namespace cleanup. This renames "pp::shared_impl" to just use the
"ppapi" namespace. The "shared_impl" was ugly and didn't help anything. Some
files in that directory used "ppapi::shared_impl" instead which was even more
confusing.
Do a little build cleanup. The old ppapi_shared_proxy.gypi is now split into
two sub-files, one for ppapi_shared, and one for ppapi_proxy. It's hopefully
easier to find stuff now.
Review URL: http://codereview.chromium.org/7014024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85303 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r-- | ppapi/shared_impl/audio_config_impl.cc | 44 | ||||
-rw-r--r-- | ppapi/shared_impl/audio_config_impl.h | 38 | ||||
-rw-r--r-- | ppapi/shared_impl/audio_impl.cc | 10 | ||||
-rw-r--r-- | ppapi/shared_impl/audio_impl.h | 15 | ||||
-rw-r--r-- | ppapi/shared_impl/char_set_impl.cc | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/char_set_impl.h | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/crypto_impl.cc | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/crypto_impl.h | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/font_impl.cc | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/font_impl.h | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/function_group_base.h | 5 | ||||
-rw-r--r-- | ppapi/shared_impl/image_data_impl.cc | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/image_data_impl.h | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/resource_object_base.h | 21 | ||||
-rw-r--r-- | ppapi/shared_impl/tracker_base.cc | 2 | ||||
-rw-r--r-- | ppapi/shared_impl/tracker_base.h | 2 | ||||
-rw-r--r-- | ppapi/shared_impl/url_util_impl.cc | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/url_util_impl.h | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/webkit_forwarding.cc | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/webkit_forwarding.h | 6 |
20 files changed, 141 insertions, 68 deletions
diff --git a/ppapi/shared_impl/audio_config_impl.cc b/ppapi/shared_impl/audio_config_impl.cc new file mode 100644 index 0000000..da4d8c5 --- /dev/null +++ b/ppapi/shared_impl/audio_config_impl.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/shared_impl/audio_config_impl.h" + +namespace ppapi { + +AudioConfigImpl::AudioConfigImpl() + : sample_rate_(PP_AUDIOSAMPLERATE_NONE), + sample_frame_count_(0) { +} + +AudioConfigImpl::~AudioConfigImpl() { +} + +bool AudioConfigImpl::Init(PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count) { + // TODO(brettw): Currently we don't actually check what the hardware + // supports, so just allow sample rates of the "guaranteed working" ones. + if (sample_rate != PP_AUDIOSAMPLERATE_44100 && + sample_rate != PP_AUDIOSAMPLERATE_48000) + return false; + + // TODO(brettw): Currently we don't actually query to get a value from the + // hardware, so just validate the range. + if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT || + sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) + return false; + + sample_rate_ = sample_rate; + sample_frame_count_ = sample_frame_count; + return true; +} + +PP_AudioSampleRate AudioConfigImpl::GetSampleRate() { + return sample_rate_; +} + +uint32_t AudioConfigImpl::GetSampleFrameCount() { + return sample_frame_count_; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/audio_config_impl.h b/ppapi/shared_impl/audio_config_impl.h new file mode 100644 index 0000000..230856f --- /dev/null +++ b/ppapi/shared_impl/audio_config_impl.h @@ -0,0 +1,38 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_SHARED_IMPL_AUDIO_CONFIG_IMPL_H_ +#define PPAPI_SHARED_IMPL_AUDIO_CONFIG_IMPL_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/shared_impl/resource_object_base.h" +#include "ppapi/thunk/ppb_audio_config_api.h" + +namespace ppapi { + +class AudioConfigImpl : public thunk::PPB_AudioConfig_API { + public: + // You must call Init before using this object. + AudioConfigImpl(); + virtual ~AudioConfigImpl(); + + // Returns false if the arguments are invalid, the object should not be + // used in this case. + bool Init(PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); + + // PPB_AudioConfig_API implementation. + virtual PP_AudioSampleRate GetSampleRate() OVERRIDE; + virtual uint32_t GetSampleFrameCount() OVERRIDE; + + private: + PP_AudioSampleRate sample_rate_; + uint32_t sample_frame_count_; + + DISALLOW_COPY_AND_ASSIGN(AudioConfigImpl); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_AUDIO_CONFIG_IMPL_H_ diff --git a/ppapi/shared_impl/audio_impl.cc b/ppapi/shared_impl/audio_impl.cc index 30e1bab..0173d6e 100644 --- a/ppapi/shared_impl/audio_impl.cc +++ b/ppapi/shared_impl/audio_impl.cc @@ -6,8 +6,7 @@ #include "base/logging.h" -namespace pp { -namespace shared_impl { +namespace ppapi { AudioImpl::AudioImpl() : playing_(false), @@ -26,6 +25,10 @@ AudioImpl::~AudioImpl() { } } +::ppapi::thunk::PPB_Audio_API* AudioImpl::AsAudio_API() { + return this; +} + void AudioImpl::SetCallback(PPB_Audio_Callback callback, void* user_data) { callback_ = callback; user_data_ = user_data; @@ -93,5 +96,4 @@ void AudioImpl::Run() { } } -} // namespace shared_impl -} // namespace pp +} // namespace ppapi diff --git a/ppapi/shared_impl/audio_impl.h b/ppapi/shared_impl/audio_impl.h index cec4a07..ba7c780 100644 --- a/ppapi/shared_impl/audio_impl.h +++ b/ppapi/shared_impl/audio_impl.h @@ -10,18 +10,24 @@ #include "base/sync_socket.h" #include "base/threading/simple_thread.h" #include "ppapi/c/ppb_audio.h" +#include "ppapi/shared_impl/resource_object_base.h" +#include "ppapi/thunk/ppb_audio_api.h" -namespace pp { -namespace shared_impl { +namespace ppapi { // Implements the logic to map shared memory and run the audio thread signaled // from the sync socket. Both the proxy and the renderer implementation use // this code. -class AudioImpl : public base::DelegateSimpleThread::Delegate { +class AudioImpl : public ResourceObjectBase, + public thunk::PPB_Audio_API, + public base::DelegateSimpleThread::Delegate { public: AudioImpl(); virtual ~AudioImpl(); + // ResourceObjectBase implementation. + virtual ::ppapi::thunk::PPB_Audio_API* AsAudio_API() OVERRIDE; + bool playing() const { return playing_; } // Sets the callback information that the background thread will use. This @@ -79,7 +85,6 @@ class AudioImpl : public base::DelegateSimpleThread::Delegate { void* user_data_; }; -} // namespace shared_impl -} // namespace pp +} // namespace ppapi #endif // PPAPI_SHARED_IMPL_AUDIO_IMPL_H_ diff --git a/ppapi/shared_impl/char_set_impl.cc b/ppapi/shared_impl/char_set_impl.cc index 012f9d6..cad3142 100644 --- a/ppapi/shared_impl/char_set_impl.cc +++ b/ppapi/shared_impl/char_set_impl.cc @@ -11,8 +11,7 @@ #include "unicode/ucnv_err.h" #include "unicode/ustring.h" -namespace pp { -namespace shared_impl { +namespace ppapi { namespace { @@ -149,5 +148,4 @@ uint16_t* CharSetImpl::CharSetToUTF16(const PPB_Core* core, return ret_buf; } -} // namespace shared_impl -} // namespace pp +} // namespace ppapi diff --git a/ppapi/shared_impl/char_set_impl.h b/ppapi/shared_impl/char_set_impl.h index 985a5d6..41411a4 100644 --- a/ppapi/shared_impl/char_set_impl.h +++ b/ppapi/shared_impl/char_set_impl.h @@ -10,8 +10,7 @@ struct PPB_Core; -namespace pp { -namespace shared_impl { +namespace ppapi { // Contains the implementation of character set conversion that is shared // between the proxy and the renderer. @@ -32,7 +31,6 @@ class CharSetImpl { uint32_t* output_length); }; -} // namespace shared_impl -} // namespace pp +} // namespace ppapi #endif // PPAPI_SHARED_IMPL_CHAR_SET_IMPL_H_ diff --git a/ppapi/shared_impl/crypto_impl.cc b/ppapi/shared_impl/crypto_impl.cc index f8e4aa2..814e629 100644 --- a/ppapi/shared_impl/crypto_impl.cc +++ b/ppapi/shared_impl/crypto_impl.cc @@ -6,13 +6,11 @@ #include "base/rand_util.h" -namespace pp { -namespace shared_impl { +namespace ppapi { // static void CryptoImpl::GetRandomBytes(char* buffer, uint32_t num_bytes) { base::RandBytes(buffer, num_bytes); } -} // namespace shared_impl -} // namespace pp +} // namespace ppapi diff --git a/ppapi/shared_impl/crypto_impl.h b/ppapi/shared_impl/crypto_impl.h index c3b3cd4..a959bc9 100644 --- a/ppapi/shared_impl/crypto_impl.h +++ b/ppapi/shared_impl/crypto_impl.h @@ -8,15 +8,13 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_stdint.h" -namespace pp { -namespace shared_impl { +namespace ppapi { class CryptoImpl { public: static void GetRandomBytes(char* buffer, uint32_t num_bytes); }; -} // namespace shared_impl -} // namespace pp +} // namespace ppapi #endif // PPAPI_SHARED_IMPL_CRYPTO_IMPL_H_ diff --git a/ppapi/shared_impl/font_impl.cc b/ppapi/shared_impl/font_impl.cc index 3feaf9f..66ac5a6 100644 --- a/ppapi/shared_impl/font_impl.cc +++ b/ppapi/shared_impl/font_impl.cc @@ -6,8 +6,7 @@ #include "ppapi/c/dev/ppb_font_dev.h" -namespace pp { -namespace shared_impl { +namespace ppapi { // static bool FontImpl::IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc) { @@ -32,5 +31,4 @@ bool FontImpl::IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc) { return true; } -} // namespace shared_impl -} // namespace pp +} // namespace ppapi diff --git a/ppapi/shared_impl/font_impl.h b/ppapi/shared_impl/font_impl.h index ebdf38a..9117ffb 100644 --- a/ppapi/shared_impl/font_impl.h +++ b/ppapi/shared_impl/font_impl.h @@ -15,8 +15,7 @@ struct PP_FontDescription_Dev; -namespace pp { -namespace shared_impl { +namespace ppapi { class FontImpl { public: @@ -27,7 +26,6 @@ class FontImpl { DISALLOW_COPY_AND_ASSIGN(FontImpl); }; -} // namespace shared_impl -} // namespace pp +} // namespace ppapi #endif // PPAPI_SHARED_IMPL_FONT_IMPL_H_ diff --git a/ppapi/shared_impl/function_group_base.h b/ppapi/shared_impl/function_group_base.h index 9b3f728..6b8976e 100644 --- a/ppapi/shared_impl/function_group_base.h +++ b/ppapi/shared_impl/function_group_base.h @@ -11,8 +11,6 @@ namespace thunk { class ResourceCreationAPI; } -namespace shared_impl { - class FunctionGroupBase { public: // Dynamic casting for this object. Returns the pointer to the given type if @@ -23,11 +21,10 @@ class FunctionGroupBase { }; template<> -inline thunk::ResourceCreationAPI* FunctionGroupBase::GetAs() { +inline ppapi::thunk::ResourceCreationAPI* FunctionGroupBase::GetAs() { return AsResourceCreation(); } -} // namespace shared_impl } // namespace ppapi #endif // PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_ diff --git a/ppapi/shared_impl/image_data_impl.cc b/ppapi/shared_impl/image_data_impl.cc index 9392927..e07d2cb 100644 --- a/ppapi/shared_impl/image_data_impl.cc +++ b/ppapi/shared_impl/image_data_impl.cc @@ -6,8 +6,7 @@ #include "third_party/skia/include/core/SkTypes.h" -namespace pp { -namespace shared_impl { +namespace ppapi { // static PP_ImageDataFormat ImageDataImpl::GetNativeImageDataFormat() { @@ -25,5 +24,4 @@ bool ImageDataImpl::IsImageDataFormatSupported(PP_ImageDataFormat format) { format == PP_IMAGEDATAFORMAT_RGBA_PREMUL; } -} // namespace shared_impl -} // namespace pp +} // namespace ppapi diff --git a/ppapi/shared_impl/image_data_impl.h b/ppapi/shared_impl/image_data_impl.h index 6b8a7cc..1d2f76f5 100644 --- a/ppapi/shared_impl/image_data_impl.h +++ b/ppapi/shared_impl/image_data_impl.h @@ -8,8 +8,7 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/ppb_image_data.h" -namespace pp { -namespace shared_impl { +namespace ppapi { // Contains the implementation of some simple image data functions that are // shared between the proxy and Chrome's implementation. Since these functions @@ -26,7 +25,6 @@ class ImageDataImpl { static bool IsImageDataFormatSupported(PP_ImageDataFormat format); }; -} // namespace shared_impl -} // namespace pp +} // namespace ppapi #endif // PPAPI_SHARED_IMPL_IMAGE_DATA_IMPL_H_ diff --git a/ppapi/shared_impl/resource_object_base.h b/ppapi/shared_impl/resource_object_base.h index 1a87360..05ed923 100644 --- a/ppapi/shared_impl/resource_object_base.h +++ b/ppapi/shared_impl/resource_object_base.h @@ -8,16 +8,20 @@ namespace ppapi { namespace thunk { +class PPB_Audio_API; +class PPB_AudioConfig_API; +class PPB_AudioTrusted_API; class PPB_Font_API; class PPB_Graphics2D_API; class PPB_ImageData_API; } -namespace shared_impl { - class ResourceObjectBase { public: + virtual thunk::PPB_Audio_API* AsAudio_API() { return NULL; } + virtual thunk::PPB_AudioConfig_API* AsAudioConfig_API() { return NULL; } + virtual thunk::PPB_AudioTrusted_API* AsAudioTrusted_API() { return NULL; } virtual thunk::PPB_Font_API* AsFont_API() { return NULL; } virtual thunk::PPB_Graphics2D_API* AsGraphics2D_API() { return NULL; } virtual thunk::PPB_ImageData_API* AsImageData_API() { return NULL; } @@ -26,6 +30,18 @@ class ResourceObjectBase { }; template<> +inline thunk::PPB_Audio_API* ResourceObjectBase::GetAs() { + return AsAudio_API(); +} +template<> +inline thunk::PPB_AudioConfig_API* ResourceObjectBase::GetAs() { + return AsAudioConfig_API(); +} +template<> +inline thunk::PPB_AudioTrusted_API* ResourceObjectBase::GetAs() { + return AsAudioTrusted_API(); +} +template<> inline thunk::PPB_Font_API* ResourceObjectBase::GetAs() { return AsFont_API(); } @@ -38,7 +54,6 @@ inline thunk::PPB_ImageData_API* ResourceObjectBase::GetAs() { return AsImageData_API(); } -} // namespace shared_impl } // namespace ppapi #endif // PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ diff --git a/ppapi/shared_impl/tracker_base.cc b/ppapi/shared_impl/tracker_base.cc index 79c4b4e..291bc18 100644 --- a/ppapi/shared_impl/tracker_base.cc +++ b/ppapi/shared_impl/tracker_base.cc @@ -7,7 +7,6 @@ #include "base/logging.h" namespace ppapi { -namespace shared_impl { static TrackerBase* (*g_global_getter)() = NULL; @@ -21,5 +20,4 @@ TrackerBase* TrackerBase::Get() { return g_global_getter(); } -} // namespace shared_impl } // namespace ppapi diff --git a/ppapi/shared_impl/tracker_base.h b/ppapi/shared_impl/tracker_base.h index c44ee2b..4b7e447 100644 --- a/ppapi/shared_impl/tracker_base.h +++ b/ppapi/shared_impl/tracker_base.h @@ -10,7 +10,6 @@ #include "ppapi/proxy/interface_id.h" namespace ppapi { -namespace shared_impl { class FunctionGroupBase; class ResourceObjectBase; @@ -43,7 +42,6 @@ class TrackerBase { pp::proxy::InterfaceID id) = 0; }; -} // namespace shared_impl } // namespace ppapi #endif // PPAPI_SHARED_IMPL_TRACKER_BASE_H_ diff --git a/ppapi/shared_impl/url_util_impl.cc b/ppapi/shared_impl/url_util_impl.cc index 32aab48..f45d4fef 100644 --- a/ppapi/shared_impl/url_util_impl.cc +++ b/ppapi/shared_impl/url_util_impl.cc @@ -6,8 +6,7 @@ #include "googleurl/src/gurl.h" -namespace pp { -namespace shared_impl { +namespace ppapi { namespace { @@ -102,5 +101,4 @@ PP_Var URLUtilImpl::GenerateURLReturn(VarFromUtf8 var_from_utf8, static_cast<uint32_t>(url.possibly_invalid_spec().size())); } -} // namespace shared_impl -} // namespace pp +} // namespace ppapi diff --git a/ppapi/shared_impl/url_util_impl.h b/ppapi/shared_impl/url_util_impl.h index 91c7999..008f317 100644 --- a/ppapi/shared_impl/url_util_impl.h +++ b/ppapi/shared_impl/url_util_impl.h @@ -15,8 +15,7 @@ class GURL; -namespace pp { -namespace shared_impl { +namespace ppapi { // Contains the implementation of PPB_URLUtil that is shared between the proxy // and the renderer. @@ -61,7 +60,6 @@ class URLUtilImpl { PP_URLComponents_Dev* components); }; -} // namespace shared_impl -} // namespace pp +} // namespace ppapi #endif diff --git a/ppapi/shared_impl/webkit_forwarding.cc b/ppapi/shared_impl/webkit_forwarding.cc index 02573f8..a99d754 100644 --- a/ppapi/shared_impl/webkit_forwarding.cc +++ b/ppapi/shared_impl/webkit_forwarding.cc @@ -4,8 +4,7 @@ #include "ppapi/shared_impl/webkit_forwarding.h" -namespace pp { -namespace shared_impl { +namespace ppapi { WebKitForwarding::Font::DrawTextParams::DrawTextParams( skia::PlatformCanvas* destination_arg, @@ -31,6 +30,5 @@ WebKitForwarding::Font::~Font() { WebKitForwarding::~WebKitForwarding() { } -} // namespace shared_impl -} // namespace pp +} // namespace ppapi diff --git a/ppapi/shared_impl/webkit_forwarding.h b/ppapi/shared_impl/webkit_forwarding.h index aa788f8..4f45344 100644 --- a/ppapi/shared_impl/webkit_forwarding.h +++ b/ppapi/shared_impl/webkit_forwarding.h @@ -23,8 +23,7 @@ namespace skia { class PlatformCanvas; } -namespace pp { -namespace shared_impl { +namespace ppapi { class WebKitForwarding { public: @@ -98,7 +97,6 @@ class WebKitForwarding { }; -} // namespace shared_impl -} // namespace pp +} // namespace ppapi #endif // PPAPI_SHARED_IMPL_WEBKIT_FORWARDING_H_ |