Fatal error with netstream example

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

[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.

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;

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.

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.

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
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

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
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);
…

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.

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?

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.

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?

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