Merged with trunk R795
authorDavid Robillard <d@drobilla.net>
Sat, 12 Aug 2006 19:43:09 +0000 (19:43 +0000)
committerDavid Robillard <d@drobilla.net>
Sat, 12 Aug 2006 19:43:09 +0000 (19:43 +0000)
Fiddled with scrolling to leave a bit of context on each side.  'scroll interval' is a single float, should make it a configuration variable some day

git-svn-id: svn://localhost/ardour2/branches/midi@796 d708f5d6-7413-0410-9779-e7cbd77b26cf

27 files changed:
gtk2_ardour/SConscript
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui_dialogs.cc
gtk2_ardour/au_pluginui.cc
gtk2_ardour/au_pluginui.h [new file with mode: 0644]
gtk2_ardour/audio_time_axis.cc
gtk2_ardour/editor_mixer.cc
gtk2_ardour/ladspa_pluginui.cc
gtk2_ardour/mixer_strip.cc
gtk2_ardour/plugin_ui.cc
gtk2_ardour/plugin_ui.h
gtk2_ardour/redirect_box.cc
gtk2_ardour/region_view.cc
gtk2_ardour/route_params_ui.cc
gtk2_ardour/route_time_axis.cc
libs/ardour/ardour/audio_unit.h
libs/ardour/ardour/cycles.h
libs/ardour/ardour/session.h
libs/ardour/audio_unit.cc
libs/ardour/session.cc
libs/ardour/session_command.cc
libs/ardour/session_midi.cc
libs/ardour/session_state.cc
libs/ardour/session_transport.cc
libs/ardour/track.cc
libs/pbd/pbd/rcu.h
libs/surfaces/control_protocol/basic_ui.cc

index 857ed4b8e10e5fe442fa087c45673c832f21a58e..8fb9a0717bc02ac81fea1f12ba4210749f53dc40 100644 (file)
@@ -202,6 +202,11 @@ mtest_files=Split("""
 mtest.cc
 """)
 
+
+rcu_files=Split("""
+rcu.cc
+""")
+
 itest_files=Split("""
 itest.cc
 """)
@@ -217,6 +222,7 @@ if env['VST']:
 if gtkardour['COREAUDIO']:
     extra_sources += coreaudio_files
     gtkardour.Append(CCFLAGS='-DHAVE_COREAUDIO')
+    gtkardour.Append(LINKFLAGS='-framework Carbon')
     gtkardour.Merge([libraries['appleutility']])
  
 if env['FFT_ANALYSIS']:
@@ -240,6 +246,7 @@ ardourlib = gtkardour.SharedLibrary(target = 'ardourgtk', source = gtkardour_fil
 
 mtest = gtkardour.Program(target = 'mtest', source = mtest_files)
 itest = gtkardour.Program(target = 'itest', source = itest_files)
+rcu = gtkardour.Program(target = 'rcu', source = rcu_files)
 
 my_subst_dict = { }
 my_subst_dict['%INSTALL_PREFIX%'] = install_prefix
index 337e10ea4b838c1e6d8065842485b2199d446d6b..0e94259194c1534f0edc4737cac639b2714377fc 100644 (file)
@@ -1326,7 +1326,7 @@ ARDOUR_UI::start_engine ()
                           settings for a new session 
                        */
                        session->save_state ("");
-                        session->save_history ();
+                        session->save_history ("");
                }
 
                /* there is too much going on, in too many threads, for us to 
@@ -1500,7 +1500,7 @@ ARDOUR_UI::save_state_canfail (string name)
                }
 
                if ((ret = session->save_state (name)) != 0) {
-                        session->save_history();
+                        session->save_history (name);
                        return ret;
                }
        }
index d2cc3e1e1cc084779ca1cd6c7a7c3a32cc076271..5a1ec874624e2d5c39862c049e0833c5a139ab5c 100644 (file)
@@ -156,7 +156,7 @@ ARDOUR_UI::unload_session ()
                        
                case 1:
                        session->save_state ("");
-                        session->save_history();
+                        session->save_history ("");
                        break;
                }
        }
index 3e0e7e4874c528466ff7f327a270157d4d0c3ed7..3f0c6f44bcc018e2437ec638668fe0775e072827 100644 (file)
 
 */
 
-#include <ardour/insert.h>
 #include <ardour/audio_unit.h>
+#include <ardour/insert.h>
+
+#include <gtkmm2ext/doi.h>
+
+#include "au_pluginui.h"
+#include "gui_thread.h"
+
+#include <appleutility/CAAudioUnit.h>
+#include <appleutility/CAComponent.h>
 
-#include "plugin_ui.h"
+#include <AudioUnit/AudioUnit.h>
+
+#include "i18n.h"
 
 using namespace ARDOUR;
 using namespace PBD;
 
