64 lines
22 KiB
HTML
64 lines
22 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>SFML - Simple and Fast Multimedia Library</title>
|
|
<meta http-equiv="Content-Type" content="text/html;"/>
|
|
<meta charset="utf-8"/>
|
|
<!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
|
|
<link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="banner-container">
|
|
<div id="banner">
|
|
<span id="sfml">SFML 2.5.1</span>
|
|
</div>
|
|
</div>
|
|
<div id="content">
|
|
<!-- Generated by Doxygen 1.8.14 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
<li><a href="globals.html"><span>File Members</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_c0a853e81d6f1c1f0a3eb7a27dc24256.html">SFML</a></li><li class="navelem"><a class="el" href="dir_dd49ddb3ba8035e4a328f8c5f31cda7e.html">Audio</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">SoundStream.hpp</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">//</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment">// SFML - Simple and Fast Multimedia Library</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment">// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment">//</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment">// This software is provided 'as-is', without any express or implied warranty.</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment">// In no event will the authors be held liable for any damages arising from the use of this software.</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment">//</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">// Permission is granted to anyone to use this software for any purpose,</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment">// including commercial applications, and to alter it and redistribute it freely,</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment">// subject to the following restrictions:</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">//</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment">// 1. The origin of this software must not be misrepresented;</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment">// you must not claim that you wrote the original software.</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment">// If you use this software in a product, an acknowledgment</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment">// in the product documentation would be appreciated but is not required.</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">//</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment">// 2. Altered source versions must be plainly marked as such,</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment">// and must not be misrepresented as being the original software.</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment">//</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="comment">// 3. This notice may not be removed or altered from any source distribution.</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="comment">//</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment"></span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#ifndef SFML_SOUNDSTREAM_HPP</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#define SFML_SOUNDSTREAM_HPP</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> </div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="comment">// Headers</span></div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="comment"></span><span class="preprocessor">#include <SFML/Audio/Export.hpp></span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#include <SFML/Audio/SoundSource.hpp></span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="preprocessor">#include <SFML/System/Thread.hpp></span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include <SFML/System/Time.hpp></span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="preprocessor">#include <SFML/System/Mutex.hpp></span></div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="preprocessor">#include <cstdlib></span></div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> </div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> </div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="keyword">namespace </span><a class="code" href="namespacesf.html">sf</a></div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span> {</div><div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="classsf_1_1SoundStream.html"> 45</a></span> <span class="keyword">class </span>SFML_AUDIO_API <a class="code" href="classsf_1_1SoundStream.html">SoundStream</a> : <span class="keyword">public</span> <a class="code" href="classsf_1_1SoundSource.html">SoundSource</a></div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> {</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="keyword">public</span>:</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> </div><div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="structsf_1_1SoundStream_1_1Chunk.html"> 53</a></span>  <span class="keyword">struct </span><a class="code" href="structsf_1_1SoundStream_1_1Chunk.html">Chunk</a></div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  {</div><div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="structsf_1_1SoundStream_1_1Chunk.html#aa3b84d69adbe663a17a7671626076df4"> 55</a></span>  <span class="keyword">const</span> Int16* <a class="code" href="structsf_1_1SoundStream_1_1Chunk.html#aa3b84d69adbe663a17a7671626076df4">samples</a>; </div><div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="structsf_1_1SoundStream_1_1Chunk.html#af47f5d94012acf8b11f056ba77aff97a"> 56</a></span>  std::size_t <a class="code" href="structsf_1_1SoundStream_1_1Chunk.html#af47f5d94012acf8b11f056ba77aff97a">sampleCount</a>; </div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  };</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="keyword">virtual</span> ~<a class="code" href="classsf_1_1SoundStream.html">SoundStream</a>();</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> </div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <span class="keywordtype">void</span> play();</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span> </div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  <span class="keywordtype">void</span> pause();</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span> </div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  <span class="keywordtype">void</span> stop();</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span> </div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getChannelCount() <span class="keyword">const</span>;</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span> </div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getSampleRate() <span class="keyword">const</span>;</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> </div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  Status getStatus() <span class="keyword">const</span>;</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span> </div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <span class="keywordtype">void</span> setPlayingOffset(<a class="code" href="classsf_1_1Time.html">Time</a> timeOffset);</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span> </div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  <a class="code" href="classsf_1_1Time.html">Time</a> getPlayingOffset() <span class="keyword">const</span>;</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span> </div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  <span class="keywordtype">void</span> setLoop(<span class="keywordtype">bool</span> loop);</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span> </div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="keywordtype">bool</span> getLoop() <span class="keyword">const</span>;</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span> </div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span> <span class="keyword">protected</span>:</div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span> </div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  <span class="keyword">enum</span></div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  {</div><div class="line"><a name="l00185"></a><span class="lineno"><a class="line" href="classsf_1_1SoundStream.html#a7707214e7cd4ffcf1c123e7bcab4092aa2f2c638731fdff0d6fe4e3e82b6f6146"> 185</a></span>  NoLoop = -1 </div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  };</div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span> </div><div class="line"><a name="l00194"></a><span class="lineno"> 194</span>  <a class="code" href="classsf_1_1SoundStream.html">SoundStream</a>();</div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span> </div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <span class="keywordtype">void</span> initialize(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channelCount, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate);</div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span> </div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  <span class="keyword">virtual</span> <span class="keywordtype">bool</span> onGetData(Chunk& data) = 0;</div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span> </div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> onSeek(<a class="code" href="classsf_1_1Time.html">Time</a> timeOffset) = 0;</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span> </div><div class="line"><a name="l00252"></a><span class="lineno"> 252</span>  <span class="keyword">virtual</span> Int64 onLoop();</div><div class="line"><a name="l00253"></a><span class="lineno"> 253</span> </div><div class="line"><a name="l00254"></a><span class="lineno"> 254</span> <span class="keyword">private</span>:</div><div class="line"><a name="l00255"></a><span class="lineno"> 255</span> </div><div class="line"><a name="l00263"></a><span class="lineno"> 263</span>  <span class="keywordtype">void</span> streamData();</div><div class="line"><a name="l00264"></a><span class="lineno"> 264</span> </div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span>  <span class="keywordtype">bool</span> fillAndPushBuffer(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bufferNum, <span class="keywordtype">bool</span> immediateLoop = <span class="keyword">false</span>);</div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span> </div><div class="line"><a name="l00290"></a><span class="lineno"> 290</span>  <span class="keywordtype">bool</span> fillQueue();</div><div class="line"><a name="l00291"></a><span class="lineno"> 291</span> </div><div class="line"><a name="l00298"></a><span class="lineno"> 298</span>  <span class="keywordtype">void</span> clearQueue();</div><div class="line"><a name="l00299"></a><span class="lineno"> 299</span> </div><div class="line"><a name="l00300"></a><span class="lineno"> 300</span>  <span class="keyword">enum</span></div><div class="line"><a name="l00301"></a><span class="lineno"> 301</span>  {</div><div class="line"><a name="l00302"></a><span class="lineno"> 302</span>  BufferCount = 3, </div><div class="line"><a name="l00303"></a><span class="lineno"> 303</span>  BufferRetries = 2 </div><div class="line"><a name="l00304"></a><span class="lineno"> 304</span>  };</div><div class="line"><a name="l00305"></a><span class="lineno"> 305</span> </div><div class="line"><a name="l00307"></a><span class="lineno"> 307</span>  <span class="comment">// Member data</span></div><div class="line"><a name="l00309"></a><span class="lineno"> 309</span> <span class="comment"></span> Thread m_thread; </div><div class="line"><a name="l00310"></a><span class="lineno"> 310</span>  <span class="keyword">mutable</span> Mutex m_threadMutex; </div><div class="line"><a name="l00311"></a><span class="lineno"> 311</span>  Status m_threadStartState; </div><div class="line"><a name="l00312"></a><span class="lineno"> 312</span>  <span class="keywordtype">bool</span> m_isStreaming; </div><div class="line"><a name="l00313"></a><span class="lineno"> 313</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_buffers[BufferCount]; </div><div class="line"><a name="l00314"></a><span class="lineno"> 314</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_channelCount; </div><div class="line"><a name="l00315"></a><span class="lineno"> 315</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_sampleRate; </div><div class="line"><a name="l00316"></a><span class="lineno"> 316</span>  Uint32 m_format; </div><div class="line"><a name="l00317"></a><span class="lineno"> 317</span>  <span class="keywordtype">bool</span> m_loop; </div><div class="line"><a name="l00318"></a><span class="lineno"> 318</span>  Uint64 m_samplesProcessed; </div><div class="line"><a name="l00319"></a><span class="lineno"> 319</span>  Int64 m_bufferSeeks[BufferCount]; </div><div class="line"><a name="l00320"></a><span class="lineno"> 320</span> };</div><div class="line"><a name="l00321"></a><span class="lineno"> 321</span> </div><div class="line"><a name="l00322"></a><span class="lineno"> 322</span> } <span class="comment">// namespace sf</span></div><div class="line"><a name="l00323"></a><span class="lineno"> 323</span> </div><div class="line"><a name="l00324"></a><span class="lineno"> 324</span> </div><div class="line"><a name="l00325"></a><span class="lineno"> 325</span> <span class="preprocessor">#endif // SFML_SOUNDSTREAM_HPP</span></div><div class="line"><a name="l00326"></a><span class="lineno"> 326</span> </div><div class="line"><a name="l00327"></a><span class="lineno"> 327</span> </div><div class="ttc" id="structsf_1_1SoundStream_1_1Chunk_html"><div class="ttname"><a href="structsf_1_1SoundStream_1_1Chunk.html">sf::SoundStream::Chunk</a></div><div class="ttdoc">Structure defining a chunk of audio data to stream. </div><div class="ttdef"><b>Definition:</b> <a href="SoundStream_8hpp_source.html#l00053">SoundStream.hpp:53</a></div></div>
|
|
<div class="ttc" id="classsf_1_1Time_html"><div class="ttname"><a href="classsf_1_1Time.html">sf::Time</a></div><div class="ttdoc">Represents a time value. </div><div class="ttdef"><b>Definition:</b> <a href="Time_8hpp_source.html#l00040">Time.hpp:40</a></div></div>
|
|
<div class="ttc" id="structsf_1_1SoundStream_1_1Chunk_html_aa3b84d69adbe663a17a7671626076df4"><div class="ttname"><a href="structsf_1_1SoundStream_1_1Chunk.html#aa3b84d69adbe663a17a7671626076df4">sf::SoundStream::Chunk::samples</a></div><div class="ttdeci">const Int16 * samples</div><div class="ttdoc">Pointer to the audio samples. </div><div class="ttdef"><b>Definition:</b> <a href="SoundStream_8hpp_source.html#l00055">SoundStream.hpp:55</a></div></div>
|
|
<div class="ttc" id="classsf_1_1SoundStream_html"><div class="ttname"><a href="classsf_1_1SoundStream.html">sf::SoundStream</a></div><div class="ttdoc">Abstract base class for streamed audio sources. </div><div class="ttdef"><b>Definition:</b> <a href="SoundStream_8hpp_source.html#l00045">SoundStream.hpp:45</a></div></div>
|
|
<div class="ttc" id="structsf_1_1SoundStream_1_1Chunk_html_af47f5d94012acf8b11f056ba77aff97a"><div class="ttname"><a href="structsf_1_1SoundStream_1_1Chunk.html#af47f5d94012acf8b11f056ba77aff97a">sf::SoundStream::Chunk::sampleCount</a></div><div class="ttdeci">std::size_t sampleCount</div><div class="ttdoc">Number of samples pointed by Samples. </div><div class="ttdef"><b>Definition:</b> <a href="SoundStream_8hpp_source.html#l00056">SoundStream.hpp:56</a></div></div>
|
|
<div class="ttc" id="namespacesf_html"><div class="ttname"><a href="namespacesf.html">sf</a></div><div class="ttdef"><b>Definition:</b> <a href="AlResource_8hpp_source.html#l00034">AlResource.hpp:34</a></div></div>
|
|
<div class="ttc" id="classsf_1_1SoundSource_html"><div class="ttname"><a href="classsf_1_1SoundSource.html">sf::SoundSource</a></div><div class="ttdoc">Base class defining a sound&#39;s properties. </div><div class="ttdef"><b>Definition:</b> <a href="SoundSource_8hpp_source.html#l00042">SoundSource.hpp:42</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
</div>
|
|
<div id="footer-container">
|
|
<div id="footer">
|
|
SFML is licensed under the terms and conditions of the <a href="https://www.sfml-dev.org/license.php">zlib/png license</a>.<br>
|
|
Copyright © Laurent Gomila ::
|
|
Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> ::
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|