OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dev/audio_config_dev.h" | 5 #include "ppapi/cpp/dev/audio_config_dev.h" |
6 | 6 |
| 7 #include "ppapi/cpp/instance.h" |
7 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
8 #include "ppapi/cpp/module_impl.h" | 9 #include "ppapi/cpp/module_impl.h" |
9 | 10 |
10 namespace pp { | 11 namespace pp { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 template <> const char* interface_name<PPB_AudioConfig_Dev>() { | 15 template <> const char* interface_name<PPB_AudioConfig_Dev>() { |
15 return PPB_AUDIO_CONFIG_DEV_INTERFACE; | 16 return PPB_AUDIO_CONFIG_DEV_INTERFACE; |
16 } | 17 } |
17 | 18 |
18 } // namespace | 19 } // namespace |
19 | 20 |
20 AudioConfig_Dev::AudioConfig_Dev() | 21 AudioConfig_Dev::AudioConfig_Dev() |
21 : sample_rate_(PP_AUDIOSAMPLERATE_NONE), | 22 : sample_rate_(PP_AUDIOSAMPLERATE_NONE), |
22 sample_frame_count_(0) { | 23 sample_frame_count_(0) { |
23 } | 24 } |
24 | 25 |
25 AudioConfig_Dev::AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate, | 26 AudioConfig_Dev::AudioConfig_Dev(Instance* instance, |
| 27 PP_AudioSampleRate_Dev sample_rate, |
26 uint32_t sample_frame_count) | 28 uint32_t sample_frame_count) |
27 : sample_rate_(sample_rate), | 29 : sample_rate_(sample_rate), |
28 sample_frame_count_(sample_frame_count) { | 30 sample_frame_count_(sample_frame_count) { |
29 if (has_interface<PPB_AudioConfig_Dev>()) { | 31 if (has_interface<PPB_AudioConfig_Dev>()) { |
30 PassRefFromConstructor( | 32 PassRefFromConstructor( |
31 get_interface<PPB_AudioConfig_Dev>()->CreateStereo16Bit( | 33 get_interface<PPB_AudioConfig_Dev>()->CreateStereo16Bit( |
32 Module::Get()->pp_module(), sample_rate, sample_frame_count)); | 34 instance->pp_instance(), sample_rate, sample_frame_count)); |
33 } | 35 } |
34 } | 36 } |
35 | 37 |
36 // static | 38 // static |
37 uint32_t AudioConfig_Dev::RecommendSampleFrameCount( | 39 uint32_t AudioConfig_Dev::RecommendSampleFrameCount( |
38 uint32_t requested_sample_frame_count) { | 40 uint32_t requested_sample_frame_count) { |
39 if (!has_interface<PPB_AudioConfig_Dev>()) | 41 if (!has_interface<PPB_AudioConfig_Dev>()) |
40 return 0; | 42 return 0; |
41 return get_interface<PPB_AudioConfig_Dev>()-> | 43 return get_interface<PPB_AudioConfig_Dev>()-> |
42 RecommendSampleFrameCount(requested_sample_frame_count); | 44 RecommendSampleFrameCount(requested_sample_frame_count); |
43 } | 45 } |
44 | 46 |
45 } // namespace pp | 47 } // namespace pp |
46 | 48 |
OLD | NEW |