-AUPluginUI::AUPluginUI (ARDOUR::AudioEngine& engine, boost::shared_ptr<PluginInsert> ap)
+AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
 {
+       if ((au = boost::dynamic_pointer_cast<AUPlugin> (insert->plugin())) == 0) {
+               error << _("unknown type of editor-supplying plugin (note: no AudioUnit support in this version of ardour)") << endmsg;
+               throw failed_constructor ();
+       }
+
+       OSStatus err = noErr;
+       
+       CAComponentDescription desc;
+       Component carbonViewComponent = NULL;
+       AudioUnitCarbonView carbonView = NULL;
+       
+       GetComponentInfo(au->get_comp()->Comp(), &desc, 0, 0, 0);
+       carbonViewComponent = get_carbon_view_component(desc.componentSubType);
+       err = OpenAComponent(carbonViewComponent, &carbonView);
+       
+       Rect rec;
+       rec.top = 0;
+       rec.left = 0;
+       rec.bottom = 400;
+       rec.right = 500;
+       
+       ProcessSerialNumber ourPSN;
+       
+       /* Here we will set the MacOSX native section of the process to the foreground for putting up this
+     * dialog box.  First step is to get our process serial number.  We do this by calling 
+     * GetCurrentProcess. 
+     * First Argument: On success this PSN will be our PSN on return.
+     * Return Value: A Macintosh error indicating success or failure.
+     */
+    err = GetCurrentProcess(&ourPSN);
+    
+    //If no error then set this process to be frontmost.
+    if (err == noErr) {
+        /* Calling SetFrontProcess to make us frontmost.
+         * First Argument: The Process Serial Number of the process we want to make frontmost.  Here
+         *    of course we pass our process serial number
+         * Return Value: An error value indicating success or failure.  We just ignore the return
+         *    value here.
+         */
+        (void)SetFrontProcess(&ourPSN);
+    } else {
+               error << "couldn't get current process" << endmsg;
+       }
+       
+       err = CreateNewWindow (kDocumentWindowClass, kWindowStandardFloatingAttributes, &rec, &wr);
+       
+       ComponentResult auResult;
+       ControlRef rootControl = NULL;
+       GetRootControl(wr, &rootControl);
+       
+       int width = 500;
+       int height = 400;
+       Float32Point location = {30, 30};
+       Float32Point size = {width, height};
+       ControlRef audioUnitControl = NULL;
+       
+       auResult = AudioUnitCarbonViewCreate(carbonView,
+                                            au->get_au()->AU(),
+                                            wr,
+                                            rootControl,
+                                            &location,
+                                            &size,
+                                            &audioUnitControl);    
+       
+       ShowWindow (wr);
+       BringToFront (wr);
+//     AudioUnitCarbonViewSetEventListener(carbonView, EventListener, this);
+#if 0
+       set_name ("PluginEditor");
+       add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
+
+       signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window*> (this)));
+#endif 
+
+       insert->GoingAway.connect (mem_fun(*this, &AUPluginUI::plugin_going_away));
+       
        info << "AUPluginUI created" << endmsg;
 }
 
@@ -35,3 +121,40 @@ AUPluginUI::~AUPluginUI ()
 {
        // nothing to do here - plugin destructor destroys the GUI
 }
+
+void
+AUPluginUI::plugin_going_away (ARDOUR::Redirect* ignored)
+{
+        ENSURE_GUI_THREAD(bind (mem_fun(*this, &AUPluginUI::plugin_going_away), ignored));
+
+        delete_when_idle (this);
+}
+
+Component
+AUPluginUI::get_carbon_view_component(OSType subtype)
+{
+       ComponentDescription desc;
+       Component component;
+       
+       desc.componentType = kAudioUnitCarbonViewComponentType; // 'auvw'
+       desc.componentSubType = subtype;
+       desc.componentManufacturer = 0;
+       desc.componentFlags = 0;
+       desc.componentFlagsMask = 0;
+       
+       // First see if we can find a carbon view designed specifically for this
+       // plug-in:
+       
+       component = FindNextComponent(NULL, &desc);
+       if (component)
+          return component;
+       
+       // If not, grab the generic carbon view, which will create a GUI for
+       // any Audio Unit.
+       
+       desc.componentSubType = kAUCarbonViewSubType_Generic;
+       component = FindNextComponent(NULL, &desc);
+       
+       return component;
+}
+
diff --git a/gtk2_ardour/au_pluginui.h b/gtk2_ardour/au_pluginui.h
new file mode 100644 (file)
index 0000000..2dcefcc
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+    Copyright (C) 2006 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __au_plugin_ui_h__
+#define __au_plugin_ui_h__
+
+#include <boost/shared_ptr.hpp>
+
+#include <Carbon/Carbon.h>
+#include <AudioUnit/AudioUnit.h>
+
+namespace ARDOUR {
+       class AUPlugin;
+       class PluginInsert;
+       class Redirect;
+}
+
+class AUPluginUI
+{
+  public:
+       AUPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>);
+       ~AUPluginUI ();
+       
+  private:
+       WindowRef wr;
+       boost::shared_ptr<ARDOUR::AUPlugin> au;
+
+       void plugin_going_away (ARDOUR::Redirect*);
+       Component get_carbon_view_component(OSType subtype);
+};
+
+#endif // __au_plugin_ui_h__
index ffa95ae23d00b40222d40d31edcba6545601108a..893bcc21c004298e6b672b665c29ab77b7416064 100644 (file)
@@ -60,8 +60,6 @@
 #include "keyboard.h"
 #include "pan_automation_time_axis.h"
 #include "playlist_selector.h"
