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

Side by Side 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: d'oh #2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ppapi/cpp/audio_config.h" 5 #include "ppapi/cpp/audio_config.h"
6 6
7 #include "ppapi/cpp/instance_handle.h" 7 #include "ppapi/cpp/instance_handle.h"
8 #include "ppapi/cpp/module.h" 8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/module_impl.h" 9 #include "ppapi/cpp/module_impl.h"
10 10
11 namespace pp { 11 namespace pp {
12 12
13 namespace { 13 namespace {
14 14
15 template <> const char* interface_name<PPB_AudioConfig>() { 15 template <> const char* interface_name<PPB_AudioConfig_1_1>() {
16 return PPB_AUDIO_CONFIG_INTERFACE; 16 return PPB_AUDIO_CONFIG_INTERFACE_1_1;
17 }
18
19 template <> const char* interface_name<PPB_AudioConfig_1_0>() {
20 return PPB_AUDIO_CONFIG_INTERFACE_1_0;
17 } 21 }
18 22
19 } // namespace 23 } // namespace
20 24
21 AudioConfig::AudioConfig() 25 AudioConfig::AudioConfig()
22 : sample_rate_(PP_AUDIOSAMPLERATE_NONE), 26 : sample_rate_(PP_AUDIOSAMPLERATE_NONE),
23 sample_frame_count_(0) { 27 sample_frame_count_(0) {
24 } 28 }
25 29
26 AudioConfig::AudioConfig(const InstanceHandle& instance, 30 AudioConfig::AudioConfig(const InstanceHandle& instance,
27 PP_AudioSampleRate sample_rate, 31 PP_AudioSampleRate sample_rate,
28 uint32_t sample_frame_count) 32 uint32_t sample_frame_count)
29 : sample_rate_(sample_rate), 33 : sample_rate_(sample_rate),
30 sample_frame_count_(sample_frame_count) { 34 sample_frame_count_(sample_frame_count) {
31 if (has_interface<PPB_AudioConfig>()) { 35 if (has_interface<PPB_AudioConfig_1_1>()) {
32 PassRefFromConstructor( 36 PassRefFromConstructor(
33 get_interface<PPB_AudioConfig>()->CreateStereo16Bit( 37 get_interface<PPB_AudioConfig_1_1>()->CreateStereo16Bit(
38 instance.pp_instance(), sample_rate, sample_frame_count));
39 } else if (has_interface<PPB_AudioConfig_1_0>()) {
40 PassRefFromConstructor(
41 get_interface<PPB_AudioConfig_1_0>()->CreateStereo16Bit(
34 instance.pp_instance(), sample_rate, sample_frame_count)); 42 instance.pp_instance(), sample_rate, sample_frame_count));
35 } 43 }
36 } 44 }
37 45
38 // static 46 // static
39 PP_AudioSampleRate AudioConfig::RecommendSampleRate( 47 PP_AudioSampleRate AudioConfig::RecommendSampleRate(
40 const InstanceHandle& instance) { 48 const InstanceHandle& instance) {
41 if (!has_interface<PPB_AudioConfig>()) 49 if (has_interface<PPB_AudioConfig_1_1>()) {
42 return PP_AUDIOSAMPLERATE_NONE; 50 return get_interface<PPB_AudioConfig_1_1>()->
43 return get_interface<PPB_AudioConfig>()-> 51 RecommendSampleRate(instance.pp_instance());
44 RecommendSampleRate(instance.pp_instance()); 52 }
53 return PP_AUDIOSAMPLERATE_NONE;
45 } 54 }
46 55
47 // static 56 // static
48 uint32_t AudioConfig::RecommendSampleFrameCount( 57 uint32_t AudioConfig::RecommendSampleFrameCount(
49 const InstanceHandle& instance, 58 const InstanceHandle& instance,
50 PP_AudioSampleRate sample_rate, 59 PP_AudioSampleRate sample_rate,
51 uint32_t requested_sample_frame_count) { 60 uint32_t requested_sample_frame_count) {
52 if (!has_interface<PPB_AudioConfig>()) 61 if (has_interface<PPB_AudioConfig_1_1>()) {
53 return 0; 62 return get_interface<PPB_AudioConfig_1_1>()->
54 return get_interface<PPB_AudioConfig>()-> 63 RecommendSampleFrameCount(instance.pp_instance(),
55 RecommendSampleFrameCount(instance.pp_instance(), 64 sample_rate,
56 sample_rate, 65 requested_sample_frame_count);
57 requested_sample_frame_count); 66 }
67 if (has_interface<PPB_AudioConfig_1_0>()) {
68 return get_interface<PPB_AudioConfig_1_0>()->
69 RecommendSampleFrameCount(sample_rate,
70 requested_sample_frame_count);
71 }
72 return 0;
58 } 73 }
59 74
60 } // namespace pp 75 } // namespace pp
61
OLDNEW
« 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