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]instanceA PP_Instance identifying one instance of a module.
[in]sample_rateA PP_AudioSampleRate which is either PP_AUDIOSAMPLERATE_44100 or PP_AUDIOSAMPLERATE_48000.
[in]sample_frame_countA uint32_t frame count returned from the RecommendSampleFrameCount function.
Returns:
A PP_Resource containing the PPB_Audio_Config if successful or a null resource if the sample frame count or bit rate are not supported.

GetSampleFrameCount() returns the sample frame count for the given PPB_Audio_Config.

Parameters:
[in]configA PP_Resource corresponding to an audio config resource.
Returns:
A uint32_t containing 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]configA PP_Resource corresponding to a PPB_Audio_Config.
Returns:
A PP_AudioSampleRate containing sample rate or PP_AUDIOSAMPLERATE_NONE if the resource is invalid.

IsAudioConfig() determines if the given resource is a PPB_Audio_Config.

Parameters:
[in]resourceA PP_Resource corresponding to an audio config resource.
Returns:
A PP_Bool containing PP_TRUE if the given resource is an AudioConfig resource, otherwise PP_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_rateA PP_AudioSampleRate which is either PP_AUDIOSAMPLERATE_44100 or PP_AUDIOSAMPLERATE_48000.
[in]requested_sample_frame_countA uint_32t requested frame count.
Returns:
A uint32_t containing 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_t containing the recommended sample frame count if successful.

The documentation for this struct was generated from the following file:
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.