Commits

Dave Dribin  committed 16d875b

Instead of show, implement description using CAShowFile() and funopen()

  • Participants
  • Parent commits 55c298b

Comments (0)

Files changed (2)

File lib/DDAudioUnitGraph.h

 
 - (float) cpuLoad;
 
-- (void) show;
+@end
 
-@end
+NSString * DDCoreAudioShowObjectToString(void * object);

File lib/DDAudioUnitGraph.m

     return (float) cpuLoad;
 }
 
-- (void) show;
+- (NSString *) description
 {
-    CAShow(mGraph);
+    return DDCoreAudioShowObjectToString(mGraph);
 }
-           
 
 @end
+
+static int dataWrite(void * context, const char * buffer, int count)
+{
+    NSMutableData * descriptionData = context;
+    [descriptionData appendBytes:buffer length:count];
+    return 0;
+}
+
+NSString * DDCoreAudioShowObjectToString(void * object)
+{
+    NSMutableData * descriptionData = [NSMutableData data];
+    FILE * dummyFile = fwopen(descriptionData, dataWrite);
+    CAShowFile(object, dummyFile);
+    fclose(dummyFile);
+    
+    NSString * description = [[NSString alloc] initWithData:descriptionData encoding:NSUTF8StringEncoding];
+    return [description autorelease];
+}