<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[A5] audio stream empty on completion of playback</title>
		<link>http://www.allegro.cc/forums/view/612639</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 24 May 2013 15:23:10 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey,</p><p>I&#39;m not sure if this is by design or a bug, but I can&#39;t seem to play a stream again once it has finished playing the ogg file. </p><p>This is roughly my code for playing the ogg files which works well:
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><a href="http://www.allegro.cc/manual/ALLEGRO_AUDIO_STREAM"><span class="a">ALLEGRO_AUDIO_STREAM</span></a><span class="k3">*</span> pMusic <span class="k3">=</span> GetMusicResource<span class="k2">(</span> nSoundResourceID <span class="k2">)</span><span class="k2">;</span>
<span class="number">  2</span>
<span class="number">  3</span><span class="k1">if</span><span class="k2">(</span> <span class="k3">!</span> pMusic <span class="k2">)</span>
<span class="number">  4</span><span class="k2">{</span>
<span class="number">  5</span>    ThrowErrorAndQuit<span class="k2">(</span> <span class="s">"Unable to load requested sound resource"</span> <span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span><span class="k2">}</span>
<span class="number">  7</span>
<span class="number">  8</span><a href="http://www.allegro.cc/manual/al_rewind_audio_stream"><span class="a">al_rewind_audio_stream</span></a><span class="k2">(</span> pMusic <span class="k2">)</span><span class="k2">;</span>
<span class="number">  9</span>
<span class="number"> 10</span><a href="http://www.allegro.cc/manual/al_attach_audio_stream_to_mixer"><span class="a">al_attach_audio_stream_to_mixer</span></a><span class="k2">(</span> pMusic, <a href="http://www.allegro.cc/manual/al_get_default_mixer"><span class="a">al_get_default_mixer</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k2">)</span><span class="k2">;</span>
</div></div><p>
I can stop and restart this stream/audio track at any time during playback with a call to:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 1</span><a href="http://www.allegro.cc/manual/al_detach_audio_stream"><span class="a">al_detach_audio_stream</span></a><span class="k2">(</span> pMusic <span class="k2">)</span><span class="k2">;</span>
<span class="number"> 2</span>
<span class="number"> 3</span><span class="c">// call back up to previous code above</span>
</div></div><p>
.. and that works well too.</p><p>However the problem arises when the ogg file finishes playing. When that happens, I can&#39;t start playback again using the ALLEGRO_AUDIO_STREAM object, all I get is silence.</p><p>Is this by design i.e. stream reaches end of file and is now finished? Is there a way to reset the stream to the start of the file when it reaches the end without destroying and recreating the stream?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ionising)</author>
		<pubDate>Thu, 23 May 2013 14:39:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Reading up on ALLEGRO_AUDIO_STREAM, it says</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>you must periodically fill fragments with new audio data. To know when a new fragment is ready to be filled, you can either directly check with al_get_available_audio_stream_fragments, or listen to events from the stream</p></div></div><p>

Maybe this is the cause of it stopping. If you just want to play, stop, and loop an ogg, you can easily do this with ALLEGRO_SAMPLE.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ph03nix)</author>
		<pubDate>Thu, 23 May 2013 16:25:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, if you create the stream yourself that&#39;s correct but if you load it from a file Allegro handles the streaming of the chunks and this works. I think it simply purges the stream on reaching the end of the file or there is a bug in Allegro. Either way, when the stream ends I just destroy it and recreate it when the audio needs to be played again.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ionising)</author>
		<pubDate>Fri, 24 May 2013 15:23:10 +0000</pubDate>
	</item>
</rss>
