AudioUnits are selectable in PluginSelector. Will crash if someone clicks

"connect" button though.
Cleaned up AUHost code to use vector<> instead of an array.


git-svn-id: svn://localhost/ardour2/trunk@732 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Taybin Rutkin 2006-08-01 04:05:15 +00:00
parent 1bc8bdcab7
commit 49ab8ea455
5 changed files with 121 additions and 85 deletions

View File

@ -57,6 +57,9 @@ if gtkardour['FFT_ANALYSIS']:
gtkardour.Merge ([libraries['fftw3f']])
gtkardour.Append(CCFLAGS='-DFFT_ANALYSIS')
if gtkardour['COREAUDIO']:
gtkardour.Append(CCFLAGS='-DHAVE_COREAUDIO')
skipped_files=Split("""
connection_editor.cc
""")

View File

@ -50,6 +50,8 @@ PluginSelector::PluginSelector (PluginManager *mgr)
session = 0;
o_selected_plug = -1;
i_selected_plug = 0;
current_selection = ARDOUR::PluginInfo::LADSPA;
lmodel = Gtk::ListStore::create(lcols);
ladspa_display.set_model (lmodel);
@ -91,6 +93,25 @@ PluginSelector::PluginSelector (PluginManager *mgr)
column->set_sort_column(i);
}
#endif
#ifdef HAVE_COREAUDIO
aumodel = ListStore::create(aucols);
au_display.set_model (aumodel);
au_display.append_column (_("Available plugins"), aucols.name);
au_display.append_column (_("# Inputs"), aucols.ins);
au_display.append_column (_("# Outputs"), aucols.outs);
au_display.set_headers_visible (true);
au_display.set_reorderable (false);
auscroller.set_border_width(10);
auscroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
auscroller.add(au_display);
for (int i = 0; i <=2; i++) {
Gtk::TreeView::Column* column = au_display.get_column(i);
column->set_sort_column(i);
}
#endif
ascroller.set_border_width(10);
ascroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
ascroller.add(added_list);
@ -124,35 +145,51 @@ PluginSelector::PluginSelector (PluginManager *mgr)
using namespace Gtk::Notebook_Helpers;
notebook.pages().push_back (TabElem (lscroller, _("LADSPA")));
#ifdef VST_SUPPORT
if (Config->get_use_vst()) {
notebook.pages().push_back (TabElem (vscroller, _("VST")));
}
#endif
#ifdef HAVE_COREAUDIO
notebook.pages().push_back (TabElem (auscroller, _("AudioUnit")));
#endif
table->set_name("PluginSelectorTable");
ladspa_display.set_name("PluginSelectorDisplay");
//ladspa_display.set_name("PluginSelectorList");
added_list.set_name("PluginSelectorList");
ladspa_display.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::row_clicked));
ladspa_display.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::ladspa_display_selection_changed));
#ifdef VST_SUPPORT
if (Config->get_use_vst()) {
vst_display.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::row_clicked));
vst_display.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::vst_display_selection_changed));
}
#endif
#ifdef HAVE_COREAUDIO
au_display.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::row_clicked));
au_display.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::au_display_selection_changed));
#endif
btn_update->signal_clicked().connect (mem_fun(*this, &PluginSelector::btn_update_clicked));
btn_add->signal_clicked().connect(mem_fun(*this, &PluginSelector::btn_add_clicked));
btn_remove->signal_clicked().connect(mem_fun(*this, &PluginSelector::btn_remove_clicked));
ladspa_display.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::ladspa_display_selection_changed));
added_list.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::added_list_selection_changed));
input_refiller ();
#ifdef VST_SUPPORT
vst_refiller ();
#endif
#ifdef HAVE_COREAUDIO
au_refiller ();
#endif
}
void
@ -193,13 +230,7 @@ PluginSelector::input_refiller ()
list<PluginInfo *>::iterator i;
char ibuf[16], obuf[16];
lmodel->clear();
#ifdef VST_SUPPORT
vmodel->clear();
#endif
#ifdef HAVE_COREAUDIO
aumodel->clear();
#endif
// Insert into GTK list
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
@ -231,6 +262,7 @@ PluginSelector::vst_refiller ()
list<PluginInfo *> &plugs = manager->vst_plugin_info ();
list<PluginInfo *>::iterator i;
char ibuf[16], obuf[16];
vmodel->clear();
// Insert into GTK list
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
@ -246,6 +278,19 @@ PluginSelector::vst_refiller ()
}
vmodel->set_sort_column (0, Gtk::SORT_ASCENDING);
}
void
PluginSelector::vst_display_selection_changed()
{
if (vst_display.get_selection()->count_selected_rows() != 0) {
btn_add->set_sensitive (true);
} else {
btn_add->set_sensitive (false);
}
current_selection = ARDOUR::PluginInfo::VST;
}
#endif //VST_SUPPORT
#ifdef HAVE_COREAUDIO
@ -260,10 +305,10 @@ void
PluginSelector::au_refiller ()
{
guint row;
// list<PluginInfo *> &plugs = manager->au_plugin_info ();
list<PluginInfo *> &plugs;
list<PluginInfo *> &plugs = manager->au_plugin_info ();
list<PluginInfo *>::iterator i;
char ibuf[16], obuf[16];
aumodel->clear();
// Insert into GTK list
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
@ -271,14 +316,27 @@ PluginSelector::au_refiller ()
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
Gtk::TreeModel::Row newrow = *(amodel->append());
newrow[acols.name] = (*i)->name.c_str();
newrow[acols.ins] = ibuf;
newrow[acols.outs] = obuf;
newrow[acols.plugin] = *i;
Gtk::TreeModel::Row newrow = *(aumodel->append());
newrow[aucols.name] = (*i)->name.c_str();
newrow[aucols.ins] = ibuf;
newrow[aucols.outs] = obuf;
newrow[aucols.plugin] = *i;
}
amodel->set_sort_column (0, Gtk::SORT_ASCENDING);
aumodel->set_sort_column (0, Gtk::SORT_ASCENDING);
}
void
PluginSelector::au_display_selection_changed()
{
if (au_display.get_selection()->count_selected_rows() != 0) {
btn_add->set_sensitive (true);
} else {
btn_add->set_sensitive (false);
}
current_selection = ARDOUR::PluginInfo::AudioUnit;
}
#endif //HAVE_COREAUDIO
void
@ -300,22 +358,20 @@ PluginSelector::use_plugin (PluginInfo* pi)
void
PluginSelector::btn_add_clicked()
{
// 0 = LADSPA, 1 = VST, 2 = AU
unsigned int page = notebook.get_current_page();
std::string name;
ARDOUR::PluginInfo *pi;
Gtk::TreeModel::Row newrow = *(amodel->append());
Gtk::TreeModel::Row row;
switch (page) {
case 0:
switch (current_selection) {
case ARDOUR::PluginInfo::LADSPA:
row = *(ladspa_display.get_selection()->get_selected());
name = row[lcols.name];
pi = row[lcols.plugin];
added_plugins.push_back (row[lcols.plugin]);
break;
case 1:
case ARDOUR::PluginInfo::VST:
#ifdef VST_SUPPORT
row = *(vst_display.get_selection()->get_selected());
name = row[vcols.name];
@ -323,7 +379,7 @@ PluginSelector::btn_add_clicked()
added_plugins.push_back (row[vcols.plugin]);
#endif
break;
case 2:
case ARDOUR::PluginInfo::AudioUnit:
#ifdef HAVE_COREAUDIO
row = *(au_display.get_selection()->get_selected());
name = row[aucols.name];
@ -331,6 +387,9 @@ PluginSelector::btn_add_clicked()
added_plugins.push_back (row[aucols.plugin]);
#endif
break;
default:
error << "Programming error. Unknown plugin selected." << endmsg;
return;
}
newrow[acols.text] = name;
@ -366,42 +425,20 @@ PluginSelector::btn_update_clicked()
vst_refiller ();
#endif
#ifdef HAVE_COREAUDIO
// au_refiller ();
au_refiller ();
#endif
}
#ifdef VST_SUPPORT
void
PluginSelector::vst_display_selection_changed()
{
if (vst_display.get_selection()->count_selected_rows() != 0) {
btn_add->set_sensitive (true);
} else {
btn_add->set_sensitive (false);
}
}
#endif
#ifdef HAVE_COREAUDIO
void
PluginSelector::vst_display_selection_changed()
{
if (au_display.get_selection()->count_selected_rows() != 0) {
btn_add->set_sensitive (true);
} else {
btn_add->set_sensitive (false);
}
}
#endif
void
PluginSelector::ladspa_display_selection_changed()
{
if (ladspa_display.get_selection()->count_selected_rows() != 0) {
btn_add->set_sensitive (true);
} else {
btn_add->set_sensitive (false);
}
if (ladspa_display.get_selection()->count_selected_rows() != 0) {
btn_add->set_sensitive (true);
} else {
btn_add->set_sensitive (false);
}
current_selection = ARDOUR::PluginInfo::LADSPA;
}
void
@ -445,4 +482,3 @@ PluginSelector::cleanup ()
added_plugins.clear();
amodel->clear();
}

