AudioUnitV3Example filterDemo won't validate

I downloaded the project March 2018, so it may have been fixed since (I couldn't find versioning in the readme file).


It builds and runs ok, but auval -v (1.6.1a1) reports the following (under render tests):


Render Test at 512 frames

Slicing Render Test at 64 frames

ERROR: Input IOData's Buffer Sizes do not match inNumFrames count

Digging into it, it seems that the prepareInputBufferList() method of the BufferedInputBus object (BufferedAudioBus.hpp) is hardcoded to allocate maxFrames (which is set to 512). When auval calls it with variable frameNum, it fails.


To fix this, I added an argument to prepareInputBufferList(), and use that to compute byteSize:



void prepareInputBufferList(UInt32 numFrames) {

UInt32 byteSize = numFrames * sizeof(float);

. . .


This may not be the correct way to address this, but it passes auval; and it seems to be what the designers intended.


Chris D

Replies

I am seeing a different validation error, using the V3 Filter Demo sample source. I'm building it under Mojave with XCode 10.3, and made a couple minor changes to get it to build (use of Swift 4.0 and stubbed out a couple small blocks in AUv3FilterDemo.swift, namely a call to presetState and the override of supportsUserPresets, which are not defined in this rev of AUAudioUnit).


It works fine in the demo app, but fails to validate in auval (and thus won't load in Logic).


I get errors of this form:


--------------------------------------------------

FORMAT TESTS:


Reported Channel Capabilities (explicit):

[1, 1] [2, 2]


Input/Output Channel Handling:

1-1 1-2 1-4 1-5 1-6 1-7 1-8 2-2 2-4 2-5 2-6 2-7 2-8 4-4 4-5 5-5 6-6 7-7 8-8

X X

ERROR: -10868 IN CALL Cannot Set Output Num Channels:2 when unit says it can

ERROR: -10868 IN CALL Cannot Set Output Num Channels:2 when unit says it can


* * FAIL


It doesn't seem to matter what I set for the Channel Capabilities (the default of [-1, -1] yields several more of these). Any idea how to fix this? I haven't found anything online about the cause of this error. Is there some reason this won't work in an XCode 10.3 build?

I experienced the same error, to me it seemed like auval could not handle the exception thrown by the Swift code in allocatedRenderResources:

public override func allocateRenderResources() throws {
        if kernelAdapter.outputBus.format.channelCount != kernelAdapter.inputBus.format.channelCount {
            throw NSError(domain: NSOSStatusErrorDomain, code: Int(kAudioUnitErr_FailedInitialization), userInfo: nil)
            self.setRenderResourcesAllocated(false)
            return
        }

        try super.allocateRenderResources()
        kernelAdapter.allocateRenderResources()
    }


So I ported the audio unit class to Objective-C which made is pass this particular auval test. Objective-C code for allocateRenderResources:

- (BOOL)allocateRenderResourcesAndReturnError:(NSError **)outError {
    if ( _kernelAdapter.outputBus.format.channelCount != _kernelAdapter.inputBus.format.channelCount) {
        if (outError) {
            *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_FailedInitialization userInfo:nil];
        }
        // Notify superclass that initialization was not successful
        self.renderResourcesAllocated = NO;
        
        return NO;
    }
    
    [super allocateRenderResourcesAndReturnError:outError];
    [_kernelAdapter allocateRenderResources];
    return YES;
}


Here you can find the whole audio unit demo project in Objective-C: https://github.com/Lax/Learn-iOS-Swift-by-Examples/tree/master/AudioUnitV3Example


Note: I sporadically experienced the same error even after the fix. This was due to a crash of my audio unit caused by memory corruption which made my AU crash at different points every time. Maybe check that as well.