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 /* From ppb_audio.idl modified Wed Aug 17 11:16:34 2011. */ | 6 /* From ppb_audio.idl modified Tue Aug 23 10:26:15 2011. */ |
7 | 7 |
8 #ifndef PPAPI_C_PPB_AUDIO_H_ | 8 #ifndef PPAPI_C_PPB_AUDIO_H_ |
9 #define PPAPI_C_PPB_AUDIO_H_ | 9 #define PPAPI_C_PPB_AUDIO_H_ |
10 | 10 |
11 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
12 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
13 #include "ppapi/c/pp_macros.h" | 13 #include "ppapi/c/pp_macros.h" |
14 #include "ppapi/c/pp_resource.h" | 14 #include "ppapi/c/pp_resource.h" |
15 #include "ppapi/c/pp_stdint.h" | 15 #include "ppapi/c/pp_stdint.h" |
16 | 16 |
(...skipping 28 matching lines...) Expand all Loading... |
45 /** | 45 /** |
46 * @addtogroup Interfaces | 46 * @addtogroup Interfaces |
47 * @{ | 47 * @{ |
48 */ | 48 */ |
49 /** | 49 /** |
50 * The <code>PPB_Audio</code> interface contains pointers to several functions | 50 * The <code>PPB_Audio</code> interface contains pointers to several functions |
51 * for handling audio resources. Please refer to the | 51 * for handling audio resources. Please refer to the |
52 * <a href="/chrome/nativeclient/docs/audio.html">Pepper | 52 * <a href="/chrome/nativeclient/docs/audio.html">Pepper |
53 * Audio API</a> for information on using this interface. | 53 * Audio API</a> for information on using this interface. |
54 * Please see descriptions for each <code>PPB_Audio</code> and | 54 * Please see descriptions for each <code>PPB_Audio</code> and |
55 * <code>PPB_AudioConfig</code> function for more details. | 55 * <code>PPB_AudioConfig</code> function for more details. A C example using |
| 56 * <code>PPB_Audio</code> and <code>PPB_AudioConfig</code> follows. |
56 * | 57 * |
57 * A C example using PPB_Audio and PPB_AudioConfig: | 58 * <strong>Example: </strong> |
58 * @code | 59 * |
| 60 * <code> |
59 * void audio_callback(void* sample_buffer, | 61 * void audio_callback(void* sample_buffer, |
60 * uint32_t buffer_size_in_bytes, | 62 * uint32_t buffer_size_in_bytes, |
61 * void* user_data) { | 63 * void* user_data) { |
62 * ... quickly fill in the buffer with samples and return to caller ... | 64 * ... quickly fill in the buffer with samples and return to caller ... |
63 * } | 65 * } |
64 * | 66 * |
65 * ...Assume the application has cached the audio configuration interface in | 67 * ...Assume the application has cached the audio configuration interface in |
66 * |audio_config_interface| and the audio interface in |audio_interface|... | 68 * |audio_config_interface| and the audio interface in |audio_interface|... |
67 * | 69 * |
68 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( | 70 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( |
69 * PP_AUDIOSAMPLERATE_44100, 4096); | 71 * PP_AUDIOSAMPLERATE_44100, 4096); |
70 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( | 72 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( |
71 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); | 73 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); |
72 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, | 74 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, |
73 * audio_callback, NULL); | 75 * audio_callback, NULL); |
74 * audio_interface->StartPlayback(pp_audio); | 76 * audio_interface->StartPlayback(pp_audio); |
75 * | 77 * |
76 * ...audio_callback() will now be periodically invoked on a seperate thread... | 78 * ...audio_callback() will now be periodically invoked on a seperate thread... |
77 * @endcode | 79 * </code> |
78 */ | 80 */ |
79 struct PPB_Audio { | 81 struct PPB_Audio { |
80 /** | 82 /** |
81 * Create is a pointer to a function that creates an audio resource. | 83 * Create is a pointer to a function that creates an audio resource. |
82 * No sound will be heard until StartPlayback() is called. The callback | 84 * No sound will be heard until StartPlayback() is called. The callback |
83 * is called with the buffer address and given user data whenever the | 85 * is called with the buffer address and given user data whenever the |
84 * buffer needs to be filled. From within the callback, you should not | 86 * buffer needs to be filled. From within the callback, you should not |
85 * call PPB_Audio functions. The callback will be called on a different | 87 * call PPB_Audio functions. The callback will be called on a different |
86 * thread than the one which created the interface. For performance-critical | 88 * thread than the one which created the interface. For performance-critical |
87 * applications (i.e. low-latency audio), the callback should avoid blocking | 89 * applications (i.e. low-latency audio), the callback should avoid blocking |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 * callback completes. | 146 * callback completes. |
145 */ | 147 */ |
146 PP_Bool (*StopPlayback)(PP_Resource audio); | 148 PP_Bool (*StopPlayback)(PP_Resource audio); |
147 }; | 149 }; |
148 /** | 150 /** |
149 * @} | 151 * @} |
150 */ | 152 */ |
151 | 153 |
152 #endif /* PPAPI_C_PPB_AUDIO_H_ */ | 154 #endif /* PPAPI_C_PPB_AUDIO_H_ */ |
153 | 155 |
OLD | NEW |