CoreAudioFormat doesn't read MP3 file, QuickTime Player does


#1

On OSX 10.10.5, JUCE fails to load some MP3 files like this one (please unpack the ZIP file). I’ve debugged the call to AudioFormatManager::createReaderFor, and I see that it calls CoreAudioFormat::createReaderFor, which returns nullptr. The file plays correctly in Quicklook and QuickTime Player.


#2

Well, not really sure what we could do about that! We’re rather at the mercy of CoreAudio. The only alternative would be for you to use ffmpeg, but that far too huge a dependency for us to embed it in juce.


#3

Okay. Thanks for the reply.


#4

There is something wrong with the code, because this particular MP3 works with 100% of all MP3 players, including core audio. It just doesn’t work with the Juce code. My feeling is that there is something with the code. MP3 reading is the most basic of functions.

The same MP3 works in iTunes, QuickLook and QuickTime, which uses CcoreAudio.

Can you please take another look at it.


#5

Take another look at what…??. We call a CoreAudio function that attempts to decode a file, and it either succeeds or fails.

It’s not clear why it would fail to open a particular file when Apple clearly have a codec that can handle it, but I’ve never seen anything in the API that enables or disables support for formats.


#6

FYI I stepped into the code, and it does just fail in CoreAudio - there’s a call to AudioFileOpenWithCallbacks which just returns the error code ‘kAudioFileUnsupportedFileTypeError’

If there’s some magic that can be used to add extra codecs to CoreAudio then please let us know and we’ll enable it, but this doesn’t seem like something our code is doing wrong.


#7

Thanks…We will figure it out. It’s weird. We may just have to use QuickTime or AVFoundation as a fallback. I definitely don’t want to delve into the confusing world of ffmpeg.


#8

You should avoid QuickTime - that’s deprecated and won’t be an option much longer.

Hmm, I guess it could be that there are newer AVFoundation functions that may provide more codecs than the function we were using (which is part of AudioToolbox). No idea why it wouldn’t all be the same but if you find there is a different function that works, let us know and maybe we could switch to using that.