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