| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (hardware_sample_rate == sample_rate && hardware_sample_frame_count > 0) { | 67 if (hardware_sample_rate == sample_rate && hardware_sample_frame_count > 0) { |
| 68 // Round up input sample_frame_count to nearest multiple. | 68 // Round up input sample_frame_count to nearest multiple. |
| 69 uint32_t multiple = (sample_frame_count + hardware_sample_frame_count - 1) / | 69 uint32_t multiple = (sample_frame_count + hardware_sample_frame_count - 1) / |
| 70 hardware_sample_frame_count; | 70 hardware_sample_frame_count; |
| 71 uint32_t recommendation = hardware_sample_frame_count * multiple; | 71 uint32_t recommendation = hardware_sample_frame_count * multiple; |
| 72 if (recommendation > PP_AUDIOMAXSAMPLEFRAMECOUNT) | 72 if (recommendation > PP_AUDIOMAXSAMPLEFRAMECOUNT) |
| 73 recommendation = PP_AUDIOMAXSAMPLEFRAMECOUNT; | 73 recommendation = PP_AUDIOMAXSAMPLEFRAMECOUNT; |
| 74 return recommendation; | 74 return recommendation; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Otherwise, recommend a conservative 30ms buffer based on sample rate. | 77 // Otherwise, recommend a conservative 50ms buffer based on sample rate. |
| 78 const uint32_t kDefault30msAt44100kHz = 1323; | 78 const uint32_t kDefault50msAt44100kHz = 2205; |
| 79 const uint32_t kDefault30msAt48000kHz = 1440; | 79 const uint32_t kDefault50msAt48000kHz = 2400; |
| 80 switch (sample_rate) { | 80 switch (sample_rate) { |
| 81 case PP_AUDIOSAMPLERATE_44100: | 81 case PP_AUDIOSAMPLERATE_44100: |
| 82 return kDefault30msAt44100kHz; | 82 return kDefault50msAt44100kHz; |
| 83 case PP_AUDIOSAMPLERATE_48000: | 83 case PP_AUDIOSAMPLERATE_48000: |
| 84 return kDefault30msAt48000kHz; | 84 return kDefault50msAt48000kHz; |
| 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) { |
| (...skipping 30 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 |