OLD | NEW |
---|---|
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 | 5 |
6 /** | 6 /** |
7 * This file defines the <code>PPB_Audio</code> interface, which provides | 7 * This file defines the <code>PPB_Audio</code> interface, which provides |
8 * realtime stereo audio streaming capabilities. | 8 * realtime stereo audio streaming capabilities. |
9 */ | 9 */ |
10 | 10 |
11 label Chrome { | 11 label Chrome { |
12 M13 = 0.6, | 12 M13 = 0.6, |
13 M14 = 1.0 | 13 M14 = 1.0 |
14 }; | 14 }; |
15 | 15 |
16 /** | 16 /** |
17 * <code>PPB_Audio_Callback</code> defines the type of an audio callback | 17 * <code>PPB_Audio_Callback</code> defines the type of an audio callback |
18 * function used to fill the audio buffer with data. Please see the | 18 * function used to fill the audio buffer with data. Please see the |
19 * <code>Create()</code> function in the <code>PPB_Audio</code> interface for | 19 * Create() function in the <code>PPB_Audio</code> interface for |
20 * more details on this callback. | 20 * more details on this callback. |
21 */ | 21 */ |
22 typedef void PPB_Audio_Callback([out] mem_t sample_buffer, | 22 typedef void PPB_Audio_Callback([out] mem_t sample_buffer, |
23 [in] uint32_t buffer_size_in_bytes, | 23 [in] uint32_t buffer_size_in_bytes, |
24 [inout] mem_t user_data); | 24 [inout] mem_t user_data); |
25 | 25 |
26 /** | 26 /** |
27 * The <code>PPB_Audio</code> interface contains pointers to several functions | 27 * The <code>PPB_Audio</code> interface contains pointers to several functions |
28 * for handling audio resources. Please refer to the | 28 * for handling audio resources. Please refer to the |
29 * <a href="/chrome/nativeclient/docs/audio.html">Pepper | 29 * <a href="/chrome/nativeclient/docs/audio.html">Pepper |
30 * Audio API</a> for information on using this interface. | 30 * Audio API</a> for information on using this interface. |
31 * Please see descriptions for each <code>PPB_Audio</code> and | 31 * Please see descriptions for each <code>PPB_Audio</code> and |
32 * <code>PPB_AudioConfig</code> function for more details. | 32 * <code>PPB_AudioConfig</code> function for more details. A C example using |
33 * <code>PPB_Audio</code> and <code>PPB_AudioConfig</code> follows. | |
33 * | 34 * |
34 * A C example using PPB_Audio and PPB_AudioConfig: | 35 * <strong>Example: </strong> |
35 * @code | 36 * |
37 * <code> | |
36 * void audio_callback(void* sample_buffer, | 38 * void audio_callback(void* sample_buffer, |
37 * uint32_t buffer_size_in_bytes, | 39 * uint32_t buffer_size_in_bytes, |
38 * void* user_data) { | 40 * void* user_data) { |
39 * ... quickly fill in the buffer with samples and return to caller ... | 41 * ... quickly fill in the buffer with samples and return to caller ... |
40 * } | 42 * } |
41 * | 43 * |
42 * ...Assume the application has cached the audio configuration interface in | 44 * ...Assume the application has cached the audio configuration interface in |
43 * |audio_config_interface| and the audio interface in |audio_interface|... | 45 * <code>audio_config_interface</code> and the audio interface in |
46 * audio_interface</code>... | |
dmichael (off chromium)
2011/08/23 20:16:11
missing first <code>
jond
2011/08/23 21:15:29
Done.
| |
44 * | 47 * |
45 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( | 48 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( |
46 * PP_AUDIOSAMPLERATE_44100, 4096); | 49 * PP_AUDIOSAMPLERATE_44100, 4096); |
47 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( | 50 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( |
48 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); | 51 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); |
49 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, | 52 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, |
50 * audio_callback, NULL); | 53 * audio_callback, NULL); |
51 * audio_interface->StartPlayback(pp_audio); | 54 * audio_interface->StartPlayback(pp_audio); |
52 * | 55 * |
53 * ...audio_callback() will now be periodically invoked on a seperate thread... | 56 * ...audio_callback() will now be periodically invoked on a separate thread... |
54 * @endcode | 57 * </code> |
55 */ | 58 */ |
56 interface PPB_Audio { | 59 interface PPB_Audio { |
57 /** | 60 /** |
58 * Create is a pointer to a function that creates an audio resource. | 61 * Create() creates an audio resource. No sound will be heard until |
59 * No sound will be heard until StartPlayback() is called. The callback | 62 * StartPlayback() is called. The callback is called with the buffer address |
60 * is called with the buffer address and given user data whenever the | 63 * and given user data whenever the buffer needs to be filled. From within the |
61 * buffer needs to be filled. From within the callback, you should not | 64 * callback, you should not call <code>PPB_Audio</code> functions. The |
62 * call PPB_Audio functions. The callback will be called on a different | 65 * callback will be called on a different thread than the one which created |
63 * thread than the one which created the interface. For performance-critical | 66 * the interface. For performance-critical applications (i.e. low-latency |
64 * applications (i.e. low-latency audio), the callback should avoid blocking | 67 * audio), the callback should avoid blocking or calling functions that can |
65 * or calling functions that can obtain locks, such as malloc. The layout and | 68 * obtain locks, such as malloc. The layout and the size of the buffer passed |
66 * the size of the buffer passed to the audio callback will be determined by | 69 * to the audio callback will be determined by the device configuration and is |
67 * the device configuration and is specified in the AudioConfig documentation. | 70 * specified in the <code>AudioConfig</code> documentation. |
68 * | 71 * |
69 * @param[in] instance A PP_Instance indentifying one instance of a module. | 72 * @param[in] instance A <code>PP_Instance<code> identifying one instance of a |
dmichael (off chromium)
2011/08/23 20:16:11
ending tag needs to be </code>
jond
2011/08/23 21:15:29
Done.
| |
70 * @param[in] config A PP_Resource containing the audio config resource. | 73 * module. |
71 * @param[in] audio_callback A PPB_Audio_Callback callback function that the | 74 * @param[in] config A <code>PP_Resource<code> corresponding to an audio |
dmichael (off chromium)
2011/08/23 20:16:11
here too
jond
2011/08/23 21:15:29
Done.
| |
72 * browser calls when it needs more samples to play. | 75 * config resource. |
76 * @param[in] audio_callback A <code>PPB_Audio_Callback<code> callback | |
dmichael (off chromium)
2011/08/23 20:16:11
here too
jond
2011/08/23 21:15:29
Done.
jond
2011/08/23 21:15:29
Done.
| |
77 * function that the browser calls when it needs more samples to play. | |
73 * @param[in] user_data A pointer to user data used in the callback function. | 78 * @param[in] user_data A pointer to user data used in the callback function. |
74 * | 79 * |
75 * @return A PP_Resource containing the audio resource if successful or | 80 * @return A <code>PP_Resource</code> containing the audio resource if |
76 * 0 if the configuration cannot be honored or the callback is null. | 81 * successful or 0 if the configuration cannot be honored or the callback is |
82 * null. | |
77 */ | 83 */ |
78 PP_Resource Create( | 84 PP_Resource Create( |
79 [in] PP_Instance instance, | 85 [in] PP_Instance instance, |
80 [in] PP_Resource config, | 86 [in] PP_Resource config, |
81 [in] PPB_Audio_Callback audio_callback, | 87 [in] PPB_Audio_Callback audio_callback, |
82 [inout] mem_t user_data); | 88 [inout] mem_t user_data); |
83 | 89 |
84 /** | 90 /** |
85 * IsAudio is a pointer to a function that determines if the given | 91 * IsAudio() determines if the provided resource is an audio resource. |
86 * resource is an audio resource. | |
87 * | 92 * |
88 * @param[in] resource A PP_Resource containing a resource. | 93 * @param[in] resource A <code>PP_Resource</code> corresponding to a generic |
94 * resource. | |
89 * | 95 * |
90 * @return A PP_BOOL containing containing PP_TRUE if the given resource is | 96 * @return A <code>PP_Bool</code> containing containing <code>PP_TRUE</code> |
91 * an Audio resource, otherwise PP_FALSE. | 97 * if the given resource is an Audio resource, otherwise |
98 * <code>PP_FALSE</code>. | |
92 */ | 99 */ |
93 PP_Bool IsAudio( | 100 PP_Bool IsAudio( |
94 [in] PP_Resource resource); | 101 [in] PP_Resource resource); |
95 | 102 |
96 /** | 103 /** |
97 * GetCurrrentConfig is a pointer to a function that returns an audio config | 104 * GetCurrrentConfig() returns an audio config resource for the given audio |
98 * resource for the given audio resource. | 105 * resource. |
99 * | 106 * |
100 * @param[in] config A PP_Resource containing the audio resource. | 107 * @param[in] config A <code>PP_Resource</code> corresponding to an audio |
108 * resource. | |
101 * | 109 * |
102 * @return A PP_Resource containing the audio config resource if successful. | 110 * @return A <code>PP_Resource</code> containing the audio config resource if |
111 * successful. | |
103 */ | 112 */ |
104 PP_Resource GetCurrentConfig( | 113 PP_Resource GetCurrentConfig( |
105 [in] PP_Resource audio); | 114 [in] PP_Resource audio); |
106 | 115 |
107 /** | 116 /** |
108 * StartPlayback is a pointer to a function that starts the playback of | 117 * StartPlayback() starts the playback of the audio resource and begins |
109 * the audio resource and begins periodically calling the callback. | 118 * periodically calling the callback. |
110 * | 119 * |
111 * @param[in] config A PP_Resource containing the audio resource. | 120 * @param[in] config A <code>PP_Resource</code> corresponding to an audio |
121 * resource. | |
112 * | 122 * |
113 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. | 123 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if |
dmichael (off chromium)
2011/08/23 20:16:11
PP_TRUE->PP_True, and two more similar problems in
jond
2011/08/23 21:15:29
Done.
| |
114 * Also returns PP_TRUE (and be a no-op) if called while playback is already | 124 * successful, otherwise <code>PP_FALSE</code>. Also returns |
125 * <code>PP_TRUE</code> (and be a no-op) if called while playback is already | |
115 * in progress. | 126 * in progress. |
116 */ | 127 */ |
117 PP_Bool StartPlayback( | 128 PP_Bool StartPlayback( |
118 [in] PP_Resource audio); | 129 [in] PP_Resource audio); |
119 | 130 |
120 /** | 131 /** |
121 * StopPlayback is a pointer to a function that stops the playback of | 132 * StopPlayback() stops the playback of the audio resource. |
122 * the audio resource. | |
123 * | 133 * |
124 * @param[in] config A PP_Resource containing the audio resource. | 134 * @param[in] config A <code>PP_Resource</code> corresponding to an audio |
135 * resource. | |
125 * | 136 * |
126 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. | 137 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if |
127 * Also returns PP_TRUE (and is a no-op) if called while playback is already | 138 * successful, otherwise <code>PP_FALSE</code>. Also returns |
128 * stopped. If a callback is in progress, StopPlayback will block until the | 139 * <code>PP_TRUE</code> (and is a no-op) if called while playback is already |
140 * stopped. If a callback is in progress, StopPlayback() will block until the | |
129 * callback completes. | 141 * callback completes. |
130 */ | 142 */ |
131 PP_Bool StopPlayback( | 143 PP_Bool StopPlayback( |
132 [in] PP_Resource audio); | 144 [in] PP_Resource audio); |
133 }; | 145 }; |
134 | 146 |
OLD | NEW |