Chromium Code Reviews| 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 |
| - |