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

Unified Diff: ppapi/cpp/audio_config.cc

Issue 9617018: Pepper: Make C++ wrappers for PPB_AudioConfig backwards compatible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/audio_config.cc
diff --git a/ppapi/cpp/audio_config.cc b/ppapi/cpp/audio_config.cc
index ef03922c05c8123580a58a3e89780b18a4a561df..19649d4f9b498194cf100ebc845d13092a511b3d 100644
--- a/ppapi/cpp/audio_config.cc
+++ b/ppapi/cpp/audio_config.cc
@@ -12,8 +12,12 @@ namespace pp {
namespace {
-template <> const char* interface_name<PPB_AudioConfig>() {
- return PPB_AUDIO_CONFIG_INTERFACE;
+template <> const char* interface_name<PPB_AudioConfig_1_1>() {
+ return PPB_AUDIO_CONFIG_INTERFACE_1_1;
+}
+
+template <> const char* interface_name<PPB_AudioConfig_1_0>() {
+ return PPB_AUDIO_CONFIG_INTERFACE_1_0;
}
} // namespace
@@ -28,9 +32,14 @@ AudioConfig::AudioConfig(const InstanceHandle& instance,
uint32_t sample_frame_count)
: sample_rate_(sample_rate),
sample_frame_count_(sample_frame_count) {
- if (has_interface<PPB_AudioConfig>()) {
+ if (has_interface<PPB_AudioConfig_1_1>()) {
+ PassRefFromConstructor(
+ get_interface<PPB_AudioConfig_1_1>()->CreateStereo16Bit(
+ instance.pp_instance(), sample_rate, sample_frame_count));
+ }
+ if (has_interface<PPB_AudioConfig_1_0>()) {
yzshen1 2012/03/06 20:54:34 You need an 'else' here. haha.
viettrungluu 2012/03/06 22:17:21 Done, thanks. I'm apparently incapable of making t
PassRefFromConstructor(
- get_interface<PPB_AudioConfig>()->CreateStereo16Bit(
+ get_interface<PPB_AudioConfig_1_0>()->CreateStereo16Bit(
instance.pp_instance(), sample_rate, sample_frame_count));
}
}
@@ -38,10 +47,13 @@ AudioConfig::AudioConfig(const InstanceHandle& instance,
// static
PP_AudioSampleRate AudioConfig::RecommendSampleRate(
const InstanceHandle& instance) {
- if (!has_interface<PPB_AudioConfig>())
- return PP_AUDIOSAMPLERATE_NONE;
- return get_interface<PPB_AudioConfig>()->
- RecommendSampleRate(instance.pp_instance());
+ if (has_interface<PPB_AudioConfig_1_1>()) {
+ return get_interface<PPB_AudioConfig_1_1>()->
+ RecommendSampleRate(instance.pp_instance());
+ }
+ if (has_interface<PPB_AudioConfig_1_0>())
+ return get_interface<PPB_AudioConfig_1_0>()->RecommendSampleRate();
+ return PP_AUDIOSAMPLERATE_NONE;
}
// static
@@ -49,13 +61,19 @@ uint32_t AudioConfig::RecommendSampleFrameCount(
const InstanceHandle& instance,
PP_AudioSampleRate sample_rate,
uint32_t requested_sample_frame_count) {
- if (!has_interface<PPB_AudioConfig>())
- return 0;
- return get_interface<PPB_AudioConfig>()->
- RecommendSampleFrameCount(instance.pp_instance(),
- sample_rate,
- requested_sample_frame_count);
+ if (has_interface<PPB_AudioConfig_1_1>()) {
+ return get_interface<PPB_AudioConfig_1_1>()->
+ RecommendSampleFrameCount(instance.pp_instance(),
+ sample_rate,
+ requested_sample_frame_count);
+ }
+ if (has_interface<PPB_AudioConfig_1_0>()) {
+ return get_interface<PPB_AudioConfig_1_0>()->
+ RecommendSampleFrameCount(instance.pp_instance(),
+ sample_rate,
+ requested_sample_frame_count);
+ }
+ return 0;
}
} // namespace pp
-
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698