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/shared_impl/ppb_audio_config_shared.h" | 5 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
6 #include "ppapi/thunk/enter.h" | 6 #include "ppapi/thunk/enter.h" |
7 | 7 |
8 namespace ppapi { | 8 namespace ppapi { |
9 | 9 |
10 PPB_AudioConfig_Shared::PPB_AudioConfig_Shared(ResourceObjectType type, | 10 PPB_AudioConfig_Shared::PPB_AudioConfig_Shared(ResourceObjectType type, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return requested_sample_frame_count; | 42 return requested_sample_frame_count; |
43 } | 43 } |
44 | 44 |
45 // static | 45 // static |
46 uint32_t PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1( | 46 uint32_t PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1( |
47 PP_Instance instance, | 47 PP_Instance instance, |
48 PP_AudioSampleRate sample_rate, | 48 PP_AudioSampleRate sample_rate, |
49 uint32_t sample_frame_count) { | 49 uint32_t sample_frame_count) { |
50 // Version 1.1: Query the back-end hardware for sample rate and buffer size, | 50 // Version 1.1: Query the back-end hardware for sample rate and buffer size, |
51 // and recommend a best fit based on request. | 51 // and recommend a best fit based on request. |
52 thunk::EnterInstance enter(instance); | 52 thunk::EnterInstanceNoLock enter(instance); |
53 if (enter.failed()) | 53 if (enter.failed()) |
54 return 0; | 54 return 0; |
55 | 55 |
56 // Get the hardware config. | 56 // Get the hardware config. |
57 PP_AudioSampleRate hardware_sample_rate = static_cast<PP_AudioSampleRate>( | 57 PP_AudioSampleRate hardware_sample_rate = static_cast<PP_AudioSampleRate>( |
58 enter.functions()->GetAudioHardwareOutputSampleRate(instance)); | 58 enter.functions()->GetAudioHardwareOutputSampleRate(instance)); |
59 uint32_t hardware_sample_frame_count = | 59 uint32_t hardware_sample_frame_count = |
60 enter.functions()->GetAudioHardwareOutputBufferSize(instance); | 60 enter.functions()->GetAudioHardwareOutputBufferSize(instance); |
61 if (sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) | 61 if (sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) |
62 sample_frame_count = PP_AUDIOMINSAMPLEFRAMECOUNT; | 62 sample_frame_count = PP_AUDIOMINSAMPLEFRAMECOUNT; |
(...skipping 21 matching lines...) Expand all Loading... |
84 case PP_AUDIOSAMPLERATE_NONE: | 84 case PP_AUDIOSAMPLERATE_NONE: |
85 return 0; | 85 return 0; |
86 } | 86 } |
87 // Unable to make a recommendation. | 87 // Unable to make a recommendation. |
88 return 0; | 88 return 0; |
89 } | 89 } |
90 | 90 |
91 // static | 91 // static |
92 PP_AudioSampleRate PPB_AudioConfig_Shared::RecommendSampleRate( | 92 PP_AudioSampleRate PPB_AudioConfig_Shared::RecommendSampleRate( |
93 PP_Instance instance) { | 93 PP_Instance instance) { |
94 thunk::EnterInstance enter(instance); | 94 thunk::EnterInstanceNoLock enter(instance); |
95 if (enter.failed()) | 95 if (enter.failed()) |
96 return PP_AUDIOSAMPLERATE_NONE; | 96 return PP_AUDIOSAMPLERATE_NONE; |
97 PP_AudioSampleRate hardware_sample_rate = static_cast<PP_AudioSampleRate>( | 97 PP_AudioSampleRate hardware_sample_rate = static_cast<PP_AudioSampleRate>( |
98 enter.functions()->GetAudioHardwareOutputSampleRate(instance)); | 98 enter.functions()->GetAudioHardwareOutputSampleRate(instance)); |
99 return hardware_sample_rate; | 99 return hardware_sample_rate; |
100 } | 100 } |
101 | 101 |
102 thunk::PPB_AudioConfig_API* PPB_AudioConfig_Shared::AsPPB_AudioConfig_API() { | 102 thunk::PPB_AudioConfig_API* PPB_AudioConfig_Shared::AsPPB_AudioConfig_API() { |
103 return this; | 103 return this; |
104 } | 104 } |
(...skipping 19 matching lines...) Expand all Loading... |
124 if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT || | 124 if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT || |
125 sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) | 125 sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) |
126 return false; | 126 return false; |
127 | 127 |
128 sample_rate_ = sample_rate; | 128 sample_rate_ = sample_rate; |
129 sample_frame_count_ = sample_frame_count; | 129 sample_frame_count_ = sample_frame_count; |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 } // namespace ppapi | 133 } // namespace ppapi |
OLD | NEW |