chromium/native_client_sdk/doc_generated/pepper_stable/c/struct_p_p_b___audio__1__1.html

{{+bindTo:partials.standard_nacl_api}}
<h1>PPB_Audio Struct Reference</h1>
<div id="doxygen-ref">
{{- dummy div to appease doxygen -}}
  <div>
<!-- Generated by Doxygen 1.7.6.1 -->


</div>
<!--header-->
<div class="contents">
<!-- doxytag: class="PPB_Audio" --><h2>
Data Fields</h2><table class="memberdecls">

<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___audio__1__1.html#a9714ecad5eeefae9d5d98c5ea29ac5ce">Create</a> )(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> config, <a class="el" href="group___typedefs.html#ga2ec91970f3cb75769ce631b3b732803e">PPB_Audio_Callback</a> audio_callback, void *user_data)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___audio__1__1.html#af516cae7c19f1439d630fd58049db85b">IsAudio</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___audio__1__1.html#a85615368f68e629eaeef6507e6b5f8b3">GetCurrentConfig</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> audio)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___audio__1__1.html#a764b5ba357af0f781839c4f696615a23">StartPlayback</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> audio)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___audio__1__1.html#a82049c2fbe4f151839fd13f8d10e8395">StopPlayback</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> audio)</td></tr>
</table>
<hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>The <code>PPB_Audio</code> interface contains pointers to several functions for handling audio resources. </p>
<p>Refer to the <a href="/native-client/devguide/coding/audio.html">Audio</a> chapter in the Developer's Guide for information on using this interface. Please see descriptions for each <code>PPB_Audio</code> and <code>PPB_AudioConfig</code> function for more details. A C example using <code>PPB_Audio</code> and <code>PPB_AudioConfig</code> follows.</p>
<p><b>Example: </b></p>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> audio_callback(<span class="keywordtype">void</span>* sample_buffer,
                     uint32_t buffer_size_in_bytes,
                     <span class="keywordtype">void</span>* user_data) {
   ... quickly fill in the buffer with samples and <span class="keywordflow">return</span> to caller ...
  }

 ...Assume the application has cached the audio configuration <span class="keyword">interface </span>in
 audio_config_interface and the audio interface in
 audio_interface...

 uint32_t count = audio_config_interface-&gt;RecommendSampleFrameCount(
     <a class="code" href="group___enums.html#ggaee750c350655f2fb0fe04c04029e0ff8ac6d1056f50ebe082622d3250def41a54">PP_AUDIOSAMPLERATE_44100</a>, 4096);
 <a class="code" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7" title="This typedef represents an opaque handle assigned by the browser to the resource.">PP_Resource</a> pp_audio_config = audio_config_interface-&gt;CreateStereo16Bit(
     pp_instance, <a class="code" href="group___enums.html#ggaee750c350655f2fb0fe04c04029e0ff8ac6d1056f50ebe082622d3250def41a54">PP_AUDIOSAMPLERATE_44100</a>, count);
 <a class="code" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7" title="This typedef represents an opaque handle assigned by the browser to the resource.">PP_Resource</a> pp_audio = audio_interface-&gt;Create(pp_instance, pp_audio_config,
     audio_callback, NULL);
 audio_interface-&gt;StartPlayback(pp_audio);

 ...audio_callback() will now be periodically invoked on a separate thread...
