OSStatus OutputImplAudioUnit::Track::renderNotifyCallback( void * audioTrack, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData ) { OSStatus err = noErr; if( *ioActionFlags &= kAudioUnitRenderAction_PostRender ) { OutputImplAudioUnit::Track * theTrack = reinterpret_cast<OutputImplAudioUnit::Track *>( audioTrack ); if( ! theTrack->isPlaying() ) { //disable render callback AURenderCallbackStruct rcbs; rcbs.inputProc = NULL; rcbs.inputProcRefCon = NULL; err = AudioUnitSetProperty( theTrack->mOutput->mMixerUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, theTrack->mInputBus, &rcbs, sizeof(rcbs) ); if( err ) { } err = AudioUnitRemoveRenderNotify( theTrack->mOutput->mMixerUnit, OutputImplAudioUnit::Track::renderNotifyCallback, audioTrack ); if( err ) { } theTrack->mOutput->removeTrack( theTrack->getTrackId() ); //now the track should be dead } } return err; }
void gst_core_audio_remove_render_callback (GstCoreAudio * core_audio) { AURenderCallbackStruct input; OSStatus status; /* Deactivate the render callback by calling SetRenderCallback * with a NULL inputProc. */ input.inputProc = NULL; input.inputProcRefCon = NULL; status = AudioUnitSetProperty (core_audio->audiounit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, /* N/A for global */ &input, sizeof (input)); if (status) { GST_WARNING_OBJECT (core_audio->osxbuf, "Failed to remove render callback %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status)); } /* Remove the RenderNotify too */ status = AudioUnitRemoveRenderNotify (core_audio->audiounit, (AURenderCallback) gst_core_audio_render_notify, core_audio); if (status) { GST_WARNING_OBJECT (core_audio->osxbuf, "Failed to remove render notify callback %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (status)); } /* We're deactivated.. */ core_audio->io_proc_needs_deactivation = FALSE; core_audio->io_proc_active = FALSE; }