-#include "plugin_selector.h"
-#include "plugin_ui.h"
 #include "prompter.h"
 #include "public_editor.h"
 #include "audio_region_view.h"
index 246dbdc6473337501d943c82165bf8c175b27cdd..9fa1a0b0b616f1dcc9205a4bfcc5e3ca33fd1cc4 100644 (file)
@@ -165,19 +165,30 @@ Editor::update_current_screen ()
 
                if (_follow_playhead) {
 
-                 playhead_cursor->canvas_item.show();
+
+                       playhead_cursor->canvas_item.show();
                        if (frame != last_update_frame) {
+                               const jack_nframes_t page_width = current_page_frames();
+
+                               // Percentage width of the visible range to use as a scroll interval
+                               // Idea: snap this to the nearest bar/beat/tick/etc, would make scrolling much
+                               // less jarring when zoomed in.. and it would be fun to watch :)
+                               static const double scroll_pct = 3.0/4.0;
+
+                               const jack_nframes_t rightmost_frame = leftmost_frame + page_width;
+                               const jack_nframes_t scroll_interval = (jack_nframes_t)(page_width * scroll_pct);
+                               const jack_nframes_t padding = (jack_nframes_t)floor((page_width-scroll_interval) / 2.0);
+
+                               if (frame < leftmost_frame + padding || frame > rightmost_frame - padding) {
 
-                               if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
-                                       
                                        if (session->transport_speed() < 0) {
-                                               if (frame > (current_page_frames()/2)) {
-                                                       center_screen (frame-(current_page_frames()/2));
+                                               if (frame > scroll_interval) {
+                                                       center_screen (frame - scroll_interval/2);
                                                } else {
-                                                       center_screen (current_page_frames()/2);
+                                                       center_screen (scroll_interval);
                                                }
                                        } else {
-                                               center_screen (frame+(current_page_frames()/2));
+                                               center_screen(frame + scroll_interval/2);
                                        }
                                }
 
@@ -185,7 +196,7 @@ Editor::update_current_screen ()
                        }
 
                } else {
-                       
+
                        if (frame != last_update_frame) {
                                if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
                                        playhead_cursor->canvas_item.hide();
@@ -200,7 +211,7 @@ Editor::update_current_screen ()
                if (current_mixer_strip) {
                        current_mixer_strip->fast_update ();
                }
-               
+
        }
 }
 
index 22b860900a64bea666c94b0fec49cc01dba7e253..9465b12c23c34e4d3f1317905737df72f6314e8f 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <midi++/manager.h>
 
-#include <ardour/audioengine.h>
 #include <ardour/plugin.h>
 #include <ardour/insert.h>
 #include <ardour/ladspa_plugin.h>
@@ -57,9 +56,8 @@ using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace sigc;
 
-LadspaPluginUI::LadspaPluginUI (AudioEngine &engine, boost::shared_ptr<PluginInsert> pi, bool scrollable)
+LadspaPluginUI::LadspaPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrollable)
        : PlugUIBase (pi),
-         engine(engine),
          button_table (initial_button_rows, initial_button_cols),
          output_table (initial_output_rows, initial_output_cols),
          hAdjustment(0.0, 0.0, 0.0),
@@ -108,7 +106,7 @@ LadspaPluginUI::LadspaPluginUI (AudioEngine &engine, boost::shared_ptr<PluginIns
        insert->active_changed.connect (mem_fun(*this, &LadspaPluginUI::redirect_active_changed));
        bypass_button.set_active (!insert->active());
        
-       build (engine);
+       build ();
 }
 
 LadspaPluginUI::~LadspaPluginUI ()
@@ -119,7 +117,7 @@ LadspaPluginUI::~LadspaPluginUI ()
 }
 
 void
-LadspaPluginUI::build (AudioEngine &engine)
+LadspaPluginUI::build ()
 
 {
        guint32 i = 0;
@@ -131,7 +129,6 @@ LadspaPluginUI::build (AudioEngine &engine)
        int button_row, button_col;
        int output_rows, output_cols;
        int button_rows, button_cols;
-       guint32 n_ins=0, n_outs = 0;
 
        prefheight = 30;
        hpacker.set_spacing (10);
@@ -203,7 +200,7 @@ LadspaPluginUI::build (AudioEngine &engine)
                                }
                        }
 
