From 4aeebb914eedf9279e4904786ce42518611de137 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 18 Oct 2011 15:08:42 +0000 Subject: changes for OS X support: change waf config define to COREAUDIO_SUPPORT, remove PluginInsert call to IO::PortCountChanged, remove use of explicit Carbon linkage, fix up AudioUnit internals to actually work (Cocoa GUIs still currently broken) git-svn-id: svn://localhost/ardour2/branches/3.0@10224 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/plugin_selector.cc | 6 +- gtk2_ardour/plugin_ui.h | 2 +- gtk2_ardour/processor_box.cc | 2 +- gtk2_ardour/wscript | 2 +- libs/ardour/ardour/audio_unit.h | 4 + libs/ardour/ardour/plugin.h | 2 +- libs/ardour/audio_unit.cc | 180 ++++++++++++++++++++++--------------- libs/ardour/buffer_manager.cc | 7 ++ libs/ardour/globals.cc | 4 +- libs/ardour/plugin.cc | 12 ++- libs/ardour/plugin_insert.cc | 18 ++-- libs/ardour/plugin_manager.cc | 30 +++---- libs/ardour/processor.cc | 2 +- libs/ardour/source_factory.cc | 10 +-- libs/ardour/wscript | 2 +- libs/panners/vbap/vbap_speakers.cc | 2 + libs/panners/vbap/vbap_speakers.h | 2 +- templates/wscript | 2 +- wscript | 13 +-- 19 files changed, 177 insertions(+), 125 deletions(-) diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc index 1b00c56fd9..a6da21e4b7 100644 --- a/gtk2_ardour/plugin_selector.cc +++ b/gtk2_ardour/plugin_selector.cc @@ -374,13 +374,13 @@ PluginSelector::lxvst_refiller (const std::string&) } void -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT PluginSelector::au_refiller (const std::string& filterstr) #else PluginSelector::au_refiller (const std::string&) #endif { -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT refiller (manager->au_plugin_info(), filterstr, "AU"); #endif } @@ -604,7 +604,7 @@ PluginSelector::build_plugin_menu () #ifdef LXVST_SUPPORT all_plugs.insert (all_plugs.end(), manager->lxvst_plugin_info().begin(), manager->lxvst_plugin_info().end()); #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT all_plugs.insert (all_plugs.end(), manager->au_plugin_info().begin(), manager->au_plugin_info().end()); #endif #ifdef LV2_SUPPORT diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index e060907986..20282c4cfa 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -304,7 +304,7 @@ class PluginUIWindow : public Gtk::Window bool create_lv2_editor (boost::shared_ptr); }; -#ifdef AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT /* this function has to be in a .mm file */ extern PlugUIBase* create_au_gui (boost::shared_ptr, Gtk::VBox**); #endif diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 9f2f1ed1e5..80b2352788 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -76,7 +76,7 @@ #include "i18n.h" -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT class AUPluginUI; #endif diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 0b5a95fbdc..296c0aaa64 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -397,7 +397,7 @@ def build(bld): if bld.is_defined('PHONE_HOME'): obj.defines += [ 'PHONE_HOME' ] - if bld.is_defined('COREAUDIO'): + if bld.is_defined('HAVE_COREAUDIO'): TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc'] obj.source += [ 'cocoacarbon.mm', 'au_pluginui.mm' ] obj.use += ' libappleutility ' diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index 0a786d5462..db38b0f234 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -94,6 +94,8 @@ class AUPlugin : public ARDOUR::Plugin bool parameter_is_control (uint32_t) const; bool parameter_is_input (uint32_t) const; bool parameter_is_output (uint32_t) const; + + void set_info (PluginInfoPtr); int set_state(const XMLNode& node, int); @@ -104,6 +106,8 @@ class AUPlugin : public ARDOUR::Plugin bool reconfigurable_io() const { return true; } bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const; + ChanCount output_streams() const; + ChanCount input_streams() const; bool configure_io (ChanCount in, ChanCount out); bool requires_fixed_size_buffers() const; diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index fcd7d6d19b..9c073d4a19 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -215,7 +215,7 @@ class Plugin : public PBD::StatefulDestructible, public Latent virtual ChanCount input_streams() const; PluginInfoPtr get_info() const { return _info; } - void set_info (const PluginInfoPtr inf) { _info = inf; } + virtual void set_info (const PluginInfoPtr inf); ARDOUR::AudioEngine& engine() const { return _engine; } ARDOUR::Session& session() const { return _session; } diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 04efb2e50c..5440156ebb 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -38,6 +38,7 @@ #include "ardour/ardour.h" #include "ardour/audioengine.h" #include "ardour/audio_buffer.h" +#include "ardour/debug.h" #include "ardour/midi_buffer.h" #include "ardour/filesystem_paths.h" #include "ardour/io.h" @@ -60,13 +61,6 @@ using namespace std; using namespace PBD; using namespace ARDOUR; -//#define TRACE_AU_API -#ifdef TRACE_AU_API -#define TRACE_API(fmt,...) fprintf (stderr, fmt, ## __VA_ARGS__) -#else -#define TRACE_API(fmt,...) -#endif - #ifndef AU_STATE_SUPPORT static bool seen_get_state_message = false; static bool seen_set_state_message = false; @@ -79,7 +73,6 @@ AUPluginInfo::CachedInfoMap AUPluginInfo::cached_info; static string preset_search_path = "/Library/Audio/Presets:/Network/Library/Audio/Presets"; static string preset_suffix = ".aupreset"; static bool preset_search_path_initialized = false; -static bool debug_io_config = true; static OSStatus _render_callback(void *userData, @@ -392,7 +385,7 @@ AUPlugin::AUPlugin (const AUPlugin& other) AUPlugin::~AUPlugin () { if (unit) { - TRACE_API ("about to call uninitialize in plugin destructor\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "about to call uninitialize in plugin destructor\n"); unit->Uninitialize (); } @@ -408,7 +401,7 @@ AUPlugin::discover_factory_presets () UInt32 dataSize = sizeof (presets); OSStatus err; - TRACE_API ("get property FactoryPresets in global scope\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "get property FactoryPresets in global scope\n"); if ((err = unit->GetProperty (kAudioUnitProperty_FactoryPresets, kAudioUnitScope_Global, 0, (void*) &presets, &dataSize)) != 0) { cerr << "cannot get factory preset info: " << err << endl; return; @@ -435,8 +428,15 @@ AUPlugin::init () { OSErr err; + /* these keep track of *configured* channel set up, + not potential set ups. + */ + + input_channels = -1; + output_channels = -1; + try { - TRACE_API ("opening AudioUnit\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "opening AudioUnit\n"); err = CAAudioUnit::Open (*(comp.get()), *unit); } catch (...) { error << _("Exception thrown during AudioUnit plugin loading - plugin ignored") << endmsg; @@ -448,11 +448,11 @@ AUPlugin::init () throw failed_constructor (); } - TRACE_API ("count global elements\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "count global elements\n"); unit->GetElementCount (kAudioUnitScope_Global, global_elements); - TRACE_API ("count input elements\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "count input elements\n"); unit->GetElementCount (kAudioUnitScope_Input, input_elements); - TRACE_API ("count output elements\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "count output elements\n"); unit->GetElementCount (kAudioUnitScope_Output, output_elements); if (input_elements > 0) { @@ -461,7 +461,7 @@ AUPlugin::init () renderCallbackInfo.inputProc = _render_callback; renderCallbackInfo.inputProcRefCon = this; - TRACE_API ("set render callback in input scope\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "set render callback in input scope\n"); if ((err = unit->SetProperty (kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, (void*) &renderCallbackInfo, sizeof(renderCallbackInfo))) != 0) { cerr << "cannot install render callback (err = " << err << ')' << endl; @@ -479,29 +479,18 @@ AUPlugin::init () info.transportStateProc = _get_transport_state_callback; //ignore result of this - don't care if the property isn't supported - TRACE_API ("set host callbacks in global scope\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "set host callbacks in global scope\n"); unit->SetProperty (kAudioUnitProperty_HostCallbacks, kAudioUnitScope_Global, 0, //elementID &info, sizeof (HostCallbackInfo)); - /* these keep track of *configured* channel set up, - not potential set ups. - */ - - input_channels = -1; - output_channels = -1; - if (set_block_size (_session.get_block_size())) { error << _("AUPlugin: cannot set processing block size") << endmsg; throw failed_constructor(); } - AUPluginInfoPtr pinfo = boost::dynamic_pointer_cast(get_info()); - _has_midi_input = pinfo->needs_midi_input (); - _has_midi_output = false; - discover_parameters (); discover_factory_presets (); @@ -770,7 +759,7 @@ AUPlugin::set_parameter (uint32_t which, float val) } const AUParameterDescriptor& d (descriptors[which]); - TRACE_API ("set parameter %d in scope %d element %d to %f\n", d.id, d.scope, d.element, val); + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("set parameter %1 in scope %2 element %3 to %4\n", d.id, d.scope, d.element, val)); unit->SetParameter (d.id, d.scope, d.element, val); /* tell the world what we did */ @@ -783,7 +772,7 @@ AUPlugin::set_parameter (uint32_t which, float val) theEvent.mArgument.mParameter.mScope = d.scope; theEvent.mArgument.mParameter.mElement = d.element; - TRACE_API ("notify about parameter change\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "notify about parameter change\n"); AUEventListenerNotify (NULL, NULL, &theEvent); Plugin::set_parameter (which, val); @@ -795,7 +784,7 @@ AUPlugin::get_parameter (uint32_t which) const float val = 0.0; if (which < descriptors.size()) { const AUParameterDescriptor& d (descriptors[which]); - TRACE_API ("get value of parameter %d in scope %d element %d\n", d.id, d.scope, d.element); + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("get value of parameter %1 in scope %2 element %3\n", d.id, d.scope, d.element)); unit->GetParameter(d.id, d.scope, d.element, val); } return val; @@ -827,7 +816,7 @@ AUPlugin::activate () { if (!initialized) { OSErr err; - TRACE_API ("call Initialize in activate()\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "call Initialize in activate()\n"); if ((err = unit->Initialize()) != noErr) { error << string_compose (_("AUPlugin: %1 cannot initialize plugin (err = %2)"), name(), err) << endmsg; } else { @@ -840,7 +829,7 @@ AUPlugin::activate () void AUPlugin::deactivate () { - TRACE_API ("call Uninitialize in deactivate()\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "call Uninitialize in deactivate()\n"); unit->Uninitialize (); initialized = false; } @@ -848,7 +837,7 @@ AUPlugin::deactivate () void AUPlugin::flush () { - TRACE_API ("call Reset in flush()\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "call Reset in flush()\n"); unit->GlobalReset (); } @@ -870,7 +859,7 @@ AUPlugin::set_block_size (pframes_t nframes) deactivate (); } - TRACE_API ("set MaximumFramesPerSlice in global scope to %u\n", numFrames); + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("set MaximumFramesPerSlice in global scope to %1\n", numFrames)); if ((err = unit->SetProperty (kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &numFrames, sizeof (numFrames))) != noErr) { cerr << "cannot set max frames (err = " << err << ')' << endl; @@ -894,6 +883,8 @@ AUPlugin::configure_io (ChanCount in, ChanCount out) int32_t audio_in = in.n_audio(); int32_t audio_out = out.n_audio(); + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("configure %1 for %2 in %3 out\n", name(), in, out)); + if (initialized) { //if we are already running with the requested i/o config, bail out here if ( (audio_in==input_channels) && (audio_out==output_channels) ) { @@ -934,6 +925,11 @@ AUPlugin::configure_io (ChanCount in, ChanCount out) return -1; } + /* reset plugin info to show currently configured state */ + + _info->n_inputs = in; + _info->n_outputs = out; + if (was_initialized) { activate (); } @@ -941,6 +937,43 @@ AUPlugin::configure_io (ChanCount in, ChanCount out) return 0; } +ChanCount +AUPlugin::input_streams() const +{ + ChanCount c; + + c.set (DataType::AUDIO, 1); + c.set (DataType::MIDI, 0); + + if (input_channels < 0) { + warning << string_compose (_("AUPlugin: %1 input_streams() called without any format set!"), name()) << endmsg; + } else { + c.set (DataType::AUDIO, input_channels); + c.set (DataType::MIDI, _has_midi_input ? 1 : 0); + } + + return c; +} + + +ChanCount +AUPlugin::output_streams() const +{ + ChanCount c; + + c.set (DataType::AUDIO, 1); + c.set (DataType::MIDI, 0); + + if (output_channels < 0) { + warning << string_compose (_("AUPlugin: %1 output_streams() called without any format set!"), name()) << endmsg; + } else { + c.set (DataType::AUDIO, output_channels); + c.set (DataType::MIDI, _has_midi_output ? 1 : 0); + } + + return c; +} + bool AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) const { @@ -962,9 +995,7 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) con vector >& io_configs = pinfo->cache.io_configs; - if (debug_io_config) { - cerr << name() << " has " << io_configs.size() << " IO Configurations\n"; - } + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("%1 has %2 IO configurations\n", name(), io_configs.size())); //Ardour expects the plugin to tell it the output configuration //but AU plugins can have multiple I/O configurations @@ -977,8 +1008,8 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) con int32_t possible_in = i->first; int32_t possible_out = i->second; - if (possible_in == audio_in && possible_out== audio_out) { - cerr << "\tCHOSEN: in " << in << " out " << out << endl; + if (possible_in == audio_in && possible_out == audio_out) { + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("\tCHOSEN: in %1 out %2\n", in, out)); return 1; } } @@ -990,9 +1021,7 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) con int32_t possible_in = i->first; int32_t possible_out = i->second; - if (debug_io_config) { - cerr << "\tin " << possible_in << " out " << possible_out << endl; - } + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("\tpossible in %1 possible out %2\n", possible_in, possible_out)); if (possible_out == 0) { warning << string_compose (_("AU %1 has zero outputs - configuration ignored"), name()) << endmsg; @@ -1124,12 +1153,10 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) con } - if (debug_io_config) { - if (plugcnt > 0) { - cerr << "\tCHOSEN: in " << in << " out " << out << " plugcnt will be " << plugcnt << endl; - } else { - cerr << "\tFAIL: no configs match requested in " << in << endl; - } + if (plugcnt > 0) { + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("\tCHOSEN: in %1 out %2 plugcnt %3\n", in, out, plugcnt)); + } else { + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("\FAIL: no io configs match %1\n", in)); } out.set (DataType::MIDI, 0); @@ -1159,9 +1186,6 @@ AUPlugin::set_output_format (AudioStreamBasicDescription& fmt) buffers = (AudioBufferList *) malloc (offsetof(AudioBufferList, mBuffers) + fmt.mChannelsPerFrame * sizeof(::AudioBuffer)); - Glib::Mutex::Lock em (_session.engine().process_lock()); - IO::PortCountChanged (ChanCount(DataType::AUDIO, fmt.mChannelsPerFrame)); - return 0; } @@ -1171,9 +1195,9 @@ AUPlugin::set_stream_format (int scope, uint32_t cnt, AudioStreamBasicDescriptio OSErr result; for (uint32_t i = 0; i < cnt; ++i) { - TRACE_API ("set stream format for %s, scope = %d element %d\n", - (scope == kAudioUnitScope_Input ? "input" : "output"), - scope, cnt); + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("set stream format for %1, scope = %2 element %3\n", + (scope == kAudioUnitScope_Input ? "input" : "output"), + scope, cnt)); if ((result = unit->SetFormat (scope, i, fmt)) != 0) { error << string_compose (_("AUPlugin: could not set stream format for %1/%2 (err = %3)"), (scope == kAudioUnitScope_Input ? "input" : "output"), i, result) << endmsg; @@ -1322,7 +1346,7 @@ AUPlugin::get_beat_and_tempo_callback (Float64* outCurrentBeat, { TempoMap& tmap (_session.tempo_map()); - TRACE_API ("AU calls ardour beat&tempo callback\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour beat&tempo callback\n"); /* more than 1 meter or more than 1 tempo means that a simplistic computation (and interpretation) of a beat position will be incorrect. So refuse to @@ -1361,7 +1385,7 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe { TempoMap& tmap (_session.tempo_map()); - TRACE_API ("AU calls ardour music time location callback\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour music time location callback\n"); /* more than 1 meter or more than 1 tempo means that a simplistic computation (and interpretation) of a beat position will be incorrect. So refuse to @@ -1420,7 +1444,7 @@ AUPlugin::get_transport_state_callback (Boolean* outIsPlaying, bool rolling; float speed; - TRACE_API ("AU calls ardour transport state callback\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour transport state callback\n"); rolling = _session.transport_rolling(); speed = _session.transport_speed (); @@ -1563,7 +1587,7 @@ AUPlugin::add_state (XMLNode* root) const CFDataRef xmlData; CFPropertyListRef propertyList; - TRACE_API ("get preset state\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "get preset state\n"); if (unit->GetAUPreset (propertyList) != noErr) { return; } @@ -1636,7 +1660,7 @@ AUPlugin::set_state(const XMLNode& node, int version) CFRelease (xmlData); if (propertyList) { - TRACE_API ("set preset\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "set preset\n"); if (unit->SetAUPreset (propertyList) == noErr) { ret = 0; @@ -1679,7 +1703,7 @@ AUPlugin::load_preset (PresetRecord r) if ((ux = user_preset_map.find (r.label)) != user_preset_map.end()) { if ((propertyList = load_property_list (ux->second)) != 0) { - TRACE_API ("set preset from user presets\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "set preset from user presets\n"); if (unit->SetAUPreset (propertyList) == noErr) { ret = true; @@ -1700,7 +1724,7 @@ AUPlugin::load_preset (PresetRecord r) preset.presetNumber = fx->second; preset.presetName = CFStringCreateWithCString (kCFAllocatorDefault, fx->first.c_str(), kCFStringEncodingUTF8); - TRACE_API ("set preset from factory presets\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "set preset from factory presets\n"); if (unit->SetPresentPreset (preset) == 0) { ret = true; @@ -1760,7 +1784,7 @@ AUPlugin::do_save_preset (string preset_name) return false; } - TRACE_API ("get current preset\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "get current preset\n"); if (unit->GetAUPreset (propertyList) != noErr) { return false; } @@ -1961,7 +1985,7 @@ AUPlugin::current_preset() const #ifdef AU_STATE_SUPPORT CFPropertyListRef propertyList; - TRACE_API ("get current preset for current_preset()\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "get current preset for current_preset()\n"); if (unit->GetAUPreset (propertyList) == noErr) { preset_name = get_preset_name_in_plist (propertyList); CFRelease(propertyList); @@ -2051,7 +2075,7 @@ AUPluginInfo::load (Session& session) try { PluginPtr plugin; - TRACE_API ("load AU as a component\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "load AU as a component\n"); boost::shared_ptr comp (new CAComponent(*descriptor)); if (!comp->IsValid()) { @@ -2061,12 +2085,14 @@ AUPluginInfo::load (Session& session) } AUPluginInfo *aup = new AUPluginInfo (*this); + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("plugin info for %1 = %2\n", this, aup)); plugin->set_info (PluginInfoPtr (aup)); boost::dynamic_pointer_cast (plugin)->set_fixed_size_buffers (aup->creator == "Universal Audio"); return plugin; } catch (failed_constructor &err) { + DEBUG_TRACE (DEBUG::AudioUnits, "failed to load component/plugin\n"); return PluginPtr (); } } @@ -2088,12 +2114,12 @@ AUPluginInfo::discover () PluginInfoList* plugs = new PluginInfoList; -#if 0 discover_fx (*plugs); discover_music (*plugs); discover_generators (*plugs); discover_instruments (*plugs); -#endif + + DEBUG_TRACE (DEBUG::PluginManager, string_compose ("AU: discovered %1 plugins\n", plugs->size())); return plugs; } @@ -2227,7 +2253,8 @@ AUPluginInfo::discover_by_description (PluginInfoList& plugs, CAComponentDescrip info->n_inputs.set (DataType::AUDIO, info->cache.io_configs.front().first); info->n_outputs.set (DataType::AUDIO, info->cache.io_configs.front().second); - cerr << "detected AU: " << info->name.c_str() << " (" << info->cache.io_configs.size() << " i/o configurations) - " << info->unique_id << endl; + DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("detected AU %1 with %2 i/o configurations - %3\n", + info->name.c_str(), info->cache.io_configs.size(), info->unique_id)); plugs.push_back (info); @@ -2282,20 +2309,20 @@ AUPluginInfo::cached_io_configuration (const std::string& unique_id, } catch (...) { warning << string_compose (_("Could not load AU plugin %1 - ignored"), name) << endmsg; - cerr << string_compose (_("Could not load AU plugin %1 - ignored"), name) << endl; return false; } - TRACE_API ("get AU channel info\n"); + DEBUG_TRACE (DEBUG::AudioUnits, "get AU channel info\n"); if ((ret = unit.GetChannelInfo (&channel_info, cnt)) < 0) { return false; } if (ret > 0) { - /* no explicit info available */ - cinfo.io_configs.push_back (pair (-1, -1)); + /* no explicit info available, so default to 1in/1out */ + + cinfo.io_configs.push_back (pair (1, 1)); } else { @@ -2563,3 +2590,14 @@ AUPluginInfo::is_instrument () const { return descriptor->IsMusicDevice(); } + +void +AUPlugin::set_info (PluginInfoPtr info) +{ + Plugin::set_info (info); + + AUPluginInfoPtr pinfo = boost::dynamic_pointer_cast(get_info()); + + _has_midi_input = pinfo->needs_midi_input (); + _has_midi_output = false; +} diff --git a/libs/ardour/buffer_manager.cc b/libs/ardour/buffer_manager.cc index 5ebbce2629..e035e4519a 100644 --- a/libs/ardour/buffer_manager.cc +++ b/libs/ardour/buffer_manager.cc @@ -18,7 +18,11 @@ */ #include + +#include "pbd/compose.h" + #include "ardour/buffer_manager.h" +#include "ardour/debug.h" #include "ardour/thread_buffers.h" using namespace ARDOUR; @@ -69,7 +73,10 @@ BufferManager::ensure_buffers (ChanCount howmany) { /* this is protected by the audioengine's process lock: we do not */ + DEBUG_TRACE (DEBUG::Processors, string_compose ("BufferManager::ensure_buffers (%1)\n", howmany)); + for (ThreadBufferList::iterator i = thread_buffers_list->begin(); i != thread_buffers_list->end(); ++i) { + DEBUG_TRACE (DEBUG::Processors, string_compose ("BufferManager::ensure_buffers, thread buffers @ %1\n", (*i))); (*i)->ensure_buffers (howmany); } } diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 48a7dc0da0..7c713980c3 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -37,7 +37,7 @@ #include "ardour/vstfx.h" #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT #include "ardour/audio_unit.h" #endif @@ -313,7 +313,7 @@ ARDOUR::init (bool use_vst, bool try_optimization) } #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT AUPluginInfo::load_cached_info (); #endif diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index 12760e5d6e..21ad91ff0e 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -45,7 +45,7 @@ #include "ardour/ladspa_plugin.h" #include "ardour/plugin_manager.h" -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT #include "ardour/audio_unit.h" #endif @@ -145,7 +145,7 @@ ARDOUR::find_plugin(Session& session, string identifier, PluginType type) break; #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT case ARDOUR::AudioUnit: plugs = mgr->au_plugin_info(); break; @@ -237,7 +237,7 @@ Plugin::preset_by_uri (const string& uri) int Plugin::connect_and_run (BufferSet& bufs, ChanMapping /*in_map*/, ChanMapping /*out_map*/, - pframes_t nframes, framecnt_t offset) + pframes_t /* nframes */, framecnt_t /*offset*/) { if (bufs.count().n_midi() > 0) { @@ -339,3 +339,9 @@ Plugin::get_state () add_state (root); return *root; } + +void +Plugin::set_info (PluginInfoPtr info) +{ + _info = info; +} diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index ea95ed09e5..78f6596330 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -30,6 +30,7 @@ #include "ardour/audio_buffer.h" #include "ardour/automation_list.h" #include "ardour/buffer_set.h" +#include "ardour/debug.h" #include "ardour/event_type_map.h" #include "ardour/ladspa_plugin.h" #include "ardour/plugin.h" @@ -49,7 +50,7 @@ #include "ardour/lxvst_plugin.h" #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT #include "ardour/audio_unit.h" #endif @@ -133,6 +134,8 @@ PluginInsert::output_streams() const { ChanCount out = _plugins.front()->get_info()->n_outputs; + DEBUG_TRACE (DEBUG::Processors, string_compose ("Plugin insert, static output streams = %1\n", out)); + if (out == ChanCount::INFINITE) { return _plugins.front()->output_streams (); } else { @@ -147,6 +150,8 @@ PluginInsert::input_streams() const { ChanCount in = _plugins[0]->get_info()->n_inputs; + DEBUG_TRACE (DEBUG::Processors, string_compose ("Plugin insert, static input streams = %1, match using %2\n", in, _match.method)); + if (_match.method == Split) { /* we are splitting 1 processor input to multiple plugin inputs, @@ -597,7 +602,7 @@ PluginInsert::plugin_factory (boost::shared_ptr other) #ifdef LXVST_SUPPORT boost::shared_ptr lxvp; #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT boost::shared_ptr ap; #endif @@ -615,7 +620,7 @@ PluginInsert::plugin_factory (boost::shared_ptr other) } else if ((lxvp = boost::dynamic_pointer_cast (other)) != 0) { return boost::shared_ptr (new LXVSTPlugin (*lxvp)); #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT } else if ((ap = boost::dynamic_pointer_cast (other)) != 0) { return boost::shared_ptr (new AUPlugin (*ap)); #endif @@ -1013,13 +1018,6 @@ PluginInsert::set_state(const XMLNode& node, int version) } } - /* catch up on I/O */ - - { - Glib::Mutex::Lock em (_session.engine().process_lock()); - IO::PortCountChanged (max(input_streams(), output_streams())); - } - return 0; } diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 7072e073ba..88dc4c13a7 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -47,12 +47,13 @@ #include "pbd/pathscanner.h" #include "pbd/whitespace.h" +#include "ardour/debug.h" +#include "ardour/filesystem_paths.h" #include "ardour/ladspa.h" -#include "ardour/session.h" -#include "ardour/plugin_manager.h" -#include "ardour/plugin.h" #include "ardour/ladspa_plugin.h" -#include "ardour/filesystem_paths.h" +#include "ardour/plugin.h" +#include "ardour/plugin_manager.h" +#include "ardour/session.h" #ifdef LV2_SUPPORT #include "ardour/lv2_plugin.h" @@ -66,7 +67,7 @@ #include "ardour/lxvst_plugin.h" #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT #include "ardour/audio_unit.h" #include #endif @@ -94,14 +95,6 @@ PluginManager::PluginManager () load_statuses (); -#ifdef HAVE_AUDIOUNITS - ProcessSerialNumber psn = { 0, kCurrentProcess }; - OSStatus returnCode = TransformProcessType(& psn, kProcessTransformToForegroundApplication); - if( returnCode != 0) { - error << _("Cannot become GUI app") << endmsg; - } -#endif - if ((s = getenv ("LADSPA_RDF_PATH"))){ lrdf_path = s; } @@ -168,6 +161,8 @@ PluginManager::~PluginManager() void PluginManager::refresh () { + DEBUG_TRACE (DEBUG::PluginManager, "PluginManager::refresh\n"); + ladspa_refresh (); #ifdef LV2_SUPPORT lv2_refresh (); @@ -184,7 +179,7 @@ PluginManager::refresh () } #endif //Native linuxVST SUPPORT -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT au_refresh (); #endif @@ -236,6 +231,8 @@ PluginManager::ladspa_refresh () } + DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA: search along: [%1]\n", ladspa_path)); + ladspa_discover_from_path (ladspa_path); } @@ -509,10 +506,11 @@ PluginManager::lv2_refresh () } #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT void PluginManager::au_refresh () { + DEBUG_TRACE (DEBUG::PluginManager, "AU: refresh\n"); delete _au_plugin_info; _au_plugin_info = AUPluginInfo::discover(); } @@ -947,7 +945,7 @@ PluginManager::lv2_plugin_info () ARDOUR::PluginInfoList& PluginManager::au_plugin_info () { -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT if (!_au_plugin_info) au_refresh(); return *_au_plugin_info; diff --git a/libs/ardour/processor.cc b/libs/ardour/processor.cc index cf641fd7cf..cbec3e6029 100644 --- a/libs/ardour/processor.cc +++ b/libs/ardour/processor.cc @@ -42,7 +42,7 @@ #include "ardour/vst_plugin.h" #endif -#ifdef HAVE_AUDIOUNITS +#ifdef AUDIOUNIT_SUPPORT #include "ardour/audio_unit.h" #endif diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 3ea63a75ed..65f9d8da28 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -40,10 +40,6 @@ #include "ardour/session.h" #ifdef HAVE_COREAUDIO -#define USE_COREAUDIO_FOR_FILES -#endif - -#ifdef USE_COREAUDIO_FOR_FILES #include "ardour/coreaudiosource.h" #endif @@ -188,7 +184,7 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) catch (failed_constructor& err) { -#ifdef USE_COREAUDIO_FOR_FILES +#ifdef HAVE_COREAUDIO /* this is allowed to throw */ @@ -252,7 +248,7 @@ SourceFactory::createReadable (DataType type, Session& s, const string& path, } catch (failed_constructor& err) { -#ifdef USE_COREAUDIO_FOR_FILES +#ifdef HAVE_COREAUDIO Source* src = new CoreAudioSource (s, path, chn, flags); #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS @@ -350,7 +346,7 @@ SourceFactory::createWritable (DataType type, Session& s, const std::string& pat } boost::shared_ptr -SourceFactory::createFromPlaylist (DataType type, Session& s, boost::shared_ptr p, const ID& orig, const std::string& name, +SourceFactory::createFromPlaylist (DataType type, Session& s, boost::shared_ptr p, const PBD::ID& orig, const std::string& name, uint32_t chn, frameoffset_t start, framecnt_t len, bool copy, bool defer_peaks) { if (type == DataType::AUDIO) { diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 48694fdb5d..210c80e434 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -391,7 +391,7 @@ def build(bld): obj.defines += [ 'LXVST_SUPPORT' ] - if bld.is_defined('COREAUDIO'): + if bld.is_defined('HAVE_COREAUDIO'): obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ] obj.use += ['libappleutility'] obj.source += [ 'audio_unit.cc' ] diff --git a/libs/panners/vbap/vbap_speakers.cc b/libs/panners/vbap/vbap_speakers.cc index 29791936fb..b84698bbd9 100644 --- a/libs/panners/vbap/vbap_speakers.cc +++ b/libs/panners/vbap/vbap_speakers.cc @@ -43,6 +43,8 @@ using namespace ARDOUR; using namespace PBD; using namespace std; +const double VBAPSpeakers::MIN_VOL_P_SIDE_LGTH = 0.01; + VBAPSpeakers::VBAPSpeakers (boost::shared_ptr s) : _dimension (2) , _parent (s) diff --git a/libs/panners/vbap/vbap_speakers.h b/libs/panners/vbap/vbap_speakers.h index 4c28fc6489..b2f8b3c9dd 100644 --- a/libs/panners/vbap/vbap_speakers.h +++ b/libs/panners/vbap/vbap_speakers.h @@ -50,7 +50,7 @@ public: ~VBAPSpeakers (); private: - static const double MIN_VOL_P_SIDE_LGTH = 0.01; + static const double MIN_VOL_P_SIDE_LGTH; int _dimension; boost::shared_ptr _parent; std::vector _speakers; diff --git a/templates/wscript b/templates/wscript index 3deb74c8d7..7d01a73bb8 100644 --- a/templates/wscript +++ b/templates/wscript @@ -11,7 +11,7 @@ def configure(conf): def build(bld): subst_dict = {} - if bld.is_defined('COREAUDIO'): + if bld.is_defined('COREAUDIO_SUPPORT'): subst_dict['%JACK_INPUT%'] = 'coreaudio:Built-in Audio:in' subst_dict['%JACK_OUTPUT%'] = 'coreaudio:Built-in Audio:out' else: diff --git a/wscript b/wscript index 72e511d880..e916d54b47 100644 --- a/wscript +++ b/wscript @@ -236,6 +236,7 @@ def set_compiler_flags (conf,opt): # check this even if we aren't using FPU optimization if not conf.is_defined('HAVE_POSIX_MEMALIGN'): optimization_flags.append("-DNO_POSIX_MEMALIGN") + debug_flags.append("-DNO_POSIX_MEMALIGN") # end optimization section @@ -289,7 +290,7 @@ def set_compiler_flags (conf,opt): # optimization_flags[:0] = [ - "-O3", + "-g", "-O2", "-fomit-frame-pointer", "-ffast-math", "-fstrength-reduce", @@ -441,9 +442,9 @@ def configure(conf): if sys.platform == 'darwin': - conf.define ('AUDIOUNITS', 1) + conf.define ('HAVE_COREAUDIO', 1) + conf.define ('AUDIOUNIT_SUPPORT', 1) conf.define ('AU_STATE_SUPPORT', 1) - conf.define ('COREAUDIO', 1) conf.define ('GTKOSX', 1) conf.define ('TOP_MENUBAR',1) conf.define ('GTKOSX',1) @@ -486,9 +487,9 @@ def configure(conf): conf.env.append_value('LINKFLAGS_GTKOSX', [ '-Xlinker', '-headerpad']) conf.env.append_value('LINKFLAGS_GTKOSX', ['-Xlinker', '2048']) - conf.env.append_value('CPPPATH_GTKOSX', "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/") - conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DHAVE_AUDIOUNITS") + conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DAUDIOUNIT_SUPPORT") + conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DAU_STATE_SUPPORT") conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'Audiotoolbox', '-framework', 'AudioUnit']) if Options.options.boost_include != '': @@ -587,6 +588,8 @@ const char* const ardour_config_info = "\\n\\ write_config_text('Architecture flags', opts.arch) write_config_text('Aubio', conf.is_defined('HAVE_AUBIO')) + write_config_text('AudioUnits', conf.is_defined('AUDIOUNIT_SUPPORT')) + write_config_text('AU state support', conf.is_defined('AU_STATE_SUPPORT')) write_config_text('Build target', conf.env['build_target']) write_config_text('CoreAudio', conf.is_defined('HAVE_COREAUDIO')) write_config_text('FLAC', conf.is_defined('HAVE_FLAC')) -- cgit v1.2.3