# prepareToPlay and releaseResources are not getting called?

**URL:** <https://forum.juce.com/t/preparetoplay-and-releaseresources-are-not-getting-called/5562>\
**Category:** Audio Plugins\
**Created:** [August 15, 2010, 8:31am UTC](https://forum.juce.com/t/preparetoplay-and-releaseresources-are-not-getting-called/5562 "2010-08-15T08:31:53Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![tomswirly](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tomswirly/32/236_2.png) [@tomswirly](https://forum.juce.com/u/tomswirly)\
**Post date:** [August 15, 2010, 7:52pm UTC](https://forum.juce.com/t/preparetoplay-and-releaseresources-are-not-getting-called/5562/5 "2010-08-15T19:52:41Z")

</div>

Well, 😃 IMHO this is a documentation bug!

If one person falls into a trap, it might be their fault, but if two do…

The documentation should say something like:

[list]  
[_]prepareToPlay() is guaranteed to be called at least once before the first call to getNextAudioBlock(), or before the first call to getNextAudioBlock() after releaseResouces() has been called.  
[/_]  
[_]releaseResources() is guaranteed to be called at least once after the last call to getNextAudioBlock() or prepareToPlay().  
[/_]  
[_]There are no other guarantees. Some streams will call prepareToPlay()/releaseResources() repeatedly if they stop and start, others will not. It is possible for releaseResources() to be called when prepareToPlay() has not.[/_][/list]  
Or another way to look at it that I find a little more intuitive:

[list][_]An AudioStream can only have two states, prepared and released,  
[/_]  
[_]An AudioStream must always start and end its life in the released state…  
[/_]  
[_]…but getNextAudioBlock() can only be called if the AudioStream is in the prepared state.  
[/_]  
[_]prepareToPlay() puts the AudioStream into the prepared state; releaseResources() puts it in the released state.  
[/_]  
[_] prepareToPlay() and releaseResources() can be called at any time, in any order.[/_][/list]

---

_[View the full topic](https://forum.juce.com/t/preparetoplay-and-releaseresources-are-not-getting-called/5562)._
