| 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 |
| 6 /* From ppb_audio.idl modified Sat Jul 16 16:50:26 2011. */ |
| 7 |
| 5 #ifndef PPAPI_C_PPB_AUDIO_H_ | 8 #ifndef PPAPI_C_PPB_AUDIO_H_ |
| 6 #define PPAPI_C_PPB_AUDIO_H_ | 9 #define PPAPI_C_PPB_AUDIO_H_ |
| 7 | 10 |
| 8 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
| 13 #include "ppapi/c/pp_macros.h" |
| 10 #include "ppapi/c/pp_resource.h" | 14 #include "ppapi/c/pp_resource.h" |
| 11 #include "ppapi/c/pp_stdint.h" | 15 #include "ppapi/c/pp_stdint.h" |
| 12 | 16 |
| 13 #define PPB_AUDIO_INTERFACE_0_6 "PPB_Audio;0.6" | |
| 14 #define PPB_AUDIO_INTERFACE_1_0 "PPB_Audio;1.0" | |
| 15 #define PPB_AUDIO_INTERFACE PPB_AUDIO_INTERFACE_1_0 | |
| 16 | |
| 17 /** | 17 /** |
| 18 * @file | 18 * @file |
| 19 * This file defines the <code>PPB_Audio</code> interface, which provides | 19 * This file defines the <code>PPB_Audio</code> interface, which provides |
| 20 * realtime stereo audio streaming capabilities. | 20 * realtime stereo audio streaming capabilities. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 |
| 23 /** | 24 /** |
| 24 * @addtogroup Typedefs | 25 * @addtogroup Typedefs |
| 25 * @{ | 26 * @{ |
| 26 */ | 27 */ |
| 27 | |
| 28 /** | 28 /** |
| 29 * <code>PPB_Audio_Callback</code> defines the type of an audio callback | 29 * <code>PPB_Audio_Callback</code> defines the type of an audio callback |
| 30 * function used to fill the audio buffer with data. Please see the | 30 * function used to fill the audio buffer with data. Please see the |
| 31 * <code>Create()</code> function in the <code>PPB_Audio</code> interface for | 31 * <code>Create()</code> function in the <code>PPB_Audio</code> interface for |
| 32 * more details on this callback. | 32 * more details on this callback. |
| 33 */ | 33 */ |
| 34 typedef void (*PPB_Audio_Callback)(void* sample_buffer, | 34 typedef void (*PPB_Audio_Callback)(void* sample_buffer, |
| 35 uint32_t buffer_size_in_bytes, | 35 uint32_t buffer_size_in_bytes, |
| 36 void* user_data); | 36 void* user_data); |
| 37 /** | 37 /** |
| (...skipping 26 matching lines...) Expand all Loading... |
| 64 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( | 64 * uint32_t count = audio_config_interface->RecommendSampleFrameCount( |
| 65 * PP_AUDIOSAMPLERATE_44100, 4096); | 65 * PP_AUDIOSAMPLERATE_44100, 4096); |
| 66 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( | 66 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( |
| 67 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); | 67 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); |
| 68 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, | 68 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, |
| 69 * audio_callback, NULL); | 69 * audio_callback, NULL); |
| 70 * audio_interface->StartPlayback(pp_audio); | 70 * audio_interface->StartPlayback(pp_audio); |
| 71 * | 71 * |
| 72 * ...audio_callback() will now be periodically invoked on a seperate thread... | 72 * ...audio_callback() will now be periodically invoked on a seperate thread... |
| 73 */ | 73 */ |
| 74 #define PPB_AUDIO_INTERFACE_0_6 "PPB_Audio;0.6" |
| 75 #define PPB_AUDIO_INTERFACE_1_0 "PPB_Audio;1.0" |
| 76 #define PPB_AUDIO_INTERFACE PPB_AUDIO_INTERFACE_1_0 |
| 77 |
| 74 struct PPB_Audio { | 78 struct PPB_Audio { |
| 75 /** | 79 /** |
| 76 * Create is a pointer to a function that creates an audio resource. | 80 * Create is a pointer to a function that creates an audio resource. |
| 77 * No sound will be heard until StartPlayback() is called. The callback | 81 * No sound will be heard until StartPlayback() is called. The callback |
| 78 * is called with the buffer address and given user data whenever the | 82 * is called with the buffer address and given user data whenever the |
| 79 * buffer needs to be filled. From within the callback, you should not | 83 * buffer needs to be filled. From within the callback, you should not |
| 80 * call PPB_Audio functions. The callback will be called on a different | 84 * call PPB_Audio functions. The callback will be called on a different |
| 81 * thread than the one which created the interface. For performance-critical | 85 * thread than the one which created the interface. For performance-critical |
| 82 * applications (i.e. low-latency audio), the callback should avoid blocking | 86 * applications (i.e. low-latency audio), the callback should avoid blocking |
| 83 * or calling functions that can obtain locks, such as malloc. The layout and | 87 * or calling functions that can obtain locks, such as malloc. The layout and |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 /** | 104 /** |
| 101 * IsAudio is a pointer to a function that determines if the given | 105 * IsAudio is a pointer to a function that determines if the given |
| 102 * resource is an audio resource. | 106 * resource is an audio resource. |
| 103 * | 107 * |
| 104 * @param[in] resource A PP_Resource containing a resource. | 108 * @param[in] resource A PP_Resource containing a resource. |
| 105 * | 109 * |
| 106 * @return A PP_BOOL containing containing PP_TRUE if the given resource is | 110 * @return A PP_BOOL containing containing PP_TRUE if the given resource is |
| 107 * an Audio resource, otherwise PP_FALSE. | 111 * an Audio resource, otherwise PP_FALSE. |
| 108 */ | 112 */ |
| 109 PP_Bool (*IsAudio)(PP_Resource resource); | 113 PP_Bool (*IsAudio)(PP_Resource resource); |
| 110 | |
| 111 /** | 114 /** |
| 112 * GetCurrrentConfig is a pointer to a function that returns an audio config | 115 * GetCurrrentConfig is a pointer to a function that returns an audio config |
| 113 * resource for the given audio resource. | 116 * resource for the given audio resource. |
| 114 * | 117 * |
| 115 * @param[in] config A PP_Resource containing the audio resource. | 118 * @param[in] config A PP_Resource containing the audio resource. |
| 116 * | 119 * |
| 117 * @return A PP_Resource containing the audio config resource if successful. | 120 * @return A PP_Resource containing the audio config resource if successful. |
| 118 */ | 121 */ |
| 119 PP_Resource (*GetCurrentConfig)(PP_Resource audio); | 122 PP_Resource (*GetCurrentConfig)(PP_Resource audio); |
| 120 | |
| 121 /** | 123 /** |
| 122 * StartPlayback is a pointer to a function that starts the playback of | 124 * StartPlayback is a pointer to a function that starts the playback of |
| 123 * the audio resource and begins periodically calling the callback. | 125 * the audio resource and begins periodically calling the callback. |
| 124 * | 126 * |
| 125 * @param[in] config A PP_Resource containing the audio resource. | 127 * @param[in] config A PP_Resource containing the audio resource. |
| 126 * | 128 * |
| 127 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. | 129 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. |
| 128 * Also returns PP_TRUE (and be a no-op) if called while playback is already | 130 * Also returns PP_TRUE (and be a no-op) if called while playback is already |
| 129 * in progress. | 131 * in progress. |
| 130 */ | 132 */ |
| 131 PP_Bool (*StartPlayback)(PP_Resource audio); | 133 PP_Bool (*StartPlayback)(PP_Resource audio); |
| 132 | |
| 133 /** | 134 /** |
| 134 * StopPlayback is a pointer to a function that stops the playback of | 135 * StopPlayback is a pointer to a function that stops the playback of |
| 135 * the audio resource. | 136 * the audio resource. |
| 136 * | 137 * |
| 137 * @param[in] config A PP_Resource containing the audio resource. | 138 * @param[in] config A PP_Resource containing the audio resource. |
| 138 * | 139 * |
| 139 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. | 140 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. |
| 140 * Also returns PP_TRUE (and is a no-op) if called while playback is already | 141 * Also returns PP_TRUE (and is a no-op) if called while playback is already |
| 141 * stopped. If a callback is in progress, StopPlayback will block until the | 142 * stopped. If a callback is in progress, StopPlayback will block until the |
| 142 * callback completes. | 143 * callback completes. |
| 143 */ | 144 */ |
| 144 PP_Bool (*StopPlayback)(PP_Resource audio); | 145 PP_Bool (*StopPlayback)(PP_Resource audio); |
| 145 }; | 146 }; |
| 146 /** | 147 /** |
| 147 * @} | 148 * @} |
| 148 */ | 149 */ |
| 149 | 150 |
| 150 #endif /* PPAPI_C_PPB_AUDIO_H_ */ | 151 #endif /* PPAPI_C_PPB_AUDIO_H_ */ |
| 151 | 152 |
| OLD | NEW |