EZAudio icon indicating copy to clipboard operation
EZAudio copied to clipboard

Error: Failed to create ExtAudioFileRef ('wht?')

Open TianGongZhongYu opened this issue 8 years ago • 4 comments

Play local music file: Error: Failed to create ExtAudioFileRef ('wht?')

TianGongZhongYu avatar Feb 01 '16 06:02 TianGongZhongYu

I'm getting this same error: "Error: Failed to create ExtAudioFileRef ('dta?')"

I see from the device logs that the application was killed by jetsam.

Here is an audio file which reliably reproduces the crash: 84b5ba842668ea22a90058a1ec90f4b5b2eeabc98f60d5c6a289bd8e33f08df0.mp3.zip

Any ideas why?

shreyasthiagaraj avatar Apr 29 '16 16:04 shreyasthiagaraj

@TianGongZhongYu is yours a Swift project? Here's a post that may be relevant to this issue:

From an Apple engineer: "This is a bug in the Swift SDK. Swift thinks ExtAudioFileRef is a CoreFoundation-style object that can retained and released, but that is not true. Please file a bug report so we can fix that.

I can't think of any workaround that will convince Swift not to try to retain and release your ExtAudioFileRef objects."

http://www.openradar.me/17211521

shreyasthiagaraj avatar Apr 29 '16 17:04 shreyasthiagaraj

This issue was brought up 5 months ago and is effecting Swift projects including mine. I was able to play the audio file right after i record it, but not after

bennettl avatar May 14 '16 22:05 bennettl

If you look at the dta? code with this lookup site:

https://www.osstatus.com/search/results?platform=all&framework=all&search=dta%3F

You can see that your audio file is corrupt. I ran into this when I tried to read a .wav file that was encoded with the mp3 codec.

Digging further, I found this block in the EZAudioUtilities.m file:

+ (void)checkResult:(OSStatus)result operation:(const char *)operation
{
    if (result == noErr) return;
    char errorString[20];
    // see if it appears to be a 4-char-code
    *(UInt32 *)(errorString + 1) = CFSwapInt32HostToBig(result);
    if (isprint(errorString[1]) && isprint(errorString[2]) && isprint(errorString[3]) && isprint(errorString[4]))
    {
        errorString[0] = errorString[5] = '\'';
        errorString[6] = '\0';
    } else
        // no, format it as an integer
        sprintf(errorString, "%d", (int)result);
    fprintf(stderr, "Error: %s (%s)\n", operation, errorString);
    if (__shouldExitOnCheckResultFail)
    {
        exit(-1);
    }
}

And this warning in EZAudioUtilities.h:

///-----------------------------------------------------------
/// @name Debugging EZAudio
///-----------------------------------------------------------

/**
 Globally sets whether or not the program should exit if a `checkResult:operation:` operation fails. Currently the behavior on EZAudio is to quit if a `checkResult:operation:` fails, but this is not desirable in any production environment. Internally there are a lot of `checkResult:operation:` operations used on all the core classes. This should only ever be set to NO in production environments since a `checkResult:operation:` failing means something breaking has likely happened.
 @param shouldExitOnCheckResultFail A BOOL indicating whether or not the running program should exist due to a `checkResult:operation:` fail.
 */
+ (void)setShouldExitOnCheckResultFail:(BOOL)shouldExitOnCheckResultFail;

//------------------------------------------------------------------------------

So it looks like EZAudio is designed to terminate the app if the audio check fails at any step of the process. You should change the shouldExitOnCheckResultFail param to "NO". Since the framework is no longer being developed it'll be up to you to write code that will handle a failed check.

lastcommit avatar Aug 03 '16 23:08 lastcommit