OLD | NEW |
1 // Copyright (c) 2011 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_CPP_AUDIO_CONFIG_H_ | 5 #ifndef PPAPI_CPP_AUDIO_CONFIG_H_ |
6 #define PPAPI_CPP_AUDIO_CONFIG_H_ | 6 #define PPAPI_CPP_AUDIO_CONFIG_H_ |
7 | 7 |
8 #include "ppapi/c/ppb_audio_config.h" | 8 #include "ppapi/c/ppb_audio_config.h" |
9 #include "ppapi/c/pp_stdint.h" | 9 #include "ppapi/c/pp_stdint.h" |
10 #include "ppapi/cpp/resource.h" | 10 #include "ppapi/cpp/resource.h" |
11 | 11 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 /// one instance of a module. | 68 /// one instance of a module. |
69 /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either | 69 /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either |
70 /// <code>PP_AUDIOSAMPLERATE_44100</code> or | 70 /// <code>PP_AUDIOSAMPLERATE_44100</code> or |
71 /// <code>PP_AUDIOSAMPLERATE_48000</code>. | 71 /// <code>PP_AUDIOSAMPLERATE_48000</code>. |
72 /// @param[in] sample_frame_count A uint32_t frame count returned from the | 72 /// @param[in] sample_frame_count A uint32_t frame count returned from the |
73 /// <code>RecommendSampleFrameCount</code> function. | 73 /// <code>RecommendSampleFrameCount</code> function. |
74 AudioConfig(Instance* instance, | 74 AudioConfig(Instance* instance, |
75 PP_AudioSampleRate sample_rate, | 75 PP_AudioSampleRate sample_rate, |
76 uint32_t sample_frame_count); | 76 uint32_t sample_frame_count); |
77 | 77 |
| 78 /// RecommendSampleRate() returns the native sample rate used by the |
| 79 /// audio system. Applications that use the recommended sample rate might |
| 80 /// obtain lower latency and higher fidelity output. |
| 81 static PP_AudioSampleRate RecommendSampleRate(Instance* instance); |
| 82 |
78 /// RecommendSampleFrameCount() returns a supported frame count closest to | 83 /// RecommendSampleFrameCount() returns a supported frame count closest to |
79 /// the requested count. The sample frame count determines the overall | 84 /// the requested count. The sample frame count determines the overall |
80 /// latency of audio. Smaller frame counts will yield lower latency, but | 85 /// latency of audio. Smaller frame counts will yield lower latency, but |
81 /// higher CPU utilization. Supported sample frame counts will vary by | 86 /// higher CPU utilization. Supported sample frame counts will vary by |
82 /// hardware and system (consider that the local system might be anywhere | 87 /// hardware and system (consider that the local system might be anywhere |
83 /// from a cell phone or a high-end audio workstation). Sample counts less | 88 /// from a cell phone or a high-end audio workstation). Sample counts less |
84 /// than <code>PP_AUDIOMINSAMPLEFRAMECOUNT</code> and greater than | 89 /// than <code>PP_AUDIOMINSAMPLEFRAMECOUNT</code> and greater than |
85 /// <code>PP_AUDIOMAXSAMPLEFRAMECOUNT</code> are never supported on any | 90 /// <code>PP_AUDIOMAXSAMPLEFRAMECOUNT</code> are never supported on any |
86 /// system, but values in between aren't necessarily valid. This function | 91 /// system, but values in between aren't necessarily valid. This function |
87 /// will return a supported count closest to the requested value for use in | 92 /// will return a supported count closest to the requested value for use in |
88 /// the constructor. | 93 /// the constructor. |
89 /// | 94 /// |
90 /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either | 95 /// @param[in] instance A pointer to an <code>Instance</code> identifying |
| 96 /// one instance of a module. |
| 97 /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either |
91 /// <code>PP_AUDIOSAMPLERATE_44100</code> or | 98 /// <code>PP_AUDIOSAMPLERATE_44100</code> or |
92 /// <code>PP_AUDIOSAMPLERATE_48000</code>. | 99 /// <code>PP_AUDIOSAMPLERATE_48000</code>. |
93 /// @param[in] requested_sample_frame_count A uint_32t requested frame count. | 100 /// @param[in] requested_sample_frame_count A uint_32t requested frame count. |
94 /// | 101 /// |
95 /// @return A uint32_t containing the recommended sample frame count if | 102 /// @return A uint32_t containing the recommended sample frame count if |
96 /// successful. If the sample frame count or bit rate is not supported, | 103 /// successful. If the sample frame count or bit rate is not supported, |
97 /// this function will fail and return 0. | 104 /// this function will fail and return 0. |
98 static uint32_t RecommendSampleFrameCount( | 105 static uint32_t RecommendSampleFrameCount( |
| 106 Instance* instance, |
99 PP_AudioSampleRate sample_rate, | 107 PP_AudioSampleRate sample_rate, |
100 uint32_t requested_sample_frame_count); | 108 uint32_t requested_sample_frame_count); |
101 | 109 |
102 /// Getter function for returning the internal | 110 /// Getter function for returning the internal |
103 /// <code>PP_AudioSampleRate</code> enum. | 111 /// <code>PP_AudioSampleRate</code> enum. |
104 /// | 112 /// |
105 /// @return The <code>PP_AudioSampleRate</code> enum. | 113 /// @return The <code>PP_AudioSampleRate</code> enum. |
106 PP_AudioSampleRate sample_rate() const { return sample_rate_; } | 114 PP_AudioSampleRate sample_rate() const { return sample_rate_; } |
107 | 115 |
108 /// Getter function for returning the internal sample frame count. | 116 /// Getter function for returning the internal sample frame count. |
109 /// | 117 /// |
110 /// @return A uint32_t containing the sample frame count. | 118 /// @return A uint32_t containing the sample frame count. |
111 uint32_t sample_frame_count() { return sample_frame_count_; } | 119 uint32_t sample_frame_count() { return sample_frame_count_; } |
112 | 120 |
113 private: | 121 private: |
114 PP_AudioSampleRate sample_rate_; | 122 PP_AudioSampleRate sample_rate_; |
115 uint32_t sample_frame_count_; | 123 uint32_t sample_frame_count_; |
116 }; | 124 }; |
117 | 125 |
118 } // namespace pp | 126 } // namespace pp |
119 | 127 |
120 #endif // PPAPI_CPP_AUDIO_CONFIG_H_ | 128 #endif // PPAPI_CPP_AUDIO_CONFIG_H_ |
121 | 129 |
OLD | NEW |