summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-01-22 17:00:57 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-01-22 17:00:57 +0000
commit44f9a6d73f92aa261177169e296b335c1319c78f (patch)
tree7e388bb02d7c42a97f2c070531555f5c0aacc10a
parent753076d75ec900146f5fbba6c78cf94376e8be75 (diff)
fix AU configure pathway so that we uninitialize the plugin if necessary; strip whitespace from AU names and creators
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6544 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/audio_unit.cc38
-rw-r--r--libs/ardour/ladspa_plugin.cc6
2 files changed, 33 insertions, 11 deletions
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
index b2933b2a09..610e54a6ff 100644
--- a/libs/ardour/audio_unit.cc
+++ b/libs/ardour/audio_unit.cc
@@ -697,6 +697,7 @@ void
AUPlugin::deactivate ()
{
unit->GlobalReset ();
+ initialized = false;
}
void
@@ -734,6 +735,12 @@ int32_t
AUPlugin::configure_io (int32_t in, int32_t out)
{
AudioStreamBasicDescription streamFormat;
+ bool was_initialized = initialized;
+
+ if (initialized) {
+ unit->Uninitialize ();
+ initialized = false;
+ }
streamFormat.mSampleRate = _session.frame_rate();
streamFormat.mFormatID = kAudioFormatLinearPCM;
@@ -766,7 +773,15 @@ AUPlugin::configure_io (int32_t in, int32_t out)
return -1;
}
- return Plugin::configure_io (in, out);
+ int ret = Plugin::configure_io (in, out);
+
+ if (ret == 0) {
+ if (was_initialized) {
+ activate ();
+ }
+ }
+
+ return ret;
}
int32_t
@@ -1019,10 +1034,12 @@ AUPlugin::render_callback(AudioUnitRenderActionFlags *ioActionFlags,
error << _("AUPlugin: render callback called illegally!") << endmsg;
return kAudioUnitErr_CannotDoInCurrentContext;
}
- for (uint32_t i = 0; i < ioData->mNumberBuffers; ++i) {
+ uint32_t limit = min ((uint32_t) ioData->mNumberBuffers, current_maxbuf);
+ for (uint32_t i = 0; i < limit; ++i) {
ioData->mBuffers[i].mNumberChannels = 1;
ioData->mBuffers[i].mDataByteSize = sizeof (Sample) * inNumberFrames;
ioData->mBuffers[i].mData = (*current_buffers)[i] + cb_offset + current_offset;
+ // cerr << "chn " << i << " rendering from " << ioData->mBuffers[i].mData << endl;
}
cb_offset += inNumberFrames;
@@ -1041,9 +1058,10 @@ AUPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in,
current_offset = offset;
cb_offset = 0;
- buffers->mNumberBuffers = maxbuf;
+ buffers->mNumberBuffers = min ((uint32_t) output_channels, maxbuf);
+ // cerr << "Will render " << buffers->mNumberBuffers << " channels\n";
- for (uint32_t i = 0; i < maxbuf; ++i) {
+ for (uint32_t i = 0; i < buffers->mNumberBuffers; ++i) {
buffers->mBuffers[i].mNumberChannels = 1;
buffers->mBuffers[i].mDataByteSize = nframes * sizeof (Sample);
buffers->mBuffers[i].mData = 0;
@@ -1056,9 +1074,12 @@ AUPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in,
current_maxbuf = 0;
frames_processed += nframes;
-
- for (uint32_t i = 0; i < maxbuf; ++i) {
+
+ uint32_t limit = min ((uint32_t) buffers->mNumberBuffers, maxbuf);
+
+ for (uint32_t i = 0; i < limit; ++i) {
if (bufs[i] + offset != buffers->mBuffers[i].mData) {
+ // cerr << "chn " << i << " rendered into " << bufs[i]+offset << endl;
memcpy (bufs[i]+offset, buffers->mBuffers[i].mData, nframes * sizeof (Sample));
}
}
@@ -2277,11 +2298,12 @@ AUPluginInfo::get_names (CAComponentDescription& comp_desc, std::string& name, G
if (colon) {
name = str.substr (colon+1);
maker = str.substr (0, colon);
- // strip_whitespace_edges (maker);
- // strip_whitespace_edges (name);
+ strip_whitespace_edges (maker);
+ strip_whitespace_edges (name);
} else {
name = str;
maker = "unknown";
+ strip_whitespace_edges (name);
}
}
diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc
index c782b54f18..f9c8fa836c 100644
--- a/libs/ardour/ladspa_plugin.cc
+++ b/libs/ardour/ladspa_plugin.cc
@@ -534,15 +534,15 @@ LadspaPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t nbufs, int32_t& i
if (LADSPA_IS_PORT_AUDIO (port_descriptor(port_index))) {
if (LADSPA_IS_PORT_INPUT (port_descriptor(port_index))) {
connect_port (port_index, bufs[min((uint32_t) in_index,nbufs - 1)] + offset);
- //cerr << this << ' ' << name() << " @ " << offset << " inport " << in_index << " = buf "
- // << min((uint32_t)in_index,nbufs) << " = " << &bufs[min((uint32_t)in_index,nbufs)][offset] << endl;
+ // cerr << this << ' ' << name() << " @ " << offset << " inport " << in_index << " = buf "
+ // << min((uint32_t)in_index,nbufs) << " = " << &bufs[min((uint32_t)in_index,nbufs)][offset] << endl;
in_index++;
} else if (LADSPA_IS_PORT_OUTPUT (port_descriptor (port_index))) {
connect_port (port_index, bufs[min((uint32_t) out_index,nbufs - 1)] + offset);
// cerr << this << ' ' << name() << " @ " << offset << " outport " << out_index << " = buf "
- // << min((uint32_t)out_index,nbufs) << " = " << &bufs[min((uint32_t)out_index,nbufs)][offset] << endl;
+ // << min((uint32_t)out_index,nbufs) << " = " << &bufs[min((uint32_t)out_index,nbufs)][offset] << endl;
out_index++;
}
}