Pepper_56_C_interfaces
Pepper_56_C_interfaces
|
#include <ppb_audio.h>
Public Attributes | |
PP_Resource(* | Create )(PP_Instance instance, PP_Resource config, PPB_Audio_Callback audio_callback, void *user_data) |
PP_Bool(* | IsAudio )(PP_Resource resource) |
PP_Resource(* | GetCurrentConfig )(PP_Resource audio) |
PP_Bool(* | StartPlayback )(PP_Resource audio) |
PP_Bool(* | StopPlayback )(PP_Resource audio) |
The PPB_Audio
interface contains pointers to several functions for handling audio resources. Refer to the Audio chapter in the Developer's Guide for information on using this interface. Please see descriptions for each PPB_Audio
and PPB_AudioConfig
function for more details. A C example using PPB_Audio
and PPB_AudioConfig
follows.
Example:
PP_Resource(* PPB_Audio_1_1::Create)(PP_Instance instance, PP_Resource config, PPB_Audio_Callback audio_callback, void *user_data) |
Create() creates an audio resource. No sound will be heard until StartPlayback() is called. The callback is called with the buffer address and given user data whenever the buffer needs to be filled. From within the callback, you should not call PPB_Audio
functions. The callback will be called on a different thread than the one which created the interface. For performance-critical applications (i.e. low-latency audio), the callback should avoid blocking or calling functions that can obtain locks, such as malloc. The layout and the size of the buffer passed to the audio callback will be determined by the device configuration and is specified in the AudioConfig
documentation.
[in] | instance | A PP_Instance identifying one instance of a module. |
[in] | config | A PP_Resource corresponding to an audio config resource. |
[in] | audio_callback | A PPB_Audio_Callback callback function that the browser calls when it needs more samples to play. |
[in] | user_data | A pointer to user data used in the callback function. |
PP_Resource
containing the audio resource if successful or 0 if the configuration cannot be honored or the callback is null. PP_Resource(* PPB_Audio_1_1::GetCurrentConfig)(PP_Resource audio) |
GetCurrrentConfig() returns an audio config resource for the given audio resource.
[in] | config | A PP_Resource corresponding to an audio resource. |
PP_Resource
containing the audio config resource if successful. PP_Bool(* PPB_Audio_1_1::IsAudio)(PP_Resource resource) |
IsAudio() determines if the provided resource is an audio resource.
[in] | resource | A PP_Resource corresponding to a generic resource. |
PP_Bool
containing containing PP_TRUE
if the given resource is an Audio resource, otherwise PP_FALSE
. PP_Bool(* PPB_Audio_1_1::StartPlayback)(PP_Resource audio) |
StartPlayback() starts the playback of the audio resource and begins periodically calling the callback.
[in] | config | A PP_Resource corresponding to an audio resource. |
PP_Bool
containing PP_TRUE
if successful, otherwise PP_FALSE
. Also returns PP_TRUE
(and be a no-op) if called while playback is already in progress. PP_Bool(* PPB_Audio_1_1::StopPlayback)(PP_Resource audio) |
StopPlayback() stops the playback of the audio resource.
[in] | config | A PP_Resource corresponding to an audio resource. |
PP_Bool
containing PP_TRUE
if successful, otherwise PP_FALSE
. Also returns PP_TRUE
(and is a no-op) if called while playback is already stopped. If a callback is in progress, StopPlayback() will block until the callback completes.