# When I Use FMOD\_NONBLOCKING Flag To Create Steam Sound,Call Releasesound Function cost long time

**URL:** <https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930>\
**Category:** FMOD Engine\
**Created:** [June 30, 2020, 3:12am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930 "2020-06-30T03:12:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![LemonTree](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@LemonTree](https://qa.fmod.com/u/LemonTree)\
**Post date:** [June 30, 2020, 3:12am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/1 "2020-06-30T03:12:09Z")

</div>

Hello Guys  
Use FMOD\_NONBLOCKING Flag To Create Steam Sound Duration 25s,when The Sound Openstate is FMOD\_OPENSTATE\_PLAYING I Call ReleaseSound to destroy it, ReleaseSound process stalling the main thread about 8ms,what can i do to avoid ReleaseSound talling the main thread？why does releasesound take so much time?@cameron-fmod

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 30, 2020, 10:40pm UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/2 "2020-06-30T22:40:43Z")

</div>

If the Stream is `FMOD_OPENSTATE_PLAYING`, the `Sound::release` call must wait until the stream thread has finished its current update pass before the stream can be safely released. To avoid any stall make sure you stop the stream first.

---

<div class="post-metadata">

**Author:** ![LemonTree](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@LemonTree](https://qa.fmod.com/u/LemonTree)\
**Post date:** [July 3, 2020, 7:03am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/3 "2020-07-03T07:03:22Z")

</div>

Hi mathew  
Thank you reply ,I will judge whether the current state of sound is FMOD\_OPENSTATE\_READY If not, stop first and wait for FMOD\_OPENSTATE\_READY Release again, but there is a huge problem of thread consumption. What is the thread doing? Why is it consuming so much? There were about 50 sound in the system at that time.

 ![pref](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/c58465dad827a2953244f76dc9d9b29e65a7d58b.jpeg)

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [July 5, 2020, 11:56pm UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/4 "2020-07-05T23:56:24Z")

</div>

To get some more information about how much CPU is being used by streaming, consider using [System::getCPUUsage](https://fmod.com/resources/documentation-api?version=2.1&page=core-api-system.html#system_getcpuusage). If you have a lot of streaming content, consider loading some as [FMOD\_CREATECOMPRESSEDSAMPLE](https://fmod.com/resources/documentation-api?version=2.1&page=core-api-common.html#fmod_createcompressedsample).

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [July 23, 2020, 11:48pm UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/5 "2020-07-23T23:48:18Z")

</div>

A post was split to a new topic: [Pitch issues with 3D sounds](https://qa.fmod.com/t/pitch-issues-with-3d-sounds/16002)

---

<div class="post-metadata">

**Author:** ![LemonTree](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@LemonTree](https://qa.fmod.com/u/LemonTree)\
**Post date:** [September 17, 2020, 9:31am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/6 "2020-09-17T09:31:26Z")

</div>

I used FMOD\_CREATECOMPRESSEDSAMPLE to create sound, why to cost much CPU at the DSP process. Used the flag to creating sound should be hardware decoding, why use FMOD\_CREATECOMPRESSEDSAMPLE the CPU cost is higher than not used it. The following are the results of my sound test using 50 different FSB Vorbis files, the sounds hadn’t stream sound.  
used FMOD\_CREATECOMPRESSEDSAMPLE:

 ![compresssampleMemory](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/df3a7288b2a1833a49f3279077bf03f80b577a20.png)  
 ![compresssample](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/489acb1c09f2602d0c4b4af12625be4b0ab1eef6.png)  
used FMOD\_CREATESAMPLE  
 ![sample](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/38ce45227e8e9465ceccd1359637b7cfc60b2f0d.png)  
 ![sampleMemory](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/4bbb6535833d8a68eee9a662c4d5e0db17f4f7a9.png)

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [September 21, 2020, 3:31am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/7 "2020-09-21T03:31:53Z")

</div>

When you play sounds as compressed samples your memory is lower because the audio data remains compressed in memory. CPU usage will be higher because chunks of the sound are decoded regularly on the CPU (there is no hardware offload for Vorbis). When you load as sample, the entire file is decoded up front, this uses a lot of memory but has very low runtime CPU cost.

---

<div class="post-metadata">

**Author:** ![LemonTree](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@LemonTree](https://qa.fmod.com/u/LemonTree)\
**Post date:** [September 21, 2020, 7:17am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/8 "2020-09-21T07:17:52Z")

</div>

thank you reply  
if I want to support hardware decoded in Mobile Device (for example Qualcomm \ Kirin \ MTK \ IOS ), what should sound format?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [September 21, 2020, 10:46pm UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/9 "2020-09-21T22:46:40Z")

</div>

There is no guaranteed hardware decoding available on mobile devices, you must use CPU decoding for most of your sounds. To support music playback, most phones can decode a single stream (mono or stereo) of AAC in hardware, that is all.

---

<div class="post-metadata">

**Author:** ![LemonTree](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@LemonTree](https://qa.fmod.com/u/LemonTree)\
**Post date:** [October 30, 2020, 7:03am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/10 "2020-10-30T07:03:26Z")

</div>

hi mathew  
My program ready to increase FMOD Core API version , But I don’t know which version is more stable.my current version is 93157

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [November 1, 2020, 11:17pm UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/11 "2020-11-01T23:17:22Z")

</div>

The most stable version available at the moment is 2.00.13 (build 112159).

---

<div class="post-metadata">

**Author:** ![LemonTree](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@LemonTree](https://qa.fmod.com/u/LemonTree)\
**Post date:** [December 11, 2020, 6:11am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/13 "2020-12-11T06:11:42Z")

</div>

hi mathew  
my program has a crash in sound release,I use FMOD\_System\_CreateSound ,create mode is:FMOD\_OPENMEMORY | FMOD\_NONBLOCKING  
the crash stack:

 ![Fmod_Sound_Release_Crash](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/9625a7e886ee4e94972fc12f56b8cdbcff3c2233.png)

---

<div class="post-metadata">

**Author:** ![tristanjl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tristanjl/32/261_2.png) [@tristanjl](https://qa.fmod.com/u/tristanjl)\
**Post date:** [December 18, 2020, 12:17am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/14 "2020-12-18T00:17:47Z")

</div>

Would you be able to send an example that can reproduce that crash?

Looking through the code, when creating a sound with open memory and non-blocking, the sound should not still have a codec to release when releasing the sound (I would expect that with a streaming sound). So I am not sure what conditions would allow that callstack to occur.

---

<div class="post-metadata">

**Author:** ![LemonTree](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@LemonTree](https://qa.fmod.com/u/LemonTree)\
**Post date:** [January 5, 2021, 6:12am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/15 "2021-01-05T06:12:33Z")

</div>

thank your reply  
The crash probability is very low,so I can’t reproduce.

---

<div class="post-metadata">

**Author:** ![tristanjl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tristanjl/32/261_2.png) [@tristanjl](https://qa.fmod.com/u/tristanjl)\
**Post date:** [January 14, 2021, 4:44am UTC](https://qa.fmod.com/t/when-i-use-fmod-nonblocking-flag-to-create-steam-sound-call-releasesound-function-cost-long-time/15930/16 "2021-01-14T04:44:13Z")

</div>

Well, the callstack seems to indicate that the issue is occuring with an ogg vorbis file. It’s possible that there’s an issue with a specific vorbis file, so it may be worth trying to identify if it is just one file that this is occurring with.