-                       if ((cui = build_control_ui (engine, i, plugin->get_nth_control (i))) == 0) {
+                       if ((cui = build_control_ui (i, plugin->get_nth_control (i))) == 0) {
                                error << string_compose(_("Plugin Editor: could not build control element for port %1"), i) << endmsg;
                                continue;
                        }
@@ -266,9 +263,6 @@ LadspaPluginUI::build (AudioEngine &engine)
                } 
        }
 
-       n_ins = plugin->get_info()->n_inputs;
-       n_outs = plugin->get_info()->n_outputs;
-
        if (box->children().empty()) {
                hpacker.remove (*frame);
        }
@@ -359,7 +353,7 @@ LadspaPluginUI::print_parameter (char *buf, uint32_t len, uint32_t param)
 }
 
 LadspaPluginUI::ControlUI*
-LadspaPluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Controllable* mcontrol)
+LadspaPluginUI::build_control_ui (guint32 port_index, PBD::Controllable* mcontrol)
 
 {
        ControlUI* control_ui;
@@ -757,3 +751,4 @@ LadspaPluginUI::setup_scale_values(guint32 port_index, ControlUI* cui)
 
        return enums;
 }
+
index 14c5b920bedd63018a5640075d6fdc2c1a465ff8..35ca99bee1079839b9a719c270b0407a6e18e5b1 100644 (file)
@@ -48,9 +48,7 @@
 #include "mixer_strip.h"
 #include "mixer_ui.h"
 #include "keyboard.h"
-#include "plugin_selector.h"
 #include "public_editor.h"
-#include "plugin_ui.h"
 #include "send_ui.h"
 #include "io_selector.h"
 #include "utils.h"
index f9db649737b9f931a954b33f5f6cc569bbaea14f..4619d50359755ee15855d479f32e668ffda3bc8d 100644 (file)
@@ -37,7 +37,6 @@
 
 #include <midi++/manager.h>
 
-#include <ardour/audioengine.h>
 #include <ardour/plugin.h>
 #include <ardour/insert.h>
 #include <ardour/ladspa_plugin.h>
@@ -63,7 +62,7 @@ using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace sigc;
 
