# Fatal error with netstream example

**URL:** <https://qa.fmod.com/t/fatal-error-with-netstream-example/15326>\
**Category:** FMOD Engine\
**Created:** [December 18, 2019, 11:54am UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326 "2019-12-18T11:54:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [December 18, 2019, 11:54am UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/1 "2019-12-18T11:54:48Z")

</div>

I am struggling to get the `net_stream_ios` example to work.

This is using the latest 2.00.06, building from the example in `api/core/examples/xcode32/net_stream.xcodeproject`

Upon first load, the state goes to `FMOD_OPENSTATE_CONNECTING` - ‘Connecting…’, then I get numerous errors about  
`UI API called on a background thread`  
and it fails with `FMOD_ERR_INTERNAL`

So it does one Main loop, then crashes after `sound->getOpenState()`

lldb has this

```auto
[ERR] CodecOggVorbis::openInternal : failed to open as ogg
[ERR] CodecMIDI::openInternal : 'HThd' ID check failed [??rd]
[LOG] SystemI::createSoundInternal : Stream: name='(null)', format=2, channels=2, frequency=44100, lengthbytes=-1, lengthpcm=-1, pcmblocksize=1152, loopstart=0, loopend=0, mode=0x00000000, channelmask=0x00000000, channelorder=0, peakvolume=0.000000.
[ERR] CodecAudioQueue::readInternal : Cannot offline render audio queue. (err: -50)
[LOG] AsyncThread::threadFunc : Finished Asynchronous operation on sound 0x141e08d48

```

and the interface shows:  
`… FMOD error 28 - An error occurred that wasn't supposed to. Contact support.`

Let me know if you need more info.

---

<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:** [December 20, 2019, 4:39am UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/2 "2019-12-20T04:39:07Z")

</div>

Thanks for reporting this, it does look like a bug. You can get around this by setting the `suggestedsoundtype` just before the `createSound` call.

```
exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_MPEG;
```

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [December 20, 2019, 12:05pm UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/3 "2019-12-20T12:05:29Z")

</div>

Great, good to know. That worked for me.

As a side note - I think netstream won’t work with aac, which is disappointing. **What filetypes will it work with?**

I was testing opus for multichannel-encoded sounds which are stream-friendly.

---

<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:** [January 6, 2020, 2:28am UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/4 "2020-01-06T02:28:34Z")

</div>

[https://fmod.com/resources/documentation-api?version=2.0&page=core-guide.html#internet-streaming](https://fmod.com/resources/documentation-api?version=2.0&page=core-guide.html#internet-streaming)

> FMOD streaming supports internet addresses. Supplying http or https in the filename will switch FMOD to streaming using native http, shoutcast or icecast.

Icecast = ogg, shoutcast = mp3 and http can be just about anything.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [January 6, 2020, 4:19pm UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/5 "2020-01-06T16:19:39Z")

</div>

Thank you so much for the support.

Just to clarify (maybe for others first coming to this) there are three types of streaming

1. Streaming a file (not loading an entire file into memory before playing) using createStream or FMOD\_CREATESTREAM
2. Streaming an http-hosted file (does it automatically as far as I can see when you enter ‘http://’ or ‘https://’ in the filename)
3. Streaming live radio / HLS / native http, shoutcast, icecast - illustrated in the net\_stream example

I am having problems with (2) when I use certain filetypes:

**opus**  
opus does not work - returns

```
[ERR] CodecOggVorbis::openInternal : failed to open as ogg, format error.

```

with this file [https://d29bun9tgdx60n.cloudfront.net/media/sounds/frKCgDTp0xlFcN6n/8nopy8nl56pub1b4.opus](https://d29bun9tgdx60n.cloudfront.net/media/sounds/frKCgDTp0xlFcN6n/8nopy8nl56pub1b4.opus)  
and these options:  
`suggestedsoundtype = FMOD_SOUND_TYPE_OPUS`  
`mode = FMOD_2D | FMOD_CREATESTREAM | FMOD_IGNORETAGS`

**ogg**  
ogg works fine with this file [https://d29bun9tgdx60n.cloudfront.net/sounds/kjlkq3f8w7ye/i94njq0jp5de.ogg](https://d29bun9tgdx60n.cloudfront.net/sounds/kjlkq3f8w7ye/i94njq0jp5de.ogg)

**mp4**  
mp4 / aac fails with

```
[ERR] CodecAudioQueue::setupAudioFile : Cannot open audio file. (err: 14)

```

with this file [https://d29bun9tgdx60n.cloudfront.net/sounds/ounozatnw0cj/y7itmg6jhet3.mp4](https://d29bun9tgdx60n.cloudfront.net/sounds/ounozatnw0cj/y7itmg6jhet3.mp4)  
and these options  
`suggestedsoundtype = FMOD_SOUND_TYPE_AUDIOQUEUE`  
`FMOD_2D | FMOD_CREATESTREAM | FMOD_IGNORETAGS`

* * *

I set this up using the play\_sound\_ios example, modifying the Main loop like so:

```
…
result = system->init(32, FMOD_INIT_NORMAL, extradriverdata);
ERRCHECK(result);

result = system->setStreamBufferSize(128*1024, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);

FMOD_CREATESOUNDEXINFO exinfo;
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_OPUS;
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);

result = system->createSound("http://echoesaround.s3.amazonaws.com/test/test-sound.opus", FMOD_2D | FMOD_CREATESTREAM | FMOD_IGNORETAGS, &exinfo, &sound1);
// result = system->createSound("https://d29bun9tgdx60n.cloudfront.net/sounds/kjlkq3f8w7ye/i94njq0jp5de.ogg", FMOD_2D | FMOD_CREATESTREAM | FMOD_IGNORETAGS, &exinfo, &sound1);
// result = system->createSound("https://d29bun9tgdx60n.cloudfront.net/sounds/ounozatnw0cj/y7itmg6jhet3.mp4", FMOD_2D | FMOD_CREATESTREAM | FMOD_IGNORETAGS, &exinfo, &sound1);
ERRCHECK(result);
…
```

---

<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:** [January 7, 2020, 10:07pm UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/6 "2020-01-07T22:07:48Z")

</div>

Development of Opus support is still on-going and is not currently supported.

At this time we cannot support streaming mp4/aac, as the codec will attempt to seek which netstream does not handle at all. The file itself works just fine, but trying to netstream it is the problem.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [January 8, 2020, 8:18am UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/7 "2020-01-08T08:18:14Z")

</div>

Thanks for the response @cameron-fmod

So m4a/mp4 (…AUDIOQUEUE) and opus (…OPUS) are out.

I need something that is

- cross-platform (ogg, opus, m4a/mp4, mp3, aiff, wav)
- ideally supported by apple’s AVAudioPlayer (m4a/mp4, mp3, aiff, wav)
- supported by fmod (ogg, mp3, aiff, wav)
- small file size (ogg, opus, m4a/mp4)
- supports multiple channels (ogg, opus, m4a/mp4, aiff, wav)

The problem with ogg is incompatibility on iOS, and the problem with mp4 is lack of seek support on fmod… (AVAudioPlayer loads netstream m4a/mp4 just fine?).

Do you have any suggestions?

---

<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:** [January 14, 2020, 3:54am UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/8 "2020-01-14T03:54:32Z")

</div>

It doesn’t sound like there is an option that will tick all the boxes for you unfortunately. You will need to compromise one of your constraints depending on what suits you best.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [January 16, 2020, 10:06am UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/9 "2020-01-16T10:06:48Z")

</div>

Thanks anyway @cameron-fmod. Your advice has been very useful. I think we will probably opt for the most ‘open’ one available (ogg). Do you have any idea on the timeline for opus support?

---

<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:** [January 16, 2020, 11:37pm UTC](https://qa.fmod.com/t/fatal-error-with-netstream-example/15326/10 "2020-01-16T23:37:12Z")

</div>

Unfortunately at this point I cannot speculate at a timeline for it.
