Core Audio output: Add debugging code for logging output to disk, only enabled at compile time as necessary
parent
5c17dc9207
commit
31e5cd9337
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
#import "Semaphore.h"
|
#import "Semaphore.h"
|
||||||
|
|
||||||
|
//#define OUTPUT_LOG
|
||||||
|
#ifdef OUTPUT_LOG
|
||||||
|
#import <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
@class OutputNode;
|
@class OutputNode;
|
||||||
|
|
||||||
@interface OutputCoreAudio : NSObject {
|
@interface OutputCoreAudio : NSObject {
|
||||||
|
@ -51,6 +56,10 @@
|
||||||
size_t _bufferSize;
|
size_t _bufferSize;
|
||||||
|
|
||||||
AudioUnit _eq;
|
AudioUnit _eq;
|
||||||
|
|
||||||
|
#ifdef OUTPUT_LOG
|
||||||
|
FILE *_logFile;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithController:(OutputNode *)c;
|
- (id)initWithController:(OutputNode *)c;
|
||||||
|
|
|
@ -152,6 +152,10 @@ static OSStatus renderCallback( void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
||||||
writeSemaphore = [[Semaphore alloc] init];
|
writeSemaphore = [[Semaphore alloc] init];
|
||||||
readSemaphore = [[Semaphore alloc] init];
|
readSemaphore = [[Semaphore alloc] init];
|
||||||
|
|
||||||
|
#ifdef OUTPUT_LOG
|
||||||
|
_logFile = fopen("/tmp/CogAudioLog.raw", "wb");
|
||||||
|
#endif
|
||||||
|
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.outputDevice" options:0 context:NULL];
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.outputDevice" options:0 context:NULL];
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQenable" options:0 context:NULL];
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQenable" options:0 context:NULL];
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQpreset" options:0 context:NULL];
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQpreset" options:0 context:NULL];
|
||||||
|
@ -590,6 +594,10 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
__block BOOL *eqEnabled = &self->eqEnabled;
|
__block BOOL *eqEnabled = &self->eqEnabled;
|
||||||
__block void *refCon = (__bridge void *)self;
|
__block void *refCon = (__bridge void *)self;
|
||||||
|
|
||||||
|
#ifdef OUTPUT_LOG
|
||||||
|
__block FILE *logFile = _logFile;
|
||||||
|
#endif
|
||||||
|
|
||||||
_au.outputProvider = ^AUAudioUnitStatus(AudioUnitRenderActionFlags * _Nonnull actionFlags, const AudioTimeStamp * _Nonnull timestamp, AUAudioFrameCount frameCount, NSInteger inputBusNumber, AudioBufferList * _Nonnull inputData)
|
_au.outputProvider = ^AUAudioUnitStatus(AudioUnitRenderActionFlags * _Nonnull actionFlags, const AudioTimeStamp * _Nonnull timestamp, AUAudioFrameCount frameCount, NSInteger inputBusNumber, AudioBufferList * _Nonnull inputData)
|
||||||
{
|
{
|
||||||
// This expects multiple buffers, so:
|
// This expects multiple buffers, so:
|
||||||
|
@ -631,6 +639,12 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef OUTPUT_LOG
|
||||||
|
if (logFile) {
|
||||||
|
fwrite(inputData->mBuffers[0].mData, 1, inputData->mBuffers[0].mDataByteSize, logFile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inputData->mBuffers[0].mNumberChannels = channels;
|
inputData->mBuffers[0].mNumberChannels = channels;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -726,6 +740,13 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
AudioComponentInstanceDispose(_eq);
|
AudioComponentInstanceDispose(_eq);
|
||||||
_eq = NULL;
|
_eq = NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef OUTPUT_LOG
|
||||||
|
if (_logFile)
|
||||||
|
{
|
||||||
|
fclose(_logFile);
|
||||||
|
_logFile = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
|
|
Loading…
Reference in New Issue