View File

@ -25,10 +25,11 @@
#include <gtkmm/treeview.h>
#include <gtkmm2ext/selector.h>
#include <ardour/plugin.h>
namespace ARDOUR {
class Session;
class PluginManager;
class Plugin;
class PluginInfo;
}
@ -45,9 +46,12 @@ class PluginSelector : public ArdourDialog
private:
ARDOUR::Session* session;
Gtk::Notebook notebook;
Gtk::ScrolledWindow lscroller;
Gtk::ScrolledWindow vscroller;
Gtk::ScrolledWindow ascroller;
Gtk::ScrolledWindow lscroller; // ladspa
Gtk::ScrolledWindow vscroller; // vst
Gtk::ScrolledWindow auscroller; // AudioUnit
Gtk::ScrolledWindow ascroller; // Added plugins
ARDOUR::PluginInfo::Type current_selection;
// page 1
struct LadspaColumns : public Gtk::TreeModel::ColumnRecord {

View File

@ -215,7 +215,7 @@ get_font_for_style (string widgetname)
{
Gtk::Window window (WINDOW_TOPLEVEL);
Gtk::Label foobar;
Glib::RefPtr<Style> style;
Glib::RefPtr<Gtk::Style> style;
window.add (foobar);
foobar.set_name (widgetname);

View File

@ -508,7 +508,8 @@ PluginManager::vst_discover (string path)
int
PluginManager::au_discover ()
{
int mNumUnits = 0;
_au_plugin_info.clear ();
int numTypes = 2; // this magic number was retrieved from the apple AUHost example.
ComponentDescription desc;
@ -516,6 +517,8 @@ PluginManager::au_discover ()
desc.componentFlagsMask = 0;
desc.componentSubType = 0;
desc.componentManufacturer = 0;
vector<ComponentDescription> vCompDescs;
for (int i = 0; i < numTypes; ++i) {
if (i == 1) {
@ -523,23 +526,6 @@ PluginManager::au_discover ()
} else {
desc.componentType = kAudioUnitType_Effect;
}
int n = CountComponents (&desc);
mNumUnits += n;
}
cout << "Number of AU plugins: " << mNumUnits << endl;
ComponentDescription* mCompDescs = new ComponentDescription[mNumUnits];
int n = 0;
for (int i = 0; i < numTypes; ++i)
{
if (i == 1) {
desc.componentType = kAudioUnitType_MusicEffect;
} else {
desc.componentType = kAudioUnitType_Effect;
}
Component comp = 0;
@ -547,17 +533,18 @@ PluginManager::au_discover ()
while (comp != NULL) {
ComponentDescription temp;
GetComponentInfo (comp, &temp, NULL, NULL, NULL);
mCompDescs[n++] = temp;
vCompDescs.push_back(temp);
comp = FindNextComponent (comp, &desc);
}
}
for (int i = 0; i < mNumUnits; ++i) {
PluginInfo* plug;
for (unsigned int i = 0; i < vCompDescs.size(); ++i) {
// the following large block is just for determining the name of the plugin.
CFStringRef itemName = NULL;
// Marc Poirier -style item name
Component auComponent = FindNextComponent (0, &(mCompDescs[i]));
Component auComponent = FindNextComponent (0, &(vCompDescs[i]));
if (auComponent != NULL) {
ComponentDescription dummydesc;
Handle nameHandle = NewHandle(sizeof(void*));
@ -575,9 +562,9 @@ PluginManager::au_discover ()
// if Marc-style fails, do the original way
if (itemName == NULL) {
CFStringRef compTypeString = UTCreateStringForOSType(mCompDescs[i].componentType);
CFStringRef compSubTypeString = UTCreateStringForOSType(mCompDescs[i].componentSubType);
CFStringRef compManufacturerString = UTCreateStringForOSType(mCompDescs[i].componentManufacturer);
CFStringRef compTypeString = UTCreateStringForOSType(vCompDescs[i].componentType);
CFStringRef compSubTypeString = UTCreateStringForOSType(vCompDescs[i].componentSubType);
CFStringRef compManufacturerString = UTCreateStringForOSType(vCompDescs[i].componentManufacturer);
itemName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ - %@ - %@"),
compTypeString, compManufacturerString, compSubTypeString);
@ -590,11 +577,17 @@ PluginManager::au_discover ()
CFRelease(compManufacturerString);
}
string realname = CFStringRefToStdString(itemName);
cout << realname << endl;
plug = new PluginInfo;
plug->name = realname;
plug->type = PluginInfo::AudioUnit;
plug->n_inputs = 0;
plug->n_outputs = 0;
plug->category = "AudioUnit";
_au_plugin_info.push_back(plug);
}
delete[] mCompDescs;
return 0;
}