예제 #1
0
void free_bundle_welsdec()
{
	if(g_at264Module != NULL)
	{
		CFBundleUnloadExecutable(g_at264Module);
	}
}
예제 #2
0
파일: plugin.cpp 프로젝트: javasdk/giada
int Plugin::unload() {

	if (module == NULL)
		return 1;

#if defined(_WIN32)

	FreeLibrary((HMODULE)module); // FIXME - error checking
	return 1;

#elif defined(__linux__)

	return dlclose(module) == 0 ? 1 : 0;

#elif defined(__APPLE__)

	/* we must unload bundles but because bundles may be in use for other
	plug-in types it is important (and mandatory on certain plug-ins,
	e.g. Korg) to do a check on the retain count. */

	CFIndex retainCount = CFGetRetainCount(module);

	if (retainCount == 1) {
		gLog("[plugin] retainCount == 1, can unload dlyb\n");
		CFBundleUnloadExecutable(module);
		CFRelease(module);
	}
	else
		gLog("[plugin] retainCount > 1 (%d), leave dlyb alone\n", (int) retainCount);

	return 1;

#endif
}
예제 #3
0
/* ioFreeModule:
	Free the module with the associated handle.
	WARNING: never primitiveFail() within, just return 0.
*/
sqInt ioFreeModule(void * moduleHandle) {
	if (!moduleHandle) 
            return 0;
	CFBundleUnloadExecutable((CFBundleRef) moduleHandle);
	CFRelease((CFBundleRef) moduleHandle);
        return 0;
}
예제 #4
0
void UnloadBundle(CFBundleRef theBundle)
{
	/*get bundle resource and convert from xml to propertylist struct so we can look for revdontunload attribute and not unload- necessary for external
	that interface with Cocoa*/
	Boolean dontunload = False;
	CFPropertyListRef tCFPropertyListRef = NULL;
	short resrefnum = CFBundleOpenBundleResourceMap (theBundle );
	CFURLRef resFileCFURLRef = CFBundleCopyResourceURL(theBundle,CFSTR("revinfo"),CFSTR("plist"),NULL);
	CFDataRef resCFDataRef;
	if (resFileCFURLRef && CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,resFileCFURLRef,&resCFDataRef,nil,nil,nil))
	{
		if (resCFDataRef)
		{
			CFStringRef errorString;
			tCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,resCFDataRef,kCFPropertyListImmutable,&errorString);
			CFRelease(resCFDataRef);
		}
	}
	if (tCFPropertyListRef)
	{
		if (CFDictionaryGetValueIfPresent((CFDictionaryRef)tCFPropertyListRef,CFSTR("revdontunload"),NULL))
			dontunload = True;
	}
	if (resFileCFURLRef)
		CFRelease(resFileCFURLRef);
	CFBundleCloseBundleResourceMap (theBundle,resrefnum);
	if (theBundle && !dontunload)
	{
		CFBundleUnloadExecutable(theBundle);
		CFRelease(theBundle);
	}
}
static void
_glitz_agl_release_bundle (CFBundleRef bundle)
{
    if (bundle) {
	CFBundleUnloadExecutable (bundle);
	CFRelease (bundle);
    }
}
예제 #6
0
	~PluginLoader ()
	{
		if (module)
		{
		#if _WIN32
			FreeLibrary ((HMODULE)module);
		#elif TARGET_API_MAC_CARBON
			CFBundleUnloadExecutable ((CFBundleRef)module);
			CFRelease ((CFBundleRef)module);
		#endif
		}
	}
