< prev index next >

modules/javafx.media/src/main/native/jfxmedia/platform/osx/avf/AVFKernelProcessor.cpp

Print this page
rev 10028 : 8156563: JavaFX Ensemble8 media sample hang and crash
Reviewed-by: almatvee, kcr

*** 1,7 **** /* ! * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 33,51 **** class AVFKernelComponent : AUEffectBase { public: AVFKernelComponent(AudioComponentInstance audioUnit, bool inProcessesInPlace = true) : AUEffectBase(audioUnit, inProcessesInPlace), mUsesKernel(false), ! mProcessor(NULL) {} virtual ~AVFKernelComponent() { ! // Don't do anything with mProcessor as it could have been deleted already } virtual AUKernelBase *NewKernel() { ! if (mProcessor) { AUKernelBase *kernel = mProcessor->NewKernel(); mUsesKernel = (kernel != NULL); return kernel; } mUsesKernel = false; --- 33,51 ---- class AVFKernelComponent : AUEffectBase { public: AVFKernelComponent(AudioComponentInstance audioUnit, bool inProcessesInPlace = true) : AUEffectBase(audioUnit, inProcessesInPlace), mUsesKernel(false), ! mProcessor(nullptr) {} virtual ~AVFKernelComponent() { ! mProcessor = nullptr; } virtual AUKernelBase *NewKernel() { ! if (mProcessor != nullptr) { AUKernelBase *kernel = mProcessor->NewKernel(); mUsesKernel = (kernel != NULL); return kernel; } mUsesKernel = false;
*** 58,68 **** const CAStreamBasicDescription &inNewFormat) { OSStatus status = this->AUEffectBase::ChangeStreamFormat(inScope, inElement, inPrevFormat, inNewFormat); ! if (inScope == kAudioUnitScope_Input && inElement == 0) { mProcessor->StreamFormatChanged(inNewFormat); } return status; } --- 58,68 ---- const CAStreamBasicDescription &inNewFormat) { OSStatus status = this->AUEffectBase::ChangeStreamFormat(inScope, inElement, inPrevFormat, inNewFormat); ! if (mProcessor != nullptr && inScope == kAudioUnitScope_Input && inElement == 0) { mProcessor->StreamFormatChanged(inNewFormat); } return status; }
*** 76,86 **** inBuffer, outBuffer, inFramesToProcess); } // Otherwise call ProcessBufferLists ! if (mProcessor) { return mProcessor->ProcessBufferLists(ioActionFlags, inBuffer, outBuffer, inFramesToProcess); } --- 76,86 ---- inBuffer, outBuffer, inFramesToProcess); } // Otherwise call ProcessBufferLists ! if (mProcessor != nullptr) { return mProcessor->ProcessBufferLists(ioActionFlags, inBuffer, outBuffer, inFramesToProcess); }
*** 94,112 **** UInt32 inDataSize) { if (inID == kAVFProperty_KernelProcessor && inScope == kAudioUnitScope_Global && inElement == 0) { if (inDataSize == sizeof(AVFKernelProcessor*)) { ! AVFKernelProcessor *processor = *((AVFKernelProcessor **)inData); if (mProcessor != processor) { ! if (mProcessor) { mProcessor->SetAudioUnit(NULL); ! mProcessor = NULL; } mProcessor = processor; ! if (mProcessor) { mProcessor->SetAudioUnit(this); const AudioStreamBasicDescription& format = GetStreamFormat(kAudioUnitScope_Input, 0); mProcessor->StreamFormatChanged(format); } --- 94,113 ---- UInt32 inDataSize) { if (inID == kAVFProperty_KernelProcessor && inScope == kAudioUnitScope_Global && inElement == 0) { if (inDataSize == sizeof(AVFKernelProcessor*)) { ! AVFKernelProcessorPtr processor = *((AVFKernelProcessorPtr*)inData); ! // this compares the raw pointers, not the shared_ptr itself if (mProcessor != processor) { ! if (mProcessor != nullptr) { mProcessor->SetAudioUnit(NULL); ! mProcessor = nullptr; } mProcessor = processor; ! if (mProcessor != nullptr) { mProcessor->SetAudioUnit(this); const AudioStreamBasicDescription& format = GetStreamFormat(kAudioUnitScope_Input, 0); mProcessor->StreamFormatChanged(format); }
*** 117,127 **** } return this->AUEffectBase::SetProperty(inID, inScope, inElement, inData, inDataSize); } private: bool mUsesKernel; ! AVFKernelProcessor *mProcessor; }; // Synchronize registration of the component volatile AudioComponent gAVFComponent = NULL; pthread_mutex_t gAVFComponentLock = PTHREAD_MUTEX_INITIALIZER; --- 118,128 ---- } return this->AUEffectBase::SetProperty(inID, inScope, inElement, inData, inDataSize); } private: bool mUsesKernel; ! AVFKernelProcessorPtr mProcessor; }; // Synchronize registration of the component volatile AudioComponent gAVFComponent = NULL; pthread_mutex_t gAVFComponentLock = PTHREAD_MUTEX_INITIALIZER;
*** 142,152 **** pthread_mutex_unlock(&gAVFComponentLock); return component; } ! AudioUnit NewKernelProcessorUnit(AVFKernelProcessor *kernel) { OSStatus status = noErr; AudioUnit unit = NULL; AudioComponent ac = GetAVFComponent(); if (!ac) { --- 143,153 ---- pthread_mutex_unlock(&gAVFComponentLock); return component; } ! AudioUnit NewKernelProcessorUnit(AVFKernelProcessorPtr kernel) { OSStatus status = noErr; AudioUnit unit = NULL; AudioComponent ac = GetAVFComponent(); if (!ac) {
*** 158,168 **** status = AudioUnitSetProperty(unit, kAVFProperty_KernelProcessor, kAudioUnitScope_Global, 0, &kernel, ! sizeof(AVFKernelProcessor**)); } if (noErr != status) { if (unit) { AudioComponentInstanceDispose(unit); --- 159,169 ---- status = AudioUnitSetProperty(unit, kAVFProperty_KernelProcessor, kAudioUnitScope_Global, 0, &kernel, ! sizeof(AVFKernelProcessorPtr*)); } if (noErr != status) { if (unit) { AudioComponentInstanceDispose(unit);
< prev index next >