søndag den 5. februar 2012

Audio Unit debug logging

The CAShow(void *) is a nice debugging function which (maybe among other things?) prints out the current state of an Audio Unit graph:

AudioUnitGraph 0xDC39002:
  Member Nodes:
node 1: 'auou' 'rioc' 'appl', instance 0x6d3c490 O I
node 2: 'aufc' 'vari' 'appl', instance 0x6d3d8a0 O I
node 3: 'aufc' 'conv' 'appl', instance 0x6d3eac0 O  
node 4: 'augn' 'afpl' 'appl', instance 0x6d3ec30 O I
  Connections:
node   4 bus   0 => node   2 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node   2 bus   0 => node   1 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved]
  CurrentState:
mLastUpdateError=0, eventsToProcess=F, isRunning=F

Here, I've connected a file player (4) to a Vari Speed (2) and then to a Remote IO (1). The Converter (3) isn't connected to anything.


Another function, which is used in the book Learning Core Audio, is this one:


// generic error handler - if err is nonzero, prints error message and exits program.
static void CheckError(OSStatus error, const char *operation)
{
if (error == noErr) return;
char str[20];
// see if it appears to be a 4-char-code
*(UInt32 *)(str + 1) = CFSwapInt32HostToBig(error);
if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) {
str[0] = str[5] = '\'';
str[6] = '\0';
} else
// no, format it as an integer
sprintf(str, "%d", (int)error);
fprintf(stderr, "Error: %s (%s)\n", operation, str);
    exit(1);
    //    [NSException raise:@"Error" format:@"See above"];
    
    
}

I'd like to make it throw an exception instead of just halting the program, but I haven't found the best way to do it yet. The out-commented one above does throw the exception but I have to Continue a couple of times before I get the error message for some reason, at which point I land somewhere in the main() function ...

Ingen kommentarer:

Send en kommentar