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

162 lines
41 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 Media 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="TheMediaKit.html" title="The Media Kit" /><link rel="prev" href="BSmallBuffer.html" title="BSmallBuffer" /><link rel="next" href="BTimeCode.html" title="BTimeCode" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BSmallBuffer.html" title="BSmallBuffer"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheMediaKit.html" title="The Media Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BTimeCode.html" title="BTimeCode"><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 Media Kit</div></div><div id="headerB">Prev: <a href="BSmallBuffer.html">BSmallBuffer</a>  Up: <a href="TheMediaKit.html">The Media Kit</a>  Next: <a href="BTimeCode.html">BTimeCode</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="BSoundPlayer"></a>BSoundPlayer</h2></div></div></div><a id="id1168605" 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></td></tr><tr><td>Mix-in Classes:</td><td></td></tr><tr><td>Declared In:</td><td><code class="filename">media/SoundPlayer.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libmedia.so</code></td></tr><tr><td>Allocation:</td><td>Constructor only</td></tr></tbody></table></td><td>
<a class="link overview" href="BSoundPlayer_Overview.html" title="BSoundPlayer">Class Overview</a>
<div class="toc"><ul><li><span class="section"><a href="BSoundPlayer.html#BSoundPlayer_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BSoundPlayer.html#BSoundPlayer_MemberFunctions">Member Functions</a></span></li><li><span class="section"><a href="BSoundPlayer.html#BSoundPlayer_Constants">Constants</a></span></li><li><span class="section"><a href="BSoundPlayer.html#BSoundPlayer_DefinedTypes">Defined Types</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="BSoundPlayer_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="BSoundPlayer_Constructor"></a>BSoundPlayer()</h4></div></div></div><div class="synopsisgroup">
<code class="constructorsynopsis cpp"><span class="methodname">BTimeSource</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">name</span><span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void </span> (*<span class="parameter">PlayBuffer</span>) (<span class="type">void* </span>, <span class="type">void* </span><span class="parameter">buffer</span>, <span class="type">size_t </span><span class="parameter">size</span>, <span class="type">const media_raw_audio_format&amp; </span><span class="parameter">format</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void </span> (*<span class="parameter">Notifier</span>) (<span class="type">void* </span>, <span class="type">sound_player_notification </span><span class="parameter">what</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void* </span><span class="parameter">cookie</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code>
<code class="constructorsynopsis cpp"><span class="methodname">BTimeSource</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">media_raw_audio_format* </span><span class="parameter">format</span></span>,<br />            <span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">name</span><span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void </span> (*<span class="parameter">PlayBuffer</span>) (<span class="type">void* </span>, <span class="type">void* </span><span class="parameter">buffer</span>, <span class="type">size_t </span><span class="parameter">size</span>, <span class="type">const media_raw_audio_format&amp; </span><span class="parameter">format</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void </span> (*<span class="parameter">Notifier</span>) (<span class="type">void* </span>, <span class="type">sound_player_notification </span><span class="parameter">what</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void* </span><span class="parameter">cookie</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code>
<code class="constructorsynopsis cpp"><span class="methodname">BTimeSource</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">media_node&amp; </span><span class="parameter">toNode</span></span>,<br />            <span class="methodparam"><span class="modifier">const </span><span class="type">media_multi_audio_format* </span><span class="parameter">format</span><span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">name</span><span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="modifier">const </span><span class="type">media_input* </span><span class="parameter">input</span><span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void </span> (*<span class="parameter">PlayBuffer</span>) (<span class="type">void* </span>, <span class="type">void* </span><span class="parameter">buffer</span>, <span class="type">size_t </span><span class="parameter">size</span>, <span class="type">const media_raw_audio_format&amp; </span><span class="parameter">format</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void </span> (*<span class="parameter">Notifier</span>) (<span class="type">void* </span>, <span class="type">sound_player_notification </span><span class="parameter">what</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />            <span class="methodparam"><span class="type">void* </span><span class="parameter">cookie</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code>
</div><p>Initializes the <code class="classname">BSoundPlayer</code> object. The
<code class="parameter">name</code> argument specifies the name to be assigned
to the sound player node (if you specify <code class="constant">NULL</code>, a
generic name will be assigned).</p><p>The <code class="parameter">PlayBuffer</code> argument specifies a pointer to a member function that
processes data and inserts it into buffers for playback<span class="deprecated">;
specify <code class="constant">NULL</code> if
you want to use the BSoundPlayer for playing BSounds</span>. The parameters to
the <code class="parameter">PlayBuffer</code> function are (in order):</p><ul class="itemizedlist"><li><p>Pointer to the cookie.</p></li><li><p>Pointer to the buffer to play.</p></li><li><p>Size of the buffer.</p></li><li><p>Format of the audio data in the buffer.</p></li></ul><p>The <code class="parameter">Notifier</code> parameter specifies a pointer to a member function that
receives notifications when events of interest occur, such as playback
starting or stopping. Specify <code class="constant">NULL</code> to use the default notification
handler. There are three possible notifications:</p><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_STARTED</code> and <code class="constant">B_STOPPED</code></span></p></td><td><p>Indicate that the <code class="classname">BSoundPlayer</code> was started or
stopped. These receive a pointer to the <code class="classname">BSoundPlayer</code> object as an
argument.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_SOUND_DONE</code></span></p></td><td><p>Indicates that a sound has finished playing. In this
case, there are two arguments: the first is a <span class="type">play_id</span> indicating which
sound finished playing, and the other is a boolean which is <code class="constant">true</code> if the
sound played at all, and <code class="constant">false</code> if the sound never played.</p></td></tr></tbody></table><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>If the callback handlers are members of a class, they must be static
members.</p></div></div></div><p>The <code class="parameter">cookie</code> parameter is a pointer that
you can use for your own purposes; it's most useful if you're using a
custom <code class="parameter">PlayBuffer</code> or
<code class="parameter">Notifier</code>.</p><p>The second form of the constructor lets you specify in the
<code class="parameter">format</code> argument the format of the audio that the
<code class="classname">BSoundPlayer</code> will perform. Since
<code class="classname">BSoundPlayer</code> can only play raw sound formats,
this is specified using the
<a class="link" href="TheMediaKit_DefinedTypes.html#media_raw_audio_format" title="media_raw_audio_format"><span class="type">media_raw_audio_format</span></a>
structure.</p><p>The third form of the constructor lets you specify a node through which
the sound should be played, and also uses a
<a class="link" href="TheMediaKit_DefinedTypes.html#media_multi_audio_format" title="media_multi_audio_format"><span class="type">media_multi_audio_format</span></a>
to specify the sound's format, instead of the older
<a class="link" href="TheMediaKit_DefinedTypes.html#media_raw_audio_format" title="media_raw_audio_format"><span class="type">media_raw_audio_format</span></a>.</p><p>You should call
<a class="link" href="BSoundPlayer.html#BSoundPlayer_InitCheck" title="InitCheck()"><code class="methodname">InitCheck()</code></a>
before using your <code class="classname">BSoundPlayer</code> object; this
will let you determine whether or not the object was successfully
constructed. One situation in which
<a class="link" href="BSoundPlayer.html#BSoundPlayer_InitCheck" title="InitCheck()"><code class="methodname">InitCheck()</code></a>
might indicate an error is if the user doesn't have a sound card installed.</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="BSoundPlayer_Destructor"></a>~BSoundPlayer()</h4></div></div></div><code class="destructorsynopsis cpp"><span class="methodname">~BSoundPlayer</span>();</code><p>Stops playback, if sound is playing,
<span class="deprecated">releases references to any BSound objects that
are in use by the BSoundPlayer,</span>
and frees all memory used by the <code class="classname">BSoundPlayer</code>.</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="BSoundPlayer_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="BSoundPlayer_BufferPlayer"></a><a id="BSoundPlayer_SetBufferPlayer"></a>
BufferPlayer(), SetBufferPlayer()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">BufferPlayerFunc </span><span class="methodname">BufferPlayer</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetBufferPlayer</span>(<span class="methodparam"><span class="type">void </span> (*<span class="parameter">PlayBuffer</span>) (<span class="type">void* </span>, <span class="type">void* </span><span class="parameter">buffer</span>, <span class="type">size_t </span><span class="parameter">size</span>, <span class="type">const media_raw_audio_format&amp; </span><span class="parameter">format</span>)</span>);</code><p><code class="methodname">BufferPlayer()</code> returns a pointer to the
current play buffer function, or <code class="constant">NULL</code> if the default
player is in use.</p><p><code class="methodname">SetBufferPlayer()</code> lets you change the play
buffer function.</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="BSoundPlayer_Cookie"></a><a id="BSoundPlayer_SetCookie"></a>
Cookie(), SetCookie()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">void* </span><span class="methodname">Cookie</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type">void </span><span class="methodname">SetCookie</span>(<span class="methodparam"><span class="type">void* </span><span class="parameter">cookie</span></span>);</code><p><code class="methodname">Cookie()</code> returns the current cookie
assigned to the <code class="classname">BSoundPlayer</code>.</p><p><code class="methodname">SetCookie()</code> lets you change the cookie
assigned to the <code class="classname">BSoundPlayer</code>.</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="BSoundPlayer_CurrentTime"></a><a id="BSoundPlayer_PerformanceTime"></a>
CurrentTime(), PerformanceTime()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">bigtime_t </span><span class="methodname">CurrentTime</span>();</code><code class="methodsynopsis cpp"><span class="type">bigtime_t </span><span class="methodname">PerformanceTime</span>();</code><p><code class="methodname">CurrentTime()</code> returns the current
media time, and <code class="methodname">PerformanceTime()</code>
returns the current performance time of the sound player node being used
by the <code class="classname">BSoundPlayer</code>.</p><p><code class="methodname">PerformanceTime()</code> will return
<code class="constant">B_ERROR</code> if the <code class="classname">BSoundPlayer</code>
object hasn't been properly initialized.</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="BSoundPlayer_EventNotifier"></a><a id="BSoundPlayer_SetEventNotifier"></a>
EventNotifier(), SetEventNotifier()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">EventNotifierFunc </span><span class="methodname">EventNotifier</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetNotifier</span>(<span class="methodparam"><span class="type">void </span>(*<span class="parameter">Notifier</span>)(<span class="type">void* </span>, <span class="type">sound_player_notification </span><span class="parameter">what</span>, ...))</span>);</code><p><code class="methodname">EventNotifier()</code> returns a
pointer to the current event notification
handler function, or <code class="constant">NULL</code> if the default player is in
use.</p><p><code class="methodname">SetNotifier()</code> lets you change the event
notification handler function.</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="BSoundPlayer_Format"></a>Format()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">media_raw_audio_format </span><span class="methodname">Format</span>() <span class="modifier">const</span>;</code><p>Returns the <code class="classname">BSoundPlayer</code>'s format. Since
the sound is always a raw sound format, the
<a class="link" href="TheMediaKit_DefinedTypes.html#media_raw_audio_format" title="media_raw_audio_format"><span class="type">media_raw_audio_format</span></a>
structure is used.</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="BSoundPlayer_GetVolumeInfo"></a>GetVolumeInfo()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">EventNotifierFunc </span><span class="methodname">EventNotifier</span>(<span class="methodparam"><span class="type">media_node* </span><span class="parameter">outNode</span></span>,<br />                                <span class="methodparam"><span class="type">int32* </span><span class="parameter">outParameter</span></span>,<br />                                <span class="methodparam"><span class="type">float* </span><span class="parameter">outMinDB</span></span>,<br />                                <span class="methodparam"><span class="type">float* </span><span class="parameter">outMaxDB</span></span>) <span class="modifier">const</span>;</code><p>Returns information about the
<code class="classname">BSoundPlayer</code>'s volume control. Pass pointers to
variables to be filled (<code class="constant">NULL</code> is not permitted),
and on return these values will be set to describe the player as
follows:</p><table class="variablelist parameters"><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="parameter">outNode</code></span></p></td><td><p>Is the node to which the <code class="classname">BSoundPlayer</code>'s audio output will be
directed.</p></td></tr><tr><td><p><span class="term"><code class="parameter">outParameter</code></span></p></td><td><p>Is the parameter ID for the volume control.</p></td></tr><tr><td><p><span class="term"><code class="parameter">outMinDB</code></span></p></td><td><p>Is the minimum volume in decibels.</p></td></tr><tr><td><p><span class="term"><code class="parameter">outMaxDB</code></span></p></td><td><p>Is the maximum volume in decibels.</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="BSoundPlayer_HasData"></a><a id="BSoundPlayer_SetHasData"></a>
HasData(), SetHasData()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">HasData</span>();</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetHasData</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">hasData</span></span>);</code><p><code class="methodname">HasData()</code> returns
<code class="constant">true</code> if there's sound queued for playback, or
<code class="constant">false</code> otherwise.</p><p><code class="methodname">SetHasData()</code> specifies whether or not
there's sound scheduled for playback.</p><p>The purpose of these functions is to optimize the
<code class="classname">BSoundPlayer</code>; if there's no data queued for
playback, the sound player node is told this, which lets it optimize its
performance. If you're using a buffer player function, you must use
<code class="methodname">SetHasData()</code> to indicate that there's data to
play:</p><pre class="programlisting example cpp"><code class="methodname">SetHasData</code>(<code class="constant">true</code>);</pre></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="BSoundPlayer_InitCheck"></a>InitCheck()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">InitCheck</span>();</code><p>Returns the status code resulting from constructing the
<code class="classname">BSoundPlayer</code> object. You should call this after
constructing the object; if the returned value is anything other than
<code class="constant">B_OK</code>, you shouldn't use the 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="BSoundPlayer_Latency"></a>Latency()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">bigtime_t </span><span class="methodname">Latency</span>();</code><p>Returns the <code class="classname">BSoundPlayer</code>'s latency.</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="BSoundPlayer_SetCallbacks"></a>SetCallbacks()</h4></div></div></div><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetCallbacks</span>(<span class="methodparam"><span class="type">void </span> (*<span class="parameter">PlayBuffer</span>) (<span class="type">void* </span>, <span class="type">void* </span><span class="parameter">buffer</span>, <span class="type">size_t </span><span class="parameter">size</span>, <span class="type">const media_raw_audio_format&amp; </span><span class="parameter">format</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />                  <span class="methodparam"><span class="type">void </span> (*<span class="parameter">Notifier</span>) (<span class="type">void* </span>, <span class="type">sound_player_notification </span><span class="parameter">what</span>)<span class="initializer"> = <span class="constant">NULL</span></span></span>,<br />                  <span class="methodparam"><span class="type">void* </span><span class="parameter">cookie</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code><p>Sets the play buffer handler function, the event notification handler
function, and the cookie all in one atomic operation.</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="BSoundPlayer_SetInitError"></a>SetInitError()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetInitError</span>(<span class="methodparam"><span class="type">status_t </span><span class="parameter">inError</span></span>);</code><p>Sets the status code that will be returned by
<a class="link" href="BSoundPlayer.html#BSoundPlayer_InitCheck" title="InitCheck()"><code class="methodname">InitCheck()</code></a>.</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="BSoundPlayer_SetSoundVolume"></a>SetSoundVolume()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">SetSoundVolume</span>(<span class="methodparam"><span class="type">play_id </span><span class="parameter">sound</span></span>,<br />                        <span class="methodparam"><span class="type">float </span><span class="parameter">volume</span></span>);</code><p>Sets the volume (from 0.0 to 1.0) of the specified sound.</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="BSoundPlayer_Start"></a><a id="BSoundPlayer_Stop"></a>
Start(), Stop()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">Start</span>();</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">Stop</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">block</span><span class="initializer"> = <span class="constant">true</span></span></span>,<br />          <span class="methodparam"><span class="type">bool </span><span class="parameter">flush</span><span class="initializer"> = <span class="constant">true</span></span></span>);</code><p><code class="methodname">Start()</code> activates the
<code class="classname">BSoundPlayer</code> by starting the time source and the
sound player node. The <code class="constant">B_STARTED</code> notification is
sent to the <code class="classname">BSoundPlayer</code>'s notification
handler.</p><p><code class="methodname">Stop()</code> deactivates the
<code class="classname">BSoundPlayer</code> by stopping the player node (if
<code class="parameter">block</code> is <code class="constant">true</code>, the
<code class="methodname">Stop()</code> function blocks until the node is
stopped). If <code class="parameter">flush</code> is
<code class="constant">true</code>, the queued sounds are all deleted from
memory.</p><p>While the <code class="classname">BSoundPlayer</code> is running, the
play buffer function (if you've specified one) will be called for each
buffer that passes through the <code class="classname">BSoundPlayer</code>'s
playback node. This hook function can be used to implement code that
performs more advanced playback of sound, such as sound that's generated
on-the-fly, or is filtered before playback.</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>The sound playback was started.</p></td></tr><tr><td><p><span class="term">Other errors.</span></p></td><td><p>As returned by the <code class="classname">BMediaRoster</code>'s
<a class="link" href="BMediaRoster.html#BMediaRoster_StartNode" title="StartNode(), StopNode()"><code class="methodname">StartNode()</code></a>
function.</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="BSoundPlayer_StartPlaying"></a><a id="BSoundPlayer_StopPlaying"></a>
<a id="BSoundPlayer_WaitForSound"></a>
<a id="BSoundPlayer_IsPlaying"></a>
StartPlaying(), StopPlaying(), WaitForSound(), IsPlaying()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">Deprecated</h5></div></div></div><div class="synopsisgroup">
<code class="methodsynopsis cpp"><span class="type">play_id </span><span class="methodname">StartPlaying</span>(<span class="methodparam"><span class="type"><span class="classname">BSound</span>* </span><span class="parameter">sound</span></span>,<br />                     <span class="methodparam"><span class="type">bigtime_t </span><span class="parameter">atTime</span><span class="initializer"> = 0</span></span>);</code>
<code class="methodsynopsis cpp"><span class="type">play_id </span><span class="methodname">StartPlaying</span>(<span class="methodparam"><span class="type"><span class="classname">BSound</span>* </span><span class="parameter">sound</span></span>,<br />                     <span class="methodparam"><span class="type">bigtime_t </span><span class="parameter">atTime</span></span>,<br />                     <span class="methodparam"><span class="type">float </span><span class="parameter">withVolume</span></span>);</code>
</div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">StopPlaying</span>(<span class="methodparam"><span class="type">play_id </span><span class="parameter">id</span></span>);</code><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">WaitForSound</span>(<span class="methodparam"><span class="type">play_id </span><span class="parameter">id</span></span>);</code><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">IsPlaying</span>(<span class="methodparam"><span class="type">play_id </span><span class="parameter">id</span></span>);</code><p class="deprecated"><code class="methodname">StartPlaying()</code>
schedules the specified <code class="classname">BSound</code> to begin playback
at the performance time specified by <code class="parameter">atTime</code>; if
<code class="parameter">atTime</code> is 0, the sound begins playing
immediately (or as soon as <code class="methodname">Start()</code> is called,
if the <code class="classname">BSoundPlayer</code> hasn't been started yet).
The <span class="type">play_id</span> returned by this function is used to identify
the sound later. If it's negative, an error occurred (see the list below
for possible values). The second form of
<code class="methodname">StartPlaying()</code> lets you specify a volume at
which the sound should play.</p><p class="deprecated"><code class="methodname">StopPlaying()</code> stops
playing the sound specified by the given
<code class="parameter">id</code>.</p><p class="deprecated"><code class="methodname">WaitForSound()</code> waits
until the specified sound stops playing.</p><p class="deprecated"><code class="methodname">IsPlaying()</code> returns
<code class="constant">true</code> if the specified sound is playing; otherwise,
it returns <code class="constant">false</code>.</p><table class="variablelist returncodes deprecated"><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p class="deprecated">No error.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_MEDIA_BAD_FORMAT</code></span></p></td><td><p class="deprecated">The audio isn't in a supported format
(<code class="methodname">StartPlaying()</code>).</p></td></tr><tr><td><p><span class="term"><code class="constant">B_BAD_VALUE</code></span></p></td><td><p class="deprecated">The specified id doesn't exist (<code class="methodname">WaitForSound()</code> and
<code class="methodname">IsPlaying()</code>).</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="BSoundPlayer_Volume"></a><a id="BSoundPlayer_SetVolume"></a>
Volume(), SetVolume()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">float </span><span class="methodname">Volume</span>();</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetVolume</span>(<span class="methodparam"><span class="type">float </span><span class="parameter">newVolume</span></span>);</code><p><code class="methodname">Volume()</code> returns the current playback volume.</p><p><code class="methodname">SetVolume()</code> changes the playback volume.</p><p>This volume is the overall volume of all the sounds being played by the
<code class="classname">BSoundPlayer</code>.<span class="deprecated"> To control the volumes of individual sounds, use the
SetSoundVolume() function.</span></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>The volume can range from 0.0 to 1.0, where 0.0 is silent and 1.0 is
maximum loudness.</p></div></div></div><p>If you'd rather handle the volume using decibels instead of the
percentage range, you can use the
<a class="link" href="BSoundPlayer.html#BSoundPlayer_VolumeDB" title="VolumeDB(), SetVolumeDB()"><code class="methodname">VolumeDB()</code></a> and
<a class="link" href="BSoundPlayer.html#BSoundPlayer_SetVolumeDB"><code class="methodname">SetVolumeDB()</code></a>
functions.</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="BSoundPlayer_VolumeDB"></a><a id="BSoundPlayer_SetVolumeDB"></a>
VolumeDB(), SetVolumeDB()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">float </span><span class="methodname">VolumeDB</span>();</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetVolumeDB</span>(<span class="methodparam"><span class="type">float </span><span class="parameter">newVolume</span></span>);</code><p><code class="methodname">VolumeDB()</code> returns the current playback volume in decibels.</p><p><code class="methodname">SetVolumeDB()</code> sets the playback volume, in decibels.</p><p>This volume is the overall volume of all the sounds being played by the
<code class="classname">BSoundPlayer</code>. To control the volumes of individual sounds, use the
<a class="link" href="BSoundPlayer.html#BSoundPlayer_SetSoundVolume" title="SetSoundVolume()"><code class="methodname">SetSoundVolume()</code></a>
function.</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>The possible range of volumes can be obtained by calling
<a class="link" href="BSoundPlayer.html#BSoundPlayer_GetVolumeInfo" title="GetVolumeInfo()"><code class="methodname">GetVolumeInfo()</code></a>.</p></div></div></div><p>If you'd rather handle the volume using a percentage range instead of
decibels, you can use the
<a class="link" href="BSoundPlayer.html#BSoundPlayer_Volume" title="Volume(), SetVolume()"><code class="methodname">Volume()</code></a> and
<a class="link" href="BSoundPlayer.html#BSoundPlayer_SetVolume"><code class="methodname">SetVolume()</code></a>
functions.</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="BSoundPlayer_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_sound_player_notification"></a>sound_player_notification</h4></div></div></div><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_STARTED</code></span></p></td><td><p>The <code class="classname">BSoundPlayer</code> has been started via the
Start()
function.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_STOPPED</code></span></p></td><td><p>The <code class="classname">BSoundPlayer</code>'s
Stop()
function has been called.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_SOUND_DONE</code></span></p></td><td><p>A sound has finished playing.</p></td></tr></tbody></table><p>These constants are passed to event notification handler functions to
indicate what sort of interesting event has occurred.</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="BSoundPlayer_DefinedTypes"></a>Defined Types</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="play_id"></a>play_id</h4></div></div></div><a id="id1171489" class="indexterm"></a><pre class="programlisting definition deprecated c">typedef <span class="type">int32</span> <span class="type">play_id</span>;</pre><p class="deprecated">Identifies a particular sound that's being played by the
<code class="classname">BSoundPlayer</code>;
<a class="link" href="BSoundPlayer.html#BSoundPlayer_StartPlaying" title="StartPlaying(), StopPlaying(), WaitForSound(), IsPlaying()"><code class="methodname">StartPlaying()</code></a>
returns values of this type.</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BSmallBuffer.html">BSmallBuffer</a>  Up: <a href="TheMediaKit.html">The Media Kit</a>  Next: <a href="BTimeCode.html">BTimeCode</a> </div><div id="footerB"><div id="footerBL"><a href="BSmallBuffer.html" title="BSmallBuffer"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheMediaKit.html" title="The Media Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BTimeCode.html" title="BTimeCode"><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>