# Streaming custom (encoded) data for create/playSound

**URL:** https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826
**Category:** FMOD Engine
**Created:** [July 3, 2019, 2:47am UTC](https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826 "2019-07-03T02:47:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)
#### Post date: [July 3, 2019, 2:47am UTC](https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826/1 "2019-07-03T02:47:37Z")

</div>

Hi,  
I would like to feed FMOD continuosly with encoded (i.e.non PCM) data in streaming fashion - with unknown length, and not via a file - and have been testing creating a sound with setFileSystem callbacks set; - but since the callbacks are file oriented and there’s e.g. no file handle - without much success (data is encoded via common codec such as mp3 which FMOD normally accepts).

I’m roughly following asyncio sample in unity c# wrapper, using CREATESTREAM opening flag, empty CREATESOUNDEXINFO; after setting at least some dummy filesize in open callback, FMOD seems to freeze after 1st call to async read callback.

:: the reason I’m trying to do this is to enhance, or rather replace in fact, FMOD networking which is very bare bones esp. wrt secure connections and/or other features such as authentication/redirects/…

Is this viable approach and can this be eventually done this way ?  
If not, is there currently a potential way of doing this with FMOD ?

Thank you !

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [July 9, 2019, 4:19am UTC](https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826/2 "2019-07-09T04:19:43Z")

</div>

Are you setting the cbsize of the [FMOD\_CREATESOUNDEXINFO](https://fmod.com/resources/documentation-api?version=2.0&page=core-api-system.html#fmod_createsoundexinfo)?

> cbsize
> 
> Size of this structure. Must be set to sizeof([FMOD\_CREATESOUNDEXINFO](https://fmod.com/resources/documentation-api?version=2.0&page=core-api-system.html#fmod_createsoundexinfo)) before calling [System::createSound](https://fmod.com/resources/documentation-api?version=2.0&page=core-api-system.html#system_createsound) or [System::createStream](https://fmod.com/resources/documentation-api?version=2.0&page=core-api-system.html#system_createstream).

---

<div class="post-metadata">

### Author: ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)
#### Post date: [July 9, 2019, 1:55pm UTC](https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826/3 "2019-07-09T13:55:30Z")

</div>

yeah, the gist of it is here: [https://pastebin.com/Mh0xvp25](https://pastebin.com/Mh0xvp25)

system is created before, is being updated via Update  
callbacks are just empty (with some logging, removing it/everything didn’t make a difference), except I’m trying to set at least ref parameters and members marked as [w] in ASYNCREADINFO in async/read callbacks

prints these (and only these) 3 lines before it stops:  
=================================== FileOpenCallback decoder ˊo\_oˋ 10000 0 0  
=================================== FileAsyncReadCallback 1075647096 0  
=================================== FileAsyncReadCallback asyncReadInfo 0 8192 2048 0 0 1166073824 1 FMOD.FILE\_ASYNCDONE\_FUNC

was not sure how to proceed / if it makes sense for FMOD to be used like this

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [July 11, 2019, 5:22am UTC](https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826/4 "2019-07-11T05:22:08Z")

</div>

it looks like you aren’t calling done() on your `FMOD_ASYNCREADINFO` anywhere, this is required to signal the async operation is complete. See how asyncio example does this.

---

<div class="post-metadata">

### Author: ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)
#### Post date: [July 15, 2019, 1:44am UTC](https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826/5 "2019-07-15T01:44:56Z")

</div>

I couldn’t make it run in 1.10.14 - was getting null in info parameter in asyncread callback ( so a new read request couldn’t be recorded no matter what )  
Upgrade to latest 2.00 seems to solve this for now ( that callback definition changed in 2.00, too )

[it’s not done yet, but at least it looks like it’s willing to run]

---

<div class="post-metadata">

### Author: ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)
#### Post date: [July 22, 2019, 6:25am UTC](https://qa.fmod.com/t/streaming-custom-encoded-data-for-create-playsound/14826/6 "2019-07-22T06:25:28Z")

</div>

compared to asyncio example it needed bigger stream buffer size for an ogg file, and different mp3 than the one used in the example didn’t work with IGNORETAGS flag as well

but it seems to be running correctly now all things considered

Thank you for the assistance !
