Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

aattachmentpoint.C

Go to the documentation of this file.
00001 #include "aattachmentpoint.h"
00002 #include "datatype.h"
00003 #include "edl.h"
00004 #include "edlsession.h"
00005 #include "playbackconfig.h"
00006 #include "plugin.h"
00007 #include "pluginserver.h"
00008 #include "renderengine.h"
00009 #include "transportque.h"
00010 
00011 AAttachmentPoint::AAttachmentPoint(RenderEngine *renderengine, Plugin *plugin)
00012 : AttachmentPoint(renderengine, plugin, TRACK_AUDIO)
00013 {
00014         buffer_vector = 0;
00015         buffer_allocation = 0;
00016 }
00017 
00018 AAttachmentPoint::~AAttachmentPoint()
00019 {
00020         delete_buffer_vector();
00021 }
00022 
00023 void AAttachmentPoint::delete_buffer_vector()
00024 {
00025         if(buffer_vector)
00026         {
00027                 for(int i = 0; i < virtual_plugins.total; i++)
00028                         delete [] buffer_vector[i];
00029                 delete [] buffer_vector;
00030         }
00031         buffer_vector = 0;
00032         buffer_allocation = 0;
00033 }
00034 
00035 void AAttachmentPoint::new_buffer_vector(int total, int size)
00036 {
00037         if(buffer_vector && size > buffer_allocation)
00038                 delete_buffer_vector();
00039 
00040         if(!buffer_vector)
00041         {
00042                 buffer_allocation = size;
00043                 buffer_vector = new double*[virtual_plugins.total];
00044                 for(int i = 0; i < virtual_plugins.total; i++)
00045                 {
00046                         buffer_vector[i] = new double[buffer_allocation];
00047                 }
00048         }
00049 }
00050 
00051 int AAttachmentPoint::get_buffer_size()
00052 {
00053 //      return renderengine->config->aconfig->fragment_size;
00054 // must be greater than value audio_read_length, calculated in PackageRenderer::create_engine
00055 // if it is not, plugin's PluginClient::in_buffer_size is below the real maximum and
00056 // we get a crush on rendering of audio plugins!
00057         int audio_read_length = renderengine->command->get_edl()->session->sample_rate;
00058         int fragment_size = renderengine->config->aconfig->fragment_size;
00059         if (audio_read_length > fragment_size)
00060                 return audio_read_length;
00061         else
00062                 return fragment_size;
00063 }
00064 
00065 void AAttachmentPoint::render(double *output, 
00066         int buffer_number,
00067         int64_t start_position, 
00068         int64_t len,
00069         int64_t sample_rate)
00070 {
00071         if(!plugin_server || !plugin->on) return;
00072 
00073         if(plugin_server->multichannel)
00074         {
00075 // Test against previous parameters for reuse of previous data
00076                 if(is_processed &&
00077                         this->start_position == start_position && 
00078                         this->len == len && 
00079                         this->sample_rate == sample_rate)
00080                 {
00081                         memcpy(output, buffer_vector[buffer_number], sizeof(double) * len);
00082                         return;
00083                 }
00084 
00085 // Update status
00086                 this->start_position = start_position;
00087                 this->len = len;
00088                 this->sample_rate = sample_rate;
00089                 is_processed = 1;
00090 
00091 // Allocate buffer vector
00092                 new_buffer_vector(virtual_plugins.total, len);
00093 
00094 // Create temporary buffer vector with output argument substituted in
00095                 double **output_temp = new double*[virtual_plugins.total];
00096                 for(int i = 0; i < virtual_plugins.total; i++)
00097                 {
00098                         if(i == buffer_number)
00099                                 output_temp[i] = output;
00100                         else
00101                                 output_temp[i] = buffer_vector[i];
00102                 }
00103 
00104 // Process plugin
00105                 plugin_servers.values[0]->process_buffer(output_temp,
00106                         start_position,
00107                         len,
00108                         sample_rate,
00109                         plugin->length *
00110                                 sample_rate /
00111                                 renderengine->edl->session->sample_rate,
00112                         renderengine->command->get_direction());
00113 
00114 // Delete temporary buffer vector
00115                 delete [] output_temp;
00116         }
00117         else
00118         {
00119 // Process plugin
00120                 double *output_temp[1];
00121                 output_temp[0] = output;
00122 //printf("AAttachmentPoint::render 1\n");
00123                 plugin_servers.values[buffer_number]->process_buffer(output_temp,
00124                         start_position,
00125                         len,
00126                         sample_rate,
00127                         plugin->length *
00128                                 sample_rate /
00129                                 renderengine->edl->session->sample_rate,
00130                         renderengine->command->get_direction());
00131 //printf("AAttachmentPoint::render 10\n");
00132         }
00133 }
00134 
00135 

Generated on Sun Jan 8 13:38:49 2006 for Cinelerra-svn by  doxygen 1.4.4