6

A similar question has been asked.. but I wanted to make it more specific to core audio.. as some of us may have noticed core audio has very little room for error.

As the answer to the said question explains, __cxa_throw is a C++ unhandled exception, which can be ignored (this problem seems to be new with Xcode 4.5.1.. I've never seen it before as well)

can we say the same about core audio? What makes me nervous is that it has to do with formatting of the audio.. which a lot of my code depends on:

I'm trying to convert an AAC file unto lPCM..

output format:

// set up the PCM output format for conversion
streamer->PCMoutputFormat.mSampleRate = 44100.0;
streamer->PCMoutputFormat.mFormatID = kAudioFormatLinearPCM;
streamer->PCMoutputFormat.mFormatFlags = kAudioFormatFlagsCanonical;
streamer->PCMoutputFormat.mBytesPerPacket = 4;
streamer->PCMoutputFormat.mFramesPerPacket = 1;
streamer->PCMoutputFormat.mBytesPerFrame = 4;
streamer->PCMoutputFormat.mChannelsPerFrame = 2;
streamer->PCMoutputFormat.mBitsPerChannel = 16;

input format:

mSampleRate = 44100
mFormatID = 1633772320 (AAC)
mFormatFlags = 0
mBytesPerPacket = 0 
mFramesPerPacket = 1024
mBytesPerFrame = 0
mChannelsPerFrame = 2
mBitsPerChannel = 0

instance variables:

game.h

@interface Game : NSObject <GKSessionDelegate>
{
    AudioStreamer *streamer;
}

@property (nonatomic, assign) AudioStreamBasicDescription mediaItemInputFormat;

audioStreamer.h

@interface AudioStreamer : NSObject
{
    @public
        AudioStreamBasicDescription PCMoutputFormat;
        AudioConverterRef audioConverter;
}

setting up converter command in game.m (this is where the __cxa_throw unhandled exception is thrown!)

// set up converter
OSStatus result = AudioConverterNew(&_mediaItemInputFormat,
                                    &streamer->PCMoutputFormat,
                                    &streamer->audioConverter);
Community
  • 1
  • 1
abbood
  • 23,101
  • 16
  • 132
  • 246
  • `__cxa_throw` is a function in gcc's C++ runtime library. It's used by the implementation to throw an exception. It is not an exception, and in particular, it is not an unhandled exception. So what, exactly, is it that you want to ignore? – Pete Becker Nov 27 '12 at 12:56
  • 1
    A call to `__cxa_throw` means that a C++ exception is thrown, not necessarily unhandled. An unhandled exception would cause the program to exit. A handled exception in somebody else's code is no more worrying than a an `if` statement. It's just another way to handle errors. – n. m. could be an AI Nov 27 '12 at 13:00
  • 2
    @PeteBecker basically if add an exception breakpoint in xcode that covers all C++ exceptions.. then the code stops at that point (in the AudioConverterNew call).. so this means that *some* C++ exception was thrown by __cxa_throw.. my question is.. is it safe to ignore this unknown exception? given that i have no objective-c exceptions and the rest of the code seems to work fine.. or should I go and dig into the code and figure out exactly what, why and where this C++ exception is thrown, otherwise my code will be unpredictable.. hope this helps – abbood Nov 27 '12 at 13:52
  • @abbood - if the exception didn't end up terminating the application then some other piece of code handled it. If you trust whatever piece of code that was then there's nothing to worry about. – Pete Becker Nov 27 '12 at 14:45
  • @PeteBecker great man.. if you put that as an answer i'll gladly award you the correct answer – abbood Nov 27 '12 at 14:52

1 Answers1

5

If the exception didn't end up terminating the application then some other piece of code handled it. If you trust whatever piece of code that was then there's nothing to worry about.

Pete Becker
  • 74,985
  • 8
  • 76
  • 165