Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: ppapi/c/ppb_audio_config.h

Issue 6502007: Rewrote/added documentation for audio (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/c/ppb_audio.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2011 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_C_PPB_AUDIO_CONFIG_H_ 5 #ifndef PPAPI_C_PPB_AUDIO_CONFIG_H_
6 #define PPAPI_C_PPB_AUDIO_CONFIG_H_ 6 #define PPAPI_C_PPB_AUDIO_CONFIG_H_
7 7
8 #include "ppapi/c/pp_bool.h" 8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/c/pp_instance.h" 9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/c/pp_macros.h" 10 #include "ppapi/c/pp_macros.h"
11 #include "ppapi/c/pp_resource.h" 11 #include "ppapi/c/pp_resource.h"
12 #include "ppapi/c/pp_stdint.h" 12 #include "ppapi/c/pp_stdint.h"
13 13
14 #define PPB_AUDIO_CONFIG_INTERFACE "PPB_AudioConfig;0.5" 14 #define PPB_AUDIO_CONFIG_INTERFACE "PPB_AudioConfig;0.5"
15 15
16 /** 16 /**
17 * @file 17 * @file
18 * Defines the API ... 18 * This file defines the PPB_AudioConfig interface for establishing an
19 * audio configuration resource within the browser. Refer to the
20 * <a href="/chrome/nativeclient/docs/audio.html">Pepper Audio API Code
21 * Walkthrough</a> for information on using this interface.
19 */ 22 */
20 23
21 /** 24 /**
22 * 25 *
23 * @addtogroup Enums 26 * @addtogroup Enums
24 * @{ 27 * @{
25 */ 28 */
29
30 /**
31 * This enumeration contains audio frame count constants.
32 * PP_AUDIOMINSAMPLEFRAMECOUNT is the minimum possible frame count.
33 * PP_AUDIOMAXSAMPLEFRAMECOUNT is the maximum possible frame count.
34 */
26 enum { 35 enum {
27 PP_AUDIOMINSAMPLEFRAMECOUNT = 64, 36 PP_AUDIOMINSAMPLEFRAMECOUNT = 64,
28 PP_AUDIOMAXSAMPLEFRAMECOUNT = 32768 37 PP_AUDIOMAXSAMPLEFRAMECOUNT = 32768
29 }; 38 };
30 /** 39 /**
31 * @} 40 * @}
32 */ 41 */
33 42
34 /** 43 /**
35 * 44 *
36 * @addtogroup Enums 45 * @addtogroup Enums
37 * @{ 46 * @{
38 */ 47 */
48
49 /**
50 * PP_AudioSampleRate is an enumeration of the different audio sampling rates.
51 * PP_AUDIOSAMPLERATE_44100 is the sample rate used on CDs and
52 * PP_AUDIOSAMPLERATE_48000 is the sample rate used on DVDs and Digital Audio
53 * Tapes.
54 */
39 typedef enum { 55 typedef enum {
40 PP_AUDIOSAMPLERATE_NONE = 0, 56 PP_AUDIOSAMPLERATE_NONE = 0,
41 PP_AUDIOSAMPLERATE_44100 = 44100, 57 PP_AUDIOSAMPLERATE_44100 = 44100,
42 PP_AUDIOSAMPLERATE_48000 = 48000 58 PP_AUDIOSAMPLERATE_48000 = 48000
43 } PP_AudioSampleRate; 59 } PP_AudioSampleRate;
44 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioSampleRate, 4); 60 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioSampleRate, 4);
45 /** 61 /**
46 * @} 62 * @}
47 */ 63 */
48 64
49 /** 65 /**
50 * @addtogroup Interfaces 66 * @addtogroup Interfaces
51 * @{ 67 * @{
52 */ 68 */
53 69
54 /** 70 /**
55 * Audio configuration. This base configuration interface supports only stereo 71 * The PPB_AudioConfig interface contains pointers to several functions for
56 * 16bit output. This class is not mutable, therefore it is okay to access 72 * establishing your audio configuration within the browser. This interface
57 * instances from different threads. 73 * only supports stereo * 16bit output. This class is not mutable, therefore
74 * it is okay to access instances from different threads.
58 */ 75 */
59 struct PPB_AudioConfig { 76 struct PPB_AudioConfig {
60 /** 77 /**
61 * Create a 16 bit stereo config with the given sample rate. We guarantee 78 * CreateStereo16bit is a pointer to a function that creates a 16 bit audio
62 * that PP_AUDIOSAMPLERATE_44100 and PP_AUDIOSAMPLERATE_48000 sample rates 79 * configuration resource. The |sample_frame_count| should be the result of
63 * are supported. The |sample_frame_count| should be the result of calling 80 * calling RecommendSampleFrameCount. If the sample frame count or bit rate
64 * RecommendSampleFrameCount. If the sample frame count or bit rate aren't 81 * isn't supported, this function will fail and return a null resource.
65 * supported, this function will fail and return a null resource.
66 * 82 *
67 * A single sample frame on a stereo device means one value for the left 83 * A single sample frame on a stereo device means one value for the left
68 * channel and one value for the right channel. 84 * channel and one value for the right channel.
69 * 85 *
70 * Buffer layout for a stereo int16 configuration: 86 * Buffer layout for a stereo int16 configuration:
71 * int16_t *buffer16; 87 * int16_t *buffer16;
72 * buffer16[0] is the first left channel sample 88 * buffer16[0] is the first left channel sample.
73 * buffer16[1] is the first right channel sample 89 * buffer16[1] is the first right channel sample.
74 * buffer16[2] is the second left channel sample 90 * buffer16[2] is the second left channel sample.
75 * buffer16[3] is the second right channel sample 91 * buffer16[3] is the second right channel sample.
76 * ... 92 * ...
77 * buffer16[2 * (sample_frame_count - 1)] is the last left channel sample 93 * buffer16[2 * (sample_frame_count - 1)] is the last left channel sample.
78 * buffer16[2 * (sample_frame_count - 1) + 1] is the last right channel sample 94 * buffer16[2 * (sample_frame_count - 1) + 1] is the last right channel
95 * sample.
79 * Data will always be in the native endian format of the platform. 96 * Data will always be in the native endian format of the platform.
97 *
98 * @param[in] instance A PP_Instance indentifying one instance of a module.
99 * @param[in] sample_rate A PP_AudioSampleRate which is either
100 * PP_AUDIOSAMPLERATE_44100 or PP_AUDIOSAMPLERATE_48000.
101 * @param[in] sample_frame_count A uint32_t frame count returned from the
102 * RecommendSampleFrameCount function.
103 * @return A PP_Resource containing the PPB_Audio_Config if successful or
104 * a null resource if the sample frame count or bit rate are not supported.
80 */ 105 */
81 PP_Resource (*CreateStereo16Bit)(PP_Instance instance, 106 PP_Resource (*CreateStereo16Bit)(PP_Instance instance,
82 PP_AudioSampleRate sample_rate, 107 PP_AudioSampleRate sample_rate,
83 uint32_t sample_frame_count); 108 uint32_t sample_frame_count);
84 109
85 /* 110 /**
86 * Returns a supported sample frame count closest to the given requested 111 * RecommendSampleFrameCount is a pointer to a function that returns the
87 * count. The sample frame count determines the overall latency of audio. 112 * supported sample frame count closest to the requested count. The sample
88 * Since one "frame" is always buffered in advance, smaller frame counts 113 * frame count determines the overall latency of audio. Since one "frame" is
89 * will yield lower latency, but higher CPU utilization. 114 * always buffered in advance, smaller frame counts will yield lower latency,
115 * but higher CPU utilization.
90 * 116 *
91 * Supported sample frame counts will vary by hardware and system (consider 117 * Supported sample frame counts will vary by hardware and system (consider
92 * that the local system might be anywhere from a cell phone or a high-end 118 * that the local system might be anywhere from a cell phone or a high-end
93 * audio workstation). Sample counts less than PP_AUDIOMINSAMPLEFRAMECOUNT 119 * audio workstation). Sample counts less than PP_AUDIOMINSAMPLEFRAMECOUNT
94 * and greater than PP_AUDIOMAXSAMPLEFRAMECOUNT are never supported on any 120 * and greater than PP_AUDIOMAXSAMPLEFRAMECOUNT are never supported on any
95 * system, but values in between aren't necessarily valid. This function 121 * system, but values in between aren't necessarily valid. This function
96 * will return a supported count closest to the requested value. 122 * will return a supported count closest to the requested value.
97 * 123 *
124 * @param[in] sample_rate A PP_AudioSampleRate which is either
125 * PP_AUDIOSAMPLERATE_44100 or PP_AUDIOSAMPLERATE_48000.
126 * @param[in] requested_sample_frame_count A uint_32t requested frame count.
98 * If you pass 0 as the requested sample count, the recommended sample for 127 * If you pass 0 as the requested sample count, the recommended sample for
99 * the local system is returned. 128 * the local system is returned.
129 * @return A uint32_t containing the recommended sample frame count if
130 * successful.
100 */ 131 */
101 uint32_t (*RecommendSampleFrameCount)(PP_AudioSampleRate sample_rate, 132 uint32_t (*RecommendSampleFrameCount)(PP_AudioSampleRate sample_rate,
102 uint32_t requested_sample_frame_count); 133 uint32_t requested_sample_frame_count);
103 134
104 /** 135 /**
105 * Returns true if the given resource is an AudioConfig object. 136 * IsAudioConfig is a pointer to a function that determines if the given
137 * resource is a PPB_Audio_Config.
138 *
139 * @param[in] resource A PP_Resource containing the audio config resource.
140 * @return A PP_BOOL containing PP_TRUE if the given resource is
141 * an AudioConfig resource, otherwise PP_FALSE.
106 */ 142 */
107 PP_Bool (*IsAudioConfig)(PP_Resource resource); 143 PP_Bool (*IsAudioConfig)(PP_Resource resource);
108 144
109 /** 145 /**
110 * Returns the sample rate for the given AudioConfig resource. If the 146 * GetSampleRate is a pointer to a function that returns the sample
111 * resource is invalid, this will return PP_AUDIOSAMPLERATE_NONE. 147 * rate for the given PPB_Audio_Config.
148 *
149 * @param[in] config A PP_Resource containing the PPB_Audio_Config.
150 * @return A PP_AudioSampleRate containing sample rate or
151 * PP_AUDIOSAMPLERATE_NONE if the resource is invalid.
112 */ 152 */
113 PP_AudioSampleRate (*GetSampleRate)(PP_Resource config); 153 PP_AudioSampleRate (*GetSampleRate)(PP_Resource config);
114 154
115 /** 155 /**
116 * Returns the sample frame count for the given AudioConfig resource. If the 156 * GetSampleFrameCount is a pointer to a function that returns the sample
117 * resource is invalid, this will return 0. See RecommendSampleFrameCount for 157 * frame count for the given PPB_Audio_Config.
158 *
159 * @param[in] config A PP_Resource containing the audio config resource.
160 * @return A uint32_t containing sample frame count or
161 * 0 if the resource is invalid. See RecommendSampleFrameCount for
118 * more on sample frame counts. 162 * more on sample frame counts.
119 */ 163 */
120 uint32_t (*GetSampleFrameCount)(PP_Resource config); 164 uint32_t (*GetSampleFrameCount)(PP_Resource config);
121 }; 165 };
122 /** 166 /**
123 * @} 167 * @}
124 */ 168 */
125 169
126 #endif /* PPAPI_C_PPB_AUDIO_CONFIG_H_ */ 170 #endif /* PPAPI_C_PPB_AUDIO_CONFIG_H_ */
127 171
OLDNEW
« no previous file with comments | « ppapi/c/ppb_audio.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698