Integrating TAAE2 with Inter App Audio( IAA) as a host application.

Hi folks,
I'm developing a multitrack recording application with TAAE2. And I want to connect my app as host app with other apps which are registered to IAA.

In my app, i got instrument and effect list which are compatible with IAA and i use Apple's IAA example to get this list.
Link: https://developer.apple.com/library/content/samplecode/InterAppAudioSuite/Introduction/Intro.html.

In my audio engine, i've declared a variable like this:
@property (nonatomic, strong, readwrite) AEAudioUnitModule * instrument;

And, i got audio component description with this code:

       AudioComponentDescription searchDesc = { 0, 0, 0, 0, 0 };
       AudioComponent comp = NULL;
       while (true) {
          comp = AudioComponentFindNext(comp, &searchDesc);
          if (comp == NULL) break;

         AudioComponentDescription desc;
          if (AudioComponentGetDescription(comp, &desc)) continue;

          if (desc.componentType == kAudioUnitType_RemoteInstrument ||
             desc.componentType == kAudioUnitType_RemoteGenerator ) {
             RemoteAU *rau = [[RemoteAU alloc] init];
             rau->_desc=desc;
             rau->_comp=comp;
             rau->_image=AudioComponentGetIcon(comp, 32);

            //CFStringRef *tmp = (__bridge CFStringRef*)&rau->_name;
            CFStringRef str = NULL;
            AudioComponentCopyName(comp, &str);
            rau->_name=(__bridge NSString *)(str);
            [publishedInstruments addObject: rau];
        }
    }

And initialize the instrument with code below:

  _instrument= [[AEAudioUnitModule alloc] initWithRenderer:self.renderer componentDescription:remoteAU->_desc];

Then i implement this code block for IAA instruments/effects audio unit property listeners:

  - (void) addAudioUnitPropertyListeners:(AEAudioUnitModule *) aeModule {
       AudioUnit localUnit= [aeModule audioUnit]
       if (localUnit) {    
     __block AEAudioController *blockSelf = self;
     AudioUnitRemoteControlEventListener block = ^(AudioUnitRemoteControlEvent event) {

          dispatch_async(dispatch_get_main_queue(), ^{
            switch (event) {
                case kAudioUnitRemoteControlEvent_TogglePlayPause:
                    // [blockSelf togglePlay];
                    break;
                case kAudioUnitRemoteControlEvent_ToggleRecord:
                    //[blockSelf toggleRecord];
                    break;
                case kAudioUnitRemoteControlEvent_Rewind:
                    //[blockSelf rewind];
                    break;
                default:
                    break;
            }
            [blockSelf notifyObservers];
        });
    };

    Check(AudioUnitSetProperty(localUnit,
                               kAudioUnitProperty_RemoteControlEventListener,
                               kAudioUnitScope_Global,
                               0,
                               &block,
                               sizeof(block)));

    static HostCallbackInfo callBackInfo;
    callBackInfo.hostUserData = (__bridge void * _Nullable)(self);
    callBackInfo.transportStateProc2 = hostStateCallback;

    UInt32 dataSize = sizeof(callBackInfo);

    //error here.!!
    Check(AudioUnitSetProperty(localUnit,
                               kAudioUnitProperty_HostCallbacks,
                               kAudioUnitScope_Global,
                               0,
                               &callBackInfo,
                               dataSize));

    Check(AudioUnitAddPropertyListener(localUnit,
                                       kAudioUnitProperty_IsInterAppConnected,
                                       InterAppConnectedChanged,
                                       (__bridge void * _Nullable)(self)));
}

}

But application got an error specified area ( //error here.) when selecting the node app. And console give this error:
error -10849 from AudioUnitSetProperty(localUnit, kAudioUnitProperty_HostCallbacks, kAudioUnitScope_Global, 0, &callBackInfo, dataSize).

Do you have any idea about the correct way to integrate TAAE2 with IAA as a host app? What am i doing wrong?
Your helps will be appreciated.
Thanks,
Onur.

Sign In or Register to comment.