Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Side by Side Diff: ppapi/c/ppb_audio.h

Issue 22320004: Add a new parameter |latency| to PPB_Audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/api/ppb_audio.idl ('k') | ppapi/cpp/audio.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /* From ppb_audio.idl modified Mon Jul 9 12:03:36 2012. */ 6 /* From ppb_audio.idl modified Thu Aug 01 13:19:46 2013. */
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 #include "ppapi/c/pp_time.h"
16 17
17 #define PPB_AUDIO_INTERFACE_1_0 "PPB_Audio;1.0" 18 #define PPB_AUDIO_INTERFACE_1_0 "PPB_Audio;1.0"
18 #define PPB_AUDIO_INTERFACE PPB_AUDIO_INTERFACE_1_0 19 #define PPB_AUDIO_INTERFACE_1_1 "PPB_Audio;1.1"
20 #define PPB_AUDIO_INTERFACE PPB_AUDIO_INTERFACE_1_1
19 21
20 /** 22 /**
21 * @file 23 * @file
22 * This file defines the <code>PPB_Audio</code> interface, which provides 24 * This file defines the <code>PPB_Audio</code> interface, which provides
23 * realtime stereo audio streaming capabilities. 25 * realtime stereo audio streaming capabilities.
24 */ 26 */
25 27
26 28
27 /** 29 /**
28 * @addtogroup Typedefs 30 * @addtogroup Typedefs
29 * @{ 31 * @{
30 */ 32 */
31 /** 33 /**
32 * <code>PPB_Audio_Callback</code> defines the type of an audio callback 34 * <code>PPB_Audio_Callback</code> defines the type of an audio callback
33 * function used to fill the audio buffer with data. Please see the 35 * function used to fill the audio buffer with data. Please see the
34 * Create() function in the <code>PPB_Audio</code> interface for 36 * Create() function in the <code>PPB_Audio</code> interface for
35 * more details on this callback. 37 * more details on this callback.
38 *
39 * @param[in] sample_buffer A buffer to fill with audio data.
40 * @param[in] buffer_size_in_bytes The size of the buffer in bytes.
41 * @param[in] latency How long before the audio data is to be presented.
42 * @param[inout] user_data An opaque pointer that was passed into
43 * <code>PPB_Audio.Create()</code>.
36 */ 44 */
37 typedef void (*PPB_Audio_Callback)(void* sample_buffer, 45 typedef void (*PPB_Audio_Callback)(void* sample_buffer,
38 uint32_t buffer_size_in_bytes, 46 uint32_t buffer_size_in_bytes,
47 PP_TimeDelta latency,
39 void* user_data); 48 void* user_data);
49
50 typedef void (*PPB_Audio_Callback_1_0)(void* sample_buffer,
51 uint32_t buffer_size_in_bytes,
52 void* user_data);
40 /** 53 /**
41 * @} 54 * @}
42 */ 55 */
43 56
44 /** 57 /**
45 * @addtogroup Interfaces 58 * @addtogroup Interfaces
46 * @{ 59 * @{
47 */ 60 */
48 /** 61 /**
49 * The <code>PPB_Audio</code> interface contains pointers to several functions 62 * The <code>PPB_Audio</code> interface contains pointers to several functions
(...skipping 21 matching lines...) Expand all
71 * PP_AUDIOSAMPLERATE_44100, 4096); 84 * PP_AUDIOSAMPLERATE_44100, 4096);
72 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit( 85 * PP_Resource pp_audio_config = audio_config_interface->CreateStereo16Bit(
73 * pp_instance, PP_AUDIOSAMPLERATE_44100, count); 86 * pp_instance, PP_AUDIOSAMPLERATE_44100, count);
74 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config, 87 * PP_Resource pp_audio = audio_interface->Create(pp_instance, pp_audio_config,
75 * audio_callback, NULL); 88 * audio_callback, NULL);
76 * audio_interface->StartPlayback(pp_audio); 89 * audio_interface->StartPlayback(pp_audio);
77 * 90 *
78 * ...audio_callback() will now be periodically invoked on a separate thread... 91 * ...audio_callback() will now be periodically invoked on a separate thread...
79 * @endcode 92 * @endcode
80 */ 93 */
81 struct PPB_Audio_1_0 { 94 struct PPB_Audio_1_1 {
82 /** 95 /**
83 * Create() creates an audio resource. No sound will be heard until 96 * Create() creates an audio resource. No sound will be heard until
84 * StartPlayback() is called. The callback is called with the buffer address 97 * StartPlayback() is called. The callback is called with the buffer address
85 * and given user data whenever the buffer needs to be filled. From within the 98 * and given user data whenever the buffer needs to be filled. From within the
86 * callback, you should not call <code>PPB_Audio</code> functions. The 99 * callback, you should not call <code>PPB_Audio</code> functions. The
87 * callback will be called on a different thread than the one which created 100 * callback will be called on a different thread than the one which created
88 * the interface. For performance-critical applications (i.e. low-latency 101 * the interface. For performance-critical applications (i.e. low-latency
89 * audio), the callback should avoid blocking or calling functions that can 102 * audio), the callback should avoid blocking or calling functions that can
90 * obtain locks, such as malloc. The layout and the size of the buffer passed 103 * obtain locks, such as malloc. The layout and the size of the buffer passed
91 * to the audio callback will be determined by the device configuration and is 104 * to the audio callback will be determined by the device configuration and is
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 * 163 *
151 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if 164 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if
152 * successful, otherwise <code>PP_FALSE</code>. Also returns 165 * successful, otherwise <code>PP_FALSE</code>. Also returns
153 * <code>PP_TRUE</code> (and is a no-op) if called while playback is already 166 * <code>PP_TRUE</code> (and is a no-op) if called while playback is already
154 * stopped. If a callback is in progress, StopPlayback() will block until the 167 * stopped. If a callback is in progress, StopPlayback() will block until the
155 * callback completes. 168 * callback completes.
156 */ 169 */
157 PP_Bool (*StopPlayback)(PP_Resource audio); 170 PP_Bool (*StopPlayback)(PP_Resource audio);
158 }; 171 };
159 172
160 typedef struct PPB_Audio_1_0 PPB_Audio; 173 typedef struct PPB_Audio_1_1 PPB_Audio;
174
175 struct PPB_Audio_1_0 {
176 PP_Resource (*Create)(PP_Instance instance,
177 PP_Resource config,
178 PPB_Audio_Callback_1_0 audio_callback,
179 void* user_data);
180 PP_Bool (*IsAudio)(PP_Resource resource);
181 PP_Resource (*GetCurrentConfig)(PP_Resource audio);
182 PP_Bool (*StartPlayback)(PP_Resource audio);
183 PP_Bool (*StopPlayback)(PP_Resource audio);
184 };
161 /** 185 /**
162 * @} 186 * @}
163 */ 187 */
164 188
165 #endif /* PPAPI_C_PPB_AUDIO_H_ */ 189 #endif /* PPAPI_C_PPB_AUDIO_H_ */
166 190
OLDNEW
« no previous file with comments | « ppapi/api/ppb_audio.idl ('k') | ppapi/cpp/audio.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698