From eb0c1a84631888e11857efd0079fce8f7e44ee66 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Thu, 14 Jul 2022 02:39:25 -0700 Subject: [PATCH] [Audio Output / Debugging] Fix sample logging Fix the sample logging function that is optionally compiled into debug versions. Signed-off-by: Christopher Snowhill --- Audio/Output/OutputAVFoundation.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Audio/Output/OutputAVFoundation.m b/Audio/Output/OutputAVFoundation.m index 9c7a9aca7..d21b1af87 100644 --- a/Audio/Output/OutputAVFoundation.m +++ b/Audio/Output/OutputAVFoundation.m @@ -254,7 +254,8 @@ static OSStatus eqRenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioA currentPtsLock = [[NSLock alloc] init]; #ifdef OUTPUT_LOG - _logFile = fopen("/tmp/CogAudioLog.raw", "wb"); + NSString *logName = [NSTemporaryDirectory() stringByAppendingPathComponent:@"CogAudioLog.raw"]; + _logFile = fopen([logName UTF8String], "wb"); #endif } @@ -837,6 +838,10 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons CMBlockBufferRef blockBuffer = nil; size_t dataByteSize = samplesRendered * sizeof(float) * streamFormat.mChannelsPerFrame; +#ifdef OUTPUT_LOG + fwrite(samplePtr, 1, dataByteSize, _logFile); +#endif + status = CMBlockBufferCreateWithMemoryBlock(kCFAllocatorDefault, nil, dataByteSize, kCFAllocatorDefault, nil, 0, dataByteSize, kCMBlockBufferAssureMemoryNowFlag, &blockBuffer); if(status != noErr || !blockBuffer) {