0

I have an Objective-C audio app based on audio unit and my problem is when I play a sound then stop it then play another sound I hear the last buffer from the first sound. I think I should just free the ioData or something but all my tries have failed.

static OSStatus playbackCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames,  AudioBufferList *ioData)
{
    RemoteIOPlayer *remoteIOplayer = (__bridge RemoteIOPlayer *)inRefCon;

    for (int i = 0 ; i < ioData->mNumberBuffers; i++)
    {
        AudioBuffer buffer = ioData->mBuffers[i];
        UInt32 *frameBuffer = buffer.mData;

        for (int j = 0; j < inNumberFrames; j++)
        {
             frameBuffer[j]= [[remoteIOplayer inMemoryAudioFile] getNextPacket:inBusNumber];
        }
    }
    return noErr;
}

Please help :) Thanks.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
Moataz Hossam
  • 413
  • 7
  • 20

1 Answers1

0

Ok its just about UNintializing the augraph and initializing it again after the user stops

Moataz Hossam
  • 413
  • 7
  • 20