-PluginUIWindow::PluginUIWindow (AudioEngine &engine, boost::shared_ptr<PluginInsert> insert, bool scrollable)
+PluginUIWindow::PluginUIWindow (boost::shared_ptr<PluginInsert> insert, bool scrollable)
        : ArdourDialog ("plugin ui")
 {
        if (insert->plugin()->has_editor()) {
@@ -92,7 +91,7 @@ PluginUIWindow::PluginUIWindow (AudioEngine &engine, boost::shared_ptr<PluginIns
 
        } else {
 
-               LadspaPluginUI*  pu  = new LadspaPluginUI (engine, insert, scrollable);
+               LadspaPluginUI*  pu  = new LadspaPluginUI (insert, scrollable);
                
                _pluginui = pu;
                get_vbox()->add (*pu);
index acd22294dd42cd34435e44bbb8047952de2ed90d..fd5516cee12d408996258e89629f4ae074e2bd62 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000 Paul Davis 
+    Copyright (C) 2000-2006 Paul Davis 
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -45,7 +45,6 @@
 #include <ardour/types.h>
 
 namespace ARDOUR {
-       class AudioEngine;
        class PluginInsert;
        class Plugin;
        class VSTPlugin;
@@ -90,7 +89,7 @@ class PlugUIBase : public virtual sigc::trackable
 class LadspaPluginUI : public PlugUIBase, public Gtk::VBox 
 {
   public:
-       LadspaPluginUI (ARDOUR::AudioEngine &, boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
+       LadspaPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
        ~LadspaPluginUI ();
        
        gint get_preferred_height () { return prefheight; }
@@ -99,7 +98,6 @@ class LadspaPluginUI : public PlugUIBase, public Gtk::VBox
        bool stop_updating(GdkEventAny*);
 
   private:
-       ARDOUR::AudioEngine &engine;
        Gtk::HBox settings_box;
        Gtk::HBox hpacker;
        
@@ -174,8 +172,8 @@ class LadspaPluginUI : public PlugUIBase, public Gtk::VBox
        sigc::connection screen_update_connection;
        void output_update();
        
-       void build (ARDOUR::AudioEngine &);
-       ControlUI* build_control_ui (ARDOUR::AudioEngine &, guint32 port_index, PBD::Controllable *);
+       void build ();
+       ControlUI* build_control_ui (guint32 port_index, PBD::Controllable *);
        std::vector<string> setup_scale_values(guint32 port_index, ControlUI* cui);
        void control_adjustment_changed (ControlUI* cui);
        void parameter_changed (uint32_t, float, ControlUI* cui);
@@ -197,7 +195,7 @@ class LadspaPluginUI : public PlugUIBase, public Gtk::VBox
 class PluginUIWindow : public ArdourDialog
 {
   public:
-       PluginUIWindow (ARDOUR::AudioEngine &, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
+       PluginUIWindow (boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false);
        ~PluginUIWindow ();
 
        PlugUIBase& pluginui() { return *_pluginui; }
@@ -236,16 +234,4 @@ class VSTPluginUI : public PlugUIBase, public Gtk::VBox
 };
 #endif // VST_SUPPORT
 
-#ifdef HAVE_COREAUDIO
-class AUPluginUI
-{
-  public:
-       AUPluginUI (ARDOUR::AudioEngine&, boost::shared_ptr<ARDOUR::PluginInsert>);
-       ~AUPluginUI ();
-       
-  private:
-       boost::shared_ptr<ARDOUR::AUPlugin> au;
-};
-#endif // HAVE_COREAUDIO
-
 #endif /* __ardour_plugin_ui_h__ */
index 92d0770bd81b165e7c57221cd5cc070346dbe563..2f612bd5531babb5fc0c3fc9656ef4789aa40173 100644 (file)
@@ -54,7 +54,6 @@
 #include "route_redirect_selection.h"
 #include "mixer_ui.h"
 #include "actions.h"
-
 #include "plugin_ui.h"
 #include "send_ui.h"
 #include "io_selector.h"
 
 #include "i18n.h"
 
+#ifdef HAVE_COREAUDIO
+#include "au_pluginui.h"
+#endif
+
 using namespace sigc;
 using namespace ARDOUR;
 using namespace PBD;
@@ -950,7 +953,7 @@ RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
                
        } else {
                
-               /* its an insert */
+               /* it's an insert */
                
                boost::shared_ptr<PluginInsert> plugin_insert;
                boost::shared_ptr<PortInsert> port_insert;
@@ -979,7 +982,7 @@ RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
 
                                        title = string_compose(_("ardour: %1: %2 (by %3)"), _route->name(), plugin_insert->name(), maker);      
                                
-                                       plugin_ui = new PluginUIWindow (_session.engine(), plugin_insert);
+                                       plugin_ui = new PluginUIWindow (plugin_insert);
                                        if (_owner_is_mixer) {
                                                ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
                                        } else {
@@ -1001,7 +1004,7 @@ RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
                        } else if (type == ARDOUR::AudioUnit) {
                                AUPluginUI* plugin_ui;
                                if (plugin_insert->get_gui() == 0) {
-                                       plugin_ui = new AUPluginUI (_session.engine(), plugin_insert);
+                                       plugin_ui = new AUPluginUI (plugin_insert);
                                } else {
                                        plugin_ui = reinterpret_cast<AUPluginUI*> (plugin_insert->get_gui());
                                }
@@ -1012,6 +1015,7 @@ RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
                                warning << "Unsupported plugin sent to RedirectBox::edit_redirect()" << endmsg;
                                return;
                        }
+
                } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
                        
                        if (!_session.engine().connected()) {
index db8f34557417c3dc216dcd972e14f00d5727e25c..68676fe85ce0ae9ccbe1ea8180172668cdd9d12f 100644 (file)
@@ -111,10 +111,14 @@ RegionView::init (Gdk::Color& basic_color, bool wfd)
        compute_colors (basic_color);
 
        name_highlight->set_data ("regionview", this);
-       name_text->set_data ("regionview", this);
+
+       if (name_text) {
+               name_text->set_data ("regionview", this);
+       }
 
        /* an equilateral triangle */
-    ArdourCanvas::Points shape;
+
+       ArdourCanvas::Points shape;
        shape.push_back (Gnome::Art::Point (-((sync_mark_width-1)/2), 1));
        shape.push_back (Gnome::Art::Point ((sync_mark_width - 1)/2, 1));
        shape.push_back (Gnome::Art::Point (0, sync_mark_width - 1));
index 86ac1e035ed997c9975bec4b3fa1f79367238079..8d8efad8a277040b849626428dc1aef60829e577 100644 (file)
@@ -556,7 +556,7 @@ RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Redirect> redirect,
                                
                if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) {                                
 
-                       LadspaPluginUI *plugin_ui = new LadspaPluginUI (session->engine(), plugin_insert, true);
+                       LadspaPluginUI *plugin_ui = new LadspaPluginUI (plugin_insert, true);
 
                        if (place == PreFader) {
                                cleanup_pre_view();
index 82d5b53cbab3b6fa58d7face68748f92ac41f356..e2e1fb2149f8ad7030a621bba7d5e8dedf831ea2 100644 (file)
@@ -61,8 +61,6 @@
 #include "gui_thread.h"
 #include "keyboard.h"
 #include "playlist_selector.h"
-#include "plugin_selector.h"
-#include "plugin_ui.h"
 #include "point_selection.h"
 #include "prompter.h"
 #include "public_editor.h"
index 5b5cd537ab3ba3773c49e9e3bf295a4ef45fd8ce..56179125bbd6c2c0b92460e370ed465d51763378 100644 (file)
@@ -86,6 +86,9 @@ class AUPlugin : public ARDOUR::Plugin
     
        bool has_editor () const;
        
+       CAAudioUnit* get_au () { return unit; }
+       CAComponent* get_comp () { return comp; }
+       
   private:
        CAComponent* comp;
     CAAudioUnit* unit;
@@ -110,6 +113,7 @@ class AUPluginInfo : public PluginInfo {
 
   private:
        static std::string get_name (CAComponentDescription&);
+       void setup_nchannels (CAComponentDescription&);
 };
 
 typedef boost::shared_ptr<AUPluginInfo> AUPluginInfoPtr;
index f194988da95043a68483613e13e3e0ef677c383a..ad3e5126690471aee915459af4e2f45fed2282c1 100644 (file)
@@ -186,8 +186,19 @@ static inline cycles_t get_cycles (void)
 
 /* begin mach */
 #elif defined(__APPLE__)
-#include <CoreAudio/CoreAudioTypes.h>
+
+#ifdef HAVE_COREAUDIO
 #include <CoreAudio/HostTime.h>
+#else // Due to MacTypes.h and libgnomecanvasmm Rect conflict
+typedef unsigned long long              UInt64;
+
+extern UInt64
+AudioGetCurrentHostTime();
+
+extern UInt64
+AudioConvertHostTimeToNanos(UInt64 inHostTime);
+#endif
+
 typedef UInt64 cycles_t;
 static inline cycles_t get_cycles (void)
 {
index cac27168a1501bb369c4510d2cde0786dac70b80..a9b8cbf290d6cac04f31f74bb628e7f7f74cadba 100644 (file)
@@ -493,7 +493,7 @@ class Session : public sigc::trackable, public Stateful
        int save_state (string snapshot_name, bool pending = false);
        int restore_state (string snapshot_name);
        int save_template (string template_name);
-        int save_history ();
+        int save_history (string snapshot_name = "");
 
        static int rename_template (string old_name, string new_name);
 
index 0a31df40ee7c207ce7456d3b3a4253ae5339f988..ad9862181407fe0ba9389fae42d817756b5df266 100644 (file)
@@ -137,7 +137,7 @@ AUPlugin::get_parameter (uint32_t which) const
 int
 AUPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const
 {
-       return -1;
+       return 0;
 }
 
 uint32_t
@@ -325,6 +325,7 @@ AUPluginInfo::discover ()
                plug->type = ARDOUR::AudioUnit;
                plug->n_inputs = 0;
                plug->n_outputs = 0;
+               // plug->setup_nchannels (temp);
                plug->category = "AudioUnit";
                plug->desc = new CAComponentDescription(temp);
 
@@ -376,3 +377,20 @@ AUPluginInfo::get_name (CAComponentDescription& comp_desc)
        
        return CFStringRefToStdString(itemName);
 }
+
+void
+AUPluginInfo::setup_nchannels (CAComponentDescription& comp_desc)
+{
+       CAAudioUnit unit;
+       
+       CAAudioUnit::Open (comp_desc, unit);
+       
+       if (unit.SupportsNumChannels()) {
+               n_inputs = n_outputs = 0;
+       } else {
+               AUChannelInfo cinfo;
+               size_t info_size = sizeof(cinfo);
+               OSStatus err = AudioUnitGetProperty (unit.AU(), kAudioUnitProperty_SupportedNumChannels, kAudioUnitScope_Global,
+                                             0, &cinfo, &info_size);
+       }
+}
index 31b7c6d356c1d0d9b809f6179a59f11ba4c93340..9cfaf18cb0a95646c47f763284f75f5a45c226de 100644 (file)
@@ -1015,7 +1015,7 @@ Session::auto_punch_start_changed (Location* location)
        if (get_record_enabled() && get_punch_in()) {
                /* capture start has been changed, so save new pending state */
                save_state ("", true);
-                save_history();
+                save_history("");
        }
 }      
 
@@ -1337,7 +1337,7 @@ Session::maybe_enable_record ()
        */
 
        save_state ("", true);
-        save_history();
+        save_history ("");
 
        if (_transport_speed) {
                if (!punch_in) {
@@ -2066,6 +2066,7 @@ Session::add_route (shared_ptr<Route> route)
 
        set_dirty();
        save_state (_current_snapshot_name);
+       save_history (_current_snapshot_name);
 
        RouteAdded (route); /* EMIT SIGNAL */
 }
@@ -2097,7 +2098,7 @@ Session::add_diskstream (Diskstream* dstream)
 
        set_dirty();
        save_state (_current_snapshot_name);
-        save_history();
+        save_history (_current_snapshot_name);
 
        DiskstreamAdded (dstream); /* EMIT SIGNAL */
 }
@@ -2161,6 +2162,7 @@ Session::remove_route (shared_ptr<Route> route)
        /* XXX should we disconnect from the Route's signals ? */
 
        save_state (_current_snapshot_name);
+       save_history (_current_snapshot_name);
 
        /* all shared ptrs to route should go out of scope here */
 }      
@@ -2849,7 +2851,7 @@ Session::remove_source (Source* source)
                */
                
                save_state (_current_snapshot_name);
-                save_history();
+                save_history (_current_snapshot_name);
        }
 
        SourceRemoved(source); /* EMIT SIGNAL */
index 1b8d6b37186ee4c3925064dc2d449766fb8a4360..af507208ab7e031172328bd8cf8b68650f32cbb2 100644 (file)
@@ -9,7 +9,6 @@ Command *Session::memento_command_factory(XMLNode *n)
 {
     PBD::ID id;
     XMLNode *before, *after;
-    //void *obj;
 
     /* get obj_id */
 
@@ -21,6 +20,7 @@ Command *Session::memento_command_factory(XMLNode *n)
     if (Diskstream *obj = diskstream_by_id(id))
        return new MementoCommand<Diskstream>(*obj, *before, *after);
     // etc.
+       
        return 0;
 }
 
index d7cdd94b2bf59debb3511da29f6c59cb1a40b34e..b0738e95a7fb3dcb578b519eb678420c9f152043 100644 (file)
@@ -605,6 +605,7 @@ Session::mmc_record_strobe (MIDI::MachineControl &mmc)
                */
                
                save_state ("", true);
+               save_history ("");
                g_atomic_int_set (&_record_status, Enabled);
                RecordStateChanged (); /* EMIT SIGNAL */
                
index 1b0befed3d03c9cdd3398f5fbd62c28934191ccb..2a08859205f86a786223c3754cab8fde92e5dfde 100644 (file)
@@ -608,7 +608,7 @@ Session::create (bool& new_session, string* mix_template, jack_nframes_t initial
                _state_of_the_state = Clean;
 
                if (save_state (_current_snapshot_name)) {
-                        save_history();
+                        save_history (_current_snapshot_name);
                        return -1;
                }
        }
@@ -1696,7 +1696,7 @@ Session::set_state (const XMLNode& node)
 
        if (state_was_pending) {
                save_state (_current_snapshot_name);
-                save_history();
+                save_history (_current_snapshot_name);
                remove_pending_capture_state ();
                state_was_pending = false;
        }
@@ -2498,7 +2498,7 @@ void
 Session::auto_save()
 {
        save_state (_current_snapshot_name);
-        save_history();
+        save_history (_current_snapshot_name);
 }
 
 RouteGroup *
@@ -3170,6 +3170,7 @@ Session::cleanup_sources (Session::cleanup_report& rep)
        */
        
        save_state ("");
+       save_history ("");
 
   out:
        _state_of_the_state = (StateOfTheState) (_state_of_the_state & ~InCleanup);
@@ -3303,7 +3304,7 @@ Session::add_instant_xml (XMLNode& node, const std::string& dir)
 
 
 int 
-Session::save_history ()
+Session::save_history (string snapshot_name)
 {
     XMLTree tree;
     string xml_path;
@@ -3311,7 +3312,11 @@ Session::save_history ()
 
     tree.set_root (&history.get_state());
 
-    xml_path = _path + _current_snapshot_name + ".history"; 
+    if (snapshot_name.empty()) {
+       snapshot_name = _current_snapshot_name;
+    }
+
+    xml_path = _path + snapshot_name + ".history"; 
 
     bak_path = xml_path + ".bak";
 
index 592f9c86c65456caa5dbb70eb19996c72f03f724..aad3617580be73453b9423031fd98b7ef7535bfe 100644 (file)
@@ -413,7 +413,7 @@ Session::non_realtime_stop (bool abort)
        if ((post_transport_work & PostTransportLocate) && get_record_enabled()) {
                /* capture start has been changed, so save pending state */
                save_state ("", true);
-                save_history();
+                save_history ("");
        }
 
         /* always try to get rid of this */
@@ -424,6 +424,7 @@ Session::non_realtime_stop (bool abort)
 
        if (did_record) {
                save_state (_current_snapshot_name);
+               save_history (_current_snapshot_name);
        }
 
        if (post_transport_work & PostTransportDuration) {
index 2f956f6046ccd25eda9a6f80786cf5f992ae033a..aa2f12aa65bb67d806b701317ac7ee5dedf9ea33 100644 (file)
@@ -224,7 +224,7 @@ Track::set_name (string str, void *src)
 
        if ((ret = IO::set_name (str, src)) == 0) {
                _session.save_state ("");
-                _session.save_history();
+                _session.save_history ("");
        }
        return ret;
 }
index 6d9586cb3c6bfc68b7be43b762d8da92f2f3c834..58a92a206a574e3e4066af422ff065cbfad304b8 100644 (file)
@@ -6,32 +6,29 @@
  
 #include <list> 
  
 template<class T>
 class RCUManager
 {
-public:
-       RCUManager (T* new_rcu_value)
-               : m_rcu_value(new_rcu_value)
-       {
+  public:
  
+       RCUManager (T* new_rcu_value) {
+               m_rcu_value = new boost::shared_ptr<T> (new_rcu_value);
        }
  
-       virtual ~RCUManager() { }
+       virtual ~RCUManager() { delete m_rcu_value; }
  
-       boost::shared_ptr<T> reader () const { return m_rcu_value; }
+        boost::shared_ptr<T> reader () const { return *((boost::shared_ptr<T> *) g_atomic_pointer_get (&m_rcu_value)); }
  
-       // should be private
        virtual boost::shared_ptr<T> write_copy () = 0;
-       // should be private
-       virtual void update (boost::shared_ptr<T> new_value) = 0;
-protected:
-       boost::shared_ptr<T> m_rcu_value;
+       virtual bool update (boost::shared_ptr<T> new_value) = 0;
+
+  protected:
+       boost::shared_ptr<T>* m_rcu_value;
+
+       // this monstrosity is needed because of some wierd behavior by g++
+
+       gpointer * the_pointer() const { return (gpointer *) &m_rcu_value; }
 };
  
  
@@ -49,37 +46,63 @@ public:
        virtual boost::shared_ptr<T> write_copy ()
        {
                m_lock.lock();
-               // I hope this is doing what I think it is doing :)
-               boost::shared_ptr<T> new_copy(new T(*RCUManager<T>::m_rcu_value));
-               // XXX todo remove old copies with only 1 reference from the list.
+
+               // clean out any dead wood
+
+               typename std::list<boost::shared_ptr<T> >::iterator i;
+
+               for (i = m_dead_wood.begin(); i != m_dead_wood.end(); ) {
+                       if ((*i).use_count() == 1) {
+                               i = m_dead_wood.erase (i);
+                       } else {
+                               ++i;
+                       }
+               }
+
+               // store the current 
+
+               current_write_old = RCUManager<T>::m_rcu_value;
+               
+               boost::shared_ptr<T> new_copy (new T(**current_write_old));
+               
                return new_copy;
        }
  
-       virtual void update (boost::shared_ptr<T> new_value)
+       virtual bool update (boost::shared_ptr<T> new_value)
        {
-               // So a current reader doesn't hold the only reference to
-               // the existing value when we assign it a new value which 
-               // should ensure that deletion of old values doesn't
-               // occur in a reader thread.
-               boost::shared_ptr<T> old_copy = RCUManager<T>::m_rcu_value;
                // we hold the lock at this point effectively blocking
                // other writers.
-               RCUManager<T>::m_rcu_value = new_value;
-               // XXX add the old value to the list of old copies.
+
+               boost::shared_ptr<T>* new_spp = new boost::shared_ptr<T> (new_value);
+
+               // update, checking that nobody beat us to it
+
+               bool ret = g_atomic_pointer_compare_and_exchange (RCUManager<T>::the_pointer(),
+                                                                 (gpointer) current_write_old,
+                                                                 (gpointer) new_spp);
+               
+               if (ret) {
+
+                       // successful update : put the old value into dead_wood,
+
+                       m_dead_wood.push_back (*current_write_old);
+
+                       // now delete it - this gets rid of the shared_ptr<T> but
+                       // because dead_wood contains another shared_ptr<T> that
+                       // references the same T, the underlying object lives on
+
+                       delete current_write_old;
+               }
+
                m_lock.unlock();
+
+               return ret;
        }
  
 private:
-       Glib::Mutex                     m_lock;
-       std::list<boost::shared_ptr<T> > m_old_values;
+       Glib::Mutex                      m_lock;
+       boost::shared_ptr<T>*            current_write_old;
+       std::list<boost::shared_ptr<T> > m_dead_wood;
 };
  
 template<class T>
index 47401c8cfe896dd9974cc7405a004e8312d155c4..bee47839140d46398d1c46cd2accda67737418df 100644 (file)
@@ -145,7 +145,7 @@ void
 BasicUI::save_state ()
 {
        session->save_state ("");
-        session->save_history();
+        session->save_history("");
 }
 
 void