| 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_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 |
| 12 | 12 |
| 13 /// @file | 13 /// @file |
| 14 /// This file defines the interface for establishing an | 14 /// This file defines the interface for establishing an |
| 15 /// audio configuration resource within the browser. | 15 /// audio configuration resource within the browser. |
| 16 | 16 |
| 17 namespace pp { | 17 namespace pp { |
| 18 | 18 |
| 19 class Instance; | 19 class InstanceHandle; |
| 20 | 20 |
| 21 /// A 16 bit stereo AudioConfig resource. Refer to the | 21 /// A 16 bit stereo AudioConfig resource. Refer to the |
| 22 /// <a href="/chrome/nativeclient/docs/audio.html">Pepper | 22 /// <a href="/chrome/nativeclient/docs/audio.html">Pepper |
| 23 /// Audio API Code Walkthrough</a> for information on using this interface. | 23 /// Audio API Code Walkthrough</a> for information on using this interface. |
| 24 /// | 24 /// |
| 25 /// A single sample frame on a stereo device means one value for the left | 25 /// A single sample frame on a stereo device means one value for the left |
| 26 /// channel and one value for the right channel. | 26 /// channel and one value for the right channel. |
| 27 /// | 27 /// |
| 28 /// Buffer layout for a stereo int16 configuration: | 28 /// Buffer layout for a stereo int16 configuration: |
| 29 /// | 29 /// |
| (...skipping 27 matching lines...) Expand all Loading... |
| 57 class AudioConfig : public Resource { | 57 class AudioConfig : public Resource { |
| 58 public: | 58 public: |
| 59 /// An empty constructor for an <code>AudioConfig</code> resource. | 59 /// An empty constructor for an <code>AudioConfig</code> resource. |
| 60 AudioConfig(); | 60 AudioConfig(); |
| 61 | 61 |
| 62 /// A constructor that creates an audio config based on the given sample rate | 62 /// A constructor that creates an audio config based on the given sample rate |
| 63 /// and frame count. If the rate and frame count aren't supported, the | 63 /// and frame count. If the rate and frame count aren't supported, the |
| 64 /// resulting resource will be is_null(). You can pass the result of | 64 /// resulting resource will be is_null(). You can pass the result of |
| 65 /// RecommendSampleFrameCount() as the sample frame count. | 65 /// RecommendSampleFrameCount() as the sample frame count. |
| 66 /// | 66 /// |
| 67 /// @param[in] instance A pointer to an <code>Instance</code> identifying | 67 /// @param[in] instance The instance with which this resource will be |
| 68 /// one instance of a module. | 68 /// associated. |
| 69 /// |
| 69 /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either | 70 /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either |
| 70 /// <code>PP_AUDIOSAMPLERATE_44100</code> or | 71 /// <code>PP_AUDIOSAMPLERATE_44100</code> or |
| 71 /// <code>PP_AUDIOSAMPLERATE_48000</code>. | 72 /// <code>PP_AUDIOSAMPLERATE_48000</code>. |
| 73 /// |
| 72 /// @param[in] sample_frame_count A uint32_t frame count returned from the | 74 /// @param[in] sample_frame_count A uint32_t frame count returned from the |
| 73 /// <code>RecommendSampleFrameCount</code> function. | 75 /// <code>RecommendSampleFrameCount</code> function. |
| 74 AudioConfig(Instance* instance, | 76 AudioConfig(const InstanceHandle& instance, |
| 75 PP_AudioSampleRate sample_rate, | 77 PP_AudioSampleRate sample_rate, |
| 76 uint32_t sample_frame_count); | 78 uint32_t sample_frame_count); |
| 77 | 79 |
| 78 /// RecommendSampleRate() returns the native sample rate used by the | 80 /// RecommendSampleRate() returns the native sample rate used by the |
| 79 /// audio system. Applications that use the recommended sample rate might | 81 /// audio system. Applications that use the recommended sample rate might |
| 80 /// obtain lower latency and higher fidelity output. | 82 /// obtain lower latency and higher fidelity output. |
| 81 static PP_AudioSampleRate RecommendSampleRate(Instance* instance); | 83 static PP_AudioSampleRate RecommendSampleRate( |
| 84 const InstanceHandle& instance); |
| 82 | 85 |
| 83 /// RecommendSampleFrameCount() returns a supported frame count closest to | 86 /// RecommendSampleFrameCount() returns a supported frame count closest to |
| 84 /// the requested count. The sample frame count determines the overall | 87 /// the requested count. The sample frame count determines the overall |
| 85 /// latency of audio. Smaller frame counts will yield lower latency, but | 88 /// latency of audio. Smaller frame counts will yield lower latency, but |
| 86 /// higher CPU utilization. Supported sample frame counts will vary by | 89 /// higher CPU utilization. Supported sample frame counts will vary by |
| 87 /// hardware and system (consider that the local system might be anywhere | 90 /// hardware and system (consider that the local system might be anywhere |
| 88 /// from a cell phone or a high-end audio workstation). Sample counts less | 91 /// from a cell phone or a high-end audio workstation). Sample counts less |
| 89 /// than <code>PP_AUDIOMINSAMPLEFRAMECOUNT</code> and greater than | 92 /// than <code>PP_AUDIOMINSAMPLEFRAMECOUNT</code> and greater than |
| 90 /// <code>PP_AUDIOMAXSAMPLEFRAMECOUNT</code> are never supported on any | 93 /// <code>PP_AUDIOMAXSAMPLEFRAMECOUNT</code> are never supported on any |
| 91 /// system, but values in between aren't necessarily valid. This function | 94 /// system, but values in between aren't necessarily valid. This function |
| 92 /// will return a supported count closest to the requested value for use in | 95 /// will return a supported count closest to the requested value for use in |
| 93 /// the constructor. | 96 /// the constructor. |
| 94 /// | 97 /// |
| 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 | 98 /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either |
| 98 /// <code>PP_AUDIOSAMPLERATE_44100</code> or | 99 /// <code>PP_AUDIOSAMPLERATE_44100</code> or |
| 99 /// <code>PP_AUDIOSAMPLERATE_48000</code>. | 100 /// <code>PP_AUDIOSAMPLERATE_48000</code>. |
| 100 /// @param[in] requested_sample_frame_count A uint_32t requested frame count. | 101 /// @param[in] requested_sample_frame_count A uint_32t requested frame count. |
| 101 /// | 102 /// |
| 102 /// @return A uint32_t containing the recommended sample frame count if | 103 /// @return A uint32_t containing the recommended sample frame count if |
| 103 /// successful. If the sample frame count or bit rate is not supported, | 104 /// successful. If the sample frame count or bit rate is not supported, |
| 104 /// this function will fail and return 0. | 105 /// this function will fail and return 0. |
| 105 static uint32_t RecommendSampleFrameCount( | 106 static uint32_t RecommendSampleFrameCount( |
| 106 Instance* instance, | 107 const InstanceHandle& instance, |
| 107 PP_AudioSampleRate sample_rate, | 108 PP_AudioSampleRate sample_rate, |
| 108 uint32_t requested_sample_frame_count); | 109 uint32_t requested_sample_frame_count); |
| 109 | 110 |
| 110 /// Getter function for returning the internal | 111 /// Getter function for returning the internal |
| 111 /// <code>PP_AudioSampleRate</code> enum. | 112 /// <code>PP_AudioSampleRate</code> enum. |
| 112 /// | 113 /// |
| 113 /// @return The <code>PP_AudioSampleRate</code> enum. | 114 /// @return The <code>PP_AudioSampleRate</code> enum. |
| 114 PP_AudioSampleRate sample_rate() const { return sample_rate_; } | 115 PP_AudioSampleRate sample_rate() const { return sample_rate_; } |
| 115 | 116 |
| 116 /// Getter function for returning the internal sample frame count. | 117 /// Getter function for returning the internal sample frame count. |
| 117 /// | 118 /// |
| 118 /// @return A uint32_t containing the sample frame count. | 119 /// @return A uint32_t containing the sample frame count. |
| 119 uint32_t sample_frame_count() { return sample_frame_count_; } | 120 uint32_t sample_frame_count() { return sample_frame_count_; } |
| 120 | 121 |
| 121 private: | 122 private: |
| 122 PP_AudioSampleRate sample_rate_; | 123 PP_AudioSampleRate sample_rate_; |
| 123 uint32_t sample_frame_count_; | 124 uint32_t sample_frame_count_; |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 } // namespace pp | 127 } // namespace pp |
| 127 | 128 |
| 128 #endif // PPAPI_CPP_AUDIO_CONFIG_H_ | 129 #endif // PPAPI_CPP_AUDIO_CONFIG_H_ |
| 129 | 130 |
| OLD | NEW |