</pre></div> </div><hr /><h2>Field Documentation</h2>
<a class="anchor" id="a9714ecad5eeefae9d5d98c5ea29ac5ce"></a><!-- doxytag: member="PPB_Audio::Create" ref="a9714ecad5eeefae9d5d98c5ea29ac5ce" args=")(PP_Instance instance, PP_Resource config, PPB_Audio_Callback audio_callback, void *user_data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___audio__1__1.html#a9714ecad5eeefae9d5d98c5ea29ac5ce">PPB_Audio::Create</a>)(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> config, <a class="el" href="group___typedefs.html#ga2ec91970f3cb75769ce631b3b732803e">PPB_Audio_Callback</a> audio_callback, void *user_data)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___audio__1__1.html#a9714ecad5eeefae9d5d98c5ea29ac5ce" title="Create() creates an audio resource.">Create()</a> creates an audio resource. </p>
<p>No sound will be heard until <a class="el" href="struct_p_p_b___audio__1__1.html#a764b5ba357af0f781839c4f696615a23" title="StartPlayback() starts the playback of the audio resource and begins periodically calling the callbac...">StartPlayback()</a> 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 <code>PPB_Audio</code> 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 <code>AudioConfig</code> documentation.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">instance</td><td>A <code>PP_Instance</code> identifying one instance of a module. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">config</td><td>A <code>PP_Resource</code> corresponding to an audio config resource. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">audio_callback</td><td>A <code>PPB_Audio_Callback</code> callback function that the browser calls when it needs more samples to play. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">user_data</td><td>A pointer to user data used in the callback function.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Resource</code> containing the audio resource if successful or 0 if the configuration cannot be honored or the callback is null. </dd></dl>
</div>
</div>
<a class="anchor" id="a85615368f68e629eaeef6507e6b5f8b3"></a><!-- doxytag: member="PPB_Audio::GetCurrentConfig" ref="a85615368f68e629eaeef6507e6b5f8b3" args=")(PP_Resource audio)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___audio__1__1.html#a85615368f68e629eaeef6507e6b5f8b3">PPB_Audio::GetCurrentConfig</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> audio)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>GetCurrrentConfig() returns an audio config resource for the given audio resource. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">config</td><td>A <code>PP_Resource</code> corresponding to an audio resource.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Resource</code> containing the audio config resource if successful. </dd></dl>
</div>
</div>
<a class="anchor" id="af516cae7c19f1439d630fd58049db85b"></a><!-- doxytag: member="PPB_Audio::IsAudio" ref="af516cae7c19f1439d630fd58049db85b" args=")(PP_Resource resource)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* <a class="el" href="struct_p_p_b___audio__1__1.html#af516cae7c19f1439d630fd58049db85b">PPB_Audio::IsAudio</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___audio__1__1.html#af516cae7c19f1439d630fd58049db85b" title="IsAudio() determines if the provided resource is an audio resource.">IsAudio()</a> determines if the provided resource is an audio resource. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">resource</td><td>A <code>PP_Resource</code> corresponding to a generic resource.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Bool</code> containing containing <code>PP_TRUE</code> if the given resource is an Audio resource, otherwise <code>PP_FALSE</code>. </dd></dl>
</div>
</div>
<a class="anchor" id="a764b5ba357af0f781839c4f696615a23"></a><!-- doxytag: member="PPB_Audio::StartPlayback" ref="a764b5ba357af0f781839c4f696615a23" args=")(PP_Resource audio)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* <a class="el" href="struct_p_p_b___audio__1__1.html#a764b5ba357af0f781839c4f696615a23">PPB_Audio::StartPlayback</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> audio)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___audio__1__1.html#a764b5ba357af0f781839c4f696615a23" title="StartPlayback() starts the playback of the audio resource and begins periodically calling the callbac...">StartPlayback()</a> starts the playback of the audio resource and begins periodically calling the callback. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">config</td><td>A <code>PP_Resource</code> corresponding to an audio resource.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Bool</code> containing <code>PP_TRUE</code> if successful, otherwise <code>PP_FALSE</code>. Also returns <code>PP_TRUE</code> (and be a no-op) if called while playback is already in progress. </dd></dl>
</div>
</div>
<a class="anchor" id="a82049c2fbe4f151839fd13f8d10e8395"></a><!-- doxytag: member="PPB_Audio::StopPlayback" ref="a82049c2fbe4f151839fd13f8d10e8395" args=")(PP_Resource audio)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* <a class="el" href="struct_p_p_b___audio__1__1.html#a82049c2fbe4f151839fd13f8d10e8395">PPB_Audio::StopPlayback</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> audio)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___audio__1__1.html#a82049c2fbe4f151839fd13f8d10e8395" title="StopPlayback() stops the playback of the audio resource.">StopPlayback()</a> stops the playback of the audio resource. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">config</td><td>A <code>PP_Resource</code> corresponding to an audio resource.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Bool</code> containing <code>PP_TRUE</code> if successful, otherwise <code>PP_FALSE</code>. Also returns <code>PP_TRUE</code> (and is a no-op) if called while playback is already stopped. If a callback is in progress, <a class="el" href="struct_p_p_b___audio__1__1.html#a82049c2fbe4f151839fd13f8d10e8395" title="StopPlayback() stops the playback of the audio resource.">StopPlayback()</a> will block until the callback completes. </dd></dl>
</div>
</div>
<hr />The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="ppb__audio_8h.html">ppb_audio.h</a></li>
</ul>
</div><!-- contents -->
</div>
{{/partials.standard_nacl_api}}