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 #ifndef PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ |
6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ | 6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ppapi/shared_impl/resource.h" | 10 #include "ppapi/shared_impl/resource.h" |
11 #include "ppapi/thunk/ppb_audio_config_api.h" | 11 #include "ppapi/thunk/ppb_audio_config_api.h" |
12 | 12 |
13 namespace ppapi { | 13 namespace ppapi { |
14 | 14 |
15 const int kBitsPerAudioInputSample = 16; | 15 const int kBitsPerAudioInputSample = 16; |
16 const int kAudioInputChannels = 1; | 16 const int kAudioInputChannels = 1; |
17 | 17 |
18 // TODO(dalecurtis, yzshen): PPAPI shouldn't hard code these values for all | 18 // TODO(dalecurtis, yzshen): PPAPI shouldn't hard code these values for all |
19 // clients. | 19 // clients. |
20 const int kBitsPerAudioOutputSample = 16; | 20 const int kBitsPerAudioOutputSample = 16; |
21 const int kAudioOutputChannels = 2; | 21 const int kAudioOutputChannels = 2; |
22 | 22 |
23 class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared | 23 class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared |
24 : public Resource, | 24 : public Resource, |
25 public thunk::PPB_AudioConfig_API { | 25 public thunk::PPB_AudioConfig_API { |
26 public: | 26 public: |
27 virtual ~PPB_AudioConfig_Shared(); | 27 ~PPB_AudioConfig_Shared() override; |
28 | 28 |
29 static PP_Resource Create(ResourceObjectType type, | 29 static PP_Resource Create(ResourceObjectType type, |
30 PP_Instance instance, | 30 PP_Instance instance, |
31 PP_AudioSampleRate sample_rate, | 31 PP_AudioSampleRate sample_rate, |
32 uint32_t sample_frame_count); | 32 uint32_t sample_frame_count); |
33 static uint32_t RecommendSampleFrameCount_1_0( | 33 static uint32_t RecommendSampleFrameCount_1_0( |
34 PP_AudioSampleRate sample_rate, | 34 PP_AudioSampleRate sample_rate, |
35 uint32_t request_sample_frame_count); | 35 uint32_t request_sample_frame_count); |
36 static uint32_t RecommendSampleFrameCount_1_1( | 36 static uint32_t RecommendSampleFrameCount_1_1( |
37 PP_Instance instance, | 37 PP_Instance instance, |
38 PP_AudioSampleRate sample_rate, | 38 PP_AudioSampleRate sample_rate, |
39 uint32_t request_sample_frame_count); | 39 uint32_t request_sample_frame_count); |
40 static PP_AudioSampleRate RecommendSampleRate(PP_Instance); | 40 static PP_AudioSampleRate RecommendSampleRate(PP_Instance); |
41 | 41 |
42 // Resource overrides. | 42 // Resource overrides. |
43 virtual thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() override; | 43 thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() override; |
44 | 44 |
45 // PPB_AudioConfig_API implementation. | 45 // PPB_AudioConfig_API implementation. |
46 virtual PP_AudioSampleRate GetSampleRate() override; | 46 PP_AudioSampleRate GetSampleRate() override; |
47 virtual uint32_t GetSampleFrameCount() override; | 47 uint32_t GetSampleFrameCount() override; |
48 | 48 |
49 private: | 49 private: |
50 // You must call Init before using this object. | 50 // You must call Init before using this object. |
51 PPB_AudioConfig_Shared(ResourceObjectType type, PP_Instance instance); | 51 PPB_AudioConfig_Shared(ResourceObjectType type, PP_Instance instance); |
52 | 52 |
53 // Returns false if the arguments are invalid, the object should not be | 53 // Returns false if the arguments are invalid, the object should not be |
54 // used in this case. | 54 // used in this case. |
55 bool Init(PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); | 55 bool Init(PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); |
56 | 56 |
57 PP_AudioSampleRate sample_rate_; | 57 PP_AudioSampleRate sample_rate_; |
58 uint32_t sample_frame_count_; | 58 uint32_t sample_frame_count_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Shared); | 60 DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Shared); |
61 }; | 61 }; |
62 | 62 |
63 } // namespace ppapi | 63 } // namespace ppapi |
64 | 64 |
65 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ | 65 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_CONFIG_SHARED_H_ |
OLD | NEW |