haiku-website/static/legacy-docs/bebook/BPushGameSound.html

70 lines
16 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Classes And Methods - The Game Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheGameKit.html" title="The Game Kit" /><link rel="prev" href="BGameSound.html" title="BGameSound" /><link rel="next" href="BSimpleGameSound.html" title="BSimpleGameSound" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BGameSound.html" title="BGameSound"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheGameKit.html" title="The Game Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BSimpleGameSound.html" title="BSimpleGameSound"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Game Kit</div></div><div id="headerB">Prev: <a href="BGameSound.html">BGameSound</a>  Up: <a href="TheGameKit.html">The Game Kit</a>  Next: <a href="BSimpleGameSound.html">BSimpleGameSound</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound"></a>BPushGameSound</h2></div></div></div><a id="id950476" class="indexterm"></a><div class="classheader"><table border="0"><colgroup><col /><col /></colgroup><tbody><tr><td><table width="100%" border="0"><colgroup><col /><col /></colgroup><tbody><tr><td>Derived From:</td><td><a class="link" href="BStreamingGameSound.html" title="BStreamingGameSound">BStreamingGameSound</a></td></tr><tr><td>Mix-in Classes:</td><td></td></tr><tr><td>Declared In:</td><td><code class="filename">game/PushGameSound.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libgame.so</code></td></tr><tr><td>Allocation:</td><td>Constructor only</td></tr></tbody></table></td><td>
<a class="link overview" href="BPushGameSound_Overview.html" title="BPushGameSound">Class Overview</a>
<div class="toc"><ul><li><span class="section"><a href="BPushGameSound.html#BPushGameSound_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BPushGameSound.html#BPushGameSound_MemberFunctions">Member Functions</a></span></li><li><span class="section"><a href="BPushGameSound.html#BPushGameSound_Constants">Constants</a></span></li></ul></div>
</td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_ConstructorDestructor"></a>Constructor and Destructor</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_Constructor"></a>BPushGameSound()</h4></div></div></div><code class="constructorsynopsis cpp"><span class="methodname">BPushGameSound</span>(<span class="methodparam"><span class="type">size_t </span><span class="parameter">inBufferFrameCount</span></span>,<br />               <span class="methodparam"><span class="modifier">const </span><span class="type"><a class="link" href="TheGameKit_DefinedTypes.html#gs_audio_format" title="gs_audio_format">gs_audio_format</a>* </span><span class="parameter">format</span></span>,<br />               <span class="methodparam"><span class="type">size_t </span><span class="parameter">inBufferCount</span><span class="initializer"> = 2</span></span>,<br />               <span class="methodparam"><span class="type">BGameSoundDevice* </span><span class="parameter">device</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code><p>
Prepares the object to play audio pushed by your application.
<code class="parameter">inBufferFrameCount</code> specifies the number of frames each audio buffer
should be able to hold. <code class="parameter">format</code> indicates the audio format that will be
streamed. <code class="parameter">inBufferCount</code> specifies the number of buffers to use, and, as
always, <code class="parameter">device</code> is the sound device to use for playback.
</p><div class="admonition note"><div class="title">Note</div><div class="graphic"><img class="icon" alt="Note" width="32" src="./images/admonitions/Info_32.png" /><div class="text"><p>Currently, <code class="parameter">device</code> must always be
<code class="constant">NULL</code> to indicate that the default
playback device should be used.</p></div></div></div><p>
By default, two audio buffers are used.
</p><p>
Be sure to call <a class="link" href="BPushGameSound.html#BPushGameSound_InitCheck" title="InitCheck()"><code class="methodname">InitCheck()</code></a> before using the <code class="classname">BPushGameSound</code> object.
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_Destructor"></a>~BPushGameSound</h4></div></div></div><code class="destructorsynopsis cpp"><span class="modifier">virtual </span><span class="methodname">~BPushGameSound</span>();</code><p>
Deletes the semaphore used to lock the object.
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_MemberFunctions"></a>Member Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_InitCheck"></a>InitCheck()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">InitCheck</span>() <span class="modifier">const</span>;</code><p>
Returns a <span class="type">status_t</span> indicating whether or not the object was successfully
initialized. A return value of <code class="constant">B_OK</code> means everything's fine; any other
value means an error occurred in the constructor.
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_LockForCyclic"></a><a id="BPushGameSound_UnlockCyclic"></a>
<a id="BPushGameSound_CurrentPosition"></a>
LockForCyclic(), UnlockCyclic(), CurrentPosition()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type"><a class="link" href="BPushGameSound.html#Enums_lock_status" title="lock_status">lock_status</a> </span><span class="methodname">LockForCyclic</span>(<span class="methodparam"><span class="type">void** </span><span class="parameter">outBasePtr</span></span>,<br />                                  <span class="methodparam"><span class="type">size_t* </span><span class="parameter">outSize</span></span>);</code><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">UnlockCyclic</span>();</code><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">size_t </span><span class="methodname">CurrentPosition</span>();</code><p>
<code class="methodname">LockForCyclic()</code> gives you access to the entire sound buffer; audio
playback continues while you have access. Use <code class="methodname">CurrentPosition()</code> to
determine where the playback is currently located in the buffer area, and
be sure to stay well ahead of it. See the
<a class="link" href="BPushGameSound_Overview.html" title="BPushGameSound">overview</a> for a more in-depth
discussion. If <code class="constant">lock_failed</code> is returned, you can't access the audio area,
but if <code class="constant">lock_ok</code> is returned, you can start pushing audio.
</p><p>
On return, <code class="parameter">outBasePtr</code> points to the first byte of the audio buffer area,
and <code class="parameter">outSize</code> indicates the total size of the audio buffer area.
</p><p>
<code class="methodname">UnlockCyclic()</code> releases the audio area.
</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code>.</span></p></td><td><p><code class="methodname">UnlockCyclic()</code> succeeded.</p></td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_LockNextPage"></a><a id="BPushGameSound_UnlockPage"></a>
LockNextPage(), UnlockPage()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type"><a class="link" href="BPushGameSound.html#Enums_lock_status" title="lock_status">lock_status</a> </span><span class="methodname">LockNextPage</span>(<span class="methodparam"><span class="type">void** </span><span class="parameter">outPagePtr</span></span>,<br />                                 <span class="methodparam"><span class="type">size_t* </span><span class="parameter">outPageSize</span></span>);</code><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">UnlockPage</span>(<span class="methodparam"><span class="type">void* </span><span class="parameter">inPagePtr</span></span>);</code><p>
<code class="methodname">LockNextPage()</code> requests access to the next page of the sound buffer. The
<a class="link" href="BPushGameSound.html#Enums_lock_status" title="lock_status"><span class="type">lock_status</span></a>
return value is <code class="constant">lock_ok</code> or <code class="constant">lock_ok_frames_dropped</code> if a valid page has
been returned. If either of these values is returned, you can then write
up to <code class="parameter">outPageSize</code> bytes of audio data into the audio page returned in
<code class="parameter">outPagePtr</code>.
</p><p>
If <code class="constant">lock_failed</code> is returned, you can't access an audio page.
</p><p>
<code class="methodname">UnlockPage()</code> releases the audio page pointed
to by <code class="parameter">inPagePtr</code> and returns
<code class="constant">B_OK</code> if it succeeds in unlocking the page.
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_Constants"></a>Constants</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="Enums_lock_status"></a><a id="lock_failed"></a>
<a id="lock_ok"></a>
<a id="lock_ok_frames_dropped"></a>
lock_status</h4></div></div></div><a id="id951197" class="indexterm"></a><a id="id951204" class="indexterm"></a><a id="id951211" class="indexterm"></a><a id="id951218" class="indexterm"></a><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">lock_failed</code></span></p></td><td><p>Couldn't get the lock; it's not time to update yet.</p></td></tr><tr><td><p><span class="term"><code class="constant">lock_ok</code></span></p></td><td><p>Locked; you can update.</p></td></tr><tr><td><p><span class="term"><code class="constant">lock_ok_frames_dropped</code></span></p></td><td><p>Locked; you can update, but you may have missed
some buffers.</p></td></tr></tbody></table><p>These values are returned by the locking functions in the <code class="classname">BPushGameSound</code>
class (
<a class="link" href="BPushGameSound.html#BPushGameSound_LockNextPage" title="LockNextPage(), UnlockPage()"><code class="methodname">LockNextPage()</code></a> and
<a class="link" href="BPushGameSound.html#BPushGameSound_LockForCyclic" title="LockForCyclic(), UnlockCyclic(), CurrentPosition()"><code class="methodname">LockForCyclic()</code></a>). If either function returns
<code class="constant">lock_failed</code>, there isn't a buffer to be filled; your code is pushing
buffers too fast.</p><p>If <code class="constant">lock_ok</code> is returned, the next buffer is ready. The
<code class="constant">lock_ok_frames_dropped</code> result is received if a buffer is available but
some buffers have been lost; this can happen if you're not pushing fast
enough.</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BGameSound.html">BGameSound</a>  Up: <a href="TheGameKit.html">The Game Kit</a>  Next: <a href="BSimpleGameSound.html">BSimpleGameSound</a> </div><div id="footerB"><div id="footerBL"><a href="BGameSound.html" title="BGameSound"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheGameKit.html" title="The Game Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BSimpleGameSound.html" title="BSimpleGameSound"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>