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 #include "ppapi/cpp/audio_config.h" | 5 #include "ppapi/cpp/audio_config.h" |
6 | 6 |
7 #include "ppapi/cpp/instance.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>() { |
16 return PPB_AUDIO_CONFIG_INTERFACE; | 16 return PPB_AUDIO_CONFIG_INTERFACE; |
17 } | 17 } |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 AudioConfig::AudioConfig() | 21 AudioConfig::AudioConfig() |
22 : sample_rate_(PP_AUDIOSAMPLERATE_NONE), | 22 : sample_rate_(PP_AUDIOSAMPLERATE_NONE), |
23 sample_frame_count_(0) { | 23 sample_frame_count_(0) { |
24 } | 24 } |
25 | 25 |
26 AudioConfig::AudioConfig(Instance* instance, | 26 AudioConfig::AudioConfig(const InstanceHandle& instance, |
27 PP_AudioSampleRate sample_rate, | 27 PP_AudioSampleRate sample_rate, |
28 uint32_t sample_frame_count) | 28 uint32_t sample_frame_count) |
29 : sample_rate_(sample_rate), | 29 : sample_rate_(sample_rate), |
30 sample_frame_count_(sample_frame_count) { | 30 sample_frame_count_(sample_frame_count) { |
31 if (has_interface<PPB_AudioConfig>()) { | 31 if (has_interface<PPB_AudioConfig>()) { |
32 PassRefFromConstructor( | 32 PassRefFromConstructor( |
33 get_interface<PPB_AudioConfig>()->CreateStereo16Bit( | 33 get_interface<PPB_AudioConfig>()->CreateStereo16Bit( |
34 instance->pp_instance(), sample_rate, sample_frame_count)); | 34 instance.pp_instance(), sample_rate, sample_frame_count)); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 // static | 38 // static |
39 PP_AudioSampleRate AudioConfig::RecommendSampleRate(Instance* instance) { | 39 PP_AudioSampleRate AudioConfig::RecommendSampleRate( |
| 40 const InstanceHandle& instance) { |
40 if (!has_interface<PPB_AudioConfig>()) | 41 if (!has_interface<PPB_AudioConfig>()) |
41 return PP_AUDIOSAMPLERATE_NONE; | 42 return PP_AUDIOSAMPLERATE_NONE; |
42 return get_interface<PPB_AudioConfig>()-> | 43 return get_interface<PPB_AudioConfig>()-> |
43 RecommendSampleRate(instance->pp_instance()); | 44 RecommendSampleRate(instance.pp_instance()); |
44 } | 45 } |
45 | 46 |
46 // static | 47 // static |
47 uint32_t AudioConfig::RecommendSampleFrameCount( | 48 uint32_t AudioConfig::RecommendSampleFrameCount( |
48 Instance* instance, | 49 const InstanceHandle& instance, |
49 PP_AudioSampleRate sample_rate, | 50 PP_AudioSampleRate sample_rate, |
50 uint32_t requested_sample_frame_count) { | 51 uint32_t requested_sample_frame_count) { |
51 if (!has_interface<PPB_AudioConfig>()) | 52 if (!has_interface<PPB_AudioConfig>()) |
52 return 0; | 53 return 0; |
53 return get_interface<PPB_AudioConfig>()-> | 54 return get_interface<PPB_AudioConfig>()-> |
54 RecommendSampleFrameCount(instance->pp_instance(), | 55 RecommendSampleFrameCount(instance.pp_instance(), |
55 sample_rate, | 56 sample_rate, |
56 requested_sample_frame_count); | 57 requested_sample_frame_count); |
57 } | 58 } |
58 | 59 |
59 } // namespace pp | 60 } // namespace pp |
60 | 61 |
OLD | NEW |