예제 #7
0
파일: fileio.cpp 프로젝트: KDE/kdepim
static void FinalizeIO()
{
    if (--sfwRefCount) {
        return;
    }
    // race condition, infinitesimal risk

    if (systemFramework) {
        CFBundleUnloadExecutable(systemFramework);
        CFRelease(systemFramework);
        systemFramework = 0;
    }
}
예제 #8
0
void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag) {
    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
        __CFBundleGetPlugInData(plugIn)->_loadOnDemand = flag;
        if (__CFBundleGetPlugInData(plugIn)->_loadOnDemand && !__CFBundleGetPlugInData(plugIn)->_isDoingDynamicRegistration && __CFBundleGetPlugInData(plugIn)->_instanceCount == 0) {
            /* Unload now if we can/should. */
            /* If we are doing dynamic registration currently, do not unload.  The unloading will happen when dynamic registration is done, if necessary. */
            CFBundleUnloadExecutable(plugIn);
        } else if (!__CFBundleGetPlugInData(plugIn)->_loadOnDemand) {
            /* Make sure we're loaded now. */
            CFBundleLoadExecutable(plugIn);
        }
    }
}
예제 #9
0
    AEffect *loadVst2xPlugin(LibraryHandle libraryHandle)
    {
        // Somewhat cheap hack to avoid a tricky compiler warning. Casting from void* to a proper function
        // pointer will cause GCC to warn that "ISO C++ forbids casting between pointer-to-function and
        // pointer-to-object". Here, we represent both types in a union and use the correct one in the given
        // context, thus avoiding the need to cast anything.
        // See also: http://stackoverflow.com/a/2742234/14302
        union {
            Vst2xPluginEntryFunc entryPointFuncPtr;
            void *entryPointVoidPtr;
        } entryPoint;

        entryPoint.entryPointVoidPtr = CFBundleGetFunctionPointerForName(libraryHandle, CFSTR("VSTPluginMain"));
        Vst2xPluginEntryFunc mainEntryPoint = entryPoint.entryPointFuncPtr;

        // VST plugins previous to the 2.4 SDK used main_macho for the entry point name
        if (mainEntryPoint == NULL) {
            entryPoint.entryPointVoidPtr = CFBundleGetFunctionPointerForName(libraryHandle, CFSTR("main_macho"));
            mainEntryPoint = entryPoint.entryPointFuncPtr;
        }

        if (mainEntryPoint == NULL) {
            logError("Couldn't get a pointer to plugin's main()");
            CFBundleUnloadExecutable(libraryHandle);
            CFRelease(libraryHandle);
            return NULL;
        }

        AEffect *plugin = mainEntryPoint(pluginVst2xHostCallback);

        if (plugin == NULL) {
            logError("Plugin's main() returns null");
            CFBundleUnloadExecutable(libraryHandle);
            CFRelease(libraryHandle);
            return NULL;
        }

        return plugin;
    }
