0

コールバック関数で目的の c 関数を呼び出す方法

コールバック関数:

static OSStatus inputRenderCallback (

    void                        *inRefCon,      
    AudioUnitRenderActionFlags  *ioActionFlags, 
    const AudioTimeStamp        *inTimeStamp,   
    UInt32                      inBusNumber,    
    UInt32                      inNumberFrames, 
    AudioBufferList             *ioData         
) {

    soundStructPtr    soundStructPointerArray   = (soundStructPtr) inRefCon;
    UInt32            frameTotalForSound        = soundStructPointerArray[inBusNumber].frameCount;
    BOOL              isStereo                  = soundStructPointerArray[inBusNumber].isStereo;


    AudioUnitSampleType *dataInLeft;
    AudioUnitSampleType *dataInRight;

    dataInLeft                 = soundStructPointerArray[inBusNumber].audioDataLeft;
    if (isStereo) dataInRight  = soundStructPointerArray[inBusNumber].audioDataRight;

    AudioUnitSampleType *outSamplesChannelLeft;
    AudioUnitSampleType *outSamplesChannelRight;

    outSamplesChannelLeft                 = (AudioUnitSampleType *) ioData->mBuffers[0].mData;
    if (isStereo) outSamplesChannelRight  = (AudioUnitSampleType *) ioData->mBuffers[1].mData;


    UInt32 sampleNumber = soundStructPointerArray[inBusNumber].sampleNumber;


    for (UInt32 frameNumber = 0; frameNumber < inNumberFrames; ++frameNumber) {

        outSamplesChannelLeft[frameNumber]                 = dataInLeft[sampleNumber];
        if (isStereo) outSamplesChannelRight[frameNumber]  = dataInRight[sampleNumber];

        sampleNumber++;

        if (sampleNumber >= frameTotalForSound){
            sampleNumber = 0;

        }
    }


    soundStructPointerArray[inBusNumber].sampleNumber = sampleNumber;


    return noErr;
}

目的の c 関数:

- (void) stopAUGraph {

    NSLog (@"Stopping audio processing graph");
    Boolean isRunning = false;
    OSStatus result = AUGraphIsRunning (processingGraph, &isRunning);
    if (noErr != result) {[self printErrorMessage: @"AUGraphIsRunning" withStatus: result]; return;}

    if (isRunning) {

        result = AUGraphStop (processingGraph);
        if (noErr != result) {[self printErrorMessage: @"AUGraphStop" withStatus: result]; return;}
        self.playing = NO;
    }
}

if (sampleNumber >= frameTotalForSound){
   sampleNumber = 0;
}

コールバック関数部分の stopAUGraph 関数を呼び出すにはどうすればよいですか

4

1 に答える 1