Data Fields
| PP_Resource(* | CreateStereo16Bit )(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) |
| uint32_t(* | RecommendSampleFrameCount )(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t requested_sample_frame_count) |
| PP_Bool(* | IsAudioConfig )(PP_Resource resource) |
| PP_AudioSampleRate(* | GetSampleRate )(PP_Resource config) |
| uint32_t(* | GetSampleFrameCount )(PP_Resource config) |
| PP_AudioSampleRate(* | RecommendSampleRate )(PP_Instance instance) |
Detailed Description
The PPB_AudioConfig interface contains pointers to several functions for establishing your audio configuration within the browser.
This interface only supports 16-bit stereo output.
Refer to the Audio chapter in the Developer's Guide for information on using this interface.
Field Documentation
| PP_Resource(* PPB_AudioConfig::CreateStereo16Bit)(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) |
CreateStereo16bit() creates a 16 bit audio configuration resource.
The sample_rate should be the result of calling RecommendSampleRate and sample_frame_count should be the result of calling RecommendSampleFrameCount. If the sample frame count or bit rate isn't supported, this function will fail and return a null resource.
A single sample frame on a stereo device means one value for the left channel and one value for the right channel.
Buffer layout for a stereo int16 configuration: int16_t *buffer16; buffer16[0] is the first left channel sample. buffer16[1] is the first right channel sample. buffer16[2] is the second left channel sample. buffer16[3] is the second right channel sample. ... buffer16[2 * (sample_frame_count - 1)] is the last left channel sample. buffer16[2 * (sample_frame_count - 1) + 1] is the last right channel sample. Data will always be in the native endian format of the platform.
- Parameters:
[in] instance A PP_Instanceidentifying one instance of a module.[in] sample_rate A PP_AudioSampleRatewhich is eitherPP_AUDIOSAMPLERATE_44100orPP_AUDIOSAMPLERATE_48000.[in] sample_frame_count A uint32_tframe count returned from theRecommendSampleFrameCountfunction.
- Returns:
- A
PP_Resourcecontaining thePPB_Audio_Configif successful or a null resource if the sample frame count or bit rate are not supported.
| uint32_t(* PPB_AudioConfig::GetSampleFrameCount)(PP_Resource config) |
GetSampleFrameCount() returns the sample frame count for the given PPB_Audio_Config.
- Parameters:
[in] config A PP_Resourcecorresponding to an audio config resource.
- Returns:
- A
uint32_tcontaining sample frame count or 0 if the resource is invalid. Refer to RecommendSampleFrameCount() for more on sample frame counts.
GetSampleRate() returns the sample rate for the given PPB_Audio_Config.
- Parameters:
[in] config A PP_Resourcecorresponding to aPPB_Audio_Config.
- Returns:
- A
PP_AudioSampleRatecontaining sample rate orPP_AUDIOSAMPLERATE_NONEif the resource is invalid.
| PP_Bool(* PPB_AudioConfig::IsAudioConfig)(PP_Resource resource) |
IsAudioConfig() determines if the given resource is a PPB_Audio_Config.
- Parameters:
[in] resource A PP_Resourcecorresponding to an audio config resource.
- Returns:
- A
PP_BoolcontainingPP_TRUEif the given resource is anAudioConfigresource, otherwisePP_FALSE.
| uint32_t(* PPB_AudioConfig::RecommendSampleFrameCount)(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t requested_sample_frame_count) |
RecommendSampleFrameCount() returns the supported sample frame count closest to the requested count.
The sample frame count determines the overall latency of audio. Since one "frame" is always buffered in advance, smaller frame counts will yield lower latency, but higher CPU utilization.
Supported sample frame counts will vary by hardware and system (consider that the local system might be anywhere from a cell phone or a high-end audio workstation). Sample counts less than PP_AUDIOMINSAMPLEFRAMECOUNT and greater than PP_AUDIOMAXSAMPLEFRAMECOUNT are never supported on any system, but values in between aren't necessarily valid. This function will return a supported count closest to the requested frame count.
RecommendSampleFrameCount() result is intended for audio output devices.
- Parameters:
[in] instance [in] sample_rate A PP_AudioSampleRatewhich is eitherPP_AUDIOSAMPLERATE_44100orPP_AUDIOSAMPLERATE_48000.[in] requested_sample_frame_count A uint_32trequested frame count.
- Returns:
- A
uint32_tcontaining the recommended sample frame count if successful.
RecommendSampleRate() returns the native sample rate that the browser is using in the backend.
Applications that use the recommended sample rate will have potentially better latency and fidelity. The return value is intended for audio output devices. If the output sample rate cannot be determined, this function can return PP_AUDIOSAMPLERATE_NONE.
- Parameters:
[in] instance
- Returns:
- A
uint32_tcontaining the recommended sample frame count if successful.
The documentation for this struct was generated from the following file: