Chromium Code Reviews| 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 | 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 15 matching lines...) Expand all Loading... | |
| 26 * The <code>PPB_Audio</code> interface contains pointers to several functions | 26 * The <code>PPB_Audio</code> interface contains pointers to several functions |
| 27 * for handling audio resources. Please refer to the | 27 * for handling audio resources. Please refer to the |
| 28 * <a href="/chrome/nativeclient/docs/audio.html">Pepper | 28 * <a href="/chrome/nativeclient/docs/audio.html">Pepper |
| 29 * Audio API</a> for information on using this interface. | 29 * Audio API</a> for information on using this interface. |
| 30 * Please see descriptions for each <code>PPB_Audio</code> and | 30 * Please see descriptions for each <code>PPB_Audio</code> and |
| 31 * <code>PPB_AudioConfig</code> function for more details. A C example using | 31 * <code>PPB_AudioConfig</code> function for more details. A C example using |
| 32 * <code>PPB_Audio</code> and <code>PPB_AudioConfig</code> follows. | 32 * <code>PPB_Audio</code> and <code>PPB_AudioConfig</code> follows. |
| 33 * | 33 * |
| 34 * <strong>Example: </strong> | 34 * <strong>Example: </strong> |
| 35 * | 35 * |
| 36 * <code> | 36 * @code |
| 37 * void audio_callback(void* sample_buffer, | 37 * void audio_callback(void* sample_buffer, |
| 38 * uint32_t buffer_size_in_bytes, | 38 * uint32_t buffer_size_in_bytes, |
| 39 * void* user_data) { | 39 * void* user_data) { |
| 40 * ... quickly fill in the buffer with samples and return to caller ... | 40 * ... quickly fill in the buffer with samples and return to caller ... |
| 41 * } | 41 * } |
| 42 * | 42 * |
| 43 * ...Assume the application has cached the audio configuration interface in | 43 * ...Assume the application has cached the audio configuration interface in |
| 44 * <code>audio_config_interface</code> and the audio interface in | 44 * <code>audio_config_interface</code> and the audio interface in |
| 45 * <code>audio_interface</code>... | 45 * <code>audio_interface</code>... |
|
cstefansen
2012/02/21 18:43:37
For my edification: will <code> tags be rendered c
jond
2012/02/24 20:44:27
Those shouldn't be there. Removing them.
On 2012/
| |
| 46 * | 46 * |
| 47 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( | 47 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( |
| 48 * PP_AUDIOSAMPLERATE_44100, 4096); | 48 * PP_AUDIOSAMPLERATE_44100, 4096); |
| 49 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( | 49 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( |
| 50 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); | 50 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); |
| 51 * 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, |
| 52 * audio_callback, NULL); | 52 * audio_callback, NULL); |
| 53 * audio_interface->StartPlayback(pp_audio); | 53 * audio_interface->StartPlayback(pp_audio); |
| 54 * | 54 * |
| 55 * ...audio_callback() will now be periodically invoked on a separate thread... | 55 * ...audio_callback() will now be periodically invoked on a separate thread... |
| 56 * </code> | 56 * @endcode |
| 57 */ | 57 */ |
| 58 interface PPB_Audio { | 58 interface PPB_Audio { |
| 59 /** | 59 /** |
| 60 * Create() creates an audio resource. No sound will be heard until | 60 * Create() creates an audio resource. No sound will be heard until |
| 61 * StartPlayback() is called. The callback is called with the buffer address | 61 * StartPlayback() is called. The callback is called with the buffer address |
| 62 * and given user data whenever the buffer needs to be filled. From within the | 62 * and given user data whenever the buffer needs to be filled. From within the |
| 63 * callback, you should not call <code>PPB_Audio</code> functions. The | 63 * callback, you should not call <code>PPB_Audio</code> functions. The |
| 64 * callback will be called on a different thread than the one which created | 64 * callback will be called on a different thread than the one which created |
| 65 * the interface. For performance-critical applications (i.e. low-latency | 65 * the interface. For performance-critical applications (i.e. low-latency |
| 66 * audio), the callback should avoid blocking or calling functions that can | 66 * audio), the callback should avoid blocking or calling functions that can |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if | 136 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if |
| 137 * successful, otherwise <code>PP_FALSE</code>. Also returns | 137 * successful, otherwise <code>PP_FALSE</code>. Also returns |
| 138 * <code>PP_TRUE</code> (and is a no-op) if called while playback is already | 138 * <code>PP_TRUE</code> (and is a no-op) if called while playback is already |
| 139 * stopped. If a callback is in progress, StopPlayback() will block until the | 139 * stopped. If a callback is in progress, StopPlayback() will block until the |
| 140 * callback completes. | 140 * callback completes. |
| 141 */ | 141 */ |
| 142 PP_Bool StopPlayback( | 142 PP_Bool StopPlayback( |
| 143 [in] PP_Resource audio); | 143 [in] PP_Resource audio); |
| 144 }; | 144 }; |
| 145 | 145 |
| OLD | NEW |