1 #include "aattachmentpoint.h"
4 #include "edlsession.h"
5 #include "playbackconfig.h"
7 #include "pluginserver.h"
8 #include "renderengine.h"
9 #include "transportque.h"
11 AAttachmentPoint::AAttachmentPoint(RenderEngine *renderengine, Plugin *plugin)
12 : AttachmentPoint(renderengine, plugin, TRACK_AUDIO)
15 buffer_allocation = 0;
18 AAttachmentPoint::~AAttachmentPoint()
20 delete_buffer_vector();
23 void AAttachmentPoint::delete_buffer_vector()
27 for(int i = 0; i < virtual_plugins.total; i++)
28 delete [] buffer_vector[i];
29 delete [] buffer_vector;
32 buffer_allocation = 0;
35 void AAttachmentPoint::new_buffer_vector(int total, int size)
37 if(buffer_vector && size > buffer_allocation)
38 delete_buffer_vector();
42 buffer_allocation = size;
43 buffer_vector = new double*[virtual_plugins.total];
44 for(int i = 0; i < virtual_plugins.total; i++)
46 buffer_vector[i] = new double[buffer_allocation];
51 int AAttachmentPoint::get_buffer_size()
53 return renderengine->config->aconfig->fragment_size;
54 // must be greater than value audio_read_length, calculated in PackageRenderer::create_engine
55 // if it is not, plugin's PluginClient::in_buffer_size is below the real maximum and
56 // we get a crush on rendering of audio plugins!
57 // int audio_read_length = renderengine->command->get_edl()->session->sample_rate;
58 // int fragment_size = renderengine->config->aconfig->fragment_size;
59 // if(audio_read_length > fragment_size)
60 // return audio_read_length;
62 // return fragment_size;
65 void AAttachmentPoint::render(double *output,
67 int64_t start_position,
71 if(!plugin_server || !plugin->on) return;
73 if(plugin_server->multichannel)
75 // Test against previous parameters for reuse of previous data
77 this->start_position == start_position &&
79 this->sample_rate == sample_rate)
81 memcpy(output, buffer_vector[buffer_number], sizeof(double) * len);
86 this->start_position = start_position;
88 this->sample_rate = sample_rate;
91 // Allocate buffer vector
92 new_buffer_vector(virtual_plugins.total, len);
94 // Create temporary buffer vector with output argument substituted in
95 double **output_temp = new double*[virtual_plugins.total];
96 for(int i = 0; i < virtual_plugins.total; i++)
98 if(i == buffer_number)
99 output_temp[i] = output;
101 output_temp[i] = buffer_vector[i];
105 plugin_servers.values[0]->process_buffer(output_temp,
111 renderengine->edl->session->sample_rate,
112 renderengine->command->get_direction());
114 // Delete temporary buffer vector
115 delete [] output_temp;
120 double *output_temp[1];
121 output_temp[0] = output;
122 //printf("AAttachmentPoint::render 1\n");
123 plugin_servers.values[buffer_number]->process_buffer(output_temp,
129 renderengine->edl->session->sample_rate,
130 renderengine->command->get_direction());
131 //printf("AAttachmentPoint::render 10\n");
139 // c-file-style: "linux"