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 |
(...skipping 11 matching lines...) Expand all Loading... |
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 * |audio_config_interface| and the audio interface in |audio_interface|... |
44 * | 46 * |
45 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( | 47 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( |
46 * PP_AUDIOSAMPLERATE_44100, 4096); | 48 * PP_AUDIOSAMPLERATE_44100, 4096); |
47 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( | 49 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( |
48 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); | 50 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); |
49 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, | 51 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, |
50 * audio_callback, NULL); | 52 * audio_callback, NULL); |
51 * audio_interface->StartPlayback(pp_audio); | 53 * audio_interface->StartPlayback(pp_audio); |
52 * | 54 * |
53 * ...audio_callback() will now be periodically invoked on a seperate thread... | 55 * ...audio_callback() will now be periodically invoked on a seperate thread... |
54 * @endcode | 56 * </code> |
55 */ | 57 */ |
56 interface PPB_Audio { | 58 interface PPB_Audio { |
57 /** | 59 /** |
58 * Create is a pointer to a function that creates an audio resource. | 60 * Create is a pointer to a function that creates an audio resource. |
59 * No sound will be heard until StartPlayback() is called. The callback | 61 * No sound will be heard until StartPlayback() is called. The callback |
60 * is called with the buffer address and given user data whenever the | 62 * is called with the buffer address and given user data whenever the |
61 * buffer needs to be filled. From within the callback, you should not | 63 * buffer needs to be filled. From within the callback, you should not |
62 * call PPB_Audio functions. The callback will be called on a different | 64 * call PPB_Audio functions. The callback will be called on a different |
63 * thread than the one which created the interface. For performance-critical | 65 * thread than the one which created the interface. For performance-critical |
64 * applications (i.e. low-latency audio), the callback should avoid blocking | 66 * applications (i.e. low-latency audio), the callback should avoid blocking |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 * | 127 * |
126 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. | 128 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. |
127 * Also returns PP_TRUE (and is a no-op) if called while playback is already | 129 * Also returns PP_TRUE (and is a no-op) if called while playback is already |
128 * stopped. If a callback is in progress, StopPlayback will block until the | 130 * stopped. If a callback is in progress, StopPlayback will block until the |
129 * callback completes. | 131 * callback completes. |
130 */ | 132 */ |
131 PP_Bool StopPlayback( | 133 PP_Bool StopPlayback( |
132 [in] PP_Resource audio); | 134 [in] PP_Resource audio); |
133 }; | 135 }; |
134 | 136 |
OLD | NEW |