예제 #10
0
int DYN_CloseLibrary(void **pvLHandle)
{

	CFBundleRef bundle = (CFBundleRef) * pvLHandle;

	if (CFBundleIsExecutableLoaded(bundle) == TRUE)
	{
		CFBundleUnloadExecutable(bundle);
		CFRelease(bundle);
	}
	else
		Log1(PCSC_LOG_ERROR, "Cannot unload library.");

	*pvLHandle = 0;
	return SCARD_S_SUCCESS;
}
예제 #11
0
OSCodeFragment::~OSCodeFragment()
{
    if (fFragmentP == NULL)
        return;
        
#if defined(HPUX) || defined(HPUX10)
    shl_unload((shl_t)fFragmentP);
#elif defined(__Win32__)
    BOOL theErr = ::FreeLibrary(fFragmentP);
    Assert(theErr);
#elif defined(__MacOSX__)
    CFBundleUnloadExecutable( fFragmentP );
    CFRelease( fFragmentP );
#else
    dlclose(fFragmentP);
#endif
}
예제 #12
0
int Vst::loadPlugin(std::string pathOnDisk)
{
    int error = 0;
    
    plugin = nullptr;
    
    CFStringRef pluginPathReference = CFStringCreateWithCString(nullptr, pathOnDisk.c_str(), kCFStringEncodingASCII);
    CFURLRef bundleUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, pluginPathReference, kCFURLPOSIXPathStyle, true);
    
    if(bundleUrl == nullptr)
    {
        std::cout<<"Could't find reference to VST URL. It might not exist, or the path is wrong."<<std::endl;
        return -1;
    }
    
    CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, bundleUrl);
    if(bundle == nullptr)
    {
        std::cout<<"Couldn't create VST Bundle reference. It might not be a VST, or corrupted"<<std::endl;
        CFRelease(bundleUrl);
        CFRelease(bundle);
        return -1;
    }
    
    VSTPlugin = (vstPluginFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("VSTPluginMain"));
    
    plugin = VSTPlugin(hostCallback);
    
    if(plugin == nullptr)
    {
        std::cout<<"Couldn't create VST Main Entry Point"<<std::endl;
        CFBundleUnloadExecutable(bundle);
        CFRelease(bundle);
        return -1;
    }
    
    CFRelease(pluginPathReference);
    CFRelease(bundleUrl);
    
    error = configureCallbacks();
    error = startPlugin();
    
    return error;
}
예제 #13
0
void RemoveConsole(void)
{
#if !__MACH__
	if (__msl_os_x.theBundle != NULL)
	{
		if (__msl_os_x.isLoaded)
		{
			__msl_os_x.theRead = NULL;
			__msl_os_x.theWrite = NULL;
			
			CFBundleUnloadExecutable(__msl_os_x.theBundle);
			__msl_os_x.isLoaded = false;
		}
		
		CFRelease(__msl_os_x.theBundle);
		__msl_os_x.theBundle = NULL;
	}
#endif
}
예제 #14
0
파일: vsthost.cpp 프로젝트: Angeldude/pd
void VSTPlugin::FreePlugin()
{
#if FLEXT_OS == FLEXT_OS_WIN
    if(hdll) { FreeLibrary(hdll); hdll = NULL; }
#elif FLEXT_OS == FLEXT_OS_MAC
#ifdef __CFM__
    if(audiomaster) DisposeCFMFromMachO(audiomaster);
    if(pluginmain) DisposeMachOFromCFM(pluginmain);
#endif
    if(hdll) {
	    CFBundleUnloadExecutable(hdll);
	    CFRelease(hdll);
        hdll = NULL;
    }
#else
#error Platform not supported
#endif    

    effect = NULL;
    audiomaster = NULL;
    pluginmain = NULL;
} 
예제 #15
0
int main(int argc, char **argv)
{
    CFBundleRef myBundle;
    UInt32 numDevs, i;
    UInt32 standard;
    Boolean isEnabled;
    OSErr err;
    DVDeviceID device;
    DVDeviceRefNum refNum;
    DVNotificationID notifyID;
    char name[256];
    int file;
    
    myBundle = findMe();
    
    numDevs = sDVFuncs.fDVCountDevices();
    printf("Number of devices: %ld\n", numDevs);
    if(numDevs == 0) {
        err = sDVFuncs.fDVNewNotification( kEveryDVDeviceRefNum, myNotifyProc,
						(void *)0x1234, &notifyID );
        if(err)
            printf("Error %d calling DVNewNotification(, %ld)\n", err, kEveryDVDeviceRefNum);
	err = sDVFuncs.fDVNotifyMeWhen( kEveryDVDeviceRefNum, notifyID,
            kDVDeviceAdded | kDVDeviceRemoved);
        if(err)
            printf("Error %d calling NotifyMeWhen(%ld, %ld)\n", err, kEveryDVDeviceRefNum, notifyID);

        while (true) {
        printf("Waiting for devices: %ld\n", numDevs);
        usleep(1000000);	// 1000 milliseconds
        numDevs = sDVFuncs.fDVCountDevices();
        }
    }
    for(i=1; i<=numDevs; i++) {
        err = sDVFuncs.fDVGetIndDevice(&device, i);
        if(err)
            printf("Error %d calling DVGetIndDevice(, %ld)\n", err, i);
        err = sDVFuncs.fDVGetDeviceName(device, name);
        if(err)
            printf("Error %d calling DVGetDeviceName(%ld)\n", err, device);
        else
            printf("Device %ld name is %s\n", device, name);
            
        err = sDVFuncs.fDVOpenDriver( device, &refNum );
        if(err)
            printf("Error %d calling DVOpenDriver(%ld)\n", err, device);
            
        err = sDVFuncs.fDVGetDeviceStandard(refNum, &standard);
        if(err)
            printf("Error %d calling DVGetDeviceStandard(%ld)\n", err, device);
        else if(standard == kNTSCStandard)
            printf("Device %ld video standard is NTSC\n", device);
        else if(standard == kPALStandard)
            printf("Device %ld video standard is PAL\n", device);
        else
            printf("Device %ld, unknown video standard %ld\n", device, standard);

	err = sDVFuncs.fDVIsEnabled(refNum, &isEnabled);
        if(err)
            printf("Error %d calling DVIsEnabled(%ld)\n", err, device);
        else
            printf("Device %ld isEnabled: %d\n", device, isEnabled);
               
        //sleep(10);
        
        printf("Destruction test...\n");
                usleep(4000);	// 4 milliseconds
        while(true) {
            err = doStatusTest(refNum, kAVCMechaModeInquiryOpcode, kAVCMechaModeDummyOperand);
            //if(err)
                //usleep(4000);	// 4 milliseconds
            err = doStatusTest6(refNum, kAVCPositionTimeCodeOpcode, kAVCPositionValueInquiry, 
                0xff, 0xff, 0xff, 0xff);
            //if(err)
                //usleep(4000);	// 4 milliseconds
            if(err != noErr) {
                UInt32 num;
                num = sDVFuncs.fDVCountDevices();
                printf("err %d, num devices %d\n", err, num);
            }
        }
        err = sDVFuncs.fDVCloseDriver( refNum );
        if(err)
            printf("Error %d calling DVCloseDriver(%ld)\n", err, device);
    
    }
    
    // Unload the bundle's executable code. 
    CFBundleUnloadExecutable( myBundle );
    CFRelease( myBundle );
    return 0;
}
예제 #16
0
void closeLibraryHandle(LibraryHandle libraryHandle) {
  CFBundleUnloadExecutable(libraryHandle);
  CFRelease(libraryHandle);
}
예제 #17
0
//------------------------------------------------------------------------------------------------------------------------------------
//
int main()
{
#if defined( _WIN32 )
	char	ModulePath[MAX_PATH];
#elif defined(__APPLE__)
	FSRef ModuleRef;
#endif
	LPRefObj	pRefMod = NULL, pRefSrc = NULL, RefItm = NULL, pRefDat = NULL;
	char	buf[256];
	ULONG	ulModID = 0, ulSrcID = 0;
	UWORD	wSel;
	BOOL	bRet;

	// Search for a Module-file like "Type0010.md3".
#if defined( _WIN32 )
	bRet = Search_Module( ModulePath );
#elif defined(__APPLE__)
	bRet = Search_Module( &ModuleRef );
#endif
	if ( bRet == false ) {
		puts( "\"Type0010 Module\" is not found.\n" );
		return -1;
	}

	// Load the Module-file.
#if defined( _WIN32 )
	bRet = Load_Module( ModulePath );
#elif defined(__APPLE__)
	bRet = Load_Module( &ModuleRef );
#endif
	if ( bRet == false ) {
		puts( "Failed in loading \"Type0010 Module\".\n" );
		return -1;
	}

	// Allocate memory for reference to Module object.
	pRefMod = (LPRefObj)malloc(sizeof(RefObj));
	if ( pRefMod == NULL ) {
		puts( "There is not enough memory." );
		return -1;
	}
	InitRefObj( pRefMod );

	// Allocate memory for Module object.
	pRefMod->pObject = (LPNkMAIDObject)malloc(sizeof(NkMAIDObject));
	if ( pRefMod->pObject == NULL ) {
		puts( "There is not enough memory." );
		if ( pRefMod != NULL )	free( pRefMod );
		return -1;
	}

	//	Open Module object
	pRefMod->pObject->refClient = (NKREF)pRefMod;
	bRet = Command_Open(	NULL,					// When Module_Object will be opend, "pParentObj" is "NULL".
								pRefMod->pObject,	// Pointer to Module_Object 
								ulModID );			// Module object ID set by Client
	if ( bRet == false ) {
		puts( "Module object can't be opened.\n" );
		if ( pRefMod->pObject != NULL )	free( pRefMod->pObject );
		if ( pRefMod != NULL )	free( pRefMod );
		return -1;
	}

	//	Enumerate Capabilities that the Module has.
	bRet = EnumCapabilities( pRefMod->pObject, &(pRefMod->ulCapCount), &(pRefMod->pCapArray), NULL, NULL );
	if ( bRet == false ) {
		puts( "Failed in enumeration of capabilities." );
		if ( pRefMod->pObject != NULL )	free( pRefMod->pObject );
		if ( pRefMod != NULL )	free( pRefMod );
		return -1;
	}

	//	Set the callback functions(ProgressProc, EventProc and UIRequestProc).
	bRet = SetProc( pRefMod );
	if ( bRet == false ) {
		puts( "Failed in setting a call back function." );
		if ( pRefMod->pObject != NULL )	free( pRefMod->pObject );
		if ( pRefMod != NULL )	free( pRefMod );
		return -1;
	}

	//	Set the kNkMAIDCapability_ModuleMode.
	if( CheckCapabilityOperation( pRefMod, kNkMAIDCapability_ModuleMode, kNkMAIDCapOperation_Set )  ){
		bRet = Command_CapSet( pRefMod->pObject, kNkMAIDCapability_ModuleMode, kNkMAIDDataType_Unsigned, 
										(NKPARAM)kNkMAIDModuleMode_Controller, NULL, NULL);
		if ( bRet == false ) {
			puts( "Failed in setting kNkMAIDCapability_ModuleMode." );
			return -1;
		}
	}

	// Module Command Loop
	do {
		printf( "\nSelect (1-6, 0)\n" );
		printf( " 1. Select Device            2. AsyncRate                3. IsAlive\n" );
		printf( " 4. Name                     5. ModuleType               6. Version\n" );
		printf( " 0. Exit\n>" );
		scanf( "%s", buf );
		wSel = atoi( buf );

		switch( wSel )
		{
			case 1:// Children
				// Select Device
				ulSrcID = 0;	// 0 means Device count is zero. 
				bRet = SelectSource( pRefMod, &ulSrcID );
				if ( bRet == false ) break;
				if( ulSrcID > 0 )
					bRet = SourceCommandLoop( pRefMod, ulSrcID );
				break;
			case 2:// AsyncRate
				bRet = SetUnsignedCapability( pRefMod, kNkMAIDCapability_AsyncRate );
				break;
			case 3:// IsAlive
				bRet = SetBoolCapability( pRefMod, kNkMAIDCapability_IsAlive );
				break;
			case 4:// Name
				bRet = SetStringCapability( pRefMod, kNkMAIDCapability_Name );
				break;
			case 5:// ModuleType
				bRet = SetUnsignedCapability( pRefMod, kNkMAIDCapability_ModuleType );
				break;
			case 6:// Version
				bRet = SetUnsignedCapability( pRefMod, kNkMAIDCapability_Version );
				break;
			default:
				wSel = 0;
		}
		if ( bRet == false ) {
			printf( "An Error occured. Enter '0' to exit.\n>" );
			scanf( "%s", buf );
			bRet = true;
		}
	} while( wSel > 0 && bRet == true );

	// Close Module_Object
	bRet = Close_Module( pRefMod );
	if ( bRet == false )
		puts( "Module object can not be closed.\n" );

	// Unload Module
#if defined( _WIN32 )
	FreeLibrary( g_hInstModule );
	g_hInstModule = NULL;
#elif defined(__APPLE__)
	if (gBundle != NULL)
	{
		CFBundleUnloadExecutable(gBundle);
		CFRelease(gBundle);
		gBundle = NULL;
	}
#endif

	// Free memory blocks allocated in this function.
	if ( pRefMod->pObject != NULL )	free( pRefMod->pObject );
	if ( pRefMod != NULL )	free( pRefMod );
	
	puts( "This sample program has terminated.\n" );
	return 0;
}
예제 #18
0
__private_extern__ void _CFBundlePlugInLoaded(CFBundleRef bundle) {
    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
    CFStringRef tempStr;
    CFPlugInDynamicRegisterFunction func = NULL;

    if (!__CFBundleGetPlugInData(bundle)->_isPlugIn || __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration || !infoDict || !CFBundleIsExecutableLoaded(bundle)) return;

    tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
    if (tempStr && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
        CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
        tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegisterFunctionKey);
        if (!tempStr || CFGetTypeID(tempStr) != CFStringGetTypeID() || CFStringGetLength(tempStr) <= 0) tempStr = CFSTR("CFPlugInDynamicRegister");
        __CFBundleGetPlugInData(bundle)->_loadOnDemand = false;
        __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true;

        /* Find the symbol and call it. */
        func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr);
        if (func) {
            func(bundle);
            // MF:!!! Unload function is never called.  Need to deal with this!
        }

        __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
        if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && __CFBundleGetPlugInData(bundle)->_instanceCount == 0) CFBundleUnloadExecutable(bundle);   // Unload now if we can/should.
    } else {
        CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
    }
}
예제 #19
0
void LoadableBundle::unload()
{
    secdebug("bundle", "%p (%s) unloaded", this, path().c_str());
	CFBundleUnloadExecutable(cfBundle());
}
예제 #20
0
void WelsEncBundleFree() {
  if (g_at264Module != NULL) {
    CFBundleUnloadExecutable (g_at264Module);
  }
}