void ivis_close( ITunesVis* plugin ) { if ( plugin != NULL ) { /* destroy FFT setup */ destroy_fftsetup( plugin->fft_setup ); /* send the plugin, visual hide and cleanup messages */ if ( plugin->imports.visual_handler ) { plugin->imports.visual_handler( kVisualPluginStopMessage, NULL, plugin->vis_ref ); plugin->imports.visual_handler( kVisualPluginDisableMessage, NULL, plugin->vis_ref ); plugin->imports.visual_handler( kVisualPluginHideWindowMessage, NULL, plugin->vis_ref ); plugin->imports.visual_handler( kVisualPluginCleanupMessage, NULL, plugin->vis_ref ); } /* send the plugin a cleanup message */ // FIXME: iTunes plugins don't expect to be unloaded until app terminates //if ( plugin->imports.main ) // plugin->imports.main( kPluginCleanupMessage, NULL, plugin->main_ref ); /* free our screen if it was allocated */ if ( plugin->screen ) release_view( plugin->screen ); /* if we have an open handle, then close it */ if ( plugin->handle ) { // FIXME: iTunes plugins don't expect to be unloaded until app terminates //dlclose( plugin->handle ); plugin->handle = NULL; } /* deallocate */ free( plugin ); } }
// Main function with event loop int main(void) { int n = -1; int count = 0; static bc_buf_ptr_t buf_pa; int dev_fd; unsigned long chunkSize; printf("Initializing egl..\n\n"); if( 0 == initEGL(0)) //No profiling { printf("EGL init failed"); goto exitNone; } //Also initialise the pipes n = initPipes(&initAttrib); if(n) { goto exitPipes; } //Initialise CMEM allocator - TODO check err status mem_cmem_init(); //Allocate mem chunkSize = initAttrib.widthPixels* initAttrib.heightPixels* initAttrib.bytesPerPixel* initAttrib.numBuffers; if(mem_cmem_alloc( chunkSize, &virtualAddress, &physicalAddress )) {goto exitCMEMInit;} paArray = (unsigned long*)malloc(initAttrib.numBuffers * sizeof(unsigned long)); freeArray = (unsigned long*)malloc(initAttrib.numBuffers * sizeof(unsigned long)); if(!paArray || !freeArray) {goto exitCMEMAlloc;} for(count = 0; count < initAttrib.numBuffers; count++) { paArray[count] = physicalAddress + count*(chunkSize/initAttrib.numBuffers); freeArray[count] = 0; } //TODO - give the allocated buffers back to requestor via answer //write_init_buffer_pipe(); init_view(); //Loop reading new data and rendering, till something happens //TODO - exit cleanly using last msg while(read_pipe() != -1) { render(bcbuf.index); //TODO - clean up message passing //if( write_pipe() != sizeof(GstBufferClassBuffer *)) { printf("Error Writing into Init Queue\n"); //TODO - try again n times ? break; } } exit: release_view(); deInitEGL(); exitCMEMAlloc: mem_cmem_free( virtualAddress); exitPipes: if(paArray) free(paArray); if(freeArray) free(freeArray); deinit_pipes(); exitCMEMInit: mem_cmem_deinit(); exitNone: return 0; }