Large nasty commit in the form of a 5000 line patch chock-full of completely
authorDavid Robillard <d@drobilla.net>
Mon, 26 Jun 2006 16:01:34 +0000 (16:01 +0000)
committerDavid Robillard <d@drobilla.net>
Mon, 26 Jun 2006 16:01:34 +0000 (16:01 +0000)
unecessary changes.  (Sorry, doing a "sprint" based thing, this is the end of the first one)

Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them.  Should be set to start work on actually recording and playing midi to/from disk now.

Relevant (significant) changes:

- Creation of a Buffer class.  Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template).  Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise.  Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below).  There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary.  Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)

- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports.  IO::register_***_port has a type argument that defaults to the default type if not passed.  Rationale:  previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things.  This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain.  (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)

- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument.  Ditto for output.

- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created.  Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part.  It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.

- MidiTrack creation.  Same thing as AudioTrack but with a different default type basically.  No big deal here.

- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)

Known broken:  Loading of sessions containing MIDI tracks.

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

194 files changed:
SConstruct
gtk2_ardour/SConscript
gtk2_ardour/about.cc
gtk2_ardour/actions.cc
gtk2_ardour/add_route_dialog.cc
gtk2_ardour/add_route_dialog.h
gtk2_ardour/analysis_window.cc
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui2.cc
gtk2_ardour/ardour_ui_dependents.cc
gtk2_ardour/ardour_ui_dialogs.cc
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/ardour_ui_mixer.cc
gtk2_ardour/ardour_ui_options.cc
gtk2_ardour/arprof
gtk2_ardour/audio_clock.cc
gtk2_ardour/audio_time_axis.cc
gtk2_ardour/automation_gain_line.cc
gtk2_ardour/automation_line.cc
gtk2_ardour/automation_pan_line.cc
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/color_manager.cc
gtk2_ardour/connection_editor.cc
gtk2_ardour/crossfade_edit.cc
gtk2_ardour/crossfade_view.cc
gtk2_ardour/curvetest.cc
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_audio_import.cc
gtk2_ardour/editor_audiotrack.cc
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_canvas_events.cc
gtk2_ardour/editor_cursors.cc
gtk2_ardour/editor_edit_groups.cc
gtk2_ardour/editor_export_audio.cc
gtk2_ardour/editor_hscroller.cc
gtk2_ardour/editor_imageframe.cc
gtk2_ardour/editor_keys.cc
gtk2_ardour/editor_markers.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_nudge.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/editor_region_list.cc
gtk2_ardour/editor_route_list.cc
gtk2_ardour/editor_rulers.cc
gtk2_ardour/editor_selection_list.cc
gtk2_ardour/editor_tempodisplay.cc
gtk2_ardour/editor_timefx.cc
gtk2_ardour/export_dialog.cc
gtk2_ardour/export_range_markers_dialog.cc
gtk2_ardour/gain_automation_time_axis.cc
gtk2_ardour/gain_meter.cc
gtk2_ardour/imageframe_socket_handler.cc
gtk2_ardour/imageframe_time_axis.cc
gtk2_ardour/io_selector.cc
gtk2_ardour/keyboard.cc
gtk2_ardour/location_ui.cc
gtk2_ardour/main.cc
gtk2_ardour/marker_time_axis.cc
gtk2_ardour/meter_bridge.cc
gtk2_ardour/meter_bridge_strip.cc
gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_ui.cc
gtk2_ardour/option_editor.cc
gtk2_ardour/pan_automation_time_axis.cc
gtk2_ardour/panner2d.cc
gtk2_ardour/panner_ui.cc
gtk2_ardour/playlist_selector.cc
gtk2_ardour/plugin_selector.cc
gtk2_ardour/plugin_ui.cc
gtk2_ardour/plugin_ui.h
gtk2_ardour/redirect_automation_line.cc
gtk2_ardour/redirect_automation_time_axis.cc
gtk2_ardour/redirect_box.cc
gtk2_ardour/region_editor.cc
gtk2_ardour/region_gain_line.cc
gtk2_ardour/region_selection.cc
gtk2_ardour/regionview.cc
gtk2_ardour/route_params_ui.cc
gtk2_ardour/route_redirect_selection.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/selection.cc
gtk2_ardour/send_ui.cc
gtk2_ardour/sfdb_ui.cc
gtk2_ardour/streamview.cc
gtk2_ardour/taperegionview.cc
gtk2_ardour/tempo_dialog.cc
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view_item.cc
gtk2_ardour/time_selection.cc
gtk2_ardour/utils.cc
gtk2_ardour/visual_time_axis.cc
gtk2_ardour/vst_pluginui.cc
libs/ardour/SConscript
libs/ardour/ardour/ardour.h
libs/ardour/ardour/audio_diskstream.h
libs/ardour/ardour/audio_track.h
libs/ardour/ardour/audioengine.h
libs/ardour/ardour/io.h
libs/ardour/ardour/playlist.h
libs/ardour/ardour/port.h
libs/ardour/ardour/region.h
libs/ardour/ardour/route.h
libs/ardour/ardour/session.h
libs/ardour/ardour/types.h
libs/ardour/audio_diskstream.cc
libs/ardour/audio_library.cc
libs/ardour/audio_playlist.cc
libs/ardour/audio_track.cc
libs/ardour/audioengine.cc
libs/ardour/audiofilesource.cc
libs/ardour/audiofilter.cc
libs/ardour/auditioner.cc
libs/ardour/automation_event.cc
libs/ardour/configuration.cc
libs/ardour/connection.cc
libs/ardour/control_protocol_manager.cc
libs/ardour/coreaudio_source.cc
libs/ardour/crossfade.cc
libs/ardour/curve.cc
libs/ardour/cycle_timer.cc
libs/ardour/destructive_filesource.cc
libs/ardour/globals.cc
libs/ardour/import.cc
libs/ardour/insert.cc
libs/ardour/io.cc
libs/ardour/jack_slave.cc
libs/ardour/ladspa_plugin.cc
libs/ardour/location.cc
libs/ardour/mtc_slave.cc
libs/ardour/named_selection.cc
libs/ardour/panner.cc
libs/ardour/playlist.cc
libs/ardour/playlist_factory.cc
libs/ardour/plugin.cc
libs/ardour/plugin_manager.cc
libs/ardour/port.cc
libs/ardour/recent_sessions.cc
libs/ardour/redirect.cc
libs/ardour/region.cc
libs/ardour/route.cc
libs/ardour/send.cc
libs/ardour/session.cc
libs/ardour/session_butler.cc
libs/ardour/session_click.cc
libs/ardour/session_events.cc
libs/ardour/session_export.cc
libs/ardour/session_feedback.cc
libs/ardour/session_midi.cc
libs/ardour/session_process.cc
libs/ardour/session_state.cc
libs/ardour/session_time.cc
libs/ardour/session_timefx.cc
libs/ardour/session_transport.cc
libs/ardour/sndfilesource.cc
libs/ardour/state_manager.cc
libs/ardour/stateful.cc
libs/ardour/tempo.cc
libs/ardour/utils.cc
libs/ardour/vst_plugin.cc
libs/fst/SConscript [new file with mode: 0644]
libs/fst/fst.c [new file with mode: 0644]
libs/fst/fst.h [new file with mode: 0644]
libs/fst/fstinfofile.c [new file with mode: 0644]
libs/fst/jackvst.h [new file with mode: 0644]
libs/fst/vsti.c [new file with mode: 0644]
libs/fst/vstwin.c [new file with mode: 0644]
libs/gtkmm2ext/gtk_ui.cc
libs/gtkmm2ext/selector.cc
libs/midi++2/fd_midiport.cc
libs/midi++2/midicontrollable.cc
libs/midi++2/midimanager.cc
libs/midi++2/mmc.cc
libs/midi++2/mmctest.cc
libs/pbd3/SConscript
libs/pbd3/base_ui.cc
libs/pbd3/basename.cc
libs/pbd3/pathscanner.cc
libs/pbd3/pbd/abstract_ui.cc
libs/pbd3/pbd/abstract_ui.h
libs/pbd3/pbd/basename.h
libs/pbd3/pbd/error.h
libs/pbd3/pbd/pool.h
libs/pbd3/pbd/ringbuffer.h
libs/pbd3/pbd/ringbufferNPT.h
libs/pbd3/pbd/transmitter.h
libs/pbd3/pool.cc
libs/pbd3/transmitter.cc
libs/pbd3/undo.cc
libs/surfaces/tranzport/tranzport_control_protocol.cc
vst/SConscript [new file with mode: 0644]
vst/winmain.c [new file with mode: 0644]

index c67cb4d03e41ed88d4ae8c066db86d829e9181c2..53b8b1bbbf7a30179deda311d9a6352720d678d9 100644 (file)
@@ -8,6 +8,7 @@ import glob
 import errno
 import time
 import platform
+import string
 from sets import Set
 import SCons.Node.FS
 
@@ -345,6 +346,21 @@ tarball_bld = Builder (action = tarballer,
 env.Append (BUILDERS = {'Distribute' : dist_bld})
 env.Append (BUILDERS = {'Tarball' : tarball_bld})
 
+#
+# Make sure they know what they are doing
+#
+
+if env['VST']:
+    sys.stdout.write ("Are you building Ardour for personal use (rather than distributiont to others)? [no]: ")
+    answer = sys.stdin.readline ()
+    answer = answer.rstrip().strip()
+    if answer != "yes" and answer != "y":
+        print 'You cannot build Ardour with VST support for distribution to others.\nIt is a violation of several different licenses. VST support disabled.'
+        env['VST'] = 0;
+    else:
+        print "OK, VST support will be enabled"
+        
+
 # ----------------------------------------------------------------------
 # Construction environment setup
 # ----------------------------------------------------------------------
@@ -650,6 +666,14 @@ else:
 
 config_prefix = '$DESTDIR' + final_config_prefix
 
+# For colorgcc ( so says the wiki, but it's still not working :/  anyone? )
+if os.environ.has_key('PATH'):
+       env['PATH'] = os.environ['PATH']
+if os.environ.has_key('TERM'):
+       env['TERM'] = os.environ['TERM']
+if os.environ.has_key('HOME'):
+       env['HOME'] = os.environ['HOME']
+
 
 # SCons should really do this for us
 
index 99c97d20a4c7a650a82263deb0f2b540c0841a11..55fa26ec857db124d3cc9a7257e4a6f97ebce36a 100644 (file)
@@ -26,7 +26,6 @@ gtkardour.Merge ([
     libraries['ardour'],
     libraries['ardour_cp'],
     libraries['gtkmm2ext'],
-#    libraries['flowcanvas'],
     libraries['midi++2'],
     libraries['pbd3'],
     libraries['gtkmm2'],
@@ -62,6 +61,7 @@ skipped_files=Split("""
 connection_editor.cc
 """)
 
+
 gtkardour_files=Split("""
 about.cc
 actions.cc
@@ -181,6 +181,7 @@ visual_time_axis.cc
 waveview.cc
 """)
 
+
 fft_analysis_files=Split("""
 analysis_window.cc
 fft_graph.cc
index 94284f58d413f08b87b6774bd4eb4028081f6b04..033b5c460413e0b4fd305f5953bc359b72e72bbd 100644 (file)
@@ -43,6 +43,7 @@ using namespace Gdk;
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 
 #ifdef WITH_PAYMENT_OPTIONS
 
index 78acffd6d1f01b7f583b88992c58d378fa2920e6..ee688c366006d72e710e15e5769d053523761311 100644 (file)
@@ -39,6 +39,7 @@ using namespace std;
 using namespace Gtk;
 using namespace Glib;
 using namespace sigc;
+using namespace PBD;
 
 vector<RefPtr<Gtk::Action> > ActionManager::session_sensitive_actions;
 vector<RefPtr<Gtk::Action> > ActionManager::region_list_selection_sensitive_actions;
index 8664dae61c61f25b230d31202f73fba864f58734..aa61cb25251dc1070719ab336d5a66315a8bd4d9 100644 (file)
@@ -35,6 +35,7 @@ using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace sigc;
 using namespace std;
+using namespace PBD;
 
 static const char* channel_setup_names[] = {
        "Mono",
@@ -44,6 +45,7 @@ static const char* channel_setup_names[] = {
        "6 Channels",
        "8 Channels",
        "Manual Setup",
+       "MIDI",
        0
 };
 
@@ -157,6 +159,13 @@ AddRouteDialog::track ()
        return track_button.get_active ();
 }
 
+bool
+AddRouteDialog::midi ()
+{
+       const string str = channel_combo.get_active_text();
+       return (str == _("MIDI"));
+}
+
 string
 AddRouteDialog::name_template ()
 {
@@ -192,7 +201,7 @@ AddRouteDialog::channels ()
        string str = channel_combo.get_active_text();
        int chns;
 
-       if (str == _("Mono")) {
+       if (str == _("Mono") || str == _("MIDI")) {
                return 1;
        } else if (str == _("Stereo")) {
                return 2;
index 28d8916985b4c5ac3aafd5144c5b6b5dd07bdab1..ae4679fd5d677fdfccd59bdf060503bfddeee25b 100644 (file)
@@ -21,6 +21,7 @@ class AddRouteDialog : public Gtk::Dialog
        ~AddRouteDialog ();
 
        bool track ();
+       bool midi ();
        std::string name_template ();
        int channels ();
        int count ();
index f044ca7388e5e31410d9ef6768200c9de1086352..5b135aad6ed7e15094302a027d457d807e1bdc0b 100644 (file)
@@ -26,7 +26,7 @@
 #include <gtkmm/treeiter.h>
 
 #include <ardour/audioregion.h>
-#include <ardour/playlist.h>
+#include <ardour/audioplaylist.h>
 #include <ardour/types.h>
 
 #include "analysis_window.h"
@@ -40,6 +40,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 AnalysisWindow::AnalysisWindow()
        : ArdourDialog(_("analysis window")),
@@ -229,7 +230,12 @@ AnalysisWindow::analyze_data (Gtk::Button *button)
        
        
                for (TrackSelection::iterator i = s.tracks.begin(); i != s.tracks.end(); ++i) {
-                       ARDOUR::Playlist *pl = (*i)->playlist();
+                       ARDOUR::AudioPlaylist *pl
+                               = dynamic_cast<ARDOUR::AudioPlaylist*>((*i)->playlist());
+
+                       if (!pl)
+                               continue;
+
                        RouteUI *rui = dynamic_cast<RouteUI *>(*i);
                        
                        // Busses don't have playlists, so we need to check that we actually are working with a playlist
index fa77c3f50b4fd7bc930ed3155e8c9fe53401c861..901541778d66e98663f5f999bf4999520b116d86 100644 (file)
@@ -56,6 +56,7 @@
 #include <ardour/session_diskstream.h>
 #include <ardour/port.h>
 #include <ardour/audio_track.h>
+#include <ardour/midi_track.h>
 
 #include "actions.h"
 #include "ardour_ui.h"
@@ -76,6 +77,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace sigc;
@@ -867,11 +869,51 @@ ARDOUR_UI::open_session ()
 
 
 void
-ARDOUR_UI::session_add_midi_track ()
+ARDOUR_UI::session_add_midi_route (bool disk)
 {
-       cerr << _("Patience is a virtue.\n");
+       Route* route;
+
+       if (session == 0) {
+               warning << _("You cannot add a track without a session already loaded.") << endmsg;
+               return;
+       }
+
+       try { 
+               if (disk) {
+                       if ((route = session->new_midi_track ()) == 0) {
+                               error << _("could not create new MIDI track") << endmsg;
+                       }
+               } else {
+                       if ((route = session->new_midi_route ()) == 0) {
+                               error << _("could not create new MIDI bus") << endmsg;
+                       }
+               }
+#if 0          
+#if CONTROLOUTS
+               if (need_control_room_outs) {
+                       pan_t pans[2];
+                       
+                       pans[0] = 0.5;
+                       pans[1] = 0.5;
+                       
+                       route->set_stereo_control_outs (control_lr_channels);
+                       route->control_outs()->set_stereo_pan (pans, this);
+               }
+#endif /* CONTROLOUTS */
+#endif
+       }
+
+       catch (...) {
+               MessageDialog msg (*editor, 
+                                  _("There are insufficient JACK ports available\n\
+to create a new track or bus.\n\
+You should save Ardour, exit and\n\
+restart JACK with more ports."));
+               msg.run ();
+       }
 }
 
+
 void
 ARDOUR_UI::session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode)
 {
@@ -917,7 +959,7 @@ restart JACK with more ports."));
 }
 
 void
-ARDOUR_UI::diskstream_added (AudioDiskstream* ds)
+ARDOUR_UI::diskstream_added (Diskstream* ds)
 {
 }
 
@@ -1164,11 +1206,14 @@ ARDOUR_UI::toggle_monitor_enable (guint32 dstream)
                return;
        }
 
-       AudioDiskstream *ds;
+       Diskstream *ds;
 
        if ((ds = session->diskstream_by_id (dstream)) != 0) {
-               Port *port = ds->io()->input (0);
-               port->request_monitor_input (!port->monitoring_input());
+               AudioDiskstream *ads = dynamic_cast<AudioDiskstream*>(ds);
+               if (ads) {
+                       Port *port = ds->io()->input (0);
+                       port->request_monitor_input (!port->monitoring_input());
+               }
        }
 }
 
@@ -1179,7 +1224,7 @@ ARDOUR_UI::toggle_record_enable (guint32 dstream)
                return;
        }
 
-       AudioDiskstream *ds;
+       Diskstream *ds;
 
        if ((ds = session->diskstream_by_id (dstream)) != 0) {
                ds->set_record_enabled (!ds->record_enabled(), this);
@@ -2144,7 +2189,11 @@ ARDOUR_UI::add_route ()
        /* XXX do something with name template */
 
        while (count) {
-               if (track) {
+               if (track && add_route_dialog->midi()) {
+                       session_add_midi_track();
+               } else if (add_route_dialog->midi()) {
+                       session_add_midi_bus();
+               } else if (track) {
                        session_add_audio_track (input_chan, output_chan, add_route_dialog->mode());
                } else {
                        session_add_audio_bus (input_chan, output_chan);
index 678342f32bb6ad683ff64a1dead56dfa9110dec1..9dad6086be6f3bb5cd32f7af195b4a0582ab12d3 100644 (file)
@@ -199,7 +199,13 @@ class ARDOUR_UI : public Gtkmm2ext::UI
                session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal);
        }
 
-       void session_add_midi_track ();
+       void session_add_midi_track () {
+               session_add_midi_route (true);
+       }
+
+       void session_add_midi_bus () {
+               session_add_midi_route (false);
+       }
 
        void set_engine (ARDOUR::AudioEngine&);
 
@@ -522,7 +528,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
        sigc::connection point_one_second_connection;
        sigc::connection point_zero_one_second_connection;
 
-       void diskstream_added (ARDOUR::AudioDiskstream*);
+       void diskstream_added (ARDOUR::Diskstream*);
 
        gint session_menu (GdkEventButton *);
 
@@ -538,6 +544,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
 
 
        void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode);
+       void session_add_midi_route (bool disk);
 
        void add_diskstream_to_menu (ARDOUR::AudioDiskstream&);
        void diskstream_selected (gint32);
index af1f3094bcdb4f94f4d83bf06c7f1a9732618070..f92201e36c543e75bb5dc42238237b7d6bc0987c 100644 (file)
@@ -47,6 +47,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace Glib;
index 1f8b0ef702bdf40c34be573e94ed250e221f5a91..0603fc6baa5acb95ee365736ac18eb2be21734c1 100644 (file)
@@ -36,6 +36,7 @@
 
 using namespace sigc;
 using namespace Gtk;
+using namespace PBD;
 
 namespace ARDOUR {
        class Session;
index eb9e72b253f3684d26fbf25edb6ff295d99ede22..1c35ed93ae3ea81823975e05723bff1bf0c1daf5 100644 (file)
@@ -39,6 +39,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Glib;
 using namespace Gtk;
 using namespace Gtkmm2ext;
@@ -76,7 +77,7 @@ ARDOUR_UI::connect_to_session (Session *s)
        shuttle_box.set_sensitive (true);
        
        if (session->n_audio_diskstreams() == 0) {
-               session->AudioDiskstreamAdded.connect (mem_fun(*this, &ARDOUR_UI::diskstream_added));
+               session->DiskstreamAdded.connect (mem_fun(*this, &ARDOUR_UI::diskstream_added));
        }
 
        if (connection_editor) {
index 3add2a150cba6e63826115fbed4ce19ec3af6df5..e23ea65716be9d3b0aa083689f2a9b1c8cbbc879 100644 (file)
@@ -40,6 +40,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 
@@ -190,13 +191,17 @@ ARDOUR_UI::install_actions ()
        ActionManager::session_sensitive_actions.push_back (act);
        act = ActionManager::register_toggle_action (common_actions, X_("ToggleBigClock"), _("Big Clock"), mem_fun(*this, &ARDOUR_UI::toggle_big_clock_window));
        ActionManager::session_sensitive_actions.push_back (act);
-       ActionManager::register_action (common_actions, X_("About"), _("About"),  mem_fun(*this, &ARDOUR_UI::show_splash));
+       act = ActionManager::register_action (common_actions, X_("About"), _("About"),  mem_fun(*this, &ARDOUR_UI::show_splash));
        act = ActionManager::register_toggle_action (common_actions, X_("ToggleColorManager"), _("Colors"), mem_fun(*this, &ARDOUR_UI::toggle_color_manager));
-       
+       ActionManager::session_sensitive_actions.push_back (act);
        act = ActionManager::register_action (common_actions, X_("AddAudioTrack"), _("Add Audio Track"), bind (mem_fun(*this, &ARDOUR_UI::session_add_audio_track), 1, 1, ARDOUR::Normal));
        ActionManager::session_sensitive_actions.push_back (act);
        act = ActionManager::register_action (common_actions, X_("AddAudioBus"), _("Add Audio Bus"), bind (mem_fun(*this, &ARDOUR_UI::session_add_audio_bus), 1, 1));
        ActionManager::session_sensitive_actions.push_back (act);
+       act = ActionManager::register_action (common_actions, X_("AddMIDITrack"), _("Add MIDI Track"), (mem_fun(*this, &ARDOUR_UI::session_add_midi_track)));
+       ActionManager::session_sensitive_actions.push_back (act);
+       act = ActionManager::register_action (common_actions, X_("AddMidiBus"), _("Add Midi Bus"), mem_fun(*this, &ARDOUR_UI::session_add_midi_bus));
+       ActionManager::session_sensitive_actions.push_back (act);
        act = ActionManager::register_action (common_actions, X_("Save"), _("Save"),  bind (mem_fun(*this, &ARDOUR_UI::save_state), string("")));
        ActionManager::session_sensitive_actions.push_back (act);
        act = ActionManager::register_action (common_actions, X_("RemoveLastCapture"), _("Remove Last Capture"), mem_fun(*this, &ARDOUR_UI::remove_last_capture));
index 8d92f70ae2d7d1957e9b891e538192c098091fb1..991f37c3a7a2cb4669bf1ec842049f638d824a78 100644 (file)
@@ -28,6 +28,7 @@
 #include "mixer_ui.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 int
 ARDOUR_UI::create_mixer ()
index ac0028b58c0d4a839064ec07e5a8e6d2fff773f0..665c92d264b2725fd1bedecb24d7ca19749661db 100644 (file)
@@ -35,6 +35,7 @@
 using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace ARDOUR;
+using namespace PBD;
 
 void
 ARDOUR_UI::setup_config_options ()
index 984866a99b2952e53458498cc642547205e687c4..8af65b5fe3987daaa2a9c2963b167c7641e201d9 100755 (executable)
@@ -6,4 +6,4 @@ if [ gprofhelper.c -nt gprofhelper.so ] ; then
 fi
 
 export LD_LIBRARY_PATH=../libs/ardour/.libs
-LDPRELOAD=./gprofhelper.so ./ardour $*
+LDPRELOAD=./gprofhelper.so ./ardev $*
index 25985c4a3b956ae1f7adc8c59e6679baac6e2211..8c6f3a7d8277f7ffddafe4f9821a7b708b89ff2f 100644 (file)
@@ -37,6 +37,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 
index 32c303de349e0f7e00ae28f953f6c2e855a8b5cc..c2fbc45a84116532b6e12d30ab01c61305f18d63 100644 (file)
@@ -80,6 +80,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace LADSPA;
 using namespace Gtk;
 using namespace Editing;
@@ -378,7 +379,7 @@ AudioTimeAxisView::playlist_changed ()
        label_view ();
 
        if (is_audio_track()) {
-               set_playlist (get_diskstream()->playlist());
+               set_playlist (dynamic_cast<AudioPlaylist*>(get_diskstream()->playlist()));
        }
 }
 
@@ -825,7 +826,8 @@ AudioTimeAxisView::rename_current_playlist ()
        AudioPlaylist *pl;
        AudioDiskstream *ds;
 
-       if (((ds = get_diskstream()) == 0) || ds->destructive() || ((pl = ds->playlist()) == 0)) {
+       if (((ds = get_diskstream()) == 0) || ds->destructive()
+                       || ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) == 0)) {
                return;
        }
 
@@ -854,7 +856,8 @@ AudioTimeAxisView::use_copy_playlist (bool prompt)
        AudioDiskstream *ds;
        string name;
 
-       if (((ds = get_diskstream()) == 0) || ds->destructive() || ((pl = ds->playlist()) == 0)) {
+       if (((ds = get_diskstream()) == 0) || ds->destructive()
+                       || ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) == 0)) {
                return;
        }
        
@@ -882,7 +885,7 @@ AudioTimeAxisView::use_copy_playlist (bool prompt)
 
        if (name.length()) {
                ds->use_copy_playlist ();
-               pl = ds->playlist();
+               pl = dynamic_cast<AudioPlaylist*>(ds->playlist());
                pl->set_name (name);
        }
 }
@@ -894,7 +897,8 @@ AudioTimeAxisView::use_new_playlist (bool prompt)
        AudioDiskstream *ds;
        string name;
 
-       if (((ds = get_diskstream()) == 0) || ds->destructive() || ((pl = ds->playlist()) == 0)) {
+       if (((ds = get_diskstream()) == 0) || ds->destructive()
+                       || ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) == 0)) {
                return;
        }
        
@@ -921,7 +925,7 @@ AudioTimeAxisView::use_new_playlist (bool prompt)
 
        if (name.length()) {
                ds->use_new_playlist ();
-               pl = ds->playlist();
+               pl = dynamic_cast<AudioPlaylist*>(ds->playlist());
                pl->set_name (name);
        }
 }
@@ -933,7 +937,7 @@ AudioTimeAxisView::clear_playlist ()
        AudioDiskstream *ds;
        
        if ((ds = get_diskstream()) != 0) {
-               if ((pl = ds->playlist()) != 0) {
+               if ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) != 0) {
                        editor.clear_playlist (*pl);
                }
        }
@@ -991,7 +995,7 @@ AudioTimeAxisView::update_diskstream_display ()
        AudioDiskstream *ds;
 
        if ((ds = get_diskstream()) != 0) {
-               set_playlist (ds->playlist ());
+               set_playlist (dynamic_cast<AudioPlaylist*> (ds->playlist ()));
        }
 
        map_frozen ();
@@ -1143,7 +1147,7 @@ Region*
 AudioTimeAxisView::find_next_region (jack_nframes_t pos, RegionPoint point, int32_t dir)
 {
        AudioDiskstream *stream;
-       AudioPlaylist *playlist;
+       Playlist *playlist;
 
        if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
                return playlist->find_next_region (pos, point, dir);
index 272e6cfc52e1283bbaac98ccab996e8d16f7412e..74e4f64e3c81ce00d8f378fe41a04af7bee4377d 100644 (file)
@@ -31,6 +31,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 AutomationGainLine::AutomationGainLine (const string & name, Session& s, TimeAxisView& tv, ArdourCanvas::Group& parent, Curve& c)
 
index 70bc676fca8cae35848bb730bc02f55292e9b3b3..b87a71ca875aa1699dc861659856f08371a4ec0b 100644 (file)
@@ -48,6 +48,7 @@
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace Gnome; // for Canvas
 
index 7a264502affc3682f48abc2126eb65e3a6fafb22..aacfbdde75972ac92cc8bf338bae87538019c900 100644 (file)
@@ -31,6 +31,7 @@
 #include <ardour/session.h>
 
 using namespace ARDOUR;
+using namespace PBD;
 
 AutomationPanLine::AutomationPanLine (const string & name, Session& s, TimeAxisView& tv, ArdourCanvas::Group& parent, Curve& c)
 
index 670a718736e8c1dfcb7139e379d1419a5c85700a..165e124adde41a35ca3254bb317268cf5c4a44f7 100644 (file)
@@ -16,6 +16,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Editing;
 
index db88e6622c51462b78cab45cb73a286cd4ca6af7..2f1a286467de7767f6e88b2485b9f3f6368fafce 100644 (file)
@@ -12,6 +12,7 @@
 
 using namespace std;
 using namespace Gtk;
+using namespace PBD;
 
 /* the global color map */
 
index f411f945c833b28bc2c76d3f2f5391216d2dae37..a7c6e265ed5adb6aa14c4bcba5c85eda031d35e9 100644 (file)
@@ -43,6 +43,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace sigc;
 
index 293324dc916c1665d96d9ea821b046dd4729cac3..5b587594de730f9bfc7b1397907587092e41253f 100644 (file)
@@ -52,6 +52,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace sigc;
 using namespace Editing;
index 4545837dfa18f5b2392083df19a2a4f574fb49e2..350698ec483b4ef8e16119a6cd743b08aca6ac43 100644 (file)
@@ -35,6 +35,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace Gnome;
 using namespace Canvas;
index 613835aa4c2956e86268c9b9b7268eedbb480e17..3c9836a5e6e5c6e123f012454f10acc0ef29da6a 100644 (file)
@@ -7,6 +7,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 int
 curvetest (string filename)
index 16a8e5d92228e8b7aa0a1fe757894a06d8348316..0e45154717060078c88596b0af58d47ea5f25ba6 100644 (file)
@@ -84,6 +84,7 @@
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Glib;
 using namespace Gtkmm2ext;
@@ -3120,7 +3121,7 @@ Editor::mapped_set_selected_regionview_from_click (AudioTimeAxisView& atv, uint3
        }
 
        
-       if ((pl = ds->playlist()) != 0) {
+       if ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) != 0) {
                pl->get_equivalent_regions (basis->region, results);
        }
        
@@ -3345,7 +3346,7 @@ Editor::set_selected_regionview_from_region_list (Region& r, Selection::Operatio
                                continue;
                        }
 
-                       if ((pl = ds->playlist()) != 0) {
+                       if ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) != 0) {
                                pl->get_region_list_equivalent_regions (*region, results);
                        }
                        
index be2f3ba44f719b0845646a6cb187c1352c257ca9..b29b51a39908a237b62e46d350ca1424c94d2dbc 100644 (file)
@@ -69,6 +69,7 @@ namespace ARDOUR {
        class AudioDiskstream;
        class RouteGroup;
        class Playlist;
+       class AudioPlaylist;
        class Region;
        class Location;
        class TempoSection;
@@ -1600,7 +1601,7 @@ class Editor : public PublicEditor
        void external_edit_region ();
 
        int write_audio_selection (TimeSelection&);
-       bool write_audio_range (ARDOUR::Playlist&, uint32_t channels, list<ARDOUR::AudioRange>&);
+       bool write_audio_range (ARDOUR::AudioPlaylist&, uint32_t channels, list<ARDOUR::AudioRange>&);
 
        void write_selection ();
 
index d88cda61e64ef85c7b5237238d9ed472a435ed1b..e20e6ee8eb51690e0d70240d787df78948a5f731 100644 (file)
@@ -12,6 +12,7 @@ using namespace Glib;
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 
 void
index 6f9d96e61e1207ea18004afc8a411beee1dcda87..f3e2ee1cb29046bcff46ba32984ba668af326fe2 100644 (file)
@@ -42,6 +42,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 using namespace Editing;
index db1353f15980f030486970a6fe7d3e6f81656f23..acad3371a0d8cd09cf8feeaf5a127930969085ee 100644 (file)
@@ -8,6 +8,7 @@
 #include "selection.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 void
 Editor::set_route_loop_selection ()
index 69aa6428a680d58ed0ec08f01d5f3faf4ffb71ab..41350a1da421142759d00e033f0ae31ba3176395 100644 (file)
@@ -46,6 +46,7 @@
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Glib;
 using namespace Gtkmm2ext;
index ff4dda91825ee667d8380da6ece7c7d976195df1..dd87fc0bce856ad979937ee70a091ac171d6f16f 100644 (file)
@@ -42,6 +42,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 bool
@@ -511,22 +512,25 @@ Editor::canvas_crossfade_view_event (GdkEvent* event, ArdourCanvas::Item* item,
        if ((atv = dynamic_cast<AudioTimeAxisView*>(&tv)) != 0) {
 
                if (atv->is_audio_track()) {
-                       
-                       AudioPlaylist* pl = atv->get_diskstream()->playlist();
-                       Playlist::RegionList* rl = pl->regions_at (event_frame (event));
 
-                       if (!rl->empty()) {
-                               DescendingRegionLayerSorter cmp;
-                               rl->sort (cmp);
+                       AudioPlaylist* pl;
+                       if ((pl = dynamic_cast<AudioPlaylist*> (atv->get_diskstream()->playlist())) != 0) {
+
+                               Playlist::RegionList* rl = pl->regions_at (event_frame (event));
+
+                               if (!rl->empty()) {
+                                       DescendingRegionLayerSorter cmp;
+                                       rl->sort (cmp);
 
-                               AudioRegionView* arv = atv->view->find_view (*(dynamic_cast<AudioRegion*> (rl->front())));
+                                       AudioRegionView* arv = atv->view->find_view (*(dynamic_cast<AudioRegion*> (rl->front())));
 
-                               /* proxy */
-                               
-                               delete rl;
+                                       /* proxy */
 
-                               return canvas_region_view_event (event, arv->get_canvas_group(), arv);
-                       } 
+                                       delete rl;
+
+                                       return canvas_region_view_event (event, arv->get_canvas_group(), arv);
+                               } 
+                       }
                }
        }
 
index 5dd1eb075bf9f6052f77027830eec1625d8587b1..2353481daf1305e530cda2aad2955469a2cf7894 100644 (file)
@@ -28,6 +28,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 Editor::Cursor::Cursor (Editor& ed, const string& color, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
index 0047999f71e69c31da8362ceded6af9c866de854..8df76fef258ca5c18c592a01efa1603e4d50a163 100644 (file)
@@ -38,6 +38,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 void
index 9781a24d2965296b82071685c4c542a003f804bc..f76f494e5fd5523dd54b48a1abf225b21a2cd7ec 100644 (file)
@@ -46,6 +46,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 void
@@ -286,7 +287,7 @@ Editor::write_audio_selection (TimeSelection& ts)
 
                if (atv->is_audio_track()) {
 
-                       Playlist* playlist = atv->get_diskstream()->playlist();
+                       AudioPlaylist* playlist = dynamic_cast<AudioPlaylist*>(atv->get_diskstream()->playlist());
                        
                        if (playlist && write_audio_range (*playlist, atv->get_diskstream()->n_channels(), ts) == 0) {
                                ret = -1;
@@ -299,7 +300,7 @@ Editor::write_audio_selection (TimeSelection& ts)
 }
 
 bool
-Editor::write_audio_range (Playlist& playlist, uint32_t channels, list<AudioRange>& range)
+Editor::write_audio_range (AudioPlaylist& playlist, uint32_t channels, list<AudioRange>& range)
 {
        AudioFileSource* fs;
        const jack_nframes_t chunk_size = 4096;
index 5b2da7dc8302a059e66c5a91d2275ebfe7e855d7..8504667daa7efb6183ca058dc890f0968b61419d 100644 (file)
@@ -24,6 +24,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 void
 Editor::hscrollbar_allocate (Gtk::Allocation &alloc)
index a8dce7d64bbabfae4f6c45b4b6036de4828ecf75..6b8691b09fe2d2f6b7ef50abd0d95d2a77a29e76 100644 (file)
@@ -44,6 +44,7 @@
 #include "public_editor.h"
 
 using namespace Gtk;
+using namespace PBD;
 
 /* <CMT Additions file="editor.cc"> */
 
index 00469281fc7f1b355d20d08613710e33703e5162..baa158cbf8374c6e73ceda214b1227ccbbcda0db 100644 (file)
@@ -36,6 +36,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 
 void
index df64b9ed43533cec5466f54c110ca8ecbb6edd49..a584561e428bc3b5f1fa33ed7cb87fecbe5beb3c 100644 (file)
@@ -41,6 +41,7 @@
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 void
index c140213bb29732d4e4a971ded8e13ad83a6ac222..1100c23f61d03309189dc29c9cb1f33a5762d91b 100644 (file)
@@ -61,6 +61,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 using namespace Editing;
@@ -3197,7 +3198,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
 
                        AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (&rv->get_time_axis_view());
                        if (atv && atv->is_audio_track()) {
-                               AudioPlaylist* pl = atv->get_diskstream()->playlist();
+                               AudioPlaylist* pl = dynamic_cast<AudioPlaylist*>(atv->get_diskstream()->playlist());
                                if (pl) {
                                        /* only freeze and capture state once */
 
index 4bcafac93d4e8c3ed45be0b6c79376598cfef9be..c6f5eeeb4819150def674e88a44e8d500b9ffb7f 100644 (file)
@@ -27,4 +27,5 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
index 39b284375634eb7e587c74ffd1d980a0fc570a2c..d3845dd26bb6b09d7cd889180be5e900cd400b06 100644 (file)
@@ -64,6 +64,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 using namespace Editing;
index 26d9717d4ac96a17bedf5cad35fbc0a504c42d79..5cf099433b1588c2481ba4b6c4ff119ebfa5c30f 100644 (file)
@@ -42,6 +42,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Glib;
 using namespace Editing;
index 79b67a544a8fe8422aade14f2ea8042112585c09..2e036f500189ac98e9a2ec2afd172b2733fb4d9b 100644 (file)
@@ -35,6 +35,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 void
index e44f6a55ebb6aa4ac2486b4b433d1a42a02f7610..47641655e7cee752d716f83e45160f16c780f1e4 100644 (file)
@@ -35,6 +35,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Editing;
 
index 3b5d00d9eddf34d8bd8354f187378d166efec565..959da1ad2d740e4a335d60d7a5290d45d978b05e 100644 (file)
@@ -40,6 +40,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 
index f4351fe51845b140563a67736995ed7ecbaf900b..5f998ada9fa5a0602c39cb874a790d9b8e5ffb60 100644 (file)
@@ -49,6 +49,7 @@
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace Editing;
index ecb2f5ba4bf7f165d005c8d04c63d9e0965048bd..6ff467454d3d0647b913175648d95010dfe667a9 100644 (file)
@@ -41,6 +41,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 
index 834127e042d21dd63aceb84813c351f16cc35819..bcf8cd85adebc19111a410e9d664b1b9262df5e6 100644 (file)
@@ -49,6 +49,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 
index 3ff6ae783d4eb5eac3b83feaa3f3e713d7a91d64..e43eb20cd1963cd23032e91b77ea8a18e02f72b2 100644 (file)
@@ -32,6 +32,7 @@
 
 using namespace Gtk;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace std;
 
 ExportRangeMarkersDialog::ExportRangeMarkersDialog (PublicEditor& editor) 
index cb96774cdbbc81afa488ab0cfcc4bf2ee24d59d5..8f41f5def093092422a4418a11b2910ae6bb9cb4 100644 (file)
@@ -28,6 +28,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 GainAutomationTimeAxisView::GainAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, ArdourCanvas::Canvas& canvas, const string & n, ARDOUR::Curve& c)
index 60b485460097221d2d86f4c6b128284ae92348ae..b7746c4b19773f416e7f6e6ca65eaec0311ac12a 100644 (file)
@@ -47,6 +47,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace sigc;
index f649eddef7473d2079cc8a69762a85ea7692eb7d..905a96de7d47a5d5136042702d5b7866fab3ddb0 100644 (file)
@@ -52,6 +52,7 @@ using namespace std;
 using namespace ardourvis ;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 
 ImageFrameSocketHandler* ImageFrameSocketHandler::_instance = 0 ;
 
index 4ed36f55e724546b081e55b8b0ff93d0cb8bc6f3..ae288ec9ab28738828a9ebd4f61a0b0a8eef3fba 100644 (file)
@@ -47,6 +47,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 
index b18e08fabd24f9d5cc84a525d413f851a7e42256..b0ecd05077994be991656b4713afc658cecbcb34 100644 (file)
@@ -49,6 +49,7 @@ using namespace Gtk;
 using namespace Glib;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtkmm2ext;
 
 IOSelectorWindow::IOSelectorWindow (Session& sess, IO& ior, bool input, bool can_cancel)
index 92dce01bb6a90fe57ab7c1ea8f402b46119862e5..17390b8b4db79020fb24d82c5e855a55eaa95d4d 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "i18n.h"
 
+using namespace PBD;
+
 #define KBD_DEBUG 1
 bool debug_keyboard = false;
 
index 21d0fb5b15558ff06313be704558cd319f15282f..f0fe230b5720df95bbf84bd804e821d5ea5e83ac 100644 (file)
@@ -38,6 +38,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 
index 2bbae3956869928488b328ace9586d444f738db0..778355c858414b1793c509ef36df39cbbd84b7e0 100644 (file)
@@ -53,6 +53,7 @@
 using namespace Gtk;
 using namespace GTK_ARDOUR;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 
 TextReceiver text_receiver ("ardour");
@@ -102,12 +103,6 @@ handler (int sig)
        shutdown (1);
 }
 
-static void 
-handler2 (int sig, siginfo_t* ctxt, void* ignored)
-{
-       handler (sig);
-}      
-
 static void *
 signal_thread (void *arg)
 {
@@ -361,9 +356,17 @@ To create it from the command line, start ardour as \"ardour --new %1"), path)
        return true;
 }
 
+#ifdef VST_SUPPORT
+/* this is called from the entry point of a wine-compiled
+   executable that is linked against gtk2_ardour built
+   as a shared library.
+*/
+extern "C" {
+int ardour_main (int argc, char *argv[])
+#else
+int main (int argc, char *argv[])
+#endif
 
-int
-main (int argc, char *argv[])
 {
        ARDOUR::AudioEngine *engine;
        vector<Glib::ustring> null_file_list;
@@ -443,7 +446,7 @@ main (int argc, char *argv[])
        
        try { 
                engine = new ARDOUR::AudioEngine (jack_client_name);
-               ARDOUR::init (*engine, use_vst, try_hw_optimization, handler2);
+               ARDOUR::init (*engine, use_vst, try_hw_optimization);
                ui->set_engine (*engine);
        } catch (AudioEngine::NoBackendAvailable& err) {
                gui_jack_error ();
@@ -463,6 +466,9 @@ main (int argc, char *argv[])
        ARDOUR::cleanup ();
        shutdown (0);
 
-       /* just another commit forcing change */
+       return 0;
 }
+#ifdef VST_SUPPORT
+} // end of extern C block
+#endif
 
index acb88257e06c54f266bb6f747aa0c54e8000895e..1c6e7af2c79e81817734e0324f770d582553c383 100644 (file)
@@ -42,6 +42,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 
index 755058acb2e8785b15ef6c1d2fb7975708df0fe0..65434d5e82fce79cbb92db6e5cbf173b7a6e4afe 100644 (file)
@@ -32,6 +32,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace sigc;
 
index 50562a68d0f34ab776eb4045feec32d84b425dce..ea3b6097206b1f2f9ff31a418b8bc9fe726aab6e 100644 (file)
@@ -40,6 +40,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 
index 3a8881916c07c7f7b1c74f578a163ef479aec188..47d884be5e49d6a2bc72f75197fc24fee87e8e9d 100644 (file)
@@ -63,6 +63,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 
index 916424b9bde8deda9d1bdb92094a1a8b3893e4e7..983903d6dd04da5e56ad802564ce46a122f13c32 100644 (file)
@@ -49,6 +49,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Glib;
 using namespace Gtkmm2ext;
index 5ac4bf5a8df5c47e75fd324110c34f5b69b8c45c..d4c27157421e8e09af02a5516944bcddbecd1bc1 100644 (file)
@@ -43,6 +43,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Editing;
 using namespace Gtkmm2ext;
index 36e6c31245fb7108b9aabc11b11a004a4fda6604..b72eda78bd18bb3297ab51302e3df3daeb89f62c 100644 (file)
@@ -31,6 +31,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 PanAutomationTimeAxisView::PanAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n)
index 36f7aab252f8b2cfe80b07a73cd8d35b40e2f070..1fb94a1321130a292b9af83766052eedf3c6111b 100644 (file)
@@ -39,6 +39,7 @@ using namespace std;
 using namespace Gtk;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 
 Panner2d::Target::Target (float xa, float ya, const char *txt)
        : x (xa), y (ya), text (txt ? strdup (txt) : 0)
index 850070fabf2d5cae8f85d506456789a6816ffd3e..63a19867a86e1d60e44478d7b6fc16e2cff86499 100644 (file)
@@ -41,6 +41,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace sigc;
index 870fa2df5f18e85063ce011388d3b9bfa80edbab..f16294bf966534f107d263179bac49aaf310412c 100644 (file)
@@ -40,6 +40,7 @@ using namespace std;
 using namespace sigc;
 using namespace Gtk;
 using namespace ARDOUR;
+using namespace PBD;
 
 PlaylistSelector::PlaylistSelector ()
        : ArdourDialog ("playlist selector")
@@ -115,7 +116,7 @@ PlaylistSelector::show_for (RouteUI* ruix)
        
        for (DSPL_Map::iterator x = dspl_map.begin(); x != dspl_map.end(); ++x) {
 
-               AudioDiskstream* ds = session->diskstream_by_id (x->first);
+               Diskstream* ds = session->diskstream_by_id (x->first);
 
                if (ds == 0) {
                        continue;
index 56f5fab9c8675aa8d862fd2c1ca287b0eaf919f4..16796df160df608cc7b77c59a99acacdac82c293 100644 (file)
@@ -36,6 +36,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 PluginSelector::PluginSelector (PluginManager *mgr)
@@ -149,6 +150,9 @@ PluginSelector::PluginSelector (PluginManager *mgr)
        added_list.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::added_list_selection_changed));
 
        input_refiller ();
+#ifdef VST_SUPPORT
+       vst_refiller ();
+#endif
 }
 
 void
@@ -306,6 +310,9 @@ PluginSelector::btn_update_clicked()
 {
        manager->refresh ();
        input_refiller ();
+#ifdef VST_SUPPORT
+       vst_refiller ();
+#endif 
 }
 
 #ifdef VST_SUPPORT
index 66231adcc38db3ca7e814d8ed66da5de845711b3..749ab9d4ac76a8d372cc0c08da19b66c9c95e1b8 100644 (file)
@@ -56,6 +56,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace sigc;
index 958b7995c6edb5ae97936e98687286b86f44ab4e..e5800e8ece3ba2ea7514d4acb1471ec01d4f979f 100644 (file)
@@ -228,7 +228,7 @@ class VSTPluginUI : public PlugUIBase, public Gtk::VBox
        Gtk::HBox   preset_box;
        Gtk::VBox   vpacker;
        
-       gboolean configure_handler (GdkEventConfigure*, Gtk::Socket*);
+       bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
        void save_plugin_setting ();
 };
 #endif
index 57b1c07967e849ff04df58bfff45ef78a915aa3c..8971e8ff10245f9105e670321bb90650c4d3de91 100644 (file)
@@ -32,6 +32,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 RedirectAutomationLine::RedirectAutomationLine (const string & name, Redirect& rd, uint32_t port, Session& s,
                                                
index 798d132a4ae2d420d5ebf2dbdc407ec0cf4fb88d..e1b71310ac1bae7030a170c40d5dcb92f3950424 100644 (file)
@@ -29,6 +29,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
 RedirectAutomationTimeAxisView::RedirectAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n,
index 3d858a8f60a05ffdf7e068907bbcb115d669da69..f5cb9522e06caf72c237fe2a888d6dfa8414df74 100644 (file)
@@ -65,6 +65,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Glib;
 using namespace Gtkmm2ext;
index 73aa3465d974a260c716de3c3c81560acef2094d..413ff01753453ef83a7405c030d748c9bd310226 100644 (file)
@@ -33,6 +33,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace std;
 
index 059289acd4516d160fdb913e718175ae356f4eba..bba9410ffba344e4a4a4121eba9993e61e2625c6 100644 (file)
@@ -16,6 +16,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 AudioRegionGainLine::AudioRegionGainLine (const string & name, Session& s, AudioRegionView& r, ArdourCanvas::Group& parent, Curve& c)
   : AutomationLine (name, r.get_time_axis_view(), parent, c),
index b3ceb8516ff92c8afe65ec0acc6f478b658ec8fa..751584cab7a5ddfe6ff9c13b308b1b6ef89c2eba 100644 (file)
@@ -6,6 +6,7 @@
 #include "region_selection.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 
 
index 4d73b64fe7db419f0dc8898d8dd423a4220a5254..114aaf5da37f2232d66c512c404bb47f3fddda87 100644 (file)
@@ -49,6 +49,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace ArdourCanvas;
 
index 7b6f00d76b2ca5844847a33c944f37f9934dc3bc..d6ec7eab6c6042d3d5c1bbbc06a8958de24ac8d6 100644 (file)
@@ -52,6 +52,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace sigc;
 
index cefe7985cbdad8b24921d805f654c822b7493b71..6d315e0aaecd10429b5570d4cbf626d5c16c0144 100644 (file)
@@ -31,6 +31,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 
 RouteRedirectSelection&
index bd2cee26e9e8f17756dcf4420bc9bb2412e61165..4559058b8d4b4b420859edfdb9b7a1e648729b7a 100644 (file)
@@ -41,6 +41,7 @@ using namespace sigc;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace ARDOUR;
+using namespace PBD;
 
 
 RouteUI::RouteUI (ARDOUR::Route& rt, ARDOUR::Session& sess, const char* m_name,
index 3c1aea1ec85caa30ff33236cf07a925c7e8311e8..2e4ed8a1176caba4287e60b7d9f78199ba21ac8c 100644 (file)
@@ -33,6 +33,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 
 struct AudioRangeComparator {
index 8ce3838176b25e960a61d18ff7c58057a25930d8..be95f753e74b134edaf1c5a3167d3e460fd3387c 100644 (file)
@@ -28,6 +28,7 @@
 #include "gui_thread.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 SendUI::SendUI (Send& s, Session& se)
        : _send (s),
index aa06d86bb893572bd0d5c07c483512d1b4375653..79546880de0644c3f04719b48ed4831bf2d69c0f 100644 (file)
@@ -42,6 +42,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace std;
 
 SoundFileBox::SoundFileBox ()
index e95411a49882b78b57879ae7fef04837706b1d8b..9b33244fad24401d6245cf9f37b1b1eb908f5159 100644 (file)
@@ -29,6 +29,7 @@
 #include "color.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 
 StreamView::StreamView (AudioTimeAxisView& tv)
@@ -361,7 +362,9 @@ StreamView::playlist_changed (AudioDiskstream *ds)
        playlist_connections.push_back (ds->playlist()->RegionRemoved.connect (mem_fun (*this, &StreamView::remove_region_view)));
        playlist_connections.push_back (ds->playlist()->StateChanged.connect (mem_fun (*this, &StreamView::playlist_state_changed)));
        playlist_connections.push_back (ds->playlist()->Modified.connect (mem_fun (*this, &StreamView::playlist_modified)));
-       playlist_connections.push_back (ds->playlist()->NewCrossfade.connect (mem_fun (*this, &StreamView::add_crossfade)));
+       AudioPlaylist* apl = dynamic_cast<AudioPlaylist*>(ds->playlist());
+       if (apl)
+               playlist_connections.push_back (apl->NewCrossfade.connect (mem_fun (*this, &StreamView::add_crossfade)));
 }
 
 void
@@ -454,7 +457,9 @@ StreamView::redisplay_diskstream ()
 
        if (_trackview.is_audio_track()) {
                _trackview.get_diskstream()->playlist()->foreach_region (this, &StreamView::add_region_view);
-               _trackview.get_diskstream()->playlist()->foreach_crossfade (this, &StreamView::add_crossfade);
+               AudioPlaylist* apl = dynamic_cast<AudioPlaylist*>(_trackview.get_diskstream()->playlist());
+               if (apl)
+                       apl->foreach_crossfade (this, &StreamView::add_crossfade);
        }
 
        for (i = region_views.begin(); i != region_views.end(); ) {
index 533b715ce4f9150896660702ae914a2ef7cf1095..641d06735015936efcfbe1384707ad402a8b224d 100644 (file)
@@ -38,6 +38,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace ArdourCanvas;
 
index 9f5fbda13f0bf341cc9dcd5a631d2a9377435ac2..7eb03625801e077dd3e26c60c82cf48b4be0b201 100644 (file)
@@ -11,6 +11,7 @@
 using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace ARDOUR;
+using namespace PBD;
 
 TempoDialog::TempoDialog (TempoMap& map, jack_nframes_t frame, const string & action)
        : ArdourDialog ("tempo dialog"),
index 1b6c1f390c8e8f9ebf80a313fea80665d76d2fcf..b5ab5baa1098a6868cacc0ffda3ef24dc2558400 100644 (file)
@@ -55,6 +55,7 @@ using namespace Gtk;
 using namespace Gdk;
 using namespace sigc; 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace ArdourCanvas;
 
index c333a8acb3f97eb0a31e6fcfae9252f206712e90..abab306a84d548044c3ea11b58c746895e42aa93 100644 (file)
@@ -38,6 +38,7 @@
 using namespace std;
 using namespace Editing;
 using namespace Glib;
+using namespace PBD;
 
 //------------------------------------------------------------------------------
 /** Initialize const static memeber data */
index 0d1b94e8a0ae140dd9d0ccb5be63fe2ad9f6ffc9..518e04cccb3056647415cb72c85a90ad8af8ac1b 100644 (file)
@@ -28,6 +28,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 AudioRange&
 TimeSelection::operator[] (uint32_t which)
index c1ad4f6ca7fd0bde94fbe210f8dec032c698ed22..91cb7ad58b21bf30c595cfbe9d3710b05428d326 100644 (file)
@@ -43,6 +43,7 @@ using namespace std;
 using namespace Gtk;
 using namespace sigc;
 using namespace Glib;
+using namespace PBD;
 
 ustring
 fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width)
index b6c96c55abfd5c71b6e896812354e526b08ca881..c27ed33089bdab3ee2ce10ea3eb5c257ff7f80d2 100644 (file)
@@ -55,6 +55,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
        
index 8b40e27070787d623c20f5bd097a7c2828f5c023..7adf702f4d38a843fbeb7a3f75188623e96ad0a5 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include <fst.h>
-
+#include <gtk/gtksocket.h>
 #include <ardour/insert.h>
 #include <ardour/vst_plugin.h>
 
@@ -29,6 +29,7 @@
 
 using namespace Gtk;
 using namespace ARDOUR;
+using namespace PBD;
 
 VSTPluginUI::VSTPluginUI (PluginInsert& pi, VSTPlugin& vp)
        : PlugUIBase (pi),
@@ -60,16 +61,12 @@ VSTPluginUI::get_preferred_height ()
 int
 VSTPluginUI::package (Gtk::Window& win)
 {
-       /* for GTK+2, remove this: you cannot add to a realized socket */
-
-       //socket.realize ();
-
        /* forward configure events to plugin window */
 
-       win.signal_configure_event().connect (bind (mem_fun (*this, &VSTPluginUI::configure_handler), &socket));
+       win.signal_configure_event().connect (bind (mem_fun (*this, &VSTPluginUI::configure_handler), &socket), false);
 
-       /* XXX in GTK2, use add_id() instead of steal, although add_id()
-          assumes that the window's owner understands the XEmbed protocol.
+       /*
+          this assumes that the window's owner understands the XEmbed protocol.
        */
        
        socket.add_id (fst_get_XID (vst.fst()));
@@ -77,45 +74,42 @@ VSTPluginUI::package (Gtk::Window& win)
        return 0;
 }
 
-gboolean
+bool
 VSTPluginUI::configure_handler (GdkEventConfigure* ev, Gtk::Socket *socket)
 {
        XEvent event;
-
        gint x, y;
+       GdkWindow* w;
 
-       if (socket->gobj() == NULL) {
-               return FALSE;
+       if (socket == 0 || ((w = socket->gobj()->plug_window) == 0)) {
+               return false;
        }
 
        event.xconfigure.type = ConfigureNotify;
-       event.xconfigure.event = GDK_WINDOW_XWINDOW (socket->get_window()->gobj());
-       event.xconfigure.window = GDK_WINDOW_XWINDOW (socket->get_window()->gobj());
+       event.xconfigure.event = GDK_WINDOW_XWINDOW (w);
+       event.xconfigure.window = GDK_WINDOW_XWINDOW (w);
 
        /* The ICCCM says that synthetic events should have root relative
         * coordinates. We still aren't really ICCCM compliant, since
         * we don't send events when the real toplevel is moved.
         */
        gdk_error_trap_push ();
-       gdk_window_get_origin (socket->get_window()->gobj(), &x, &y);
+       gdk_window_get_origin (w, &x, &y);
        gdk_error_trap_pop ();
 
        event.xconfigure.x = x;
        event.xconfigure.y = y;
-       event.xconfigure.width = GTK_WIDGET(socket)->allocation.width;
-       event.xconfigure.height = GTK_WIDGET(socket)->allocation.height;
+       event.xconfigure.width = GTK_WIDGET(socket->gobj())->allocation.width;
+       event.xconfigure.height = GTK_WIDGET(socket->gobj())->allocation.height;
 
        event.xconfigure.border_width = 0;
        event.xconfigure.above = None;
        event.xconfigure.override_redirect = False;
 
        gdk_error_trap_push ();
-       XSendEvent (GDK_WINDOW_XDISPLAY (socket->get_window()->gobj()),
-                   GDK_WINDOW_XWINDOW (socket->get_window()->gobj()),
-                   False, StructureNotifyMask, &event);
-       // gdk_display_sync (GDK_WINDOW_XDISPLAY (socket->plug_window));
+       XSendEvent (GDK_WINDOW_XDISPLAY (w), GDK_WINDOW_XWINDOW (w), False, StructureNotifyMask, &event);
        gdk_error_trap_pop ();
 
-       return FALSE;
+       return false;
 }
 
index bd5f8a4256c401b6a8090b175a9fc08dca178bda..c42728f85b82b37af9b6eefbf9552bad467e4bd2 100644 (file)
@@ -36,6 +36,13 @@ audiofilesource.cc
 audiofilter.cc
 audioregion.cc
 audiosource.cc
+diskstream.cc
+midi_source.cc
+midi_diskstream.cc
+midi_playlist.cc
+midi_track.cc
+midi_region.cc
+smf_source.cc
 auditioner.cc
 automation.cc
 automation_event.cc
index fee6c601a2ebf1c1c390d5dc892e31e584ed4c28..c0dfea9a950e9edccc885a363dcbdc933feaf728 100644 (file)
@@ -45,7 +45,7 @@ namespace ARDOUR {
 
        static const jack_nframes_t max_frames = JACK_MAX_FRAMES;
 
-       int init (AudioEngine&, bool with_vst, bool try_optimization, void (*sighandler)(int,siginfo_t*,void*) = 0);
+       int init (AudioEngine&, bool with_vst, bool try_optimization);
        int cleanup ();
 
        
index 9355a3fccbf7a815aa5d2e8eb7f446382c24efb3..d1833d01a5773dbb0908649baa01ef87d3c1b27d 100644 (file)
@@ -18,8 +18,8 @@
     $Id: diskstream.h 579 2006-06-12 19:56:37Z essej $
 */
 
-#ifndef __ardour_diskstream_h__
-#define __ardour_diskstream_h__
+#ifndef __ardour_audio_diskstream_h__
+#define __ardour_audio_diskstream_h__
 
 #include <sigc++/signal.h>
 
@@ -42,8 +42,8 @@
 #include <ardour/route.h>
 #include <ardour/port.h>
 #include <ardour/utils.h>
-#include <ardour/stateful.h>
-
+#include <ardour/diskstream.h>
+#include <ardour/audioplaylist.h>
 struct tm;
 
 namespace ARDOUR {
@@ -55,52 +55,23 @@ class AudioPlaylist;
 class AudioFileSource;
 class IO;
 
-class AudioDiskstream : public Stateful, public sigc::trackable
+class AudioDiskstream : public Diskstream
 {      
   public:
-       enum Flag {
-               Recordable = 0x1,
-               Hidden = 0x2,
-               Destructive = 0x4
-       };
-
-       AudioDiskstream (Session &, const string& name, Flag f = Recordable);
+       AudioDiskstream (Session &, const string& name, Diskstream::Flag f = Recordable);
        AudioDiskstream (Session &, const XMLNode&);
 
-       string name() const { return _name; }
-
-       ARDOUR::IO* io() const { return _io; }
        void set_io (ARDOUR::IO& io);
 
        AudioDiskstream& ref() { _refcnt++; return *this; }
-       void unref() { if (_refcnt) _refcnt--; if (_refcnt == 0) delete this; }
-       uint32_t refcnt() const { return _refcnt; }
+       //void unref() { if (_refcnt) _refcnt--; if (_refcnt == 0) delete this; }
+       //uint32_t refcnt() const { return _refcnt; }
 
        float playback_buffer_load() const;
        float capture_buffer_load() const;
 
-       void set_flag (Flag f) {
-               _flags |= f;
-       }
-
-       void unset_flag (Flag f) {
-               _flags &= ~f;
-       }
-
-       AlignStyle alignment_style() const { return _alignment_style; }
-       void set_align_style (AlignStyle);
-       void set_persistent_align_style (AlignStyle);
-
-       bool hidden() const { return _flags & Hidden; }
-       bool recordable() const { return _flags & Recordable; }
-       bool destructive() const { return _flags & Destructive; }
-
-       void set_destructive (bool yn);
-
-       jack_nframes_t roll_delay() const { return _roll_delay; }
-       void set_roll_delay (jack_nframes_t);
-
-       int set_name (string str, void* src);
+       //void set_align_style (AlignStyle);
+       //void set_persistent_align_style (AlignStyle);
 
        string input_source (uint32_t n=0) const {
                if (n < channels.size()) {
@@ -115,13 +86,7 @@ class AudioDiskstream : public Stateful, public sigc::trackable
        }
 
        void set_record_enabled (bool yn, void *src);
-       bool record_enabled() const { return g_atomic_int_get (&_record_enabled); }
-       void punch_in ();
-       void punch_out ();
-
-       bool  reversed() const { return _actual_speed < 0.0f; }
-       double speed() const { return _visible_speed; }
-       void set_speed (double);
+       //void set_speed (double);
 
        float peak_power(uint32_t n=0) { 
                float x = channels[n].peak_power;
@@ -133,12 +98,14 @@ class AudioDiskstream : public Stateful, public sigc::trackable
                }
        }
 
-       int  use_playlist (AudioPlaylist *);
+       int use_playlist (Playlist *);
        int use_new_playlist ();
        int use_copy_playlist ();
 
-       void start_scrub (jack_nframes_t where);
-       void end_scrub ();
+       void start_scrub (jack_nframes_t where) {} // FIXME?
+       void end_scrub () {} // FIXME?
+
+       Playlist *playlist () { return _playlist; }
 
        Sample *playback_buffer (uint32_t n=0) {
                if (n < channels.size())
@@ -152,41 +119,16 @@ class AudioDiskstream : public Stateful, public sigc::trackable
                return 0;
        }
 
-       AudioPlaylist *playlist () { return _playlist; }
-
        AudioFileSource *write_source (uint32_t n=0) {
                if (n < channels.size())
                        return channels[n].write_source;
                return 0;
        }
 
-       jack_nframes_t current_capture_start() const { return capture_start_frame; }
-       jack_nframes_t current_capture_end() const { return capture_start_frame + capture_captured; }
-       jack_nframes_t get_capture_start_frame (uint32_t n=0);
-       jack_nframes_t get_captured_frames (uint32_t n=0);
-       
-       uint32_t n_channels() { return _n_channels; }
-
        int add_channel ();
        int remove_channel ();
        
-       static void set_disk_io_chunk_frames (uint32_t n) {
-               disk_io_chunk_frames = n;
-       }
-
-       static jack_nframes_t disk_io_frames() { return disk_io_chunk_frames; }
        
-       sigc::signal<void,void*> record_enable_changed;
-       sigc::signal<void>       speed_changed;
-       sigc::signal<void,void*> reverse_changed;
-       sigc::signal<void>       PlaylistChanged;
-       sigc::signal<void>       AlignmentStyleChanged;
-
-       static sigc::signal<void> DiskOverrun;
-       static sigc::signal<void> DiskUnderrun;
-       static sigc::signal<void,AudioDiskstream*> AudioDiskstreamCreated;   // XXX use a ref with sigc2
-       static sigc::signal<void,list<AudioFileSource*>*> DeleteSources;
-
        /* stateful */
 
        XMLNode& get_state(void);
@@ -194,9 +136,7 @@ class AudioDiskstream : public Stateful, public sigc::trackable
 
        void monitor_input (bool);
 
-       jack_nframes_t capture_offset() const { return _capture_offset; }
-       void           set_capture_offset ();
-
+       // FIXME: these don't belong here
        static void swap_by_ptr (Sample *first, Sample *last) {
                while (first < last) {
                        Sample tmp = *first;
@@ -213,21 +153,12 @@ class AudioDiskstream : public Stateful, public sigc::trackable
                }
        }
 
-       bool slaved() const { return _slaved; }
-       void set_slaved(bool yn) { _slaved = yn; }
-
-       int set_loop (Location *loc);
-       sigc::signal<void,Location *> LoopSet;
-
-       std::list<Region*>& last_capture_regions () {
-               return _last_capture_regions;
-       }
-
-       void handle_input_change (IOChange, void *src);
-
-       id_t id() const { return _id; }
-
-       XMLNode* deprecated_io_node;
+       //void handle_input_change (IOChange, void *src);
+       
+       //static sigc::signal<void> DiskOverrun;
+       //static sigc::signal<void> DiskUnderrun;
+       //static sigc::signal<void,AudioDiskstream*> AudioDiskstreamCreated;   // XXX use a ref with sigc2
+       static sigc::signal<void,list<AudioFileSource*>*> DeleteSources;
 
   protected:
        friend class Session;
@@ -237,9 +168,9 @@ class AudioDiskstream : public Stateful, public sigc::trackable
           while they are called.
        */
 
-       void set_pending_overwrite (bool);
+       void set_pending_overwrite(bool);
        int  overwrite_existing_buffers ();
-       void reverse_scrub_buffer (bool to_forward);
+       void reverse_scrub_buffer (bool to_forward) {} // FIXME?
        void set_block_size (jack_nframes_t);
        int  internal_playback_seek (jack_nframes_t distance);
        int  can_internal_playback_seek (jack_nframes_t distance);
@@ -247,9 +178,6 @@ class AudioDiskstream : public Stateful, public sigc::trackable
        void reset_write_sources (bool, bool force = false);
        void non_realtime_input_change ();
 
-       uint32_t read_data_count() const { return _read_data_count; }
-       uint32_t write_data_count() const { return _write_data_count; }
-
   protected:
        friend class Auditioner;
        int  seek (jack_nframes_t which_sample, bool complete_refill = false);
@@ -257,38 +185,23 @@ class AudioDiskstream : public Stateful, public sigc::trackable
   protected:
        friend class AudioTrack;
 
-       void prepare ();
        int  process (jack_nframes_t transport_frame, jack_nframes_t nframes, jack_nframes_t offset, bool can_record, bool rec_monitors_input);
        bool commit  (jack_nframes_t nframes);
-       void recover (); /* called if commit will not be called, but process was */
 
   private:
 
        /* use unref() to destroy a diskstream */
-
        ~AudioDiskstream();
 
-       enum TransitionType {
-               CaptureStart = 0,
-               CaptureEnd
-       };
-       
-       struct CaptureTransition {
-
-               TransitionType   type;
-               // the start or end file frame pos
-               jack_nframes_t   capture_val;
-       };
-       
        struct ChannelInfo {
 
                Sample     *playback_wrap_buffer;
                Sample     *capture_wrap_buffer;
                Sample     *speed_buffer;
 
-               float       peak_power;
+               float       peak_power;
 
-               AudioFileSource   *fades_source;
+               AudioFileSource   *fades_source;
                AudioFileSource   *write_source;
 
                Port         *source;
@@ -312,90 +225,25 @@ class AudioDiskstream : public Stateful, public sigc::trackable
 
        typedef vector<ChannelInfo> ChannelList;
 
-
-       string            _name;
-       ARDOUR::Session&  _session;
-       ARDOUR::IO*       _io;
-       ChannelList        channels;
-       uint32_t      _n_channels;
-       id_t              _id;
-
-       mutable gint             _record_enabled;
-       AudioPlaylist*           _playlist;
-       double                   _visible_speed;
-       double                   _actual_speed;
-       /* items needed for speed change logic */
-       bool                     _buffer_reallocation_required;
-       bool                     _seek_required;
-       
-       bool                      force_refill;
-       jack_nframes_t            capture_start_frame;
-       jack_nframes_t            capture_captured;
-       bool                      was_recording;
-       jack_nframes_t            adjust_capture_position;
-       jack_nframes_t           _capture_offset;
-       jack_nframes_t           _roll_delay;
-       jack_nframes_t            first_recordable_frame;
-       jack_nframes_t            last_recordable_frame;
-       int                       last_possibly_recording;
-       AlignStyle               _alignment_style;
-       bool                     _scrubbing;
-       bool                     _slaved;
-       bool                     _processed;
-       Location*                 loop_location;
-       jack_nframes_t            overwrite_frame;
-       off_t                     overwrite_offset;
-       bool                      pending_overwrite;
-       bool                      overwrite_queued;
-       IOChange                  input_change_pending;
-       jack_nframes_t            wrap_buffer_size;
-       jack_nframes_t            speed_buffer_size;
-
-       uint64_t                  last_phase;
-       uint64_t                  phi;
-       
-       jack_nframes_t            file_frame;           
-       jack_nframes_t            playback_sample;
-       jack_nframes_t            playback_distance;
-
-       uint32_t                 _read_data_count;
-       uint32_t                 _write_data_count;
-
-       bool                      in_set_state;
-       AlignStyle               _persistent_alignment_style;
-       bool                      first_input_change;
-
-       Glib::Mutex  state_lock;
-
-       jack_nframes_t scrub_start;
-       jack_nframes_t scrub_buffer_size;
-       jack_nframes_t scrub_offset;
-       uint32_t _refcnt;
-
-       sigc::connection ports_created_c;
-       sigc::connection plmod_connection;
-       sigc::connection plstate_connection;
-       sigc::connection plgone_connection;
-
        /* the two central butler operations */
 
        int do_flush (char * workbuf, bool force = false);
        int do_refill (Sample *mixdown_buffer, float *gain_buffer, char *workbuf);
+       
+       virtual int non_realtime_do_refill() { return do_refill(0, 0, 0); }
 
        int read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer, char * workbuf, jack_nframes_t& start, jack_nframes_t cnt, 
                  ChannelInfo& channel_info, int channel, bool reversed);
 
-       uint32_t i_am_the_modifier;
-       
        /* XXX fix this redundancy ... */
 
-       void playlist_changed (Change);
-       void playlist_modified ();
+       //void playlist_changed (Change);
+       //void playlist_modified ();
        void playlist_deleted (Playlist*);
-       void session_controls_changed (Session::ControlType);
+       void session_controls_changed (Session::ControlType) {} // FIXME?
 
        void finish_capture (bool rec_monitors_input);
-       void clean_up_capture (struct tm&, time_t, bool abort);
+       void clean_up_capture (struct tm&, time_t, bool abort) {} // FIXME?
        void transport_stopped (struct tm&, time_t, bool abort);
 
        struct CaptureInfo {
@@ -406,29 +254,25 @@ class AudioDiskstream : public Stateful, public sigc::trackable
        vector<CaptureInfo*> capture_info;
        Glib::Mutex  capture_info_lock;
        
-       void init (Flag);
+       void init (Diskstream::Flag);
 
        void init_channel (ChannelInfo &chan);
        void destroy_channel (ChannelInfo &chan);
        
-       static jack_nframes_t disk_io_chunk_frames;
-
        int use_new_write_source (uint32_t n=0);
-       int use_new_fade_source (uint32_t n=0);
+       int use_new_fade_source (uint32_t n=0) { return 0; } // FIXME?
 
        int find_and_use_playlist (const string&);
 
        void allocate_temporary_buffers ();
 
-       unsigned char _flags;
+       int  create_input_port () { return 0; } // FIXME?
+       int  connect_input_port () { return 0; } // FIXME?
+       int  seek_unlocked (jack_nframes_t which_sample) { return 0; } // FIXME?
 
-       int  create_input_port ();
-       int  connect_input_port ();
-       int  seek_unlocked (jack_nframes_t which_sample);
+       int ports_created () { return 0; } // FIXME?
 
-       int ports_created ();
-
-       bool realtime_set_speed (double, bool global_change);
+       //bool realtime_set_speed (double, bool global_change);
        void non_realtime_set_speed ();
 
        std::list<Region*> _last_capture_regions;
@@ -440,8 +284,12 @@ class AudioDiskstream : public Stateful, public sigc::trackable
        void set_align_style_from_io();
        void setup_destructive_playlist ();
        void use_destructive_playlist ();
+       
+
+       ChannelList    channels;
+       AudioPlaylist* _playlist;
 };
 
 }; /* namespace ARDOUR */
 
-#endif /* __ardour_diskstream_h__ */
+#endif /* __ardour_audio_diskstream_h__ */
index 1c17cbc85991e91e8356211d6ef0a954ce3d0d7b..9d06f9425d1db09094b0f70b8b5e0076a4e477b9 100644 (file)
@@ -52,7 +52,7 @@ class AudioTrack : public Route
        bool can_record() const { return true; }
        void set_record_enable (bool yn, void *src);
 
-       AudioDiskstream& disk_stream() const { return *diskstream; }
+       AudioDiskstream& disk_stream() const { return *_diskstream; }
        int set_diskstream (AudioDiskstream&, void *);
        int use_diskstream (string name);
        int use_diskstream (id_t id);
@@ -99,7 +99,7 @@ class AudioTrack : public Route
        void set_meter_point (MeterPoint, void* src);
 
   protected:
-       AudioDiskstream *diskstream;
+       AudioDiskstream *_diskstream;
        MeterPoint _saved_meter_point;
        TrackMode _mode;
 
index 50bf7dddcceb2b68eb35df0d63d135608ed56f56..6f3de184737e419be0026a909ee8b503e7aee509 100644 (file)
@@ -34,6 +34,7 @@
 #include <ardour/ardour.h>
 #include <jack/jack.h>
 #include <jack/transport.h>
+#include <ardour/buffer.h>
 
 namespace ARDOUR {
 
@@ -104,8 +105,8 @@ class AudioEngine : public sigc::trackable
                virtual const char *what() const throw() { return "could not connect to engine backend"; }
        };
 
-       Port *register_audio_input_port (const std::string& portname);
-       Port *register_audio_output_port (const std::string& portname);
+       Port *register_input_port (Buffer::Type type, const std::string& portname);
+       Port *register_output_port (Buffer::Type type, const std::string& portname);
        int   unregister_port (Port *);
        
        int connect (const std::string& source, const std::string& destination);
index 8ae45fe65c1b42fa28bf1ef931e955f512828f0f..fa2fe9851d25643cdc5e77250eb051c73414a6fc 100644 (file)
@@ -39,6 +39,7 @@
 #include <ardour/utils.h>
 #include <ardour/state_manager.h>
 #include <ardour/curve.h>
+#include <ardour/buffer.h>
 
 using std::string;
 using std::vector;
@@ -53,6 +54,11 @@ class Port;
 class Connection;
 class Panner;
 
+/** A collection of input and output ports with connections.
+ *
+ * An IO can contain ports of varying types, making routes/inserts/etc with
+ * varied combinations of types (eg MIDI and audio) possible.
+ */
 class IO : public Stateful, public ARDOUR::StateManager
 {
 
@@ -61,7 +67,8 @@ class IO : public Stateful, public ARDOUR::StateManager
 
        IO (Session&, string name, 
            int input_min = -1, int input_max = -1, 
-           int output_min = -1, int output_max = -1);
+           int output_min = -1, int output_max = -1,
+               Buffer::Type default_type = Buffer::AUDIO);
 
        virtual ~IO();
 
@@ -80,20 +87,22 @@ class IO : public Stateful, public ARDOUR::StateManager
        
        virtual void silence  (jack_nframes_t, jack_nframes_t offset);
 
+       // These should be moved in to a separate object that manipulates an IO
+       
        void pan (vector<Sample*>& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset, gain_t gain_coeff);
        void pan_automated (vector<Sample*>& bufs, uint32_t nbufs, jack_nframes_t start_frame, jack_nframes_t end_frame, 
                            jack_nframes_t nframes, jack_nframes_t offset);
        void collect_input  (vector<Sample*>&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset);
-       void deliver_output (vector<Sample *>&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset);
-       void deliver_output_no_pan (vector<Sample *>&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset);
+       void deliver_output (vector<Sample*>&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset);
+       void deliver_output_no_pan (vector<Sample*>&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset);
        void just_meter_input (jack_nframes_t start_frame, jack_nframes_t end_frame, 
                               jack_nframes_t nframes, jack_nframes_t offset);
 
        virtual uint32_t n_process_buffers () { return 0; }
 
        virtual void   set_gain (gain_t g, void *src);
-       void   inc_gain (gain_t delta, void *src);
-       gain_t         gain () const                      { return _desired_gain; }
+       void           inc_gain (gain_t delta, void *src);
+       gain_t         gain () const { return _desired_gain; }
        virtual gain_t effective_gain () const;
 
        Panner& panner() { return *_panner; }
@@ -106,8 +115,8 @@ class IO : public Stateful, public ARDOUR::StateManager
        Connection *input_connection() const { return _input_connection; }
        Connection *output_connection() const { return _output_connection; }
 
-       int add_input_port (string source, void *src);
-       int add_output_port (string destination, void *src);
+       int add_input_port (string source, void *src, Buffer::Type type = Buffer::NIL);
+       int add_output_port (string destination, void *src, Buffer::Type type = Buffer::NIL);
 
        int remove_input_port (Port *, void *src);
        int remove_output_port (Port *, void *src);
@@ -289,6 +298,7 @@ public:
        id_t                _id;
        bool                 no_panner_reset;
        XMLNode*             deferred_state;
+       Buffer::Type        _default_type;
 
        virtual void set_deferred_state() {}
 
index c653c8502e07ded5ec6db448f072d2a2a6b44ea7..0a988b3c1016aee8c8321d6ecc47fae5ab273716 100644 (file)
@@ -53,7 +53,7 @@ class Playlist : public Stateful, public StateManager {
        Playlist (const Playlist&, string name, bool hidden = false);
        Playlist (const Playlist&, jack_nframes_t start, jack_nframes_t cnt, string name, bool hidden = false);
 
-       virtual jack_nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, char * workbuf, jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n=0) = 0;
+       //virtual jack_nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, char * workbuf, jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n=0) = 0;
        virtual void clear (bool with_delete = false, bool with_save = true);
        virtual void dump () const;
        virtual UndoAction get_memento() const = 0;
index ff9c25e1c4e0c4f0cd06da2f3c368da85439e332..0b7d79cbd674c642089ffd696758cd4611d0847b 100644 (file)
@@ -33,24 +33,24 @@ class AudioEngine;
 class Port : public sigc::trackable {
    public:
        virtual ~Port() { 
-               free (port);
+               free (_port);
        }
 
        Sample *get_buffer (jack_nframes_t nframes) {
                if (_flags & JackPortIsOutput) {
                        return _buffer;
                } else {
-                       return (Sample *) jack_port_get_buffer (port, nframes);
+                       return (Sample *) jack_port_get_buffer (_port, nframes);
                }
        }
 
        void reset_buffer () {
                if (_flags & JackPortIsOutput) {
-                       _buffer = (Sample *) jack_port_get_buffer (port, 0);
+                       _buffer = (Sample *) jack_port_get_buffer (_port, 0);
                } else {
                        _buffer = 0; /* catch illegal attempts to use it */
                }
-               silent = false;
+               _silent = false;
        }
 
        std::string name() { 
@@ -58,7 +58,7 @@ class Port : public sigc::trackable {
        }
 
        std::string short_name() { 
-               return jack_port_short_name (port);
+               return jack_port_short_name (_port);
        }
        
        int set_name (std::string str);
@@ -68,7 +68,7 @@ class Port : public sigc::trackable {
        }
 
        bool is_mine (jack_client_t *client) { 
-               return jack_port_is_mine (client, port);
+               return jack_port_is_mine (client, _port);
        }
 
        const char* type() const {
@@ -76,21 +76,21 @@ class Port : public sigc::trackable {
        }
 
        int connected () const {
-               return jack_port_connected (port);
+               return jack_port_connected (_port);
        }
        
        bool connected_to (const std::string& portname) const {
-               return jack_port_connected_to (port, portname.c_str());
+               return jack_port_connected_to (_port, portname.c_str());
        }
 
        const char ** get_connections () const {
-               return jack_port_get_connections (port);
+               return jack_port_get_connections (_port);
        }
 
        void reset_overs () {
                _short_overs = 0;
                _long_overs = 0;
-               overlen = 0;
+               _overlen = 0;
        }
 
        void reset_peak_meter () {
@@ -103,18 +103,18 @@ class Port : public sigc::trackable {
        }
 
        void enable_metering() {
-               metering++;
+               _metering++;
        }
        
        void disable_metering () {
-               if (metering) { metering--; }
+               if (_metering) { _metering--; }
        }
 
-       float    peak_db() const { return _peak_db; }
+       float                       peak_db() const { return _peak_db; }
        jack_default_audio_sample_t peak()    const { return _peak; }
 
        uint32_t short_overs () const { return _short_overs; }
-       uint32_t long_overs () const { return _long_overs; }
+       uint32_t long_overs ()  const { return _long_overs; }
        
        static void set_short_over_length (jack_nframes_t);
        static void set_long_over_length (jack_nframes_t);
@@ -128,7 +128,7 @@ class Port : public sigc::trackable {
        }
        
        bool monitoring_input () const {
-               return jack_port_monitoring_input (port);
+               return jack_port_monitoring_input (_port);
        }
 
        bool can_monitor () const {
@@ -136,30 +136,29 @@ class Port : public sigc::trackable {
        }
        
        void ensure_monitor_input (bool yn) {
-               jack_port_request_monitor (port, yn);
+               jack_port_request_monitor (_port, yn);
        }
        
        void request_monitor_input (bool yn) {
-               jack_port_request_monitor (port, yn);
+               jack_port_request_monitor (_port, yn);
        }
 
        jack_nframes_t latency () const {
-               return jack_port_get_latency (port);
+               return jack_port_get_latency (_port);
        }
 
        void set_latency (jack_nframes_t nframes) {
-               jack_port_set_latency (port, nframes);
+               jack_port_set_latency (_port, nframes);
        }
 
        sigc::signal<void,bool> MonitorInputChanged;
        sigc::signal<void,bool> ClockSyncChanged;
 
-       bool is_silent() const { return silent; }
+       bool is_silent() const { return _silent; }
 
+       /** Assumes that the port is an audio output port */
        void silence (jack_nframes_t nframes, jack_nframes_t offset) {
-               /* assumes that the port is an output port */
-
-               if (!silent) {
+               if (!_silent) {
                        memset (_buffer + offset, 0, sizeof (Sample) * nframes);
                        if (offset == 0) {
                                /* XXX this isn't really true, but i am not sure
@@ -167,13 +166,13 @@ class Port : public sigc::trackable {
                                   want to set it true when the entire port
                                   buffer has been overrwritten.
                                */
-                               silent = true;
+                               _silent = true;
                        }
                }
        }
        
        void mark_silence (bool yn) {
-               silent = yn;
+               _silent = yn;
        }
 
   private:
@@ -184,7 +183,7 @@ class Port : public sigc::trackable {
        
        /* engine isn't supposed to below here */
 
-       Sample       *_buffer;
+       Sample *_buffer;
 
        /* cache these 3 from JACK so that we can
           access them for reconnecting.
@@ -194,18 +193,18 @@ class Port : public sigc::trackable {
        std::string   _type;
        std::string   _name;
 
-       bool           last_monitor : 1;
-       bool           silent : 1;
-       jack_port_t   *port;
-       jack_nframes_t      overlen;
-       jack_default_audio_sample_t      _peak;
-       float         _peak_db;
-       uint32_t _short_overs;
-       uint32_t _long_overs;
-       unsigned short  metering;
+       bool                         _last_monitor : 1;
+       bool                         _silent : 1;
+       jack_port_t                 *_port;
+       jack_nframes_t               _overlen;
+       jack_default_audio_sample_t  _peak;
+       float                        _peak_db;
+       uint32_t                     _short_overs;
+       uint32_t                     _long_overs;
+       unsigned short               _metering;
        
-       static jack_nframes_t long_over_length;
-       static jack_nframes_t short_over_length;
+       static jack_nframes_t        _long_over_length;
+       static jack_nframes_t        _short_over_length;
 };
  
 }; /* namespace ARDOUR */
index aae776625e6c45703c99fa8b8b9a3d02461b6b70..67b5b3d9dda7d20fa5bb943dc8af1d9085fe601e 100644 (file)
@@ -140,11 +140,11 @@ class Region : public Stateful, public StateManager
                return ARDOUR::coverage (_position, _position + _length - 1, start, end);
        }
 
-       virtual jack_nframes_t read_at (Sample *buf, Sample *mixdown_buffer, 
+       /*virtual jack_nframes_t read_at (Sample *buf, Sample *mixdown_buffer, 
                                        float *gain_buffer, char * workbuf, jack_nframes_t position, jack_nframes_t cnt, 
                                        uint32_t chan_n = 0,
                                        jack_nframes_t read_frames = 0,
-                                       jack_nframes_t skip_frames = 0) const = 0;
+                                       jack_nframes_t skip_frames = 0) const = 0;*/
 
        /* EDITING OPERATIONS */
 
index 5686dfc9081937c02c6a62d9bbf0db23f39fb5ac..747dae939cb4fedc335d90a86e8fa1132f3eb408 100644 (file)
@@ -38,6 +38,7 @@
 #include <ardour/io.h>
 #include <ardour/session.h>
 #include <ardour/redirect.h>
+#include <ardour/buffer.h>
 
 namespace ARDOUR {
 
@@ -66,7 +67,9 @@ class Route : public IO
        };
 
 
-       Route (Session&, std::string name, int input_min, int input_max, int output_min, int output_max, Flag flags = Flag(0));
+       Route (Session&, std::string name, int input_min, int input_max, int output_min, int output_max,
+              Flag flags = Flag(0), Buffer::Type default_type = Buffer::AUDIO);
+       
        Route (Session&, const XMLNode&);
        virtual ~Route();
 
index a193536d744d4555ad4bd466c80eac53a287335d..6284e949005ab5ebbdb6bcb7ad5f1e5962a2d065 100644 (file)
@@ -62,11 +62,13 @@ namespace ARDOUR {
 class Port;
 class AudioEngine;
 class Slave;
-class AudioDiskstream; 
+class Diskstream;
 class Route;
 class AuxInput;
 class Source;
 class AudioSource;
+
+class AudioDiskstream;
 class AudioFileSource;
 class Auditioner;
 class Insert;
@@ -79,11 +81,18 @@ class TempoMap;
 class AudioTrack;
 class NamedSelection;
 class AudioRegion;
+
 class Region;
 class Playlist;
 class VSTPlugin;
 class ControlProtocolManager;
 
+//class MidiDiskstream;
+class MidiSource;
+class MidiTrack;
+class MidiRegion;
+class SMFSource;
+
 struct AudioExportSpecification;
 struct RouteGroup;
 
@@ -264,8 +273,8 @@ class Session : public sigc::trackable, public Stateful
        vector<Sample*>& get_silent_buffers (uint32_t howmany);
        vector<Sample*>& get_send_buffers () { return _send_buffers; }
 
-       AudioDiskstream    *diskstream_by_id (id_t id);
-       AudioDiskstream    *diskstream_by_name (string name);
+       Diskstream    *diskstream_by_id (id_t id);
+       Diskstream    *diskstream_by_name (string name);
 
        bool have_captured() const { return _have_captured; }
 
@@ -352,7 +361,7 @@ class Session : public sigc::trackable, public Stateful
        sigc::signal<void> HaltOnXrun;
 
        sigc::signal<void,Route*> RouteAdded;
-       sigc::signal<void,AudioDiskstream*> AudioDiskstreamAdded;
+       sigc::signal<void,Diskstream*> DiskstreamAdded;
 
        void request_roll ();
        void request_bounded_roll (jack_nframes_t start, jack_nframes_t end);
@@ -364,15 +373,15 @@ class Session : public sigc::trackable, public Stateful
        void goto_start () { request_locate (start_location->start(), false); }
        void use_rf_shuttle_speed ();
        void request_transport_speed (float speed);
-       void request_overwrite_buffer (AudioDiskstream*);
-       void request_diskstream_speed (AudioDiskstream&, float speed);
+       void request_overwrite_buffer (Diskstream*);
+       void request_diskstream_speed (Diskstream&, float speed);
        void request_input_change_handling ();
 
        bool locate_pending() const { return static_cast<bool>(post_transport_work&PostTransportLocate); }
        bool transport_locked () const;
 
        int wipe ();
-       int wipe_diskstream (AudioDiskstream *);
+       //int wipe_diskstream (AudioDiskstream *);
 
        int remove_region_from_region_list (Region&);
 
@@ -545,10 +554,11 @@ class Session : public sigc::trackable, public Stateful
 
        /* fundamental operations. duh. */
 
-
        AudioTrack *new_audio_track (int input_channels, int output_channels, TrackMode mode = Normal);
-
        Route *new_audio_route (int input_channels, int output_channels);
+       
+       MidiTrack *new_midi_track (TrackMode mode = Normal);
+       Route *new_midi_route ();
 
        void   remove_route (Route&);
        void   resort_routes (void *src);
@@ -1429,12 +1439,12 @@ class Session : public sigc::trackable, public Stateful
        bool waiting_to_start;
 
        void set_auto_loop (bool yn);
-       void overwrite_some_buffers (AudioDiskstream*);
+       void overwrite_some_buffers (Diskstream*);
        void flush_all_redirects ();
        void locate (jack_nframes_t, bool with_roll, bool with_flush, bool with_loop=false);
        void start_locate (jack_nframes_t, bool with_roll, bool with_flush, bool with_loop=false);
        void force_locate (jack_nframes_t frame, bool with_roll = false);
-       void set_diskstream_speed (AudioDiskstream*, float speed);
+       void set_diskstream_speed (Diskstream*, float speed);
        void set_transport_speed (float speed, bool abort = false);
        void stop_transport (bool abort = false);
        void start_transport ();
@@ -1468,7 +1478,7 @@ class Session : public sigc::trackable, public Stateful
        AudioDiskstreamList  audio_diskstreams; 
        mutable Glib::RWLock diskstream_lock;
        uint32_t dstream_buffer_size;
-       void add_diskstream (AudioDiskstream*);
+       void add_diskstream (Diskstream*);
        int  load_diskstreams (const XMLNode&);
 
        /* routes stuff */
@@ -1536,7 +1546,7 @@ class Session : public sigc::trackable, public Stateful
        Playlist *XMLPlaylistFactory (const XMLNode&);
 
        void playlist_length_changed (Playlist *);
-       void diskstream_playlist_changed (AudioDiskstream *);
+       void diskstream_playlist_changed (Diskstream *);
 
        /* NAMED SELECTIONS */
 
index a0a209b569248ee87a6a40cb65b0c7e22944216d..e729bbe956cebd2b52da3100c5248cd8178c6f2b 100644 (file)
@@ -47,6 +47,8 @@ namespace ARDOUR {
        typedef uint32_t                    layer_t;
        typedef uint64_t                    id_t;
 
+       typedef unsigned char RawMidi;
+
        enum IOChange {
                NoChange = 0,
                ConfigurationChanged = 0x1,
index 043b2a1c9760d23af169493b536ec32c12a06932..277fad0ae89098a3910f9ab3b77dfc2bc78adfc9 100644 (file)
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
-jack_nframes_t AudioDiskstream::disk_io_chunk_frames;
-
-sigc::signal<void,AudioDiskstream*>    AudioDiskstream::AudioDiskstreamCreated;
+//sigc::signal<void,AudioDiskstream*>    AudioDiskstream::AudioDiskstreamCreated;
 sigc::signal<void,list<AudioFileSource*>*> AudioDiskstream::DeleteSources;
-sigc::signal<void>                AudioDiskstream::DiskOverrun;
-sigc::signal<void>                AudioDiskstream::DiskUnderrun;
+//sigc::signal<void>                AudioDiskstream::DiskOverrun;
+//sigc::signal<void>                AudioDiskstream::DiskUnderrun;
 
-AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Flag flag)
-       : _name (name),
-         _session (sess)
+AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Diskstream::Flag flag)
+       : Diskstream(sess, name, flag)
+       , _playlist(NULL)
 {
        /* prevent any write sources from being created */
 
@@ -74,12 +73,12 @@ AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Flag flag)
 
        in_set_state = false;
 
-       AudioDiskstreamCreated (this); /* EMIT SIGNAL */
+       DiskstreamCreated (this); /* EMIT SIGNAL */
 }
        
 AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node)
-       : _session (sess)
-       
+       : Diskstream(sess, node)
+       , _playlist(NULL)
 {
        in_set_state = true;
        init (Recordable);
@@ -95,7 +94,7 @@ AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node)
                use_destructive_playlist ();
        }
 
-       AudioDiskstreamCreated (this); /* EMIT SIGNAL */
+       DiskstreamCreated (this); /* EMIT SIGNAL */
 }
 
 void
@@ -128,44 +127,9 @@ AudioDiskstream::init_channel (ChannelInfo &chan)
 
 
 void
-AudioDiskstream::init (Flag f)
+AudioDiskstream::init (Diskstream::Flag f)
 {
-       _id = new_id();
-       _refcnt = 0;
-       _flags = f;
-       _io = 0;
-       _alignment_style = ExistingMaterial;
-       _persistent_alignment_style = ExistingMaterial;
-       first_input_change = true;
-       _playlist = 0;
-       i_am_the_modifier = 0;
-       g_atomic_int_set (&_record_enabled, 0);
-       was_recording = false;
-       capture_start_frame = 0;
-       capture_captured = 0;
-       _visible_speed = 1.0f;
-       _actual_speed = 1.0f;
-       _buffer_reallocation_required = false;
-       _seek_required = false;
-       first_recordable_frame = max_frames;
-       last_recordable_frame = max_frames;
-       _roll_delay = 0;
-       _capture_offset = 0;
-       _processed = false;
-       _slaved = false;
-       adjust_capture_position = 0;
-       last_possibly_recording = 0;
-       loop_location = 0;
-       wrap_buffer_size = 0;
-       speed_buffer_size = 0;
-       last_phase = 0;
-       phi = (uint64_t) (0x1000000);
-       file_frame = 0;
-       playback_sample = 0;
-       playback_distance = 0;
-       _read_data_count = 0;
-       _write_data_count = 0;
-       deprecated_io_node = 0;
+       Diskstream::init(f);
 
        /* there are no channels at this point, so these
           two calls just get speed_buffer_size and wrap_buffer
@@ -215,9 +179,8 @@ AudioDiskstream::~AudioDiskstream ()
 {
        Glib::Mutex::Lock lm (state_lock);
 
-       if (_playlist) {
+       if (_playlist)
                _playlist->unref ();
-       }
 
        for (ChannelList::iterator chan = channels.begin(); chan != channels.end(); ++chan) {
                destroy_channel((*chan));
@@ -225,7 +188,7 @@ AudioDiskstream::~AudioDiskstream ()
        
        channels.clear();
 }
-
+/*
 void
 AudioDiskstream::handle_input_change (IOChange change, void *src)
 {
@@ -236,7 +199,7 @@ AudioDiskstream::handle_input_change (IOChange change, void *src)
                _session.request_input_change_handling ();
        }
 }
-
+*/
 void
 AudioDiskstream::non_realtime_input_change ()
 {
@@ -346,8 +309,10 @@ AudioDiskstream::find_and_use_playlist (const string& name)
 }
 
 int
-AudioDiskstream::use_playlist (AudioPlaylist* playlist)
+AudioDiskstream::use_playlist (Playlist* playlist)
 {
+       assert(dynamic_cast<AudioPlaylist*>(playlist));
+
        {
                Glib::Mutex::Lock lm (state_lock);
 
@@ -363,7 +328,7 @@ AudioDiskstream::use_playlist (AudioPlaylist* playlist)
                        _playlist->unref();
                }
                        
-               _playlist = playlist;
+               _playlist = dynamic_cast<AudioPlaylist*>(playlist);
                _playlist->ref();
 
                if (!in_set_state && recordable()) {
@@ -386,17 +351,6 @@ AudioDiskstream::use_playlist (AudioPlaylist* playlist)
        return 0;
 }
 
-void
-AudioDiskstream::playlist_deleted (Playlist* pl)
-{
-       /* this catches an ordering issue with session destruction. playlists 
-          are destroyed before diskstreams. we have to invalidate any handles
-          we have to the playlist.
-       */
-
-       _playlist = 0;
-}
-
 int
 AudioDiskstream::use_new_playlist ()
 {
@@ -446,6 +400,19 @@ AudioDiskstream::use_copy_playlist ()
        }
 }
 
+
+void
+AudioDiskstream::playlist_deleted (Playlist* pl)
+{
+       /* this catches an ordering issue with session destruction. playlists 
+          are destroyed before diskstreams. we have to invalidate any handles
+          we have to the playlist.
+       */
+
+       _playlist = 0;
+}
+
+
 void
 AudioDiskstream::setup_destructive_playlist ()
 {
@@ -499,67 +466,6 @@ AudioDiskstream::set_io (IO& io)
        set_align_style_from_io ();
 }
 
-int
-AudioDiskstream::set_name (string str, void *src)
-{
-       if (str != _name) {
-               _playlist->set_name (str);
-               _name = str;
-               
-               if (!in_set_state && recordable()) {
-                       /* rename existing capture files so that they have the correct name */
-                       return rename_write_sources ();
-               } else {
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-void
-AudioDiskstream::set_speed (double sp)
-{
-       _session.request_diskstream_speed (*this, sp);
-
-       /* to force a rebuffering at the right place */
-       playlist_modified();
-}
-
-bool
-AudioDiskstream::realtime_set_speed (double sp, bool global)
-{
-       bool changed = false;
-       double new_speed = sp * _session.transport_speed();
-       
-       if (_visible_speed != sp) {
-               _visible_speed = sp;
-               changed = true;
-       }
-       
-       if (new_speed != _actual_speed) {
-               
-               jack_nframes_t required_wrap_size = (jack_nframes_t) floor (_session.get_block_size() * 
-                                                                           fabs (new_speed)) + 1;
-               
-               if (required_wrap_size > wrap_buffer_size) {
-                       _buffer_reallocation_required = true;
-               }
-               
-               _actual_speed = new_speed;
-               phi = (uint64_t) (0x1000000 * fabs(_actual_speed));
-       }
-
-       if (changed) {
-               if (!global) {
-                       _seek_required = true;
-               }
-                speed_changed (); /* EMIT SIGNAL */
-       }
-
-       return _buffer_reallocation_required || _seek_required;
-}
-
 void
 AudioDiskstream::non_realtime_set_speed ()
 {
@@ -583,13 +489,6 @@ AudioDiskstream::non_realtime_set_speed ()
        }
 }
 
-void
-AudioDiskstream::prepare ()
-{
-       _processed = false;
-       playback_distance = 0;
-}
-
 void
 AudioDiskstream::check_record_status (jack_nframes_t transport_frame, jack_nframes_t nframes, bool can_record)
 {
@@ -1009,13 +908,6 @@ AudioDiskstream::process (jack_nframes_t transport_frame, jack_nframes_t nframes
        return ret;
 }
 
-void
-AudioDiskstream::recover ()
-{
-       state_lock.unlock();
-       _processed = false;
-}
-
 bool
 AudioDiskstream::commit (jack_nframes_t nframes)
 {
@@ -1155,9 +1047,9 @@ AudioDiskstream::seek (jack_nframes_t frame, bool complete_refill)
        file_frame = frame;
 
        if (complete_refill) {
-               while ((ret = do_refill (0, 0, 0)) > 0);
+               while ((ret = non_realtime_do_refill ()) > 0);
        } else {
-               ret = do_refill (0, 0, 0);
+               ret = non_realtime_do_refill ();
        }
 
        return ret;
@@ -1649,21 +1541,6 @@ AudioDiskstream::do_flush (char * workbuf, bool force_flush)
        return ret;
 }
 
-void
-AudioDiskstream::playlist_changed (Change ignored)
-{
-       playlist_modified ();
-}
-
-void
-AudioDiskstream::playlist_modified ()
-{
-       if (!i_am_the_modifier && !overwrite_queued) {
-               _session.request_overwrite_buffer (this);
-               overwrite_queued = true;
-       } 
-}
-
 void
 AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_capture)
 {
@@ -1898,7 +1775,7 @@ AudioDiskstream::finish_capture (bool rec_monitors_input)
 void
 AudioDiskstream::set_record_enabled (bool yn, void* src)
 {
-        bool rolling = _session.transport_speed() != 0.0f;
+    bool rolling = _session.transport_speed() != 0.0f;
 
        if (!recordable() || !_session.record_enabling_legal()) {
                return;
@@ -1958,7 +1835,7 @@ XMLNode&
 AudioDiskstream::get_state ()
 {
        XMLNode* node = new XMLNode ("AudioDiskstream");
-       char buf[64];
+       char buf[64] = "";
        LocaleGuard lg (X_("POSIX"));
 
        snprintf (buf, sizeof(buf), "0x%x", _flags);
@@ -2288,23 +2165,6 @@ AudioDiskstream::monitor_input (bool yn)
        }
 }
 
-void
-AudioDiskstream::set_capture_offset ()
-{
-       if (_io == 0) {
-               /* can't capture, so forget it */
-               return;
-       }
-
-       _capture_offset = _io->input_latency();
-}
-
-void
-AudioDiskstream::set_persistent_align_style (AlignStyle a)
-{
-       _persistent_alignment_style = a;
-}
-
 void
 AudioDiskstream::set_align_style_from_io ()
 {
@@ -2330,20 +2190,6 @@ AudioDiskstream::set_align_style_from_io ()
        }
 }
 
-void
-AudioDiskstream::set_align_style (AlignStyle a)
-{
-       if (record_enabled() && _session.actively_recording()) {
-               return;
-       }
-
-
-       if (a != _alignment_style) {
-               _alignment_style = a;
-               AlignmentStyleChanged ();
-       }
-}
-
 int
 AudioDiskstream::add_channel ()
 {
@@ -2394,57 +2240,6 @@ AudioDiskstream::capture_buffer_load () const
                        (double) channels.front().capture_buf->bufsize());
 }
 
-int
-AudioDiskstream::set_loop (Location *location)
-{
-       if (location) {
-               if (location->start() >= location->end()) {
-                       error << string_compose(_("Location \"%1\" not valid for track loop (start >= end)"), location->name()) << endl;
-                       return -1;
-               }
-       }
-
-       loop_location = location;
-
-        LoopSet (location); /* EMIT SIGNAL */
-       return 0;
-}
-
-jack_nframes_t
-AudioDiskstream::get_capture_start_frame (uint32_t n)
-{
-       Glib::Mutex::Lock lm (capture_info_lock);
-
-       if (capture_info.size() > n) {
-               return capture_info[n]->start;
-       }
-       else {
-               return capture_start_frame;
-       }
-}
-
-jack_nframes_t
-AudioDiskstream::get_captured_frames (uint32_t n)
-{
-       Glib::Mutex::Lock lm (capture_info_lock);
-
-       if (capture_info.size() > n) {
-               return capture_info[n]->frames;
-       }
-       else {
-               return capture_captured;
-       }
-}
-
-void
-AudioDiskstream::punch_in ()
-{
-}
-
-void
-AudioDiskstream::punch_out ()
-{
-}
 
 int
 AudioDiskstream::use_pending_capture_data (XMLNode& node)
@@ -2541,22 +2336,3 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
 
        return 0;
 }
-
-void
-AudioDiskstream::set_roll_delay (jack_nframes_t nframes)
-{
-       _roll_delay = nframes;
-}
-
-void
-AudioDiskstream::set_destructive (bool yn)
-{
-       if (yn != destructive()) {
-               reset_write_sources (true, true);
-               if (yn) {
-                       _flags |= Destructive;
-               } else {
-                       _flags &= ~Destructive;
-               }
-       }
-}
index bf462f7128a2cbe496317f2e4bb9e367ea8756f5..7f421e86c817dc4074aa19cdbfed9e29bc98a55d 100644 (file)
@@ -42,6 +42,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 static char* SOUNDFILE = "http://ardour.org/ontology/Soundfile";
 
index 9f3c02ce436a2c3043e0a393f7ff9afda19b57cf..be5c9ab5d95c563002bf818bb2802e0c33fa0214 100644 (file)
@@ -37,6 +37,7 @@
 using namespace ARDOUR;
 using namespace sigc;
 using namespace std;
+using namespace PBD;
 
 AudioPlaylist::State::~State ()
 {
@@ -242,16 +243,18 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, ch
 
        for (vector<uint32_t>::iterator l = relevant_layers.begin(); l != relevant_layers.end(); ++l) {
 
+               // FIXME: Should be vector<AudioRegion*>
                vector<Region*>& r (relevant_regions[*l]);
                vector<Crossfade*>& x (relevant_xfades[*l]);
 
                for (vector<Region*>::iterator i = r.begin(); i != r.end(); ++i) {
-                       (*i)->read_at (buf, mixdown_buffer, gain_buffer, workbuf, start, cnt, chan_n, read_frames, skip_frames);
-                       _read_data_count += (*i)->read_data_count();
+                       AudioRegion* const ar = dynamic_cast<AudioRegion*>(*i);
+                       assert(ar);
+                       ar->read_at (buf, mixdown_buffer, gain_buffer, workbuf, start, cnt, chan_n, read_frames, skip_frames);
+                       _read_data_count += ar->read_data_count();
                }
                
                for (vector<Crossfade*>::iterator i = x.begin(); i != x.end(); ++i) {
-                       
                        (*i)->read_at (buf, mixdown_buffer, gain_buffer, workbuf, start, cnt, chan_n);
 
                        /* don't JACK up _read_data_count, since its the same data as we just
index d146b92a4ba4c5e042ad49224424e9578f3444ff..0f22ebbe44b8d51016928d5d367175ce8d940fb3 100644 (file)
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode mode)
        : Route (sess, name, 1, -1, -1, -1, flag),
-         diskstream (0),
+         _diskstream (0),
          _midi_rec_enable_control (*this, _session.midi_port())
 {
        AudioDiskstream::Flag dflags = AudioDiskstream::Flag (0);
@@ -74,7 +75,7 @@ AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode
 
 AudioTrack::AudioTrack (Session& sess, const XMLNode& node)
        : Route (sess, "to be renamed", 0, 0, -1, -1),
-         diskstream (0),
+         _diskstream (0),
          _midi_rec_enable_control (*this, _session.midi_port())
 {
        _freeze_record.state = NoFreeze;
@@ -88,8 +89,8 @@ AudioTrack::AudioTrack (Session& sess, const XMLNode& node)
 
 AudioTrack::~AudioTrack ()
 {
-       if (diskstream) {
-               diskstream->unref();
+       if (_diskstream) {
+               _diskstream->unref();
        }
 }
 
@@ -104,16 +105,16 @@ AudioTrack::handle_smpte_offset_change ()
 int
 AudioTrack::deprecated_use_diskstream_connections ()
 {
-       if (diskstream->deprecated_io_node == 0) {
+       if (_diskstream->deprecated_io_node == 0) {
                return 0;
        }
 
        const XMLProperty* prop;
-       XMLNode& node (*diskstream->deprecated_io_node);
+       XMLNode& node (*_diskstream->deprecated_io_node);
 
        /* don't do this more than once. */
 
-       diskstream->deprecated_io_node = 0;
+       _diskstream->deprecated_io_node = 0;
 
        set_input_minimum (-1);
        set_input_maximum (-1);
@@ -156,15 +157,15 @@ AudioTrack::deprecated_use_diskstream_connections ()
 int
 AudioTrack::set_diskstream (AudioDiskstream& ds, void *src)
 {
-       if (diskstream) {
-               diskstream->unref();
+       if (_diskstream) {
+               _diskstream->unref();
        }
 
-       diskstream = &ds.ref();
-       diskstream->set_io (*this);
-       diskstream->set_destructive (_mode == Destructive);
+       _diskstream = &ds.ref();
+       _diskstream->set_io (*this);
+       _diskstream->set_destructive (_mode == Destructive);
 
-       if (diskstream->deprecated_io_node) {
+       if (_diskstream->deprecated_io_node) {
 
                if (!connecting_legal) {
                        ConnectingLegal.connect (mem_fun (*this, &AudioTrack::deprecated_use_diskstream_connections));
@@ -173,11 +174,11 @@ AudioTrack::set_diskstream (AudioDiskstream& ds, void *src)
                }
        }
 
-       diskstream->set_record_enabled (false, this);
-       diskstream->monitor_input (false);
+       _diskstream->set_record_enabled (false, this);
+       _diskstream->monitor_input (false);
 
        ic_connection.disconnect();
-       ic_connection = input_changed.connect (mem_fun (*diskstream, &AudioDiskstream::handle_input_change));
+       ic_connection = input_changed.connect (mem_fun (*_diskstream, &AudioDiskstream::handle_input_change));
 
        diskstream_changed (src); /* EMIT SIGNAL */
 
@@ -189,8 +190,8 @@ AudioTrack::use_diskstream (string name)
 {
        AudioDiskstream *dstream;
 
-       if ((dstream = _session.diskstream_by_name (name)) == 0) {
-         error << string_compose(_("AudioTrack: diskstream \"%1\" not known by session"), name) << endmsg;
+       if ((dstream = dynamic_cast<AudioDiskstream*>(_session.diskstream_by_name (name))) == 0) {
+         error << string_compose(_("AudioTrack: audio diskstream \"%1\" not known by session"), name) << endmsg;
                return -1;
        }
        
@@ -202,8 +203,8 @@ AudioTrack::use_diskstream (id_t id)
 {
        AudioDiskstream *dstream;
 
-       if ((dstream = _session.diskstream_by_id (id)) == 0) {
-               error << string_compose(_("AudioTrack: diskstream \"%1\" not known by session"), id) << endmsg;
+       if ((dstream = dynamic_cast<AudioDiskstream*>(_session.diskstream_by_id (id))) == 0) {
+               error << string_compose(_("AudioTrack: audio diskstream \"%1\" not known by session"), id) << endmsg;
                return -1;
        }
        
@@ -213,7 +214,7 @@ AudioTrack::use_diskstream (id_t id)
 bool
 AudioTrack::record_enabled () const
 {
-       return diskstream->record_enabled ();
+       return _diskstream->record_enabled ();
 }
 
 void
@@ -230,13 +231,13 @@ AudioTrack::set_record_enable (bool yn, void *src)
 
        /* keep track of the meter point as it was before we rec-enabled */
 
-       if (!diskstream->record_enabled()) {
+       if (!_diskstream->record_enabled()) {
                _saved_meter_point = _meter_point;
        }
        
-       diskstream->set_record_enabled (yn, src);
+       _diskstream->set_record_enabled (yn, src);
 
-       if (diskstream->record_enabled()) {
+       if (_diskstream->record_enabled()) {
                set_meter_point (MeterInput, this);
        } else {
                set_meter_point (_saved_meter_point, this);
@@ -398,7 +399,7 @@ AudioTrack::state(bool full_state)
        /* Alignment: act as a proxy for the diskstream */
        
        XMLNode* align_node = new XMLNode (X_("alignment"));
-       switch (diskstream->alignment_style()) {
+       switch (_diskstream->alignment_style()) {
        case ExistingMaterial:
                snprintf (buf, sizeof (buf), X_("existing"));
                break;
@@ -452,7 +453,7 @@ AudioTrack::state(bool full_state)
           diskstream.
        */
 
-       snprintf (buf, sizeof (buf), "%" PRIu64, diskstream->id());
+       snprintf (buf, sizeof (buf), "%" PRIu64, _diskstream->id());
        root.add_property ("diskstream-id", buf);
 
        return root;
@@ -524,9 +525,9 @@ AudioTrack::set_state_part_two ()
 
                if ((prop = fnode->property (X_("style"))) != 0) {
                        if (prop->value() == "existing") {
-                               diskstream->set_persistent_align_style (ExistingMaterial);
+                               _diskstream->set_persistent_align_style (ExistingMaterial);
                        } else if (prop->value() == "capture") {
-                               diskstream->set_persistent_align_style (CaptureTime);
+                               _diskstream->set_persistent_align_style (CaptureTime);
                        }
                }
        }
@@ -536,7 +537,7 @@ AudioTrack::set_state_part_two ()
 uint32_t
 AudioTrack::n_process_buffers ()
 {
-       return max ((uint32_t) diskstream->n_channels(), redirect_max_outs);
+       return max ((uint32_t) _diskstream->n_channels(), redirect_max_outs);
 }
 
 void
@@ -567,7 +568,7 @@ AudioTrack::no_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nf
                return 0;
        }
 
-       diskstream->check_record_status (start_frame, nframes, can_record);
+       _diskstream->check_record_status (start_frame, nframes, can_record);
 
        bool send_silence;
        
@@ -586,7 +587,7 @@ AudioTrack::no_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nf
                                send_silence = true;
                        }
                } else {
-                       if (diskstream->record_enabled()) {
+                       if (_diskstream->record_enabled()) {
                                if (Config->get_use_sw_monitoring()) {
                                        send_silence = false;
                                } else {
@@ -660,13 +661,13 @@ AudioTrack::roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nfram
                   playback distance to zero, thus causing diskstream::commit
                   to do nothing.
                */
-               return diskstream->process (transport_frame, 0, 0, can_record, rec_monitors_input);
+               return _diskstream->process (transport_frame, 0, 0, can_record, rec_monitors_input);
        } 
 
        _silent = false;
        apply_gain_automation = false;
 
-       if ((dret = diskstream->process (transport_frame, nframes, offset, can_record, rec_monitors_input)) != 0) {
+       if ((dret = _diskstream->process (transport_frame, nframes, offset, can_record, rec_monitors_input)) != 0) {
                
                silence (nframes, offset);
 
@@ -679,7 +680,7 @@ AudioTrack::roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nfram
                just_meter_input (start_frame, end_frame, nframes, offset);
        }
 
-       if (diskstream->record_enabled() && !can_record && !_session.get_auto_input()) {
+       if (_diskstream->record_enabled() && !can_record && !_session.get_auto_input()) {
 
                /* not actually recording, but we want to hear the input material anyway,
                   at least potentially (depending on monitoring options)
@@ -687,7 +688,7 @@ AudioTrack::roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nfram
 
                passthru (start_frame, end_frame, nframes, offset, 0, true);
 
-       } else if ((b = diskstream->playback_buffer(0)) != 0) {
+       } else if ((b = _diskstream->playback_buffer(0)) != 0) {
 
                /*
                  XXX is it true that the earlier test on n_outputs()
@@ -709,8 +710,8 @@ AudioTrack::roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nfram
 
                for (i = 0, n = 1; i < limit; ++i, ++n) {
                        memcpy (bufs[i], b, sizeof (Sample) * nframes); 
-                       if (n < diskstream->n_channels()) {
-                               tmpb = diskstream->playback_buffer(n);
+                       if (n < _diskstream->n_channels()) {
+                               tmpb = _diskstream->playback_buffer(n);
                                if (tmpb!=0) {
                                        b = tmpb;
                                }
@@ -719,7 +720,7 @@ AudioTrack::roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nfram
 
                /* don't waste time with automation if we're recording or we've just stopped (yes it can happen) */
 
-               if (!diskstream->record_enabled() && _session.transport_rolling()) {
+               if (!_diskstream->record_enabled() && _session.transport_rolling()) {
                        Glib::Mutex::Lock am (automation_lock, Glib::TRY_LOCK);
                        
                        if (am.locked() && gain_automation_playback()) {
@@ -755,7 +756,7 @@ AudioTrack::silent_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jac
 
        silence (nframes, offset);
 
-       return diskstream->process (_session.transport_frame() + offset, nframes, offset, can_record, rec_monitors_input);
+       return _diskstream->process (_session.transport_frame() + offset, nframes, offset, can_record, rec_monitors_input);
 }
 
 void
@@ -776,7 +777,7 @@ AudioTrack::set_name (string str, void *src)
                return -1;
        }
 
-       if (diskstream->set_name (str, src)) {
+       if (_diskstream->set_name (str, src)) {
                return -1;
        }
 
@@ -801,8 +802,12 @@ AudioTrack::export_stuff (vector<Sample*>& buffers, char * workbuf, uint32_t nbu
        Sample * b;
        
        Glib::RWLock::ReaderLock rlock (redirect_lock);
-               
-       if (diskstream->playlist()->read (buffers[0], mix_buffer, gain_buffer, workbuf, start, nframes) != nframes) {
+
+       // FIXME
+       AudioPlaylist* const apl = dynamic_cast<AudioPlaylist*>(_diskstream->playlist());
+       assert(apl);
+
+       if (apl->read (buffers[0], mix_buffer, gain_buffer, workbuf, start, nframes) != nframes) {
                return -1;
        }
 
@@ -811,8 +816,8 @@ AudioTrack::export_stuff (vector<Sample*>& buffers, char * workbuf, uint32_t nbu
        b = buffers[0];
        ++bi;
        for (; bi != buffers.end(); ++bi, ++n) {
-               if (n < diskstream->n_channels()) {
-                       if (diskstream->playlist()->read ((*bi), mix_buffer, gain_buffer, workbuf, start, nframes, n) != nframes) {
+               if (n < _diskstream->n_channels()) {
+                       if (apl->read ((*bi), mix_buffer, gain_buffer, workbuf, start, nframes, n) != nframes) {
                                return -1;
                        }
                        b = (*bi);
@@ -888,7 +893,7 @@ void
 AudioTrack::set_latency_delay (jack_nframes_t longest_session_latency)
 {
        Route::set_latency_delay (longest_session_latency);
-       diskstream->set_roll_delay (_roll_delay);
+       _diskstream->set_roll_delay (_roll_delay);
 }
 
 jack_nframes_t
@@ -933,7 +938,7 @@ AudioTrack::freeze (InterThreadInfo& itt)
        AudioRegion* region;
        string region_name;
        
-       if ((_freeze_record.playlist = diskstream->playlist()) == 0) {
+       if ((_freeze_record.playlist = dynamic_cast<AudioPlaylist*>(_diskstream->playlist())) == 0) {
                return;
        }
 
@@ -1000,13 +1005,13 @@ AudioTrack::freeze (InterThreadInfo& itt)
                                  (AudioRegion::Flag) (AudioRegion::WholeFile|AudioRegion::DefaultFlags),
                                  false);
 
-       new_playlist->set_orig_diskstream_id (diskstream->id());
+       new_playlist->set_orig_diskstream_id (_diskstream->id());
        new_playlist->add_region (*region, 0);
        new_playlist->set_frozen (true);
        region->set_locked (true);
 
-       diskstream->use_playlist (dynamic_cast<AudioPlaylist*>(new_playlist));
-       diskstream->set_record_enabled (false, this);
+       _diskstream->use_playlist (dynamic_cast<AudioPlaylist*>(new_playlist));
+       _diskstream->set_record_enabled (false, this);
 
        _freeze_record.state = Frozen;
        FreezeChange(); /* EMIT SIGNAL */
@@ -1016,7 +1021,7 @@ void
 AudioTrack::unfreeze ()
 {
        if (_freeze_record.playlist) {
-               diskstream->use_playlist (_freeze_record.playlist);
+               _diskstream->use_playlist (_freeze_record.playlist);
 
                if (_freeze_record.have_mementos) {
 
@@ -1149,10 +1154,10 @@ AudioTrack::MIDIRecEnableControl::write_feedback (MIDI::byte* buf, int32_t& bufs
 void
 AudioTrack::set_mode (TrackMode m)
 {
-       if (diskstream) {
+       if (_diskstream) {
                if (_mode != m) {
                        _mode = m;
-                       diskstream->set_destructive (m == Destructive);
+                       _diskstream->set_destructive (m == Destructive);
                        ModeChanged();
                }
        }
index c4f90efd4945955e65f30bef09bf279b45a20e1d..72708b46f89868d5907a1275aed30f1589d91bbc 100644 (file)
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
-jack_nframes_t Port::short_over_length = 2;
-jack_nframes_t Port::long_over_length = 10;
+// Why here? [DR]
+jack_nframes_t Port::_short_over_length = 2;
+jack_nframes_t Port::_long_over_length = 10;
 
 AudioEngine::AudioEngine (string client_name) 
 {
@@ -91,12 +93,6 @@ _thread_init_callback (void *arg)
        */
 
        PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("Audioengine"), 4096);
-
-#ifdef VST_SUPPORT
-       if (Config->get_use_vst()) {
-               fst_adopt_thread ();
-       }
-#endif
 }
 
 int
@@ -279,8 +275,8 @@ AudioEngine::process_callback (jack_nframes_t nframes)
                        Port *port = (*i);
                        bool x;
                        
-                       if (port->last_monitor != (x = port->monitoring_input ())) {
-                               port->last_monitor = x;
+                       if (port->_last_monitor != (x = port->monitoring_input ())) {
+                               port->_last_monitor = x;
                                /* XXX I think this is dangerous, due to 
                                   a likely mutex in the signal handlers ...
                                */
@@ -393,18 +389,19 @@ AudioEngine::remove_session ()
 }
 
 Port *
-AudioEngine::register_audio_input_port (const string& portname)
+AudioEngine::register_input_port (Buffer::Type type, const string& portname)
 {
        if (!_running) {
                if (!_has_run) {
-                       fatal << _("register audio input port called before engine was started") << endmsg;
+                       fatal << _("register input port called before engine was started") << endmsg;
                        /*NOTREACHED*/
                } else {
                        return 0;
                }
        }
 
-       jack_port_t *p = jack_port_register (_jack, portname.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
+       jack_port_t *p = jack_port_register (_jack, portname.c_str(),
+               Buffer::type_to_jack_type(type), JackPortIsInput, 0);
 
        if (p) {
 
@@ -424,11 +421,11 @@ AudioEngine::register_audio_input_port (const string& portname)
 }
 
 Port *
-AudioEngine::register_audio_output_port (const string& portname)
+AudioEngine::register_output_port (Buffer::Type type, const string& portname)
 {
        if (!_running) {
                if (!_has_run) {
-                       fatal << _("register audio output port called before engine was started") << endmsg;
+                       fatal << _("register output port called before engine was started") << endmsg;
                        /*NOTREACHED*/
                } else {
                        return 0;
@@ -437,7 +434,8 @@ AudioEngine::register_audio_output_port (const string& portname)
 
        jack_port_t *p;
 
-       if ((p = jack_port_register (_jack, portname.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)) != 0) {
+       if ((p = jack_port_register (_jack, portname.c_str(),
+               Buffer::type_to_jack_type(type), JackPortIsOutput, 0)) != 0) {
                Port *newport = new Port (p);
                ports.insert (ports.begin(), newport);
                return newport;
@@ -451,6 +449,7 @@ AudioEngine::register_audio_output_port (const string& portname)
        return 0;
 }
 
+
 int          
 AudioEngine::unregister_port (Port *port)
 {
@@ -463,7 +462,7 @@ AudioEngine::unregister_port (Port *port)
 
        if (port) {
 
-               int ret = jack_port_unregister (_jack, port->port);
+               int ret = jack_port_unregister (_jack, port->_port);
                
                if (ret == 0) {
 
@@ -554,7 +553,7 @@ AudioEngine::disconnect (Port *port)
                }
        }
 
-       int ret = jack_port_disconnect (_jack, port->port);
+       int ret = jack_port_disconnect (_jack, port->_port);
 
        if (ret == 0) {
                remove_connections_for (port);
@@ -704,7 +703,6 @@ AudioEngine::n_physical_inputs () const
 }
 
 string
-
 AudioEngine::get_nth_physical (uint32_t n, int flag)
 {
        const char ** ports;
@@ -752,7 +750,7 @@ AudioEngine::get_port_total_latency (const Port& port)
                } 
        }
 
-       return jack_port_get_total_latency (_jack, port.port);
+       return jack_port_get_total_latency (_jack, port._port);
 }
 
 void
@@ -830,7 +828,7 @@ AudioEngine::remove_all_ports ()
 
        if (_jack) {
                for (Ports::iterator i = ports.begin(); i != ports.end(); ++i) {
-                       jack_port_unregister (_jack, (*i)->port);
+                       jack_port_unregister (_jack, (*i)->_port);
                }
        }
 
@@ -953,7 +951,7 @@ AudioEngine::reconnect_to_jack ()
                
                short_name = long_name.substr (long_name.find_last_of (':') + 1);
 
-               if (((*i)->port = jack_port_register (_jack, short_name.c_str(), (*i)->type(), (*i)->flags(), 0)) == 0) {
+               if (((*i)->_port = jack_port_register (_jack, short_name.c_str(), (*i)->type(), (*i)->flags(), 0)) == 0) {
                        error << string_compose (_("could not reregister %1"), (*i)->name()) << endmsg;
                        break;
                } else {
@@ -968,7 +966,7 @@ AudioEngine::reconnect_to_jack ()
 
        if (i != ports.end()) {
                for (Ports::iterator i = ports.begin(); i != ports.end(); ++i) {
-                       jack_port_unregister (_jack, (*i)->port);
+                       jack_port_unregister (_jack, (*i)->_port);
                }
                return -1;
        } 
index fbddcdafdfaf959b382ee503e054459bd2639a9e..1e13a29acc063ab2d6339c80247ba07cfabc2a04 100644 (file)
@@ -50,6 +50,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 string AudioFileSource::peak_dir = "";
 string AudioFileSource::search_path;
index 843a3a7d3409d379e229796b31c689a9e31fd57f..a26d9674bd06f1395fa09820ca304d4f2d32fbe0 100644 (file)
@@ -30,6 +30,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 int
 AudioFilter::make_new_sources (AudioRegion& region, AudioRegion::SourceList& nsrcs)
index 2f0b943c0e68e95827a4476b64c35946d02205d4..262663970dbeb1f1af5fab37ac4f0d7f4c8aed5d 100644 (file)
@@ -44,12 +44,12 @@ Auditioner::Auditioner (Session& s)
        defer_pan_reset ();
 
        if (left.length()) {
-               add_output_port (left, this);
+               add_output_port (left, this, Buffer::AUDIO);
        }
 
        if (right.length()) {
                disk_stream().add_channel();
-               add_output_port (right, this);
+               add_output_port (right, this, Buffer::AUDIO);
        }
 
        allow_pan_reset ();
@@ -67,8 +67,12 @@ Auditioner::~Auditioner ()
 AudioPlaylist&
 Auditioner::prepare_playlist ()
 {
-       diskstream->playlist()->clear (false, false);
-       return *diskstream->playlist();
+       // FIXME
+       AudioPlaylist* const apl = dynamic_cast<AudioPlaylist*>(_diskstream->playlist());
+       assert(apl);
+
+       apl->clear (false, false);
+       return *apl;
 }
 
 void
@@ -82,13 +86,13 @@ Auditioner::audition_current_playlist ()
        }
 
        Glib::Mutex::Lock lm (lock);
-       diskstream->seek (0);
-       length = diskstream->playlist()->get_maximum_extent();
+       _diskstream->seek (0);
+       length = _diskstream->playlist()->get_maximum_extent();
        current_frame = 0;
 
        /* force a panner reset now that we have all channels */
 
-       _panner->reset (n_outputs(), diskstream->n_channels());
+       _panner->reset (n_outputs(), _diskstream->n_channels());
 
        g_atomic_int_set (&_active, 1);
 }
@@ -108,23 +112,23 @@ Auditioner::audition_region (AudioRegion& region)
        the_region = new AudioRegion (region);
        the_region->set_position (0, this);
 
-       diskstream->playlist()->clear (true, false);
-       diskstream->playlist()->add_region (*the_region, 0, 1, false);
+       _diskstream->playlist()->clear (true, false);
+       _diskstream->playlist()->add_region (*the_region, 0, 1, false);
 
-       while (diskstream->n_channels() < the_region->n_channels()) {
-               diskstream->add_channel ();
+       while (_diskstream->n_channels() < the_region->n_channels()) {
+               _diskstream->add_channel ();
        }
 
-       while (diskstream->n_channels() > the_region->n_channels()) {
-               diskstream->remove_channel ();
+       while (_diskstream->n_channels() > the_region->n_channels()) {
+               _diskstream->remove_channel ();
        }
 
        /* force a panner reset now that we have all channels */
 
-       _panner->reset (n_outputs(), diskstream->n_channels());
+       _panner->reset (n_outputs(), _diskstream->n_channels());
 
        length = the_region->length();
-       diskstream->seek (0);
+       _diskstream->seek (0);
        current_frame = 0;
        g_atomic_int_set (&_active, 1);
 }
@@ -143,14 +147,14 @@ Auditioner::play_audition (jack_nframes_t nframes)
 
        this_nframes = min (nframes, length - current_frame);
 
-       diskstream->prepare ();
+       _diskstream->prepare ();
 
        if ((ret = roll (this_nframes, current_frame, current_frame + nframes, 0, false, false, false)) != 0) {
                silence (nframes, 0);
                return ret;
        }
 
-       need_butler = diskstream->commit (this_nframes);
+       need_butler = _diskstream->commit (this_nframes);
        current_frame += this_nframes;
 
        if (current_frame >= length) {
index 17888c4a7c02d7d6c42c33e514a94ab935a49358..3df7dd94f7ae0aa44104c3f9e00599774dcbce29 100644 (file)
@@ -31,6 +31,7 @@
 using namespace std;
 using namespace ARDOUR;
 using namespace sigc;
+using namespace PBD;
 
 #if 0
 static void dumpit (const AutomationList& al, string prefix = "")
index e73208b872ec8b6ca36cbc59737014eae1190e3f..fc708f805de832b5b67d81f3c38af8b1d0722759 100644 (file)
@@ -34,6 +34,7 @@
 
 using namespace ARDOUR;
 using namespace std;
+using namespace PBD;
 
 /* this is global so that we do not have to indirect through an object pointer
    to reference it.
index 719751f7baeeb84df80b1ee399755aad3f63d217..fbfd02d50904cf6b4775c814309babca8233553f 100644 (file)
@@ -28,6 +28,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 Connection::Connection (const XMLNode& node)
 {
index 16437cf8ce225c6b7b55a4891f7877fa2cb2760f..c2fb18895322398a462e6e874dc812c46a1602cc 100644 (file)
@@ -9,11 +9,9 @@
 #include <ardour/session.h>
 #include <ardour/control_protocol_manager.h>
 
-
-
-
 using namespace ARDOUR;
 using namespace std;
+using namespace PBD;
 
 #include "i18n.h"
 
index 76744626535a625eb683158dc301cda528c21111..1b0ee565e757a617c91d4e55a55e05345b86c869 100644 (file)
@@ -26,6 +26,7 @@
 #include <AudioToolbox/AudioFormat.h>
 
 using namespace ARDOUR;
+using namespace PBD;
 
 CoreAudioSource::CoreAudioSource (const XMLNode& node)
        : AudioFileSource (node)
index 767fdd85e644cf50fcd6310c2d703f3ccba53026..5d36c63f011818558a33499f5fecc2bbdaecde9c 100644 (file)
@@ -33,7 +33,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 jack_nframes_t Crossfade::_short_xfade_length = 0;
 Change Crossfade::ActiveChanged = ARDOUR::new_change();
index a515c3a39a8e341efe04950e0edc5ca4df29bb1e..977b6dfd7be5088fc88df669e594497e57564a71 100644 (file)
@@ -38,6 +38,7 @@
 using namespace std;
 using namespace ARDOUR;
 using namespace sigc;
+using namespace PBD;
 
 Curve::Curve (double minv, double maxv, double canv, bool nostate)
        : AutomationList (canv, nostate)
index c48b7fb861e07fbd0d42e36913b3a3819ce62d29..3031d5a7ec93c624a481a277496a927edb26c7eb 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "i18n.h"
 
+using namespace PBD;
+
 float CycleTimer::cycles_per_usec = 0;
 
 float
index 306b37732044ebe6cb706464961b81ec3fe442d0..cce757509a48efb592899a02db6351c29bad32ec 100644 (file)
@@ -61,6 +61,7 @@ typedef off_t off64_t;
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 gain_t* DestructiveFileSource::out_coefficient = 0;
 gain_t* DestructiveFileSource::in_coefficient = 0;
index aa725d4bb3fe45151043cf2ff43b25baeb9c75a3..f3e6e1b94797f1adea7c5d2c5a54d6aa4437aed3 100644 (file)
@@ -70,6 +70,7 @@ ARDOUR::OSC* ARDOUR::osc = 0;
 
 using namespace ARDOUR;
 using namespace std;
+using namespace PBD;
 
 MIDI::Port *default_mmc_port = 0;
 MIDI::Port *default_mtc_port = 0;
@@ -191,7 +192,7 @@ setup_midi (AudioEngine& engine     )
 }
 
 int
-ARDOUR::init (AudioEngine& engine, bool use_vst, bool try_optimization, void (*sighandler)(int,siginfo_t*,void*))
+ARDOUR::init (AudioEngine& engine, bool use_vst, bool try_optimization)
 {
         bool generic_mix_functions = true;
 
@@ -216,7 +217,7 @@ ARDOUR::init (AudioEngine& engine, bool use_vst, bool try_optimization, void (*s
 #endif
 
 #ifdef VST_SUPPORT
-       if (Config->get_use_vst() && fst_init (sighandler)) {
+       if (Config->get_use_vst() && fst_init ()) {
                return -1;
        }
 #endif
index 410171a590f36cfe2fc3c734ed0f5db03a72c3cd..b70a7bbc9c0154e8af0ca4cb9f8c462f78fd8193 100644 (file)
@@ -44,6 +44,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 #define BLOCKSIZE 4096U
 
index c3c3462016b1355ab8fdf3d236bd02a271d0f19e..fc05355d4ae821ec39fc4f13cbef4bb0b9996e7d 100644 (file)
@@ -38,7 +38,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 Insert::Insert(Session& s, Placement p)
        : Redirect (s, s.next_insert_name(), p)
index 2f04b7eaca380e595a9528ff20eaaf119f2aa6b2..82253964864757ad241058cb258c42eba5ee9ac4 100644 (file)
@@ -55,7 +55,8 @@ extern "C" int isinf (double);
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
+
 
 static float current_automation_version_number = 1.0;
 
@@ -96,11 +97,18 @@ static bool sort_ports_by_name (Port* a, Port* b)
 }
 
 
+/** The 'default_type' argument here isn't very good, but port creation is too 
+ * brufty and all over the place to make anything else feasible without massive
+ * changes.  The default typed passed is the type of port that will be created
+ * by ensure_io and friends.  This is a temporary compatibility hack to get
+ * multiple data types off the gound and should be removed.
+ */
 IO::IO (Session& s, string name,
-
-       int input_min, int input_max, int output_min, int output_max)
+       int input_min, int input_max, int output_min, int output_max,
+       Buffer::Type default_type)
        : _session (s),
          _name (name),
+         _default_type(default_type),
          _midi_gain_control (*this, _session.midi_port()),
          _gain_automation_curve (0.0, 2.0, 1.0),
          _input_minimum (input_min),
@@ -784,11 +792,20 @@ IO::remove_output_port (Port* port, void* src)
        return -1;
 }
 
+/** Add an output port.
+ *
+ * @param destination Name of input port to connect new port to.
+ * @param src Source for emitted ConfigurationChanged signal.
+ * @param type Data type of port.  Default value (Buffer::NIL) will use this IO's default type.
+ */
 int
-IO::add_output_port (string destination, void* src)
+IO::add_output_port (string destination, void* src, Buffer::Type type)
 {
        Port* our_port;
-       char buf[64];
+       char name[64];
+
+       if (type == Buffer::NIL)
+               type = _default_type;
 
        {
                Glib::Mutex::Lock em(_session.engine().process_lock());
@@ -802,14 +819,15 @@ IO::add_output_port (string destination, void* src)
                
                        /* Create a new output port */
                        
+                       // FIXME: naming scheme for differently typed ports?
                        if (_output_maximum == 1) {
-                               snprintf (buf, sizeof (buf), _("%s/out"), _name.c_str());
+                               snprintf (name, sizeof (name), _("%s/out"), _name.c_str());
                        } else {
-                               snprintf (buf, sizeof (buf), _("%s/out %u"), _name.c_str(), find_output_port_hole());
+                               snprintf (name, sizeof (name), _("%s/out %u"), _name.c_str(), find_output_port_hole());
                        }
                        
-                       if ((our_port = _session.engine().register_audio_output_port (buf)) == 0) {
-                               error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg;
+                       if ((our_port = _session.engine().register_output_port (type, name)) == 0) {
+                               error << string_compose(_("IO: cannot register output port %1"), name) << endmsg;
                                return -1;
                        }
                        
@@ -885,11 +903,21 @@ IO::remove_input_port (Port* port, void* src)
        return -1;
 }
 
+
+/** Add an input port.
+ *
+ * @param type Data type of port.  The appropriate Jack port type, and @ref Port will be created.
+ * @param destination Name of input port to connect new port to.
+ * @param src Source for emitted ConfigurationChanged signal.
+ */
 int
-IO::add_input_port (string source, void* src)
+IO::add_input_port (string source, void* src, Buffer::Type type)
 {
        Port* our_port;
-       char buf[64];
+       char name[64];
+       
+       if (type == Buffer::NIL)
+               type = _default_type;
 
        {
                Glib::Mutex::Lock em (_session.engine().process_lock());
@@ -903,14 +931,15 @@ IO::add_input_port (string source, void* src)
 
                        /* Create a new input port */
                        
+                       // FIXME: naming scheme for differently typed ports?
                        if (_input_maximum == 1) {
-                               snprintf (buf, sizeof (buf), _("%s/in"), _name.c_str());
+                               snprintf (name, sizeof (name), _("%s/in"), _name.c_str());
                        } else {
-                               snprintf (buf, sizeof (buf), _("%s/in %u"), _name.c_str(), find_input_port_hole());
+                               snprintf (name, sizeof (name), _("%s/in %u"), _name.c_str(), find_input_port_hole());
                        }
                        
-                       if ((our_port = _session.engine().register_audio_input_port (buf)) == 0) {
-                               error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;
+                       if ((our_port = _session.engine().register_input_port (type, name)) == 0) {
+                               error << string_compose(_("IO: cannot register input port %1"), name) << endmsg;
                                return -1;
                        }
                        
@@ -1006,6 +1035,8 @@ IO::ensure_inputs_locked (uint32_t n, bool clear, void* src)
                
                /* Create a new input port */
                
+               // FIXME: of what type?
+
                if (_input_maximum == 1) {
                        snprintf (buf, sizeof (buf), _("%s/in"), _name.c_str());
                }
@@ -1015,7 +1046,7 @@ IO::ensure_inputs_locked (uint32_t n, bool clear, void* src)
                
                try {
                        
-                       if ((input_port = _session.engine().register_audio_input_port (buf)) == 0) {
+                       if ((input_port = _session.engine().register_input_port (_default_type, buf)) == 0) {
                                error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;
                                return -1;
                        }
@@ -1106,6 +1137,8 @@ IO::ensure_io (uint32_t nin, uint32_t nout, bool clear, void* src)
                
                /* create any necessary new ports */
                
+               // FIXME: of what type?
+
                while (_ninputs < nin) {
                        
                        char buf[64];
@@ -1120,7 +1153,7 @@ IO::ensure_io (uint32_t nin, uint32_t nout, bool clear, void* src)
                        }
                        
                        try {
-                               if ((port = _session.engine().register_audio_input_port (buf)) == 0) {
+                               if ((port = _session.engine().register_input_port (_default_type, buf)) == 0) {
                                        error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;
                                        return -1;
                                }
@@ -1153,7 +1186,7 @@ IO::ensure_io (uint32_t nin, uint32_t nout, bool clear, void* src)
                        }
                        
                        try { 
-                               if ((port = _session.engine().register_audio_output_port (buf)) == 0) {
+                               if ((port = _session.engine().register_output_port (_default_type, buf)) == 0) {
                                        error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg;
                                        return -1;
                                }
@@ -1278,7 +1311,7 @@ IO::ensure_outputs_locked (uint32_t n, bool clear, void* src)
                        snprintf (buf, sizeof (buf), _("%s/out %u"), _name.c_str(), find_output_port_hole());
                }
                
-               if ((output_port = _session.engine().register_audio_output_port (buf)) == 0) {
+               if ((output_port = _session.engine().register_output_port (_default_type, buf)) == 0) {
                        error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg;
                        return -1;
                }
index be8d585aaa9fc832915233befc8fd61adc726a37..352bcaeee54e1603b466f59883edf40e0e721358 100644 (file)
@@ -23,7 +23,6 @@
 #include <errno.h>
 #include <jack/jack.h>
 #include <jack/transport.h>
-#include <pbd/error.h>
 
 #include <ardour/slave.h>
 #include <ardour/session.h>
index 50757f9acd2e3c87561595cd388f7e037cc17cfe..11001655d2974efa014c1d5f5ec3377665397872 100644 (file)
@@ -49,6 +49,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 LadspaPlugin::LadspaPlugin (void *mod, AudioEngine& e, Session& session, uint32_t index, jack_nframes_t rate)
        : Plugin (e, session)
index 28ec42a3941fa451be98fbebf99adc6d69653280..b2af52284e91bfa232e575cbcd69addc23fec91d 100644 (file)
@@ -36,6 +36,7 @@
 using namespace std;
 using namespace ARDOUR;
 using namespace sigc;
+using namespace PBD;
 
 Location::Location (const Location& other)
        : _name (other._name),
index c1f87bf36d5944e922f90c7e66ce8075ee301fca..32642d570d4291cdc3132b41ae99efa5f97d42cb 100644 (file)
@@ -37,6 +37,7 @@
 using namespace ARDOUR;
 using namespace sigc;
 using namespace MIDI;
+using namespace PBD;
 
 MTC_Slave::MTC_Slave (Session& s, MIDI::Port& p) 
        : session (s)
index 9c5830dfc10ca1d9dcad13278eb7a8818e0c8832..605d7cae13109346695f54525363e730bede9bf9 100644 (file)
@@ -29,6 +29,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 sigc::signal<void,NamedSelection*> NamedSelection::NamedSelectionCreated;
 
index bc7b47273282e76734e94508f90d210c7f1f1877..83c9e6eb4d7f48854bb4cbc8246451172b52f9a9 100644 (file)
@@ -44,9 +44,9 @@
 
 #include <pbd/mathfix.h>
 
-
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 float Panner::current_automation_version_number = 1.0;
 
index 1bc6ccac6db957af9feed18e07a0a152779f7a65..7dee8667673a2a1bcd5ccebc24afff66cee8fd48 100644 (file)
@@ -41,7 +41,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 sigc::signal<void,Playlist*> Playlist::PlaylistCreated;
 
index fc4618d1dcf7a15c82e263b3f407bf899f1e6cec..7c7060dae80099e44390f8eb7c9dee532f258a2e 100644 (file)
@@ -1,3 +1,25 @@
+/*
+    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
+    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.
+
+    $Id$
+*/
+
+#include <pbd/error.h>
+
 #include <ardour/session.h>
 
 #include <ardour/playlist.h>
@@ -10,6 +32,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 Region*
 ARDOUR::createRegion (const Region& region, jack_nframes_t start, 
index e9665908a3c632e998f2689f3c55b1b2cb2bc40a..2d1f8ffcbd06c888626865b65728b8eddf99482b 100644 (file)
@@ -48,6 +48,7 @@
 #include <locale.h>
 
 using namespace ARDOUR;
+using namespace PBD;
 
 Plugin::Plugin (AudioEngine& e, Session& s)
        : _engine (e), _session (s)
index e1f34199d6a42a2a6420a2c1b4dc472a45a2b69a..b096e817857e65e5fa9dcdab258cf59ef0a55e03 100644 (file)
@@ -44,6 +44,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 PluginManager* PluginManager::_manager = 0;
 
index c5c03d0a05948255066a4dccda538db478324228..7ec0d5a05ab2824827b29b965ca30ff16dbada79 100644 (file)
@@ -24,15 +24,15 @@ using namespace ARDOUR;
 using namespace std;
 
 Port::Port (jack_port_t *p) 
-       : port (p)
+       : _port (p)
 {
-       if (port == 0) {
+       if (_port == 0) {
                throw failed_constructor();
        }
        
-       _flags = JackPortFlags (jack_port_flags (port));
-       _type  = jack_port_type (port); 
-       _name = jack_port_name (port);
+       _flags = JackPortFlags (jack_port_flags (_port));
+       _type  = jack_port_type (_port); 
+       _name = jack_port_name (_port);
 
        reset ();
 }
@@ -42,9 +42,9 @@ Port::reset ()
 {
        reset_buffer ();
        
-       last_monitor = false;
-       silent = false;
-       metering = 0;
+       _last_monitor = false;
+       _silent = false;
+       _metering = 0;
        
        reset_meters ();
 }
@@ -54,7 +54,7 @@ Port::set_name (string str)
 {
        int ret;
 
-       if ((ret = jack_port_set_name (port, str.c_str())) == 0) {
+       if ((ret = jack_port_set_name (_port, str.c_str())) == 0) {
                _name = str;
        }
        
index efbdb807f734b341a1f53ba9b9bc54dc6ef3a6e6..954162dd183547c3589ef964fe5aa7d724a92481 100644 (file)
@@ -27,9 +27,9 @@
 #include <ardour/utils.h>
 #include "i18n.h"
 
-
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 int
 ARDOUR::read_recent_sessions (RecentSessions& rs)
index 746d2790e229f18c7fccb6dd8e0852df01449903..33fec5088f189ebe08693b2d0007426df9319dd3 100644 (file)
@@ -39,7 +39,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 const string Redirect::state_node_name = "Redirect";
 sigc::signal<void,Redirect*> Redirect::RedirectCreated;
index 08df23146b0bc607c0307698683def1fab00d92c..8c27a3bebc699732449943c0cf7bf9d6a959a0b9 100644 (file)
@@ -37,6 +37,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 Change Region::FadeChanged = ARDOUR::new_change ();
 Change Region::SyncOffsetChanged = ARDOUR::new_change ();
index 2ed06594857838a1635efa2d8264f7392534ed2b..568bfddfc34886e485424409f13f19a3da65eaab 100644 (file)
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 
 uint32_t Route::order_key_cnt = 0;
 
 
-Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg)
-       : IO (sess, name, input_min, input_max, output_min, output_max),
+Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg, Buffer::Type default_type)
+       : IO (sess, name, input_min, input_max, output_min, output_max, default_type),
          _flags (flg),
          _midi_solo_control (*this, MIDIToggleControl::SoloControl, _session.midi_port()),
          _midi_mute_control (*this, MIDIToggleControl::MuteControl, _session.midi_port())
index 50fdd4a96a0de82d6f2f02555552b5881e284206..2b72fb9bdbdf660b856949528eeb1bdc5b08045b 100644 (file)
@@ -29,6 +29,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 
 Send::Send (Session& s, Placement p)
        : Redirect (s, s.next_send_name(), p)
index a5c8c0cf99d94dbdb36d7e5c2694f50d1c347c07..c6c6f0444ccb22bc6604c9e04fb7ca1a6402f49b 100644 (file)
 #include <ardour/audioengine.h>
 #include <ardour/configuration.h>
 #include <ardour/session.h>
-#include <ardour/audio_diskstream.h>
 #include <ardour/utils.h>
+#include <ardour/audio_diskstream.h>
 #include <ardour/audioplaylist.h>
 #include <ardour/audioregion.h>
 #include <ardour/audiofilesource.h>
+#include <ardour/midi_diskstream.h>
+#include <ardour/midi_playlist.h>
+#include <ardour/midi_region.h>
+#include <ardour/smf_source.h>
 #include <ardour/destructive_filesource.h>
 #include <ardour/auditioner.h>
 #include <ardour/recent_sessions.h>
@@ -59,6 +63,7 @@
 #include <ardour/slave.h>
 #include <ardour/tempo.h>
 #include <ardour/audio_track.h>
+#include <ardour/midi_track.h>
 #include <ardour/cycle_timer.h>
 #include <ardour/named_selection.h>
 #include <ardour/crossfade.h>
@@ -73,7 +78,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 const char* Session::_template_suffix = X_(".template");
 const char* Session::_statefile_suffix = X_(".ardour");
@@ -300,6 +305,7 @@ Session::Session (AudioEngine &eng,
          _midi_port (default_midi_port),
          pending_events (2048),
          //midi_requests (16),
+         _send_smpte_update (false),
          main_outs (0)
 
 {
@@ -617,8 +623,13 @@ Session::when_engine_running ()
                        
                        /* default state for Click */
 
+                       // FIXME: there's no JackPortIsAudio flag or anything like that, so this is _bad_.
+                       // we need a get_nth_physical_audio_output or similar, but the existing one just
+                       // deals with strings :/
+
                        first_physical_output = _engine.get_nth_physical_output (0);
-                       
+                       cerr << "FIXME: click type" << endl;
+
                        if (first_physical_output.length()) {
                                if (_click_io->add_output_port (first_physical_output, this)) {
                                        // relax, even though its an error
@@ -736,7 +747,7 @@ Session::when_engine_running ()
                        _master_out->defer_pan_reset ();
                        
                        while ((int) _master_out->n_inputs() < _master_out->input_maximum()) {
-                               if (_master_out->add_input_port ("", this)) {
+                               if (_master_out->add_input_port ("", this)) { // FIXME
                                        error << _("cannot setup master inputs") 
                                              << endmsg;
                                        break;
@@ -744,7 +755,7 @@ Session::when_engine_running ()
                        }
                        n = 0;
                        while ((int) _master_out->n_outputs() < _master_out->output_maximum()) {
-                               if (_master_out->add_output_port (_engine.get_nth_physical_output (n), this)) {
+                               if (_master_out->add_output_port (_engine.get_nth_physical_output (n), this)) { // FIXME
                                        error << _("cannot setup master outputs")
                                              << endmsg;
                                        break;
@@ -882,7 +893,7 @@ Session::playlist_length_changed (Playlist* pl)
 }
 
 void
-Session::diskstream_playlist_changed (AudioDiskstream* dstream)
+Session::diskstream_playlist_changed (Diskstream* dstream)
 {
        Playlist *playlist;
 
@@ -1670,6 +1681,202 @@ Session::resort_routes (void* src)
 
 }
 
+MidiTrack*
+Session::new_midi_track (TrackMode mode)
+{
+       MidiTrack *track;
+       char track_name[32];
+       uint32_t n = 0;
+       uint32_t channels_used = 0;
+       string port;
+
+       /* count existing midi tracks */
+
+       {
+               Glib::RWLock::ReaderLock lm (route_lock);
+               for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
+                       if (dynamic_cast<MidiTrack*>(*i) != 0) {
+                               if (!(*i)->hidden()) {
+                                       n++;
+                                       channels_used += (*i)->n_inputs();
+                               }
+                       }
+               }
+       }
+
+       /* check for duplicate route names, since we might have pre-existing
+          routes with this name (e.g. create Midi1, Midi2, delete Midi1,
+          save, close,restart,add new route - first named route is now
+          Midi2)
+       */
+
+       do {
+               snprintf (track_name, sizeof(track_name), "Midi %" PRIu32, n+1);
+               if (route_by_name (track_name) == 0) {
+                       break;
+               }
+               n++;
+
+       } while (n < (UINT_MAX-1));
+
+       try {
+               track = new MidiTrack (*this, track_name, Route::Flag (0), mode);
+
+               if (track->ensure_io (1, 1, false, this)) {
+                       error << string_compose (_("cannot configure %1 in/%2 out configuration for new midi track"), track_name)
+                             << endmsg;
+               }
+#if 0
+               if (nphysical_in) {
+                       for (uint32_t x = 0; x < track->n_inputs() && x < nphysical_in; ++x) {
+                               
+                               port = "";
+                               
+                               if (input_auto_connect & AutoConnectPhysical) {
+                                       port = _engine.get_nth_physical_input ((channels_used+x)%nphysical_in);
+                               } 
+                               
+                               if (port.length() && track->connect_input (track->input (x), port, this)) {
+                                       break;
+                               }
+                       }
+               }
+               
+               for (uint32_t x = 0; x < track->n_outputs(); ++x) {
+                       
+                       port = "";
+
+                       if (nphysical_out && (output_auto_connect & AutoConnectPhysical)) {
+                               port = _engine.get_nth_physical_output ((channels_used+x)%nphysical_out);
+                       } else if (output_auto_connect & AutoConnectMaster) {
+                               if (_master_out) {
+                                       port = _master_out->input (x%_master_out->n_inputs())->name();
+                               }
+                       }
+
+                       if (port.length() && track->connect_output (track->output (x), port, this)) {
+                               break;
+                       }
+               }
+
+               if (_control_out) {
+                       vector<string> cports;
+                       uint32_t ni = _control_out->n_inputs();
+
+                       for (n = 0; n < ni; ++n) {
+                               cports.push_back (_control_out->input(n)->name());
+                       }
+
+                       track->set_control_outs (cports);
+               }
+#endif
+               track->diskstream_changed.connect (mem_fun (this, &Session::resort_routes));
+
+               add_route (track);
+
+               track->set_remote_control_id (ntracks());
+       }
+
+       catch (failed_constructor &err) {
+               error << _("Session: could not create new midi track.") << endmsg;
+               return 0;
+       }
+
+       return track;
+}
+
+
+Route*
+Session::new_midi_route ()
+{
+       Route *bus;
+       char bus_name[32];
+       uint32_t n = 0;
+       string port;
+
+       /* count existing midi busses */
+
+       {
+               Glib::RWLock::ReaderLock lm (route_lock);
+               for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
+                       if (dynamic_cast<MidiTrack*>(*i) == 0) {
+                               if (!(*i)->hidden()) {
+                                       n++;
+                               }
+                       }
+               }
+       }
+
+       do {
+               snprintf (bus_name, sizeof(bus_name), "Bus %" PRIu32, n+1);
+               if (route_by_name (bus_name) == 0) {
+                       break;
+               }
+               n++;
+
+       } while (n < (UINT_MAX-1));
+
+       try {
+               bus = new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), Buffer::MIDI);
+               
+               if (bus->ensure_io (1, 1, false, this)) {
+                       error << (_("cannot configure 1 in/1 out configuration for new midi track"))
+                             << endmsg;
+               }
+#if 0
+               for (uint32_t x = 0; x < bus->n_inputs(); ++x) {
+                       
+                       port = "";
+
+                       if (input_auto_connect & AutoConnectPhysical) {
+                               port = _engine.get_nth_physical_input ((n+x)%n_physical_inputs);
+                       } 
+                       
+                       if (port.length() && bus->connect_input (bus->input (x), port, this)) {
+                               break;
+                       }
+               }
+
+               for (uint32_t x = 0; x < bus->n_outputs(); ++x) {
+                       
+                       port = "";
+
+                       if (output_auto_connect & AutoConnectPhysical) {
+                               port = _engine.get_nth_physical_input ((n+x)%n_physical_outputs);
+                       } else if (output_auto_connect & AutoConnectMaster) {
+                               if (_master_out) {
+                                       port = _master_out->input (x%_master_out->n_inputs())->name();
+                               }
+                       }
+
+                       if (port.length() && bus->connect_output (bus->output (x), port, this)) {
+                               break;
+                       }
+               }
+#endif
+/*
+               if (_control_out) {
+                       vector<string> cports;
+                       uint32_t ni = _control_out->n_inputs();
+
+                       for (uint32_t n = 0; n < ni; ++n) {
+                               cports.push_back (_control_out->input(n)->name());
+                       }
+                       bus->set_control_outs (cports);
+               }
+*/             
+               add_route (bus);
+       }
+
+       catch (failed_constructor &err) {
+               error << _("Session: could not create new MIDI route.") << endmsg;
+               return 0;
+       }
+
+       return bus;
+}
+
+
 AudioTrack*
 Session::new_audio_track (int input_channels, int output_channels, TrackMode mode)
 {
@@ -1820,7 +2027,7 @@ Session::new_audio_route (int input_channels, int output_channels)
        } while (n < (UINT_MAX-1));
 
        try {
-               bus = new Route (*this, bus_name, -1, -1, -1, -1);
+               bus = new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), Buffer::AUDIO);
 
                if (bus->ensure_io (input_channels, output_channels, false, this)) {
                        error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"),
@@ -1872,7 +2079,7 @@ Session::new_audio_route (int input_channels, int output_channels)
        }
 
        catch (failed_constructor &err) {
-               error << _("Session: could not create new route.") << endmsg;
+               error << _("Session: could not create new audio route.") << endmsg;
                return 0;
        }
 
@@ -1908,10 +2115,17 @@ Session::add_route (Route* route)
 }
 
 void
-Session::add_diskstream (AudioDiskstream* dstream)
+Session::add_diskstream (Diskstream* s)
 {
+       // FIXME: temporary.  duh.
+       AudioDiskstream* dstream = dynamic_cast<AudioDiskstream*>(s);
+       if (!dstream) {
+               cerr << "FIXME: Non Audio Diskstream" << endl;
+               return;
+       }
+
        /* need to do this in case we're rolling at the time, to prevent false underruns */
-       dstream->do_refill(0, 0, 0);
+       dstream->non_realtime_do_refill();
        
        { 
                Glib::RWLock::WriterLock lm (diskstream_lock);
@@ -1935,7 +2149,7 @@ Session::add_diskstream (AudioDiskstream* dstream)
        set_dirty();
        save_state (_current_snapshot_name);
 
-       AudioDiskstreamAdded (dstream); /* EMIT SIGNAL */
+       DiskstreamAdded (dstream); /* EMIT SIGNAL */
 }
 
 void
@@ -2279,11 +2493,12 @@ Session::get_maximum_extent () const
        return max;
 }
 
-AudioDiskstream *
+Diskstream *
 Session::diskstream_by_name (string name)
 {
        Glib::RWLock::ReaderLock lm (diskstream_lock);
 
+       // FIXME: duh
        for (AudioDiskstreamList::iterator i = audio_diskstreams.begin(); i != audio_diskstreams.end(); ++i) {
                if ((*i)->name() == name) {
                        return* i;
@@ -2293,11 +2508,12 @@ Session::diskstream_by_name (string name)
        return 0;
 }
 
-AudioDiskstream *
+Diskstream *
 Session::diskstream_by_id (id_t id)
 {
        Glib::RWLock::ReaderLock lm (diskstream_lock);
 
+       // FIXME: duh
        for (AudioDiskstreamList::iterator i = audio_diskstreams.begin(); i != audio_diskstreams.end(); ++i) {
                if ((*i)->id() == id) {
                        return *i;
index d29bf3937b67ed967cf7dcc248cf62a4f73acf9b..b1451912d061df8480bf6d32f0efedbe690349a9 100644 (file)
@@ -42,7 +42,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 static float _read_data_rate;
 static float _write_data_rate;
@@ -174,9 +174,8 @@ Session::butler_thread_work ()
        butler_gain_buffer = new gain_t[AudioDiskstream::disk_io_frames()];
        // this buffer is used for temp conversion purposes in filesources
        char * conv_buffer = conversion_buffer(ButlerContext);
-
+       
        while (true) {
-
                pfd[0].fd = butler_request_pipe[0];
                pfd[0].events = POLLIN|POLLERR|POLLHUP;
                
@@ -198,14 +197,13 @@ Session::butler_thread_work ()
                }
                
                if (pfd[0].revents & POLLIN) {
-                       
+
                        char req;
                        
                        /* empty the pipe of all current requests */
                        
                        while (1) {
                                size_t nread = ::read (butler_request_pipe[0], &req, sizeof (req));
-                               
                                if (nread == 1) {
                                        
                                        switch ((ButlerRequest::Type) req) {
@@ -240,10 +238,10 @@ Session::butler_thread_work ()
                                }
                        }
                }
-       
-               for (i = audio_diskstreams.begin(); i != audio_diskstreams.end(); ++i) {
+
+               //for (i = audio_diskstreams.begin(); i != audio_diskstreams.end(); ++i) {
                        // cerr << "BEFORE " << (*i)->name() << ": pb = " << (*i)->playback_buffer_load() << " cp = " << (*i)->capture_buffer_load() << endl;
-               }
+               //}
 
                if (transport_work_requested()) {
                        butler_transport_work ();
@@ -258,7 +256,6 @@ Session::butler_thread_work ()
                Glib::RWLock::ReaderLock dsm (diskstream_lock);
                
                for (i = audio_diskstreams.begin(); !transport_work_requested() && butler_should_run && i != audio_diskstreams.end(); ++i) {
-                       
                        // cerr << "rah fondr " << (*i)->io()->name () << endl;
 
                        switch ((*i)->do_refill (butler_mixdown_buffer, butler_gain_buffer, conv_buffer)) {
@@ -299,9 +296,8 @@ Session::butler_thread_work ()
                bytes = 0;
                compute_io = true;
                gettimeofday (&begin, 0);
-               
+
                for (i = audio_diskstreams.begin(); !transport_work_requested() && butler_should_run && i != audio_diskstreams.end(); ++i) {
-                       
                        // cerr << "write behind for " << (*i)->name () << endl;
                        
                        switch ((*i)->do_flush (conv_buffer)) {
@@ -375,18 +371,17 @@ Session::butler_thread_work ()
 
 
 void
-Session::request_overwrite_buffer (AudioDiskstream* stream)
+Session::request_overwrite_buffer (Diskstream* stream)
 {
        Event *ev = new Event (Event::Overwrite, Event::Add, Event::Immediate, 0, 0, 0.0);
        ev->set_ptr (stream);
        queue_event (ev);
 }
 
+/** Process thread. */
 void
-Session::overwrite_some_buffers (AudioDiskstream* ds)
+Session::overwrite_some_buffers (Diskstream* ds)
 {
-       /* executed by the audio thread */
-
        if (actively_recording()) {
                return;
        }
index 4503287da12aff17508b9aea87fbf0f3b38d4fbf..1d14fd4a80a77307365b0cb7369d0e5521377fe5 100644 (file)
@@ -32,6 +32,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 Pool Session::Click::pool ("click", sizeof (Click), 128);
 
index 586dea05a3aba59ffc32393f90be57a5669edc11..79d20c8c3961e91990e2c7d20ea4ec4cae85b9b7 100644 (file)
@@ -33,7 +33,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 MultiAllocSingleReleasePool Session::Event::pool ("event", sizeof (Session::Event), 512);
 
@@ -397,7 +397,7 @@ Session::process_event (Event* ev)
                break;
 
        case Event::SetDiskstreamSpeed:
-               set_diskstream_speed (static_cast<AudioDiskstream*> (ev->ptr), ev->speed);
+               set_diskstream_speed (static_cast<Diskstream*> (ev->ptr), ev->speed);
                break;
 
        case Event::SetSlaveSource:
index f6ea0c9f3ff867a9e9e5db2f320514f873c501db..ddced9cc5f85f169169d036a6c2f25f11647747e 100644 (file)
@@ -54,7 +54,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 static int
 convert_spec_to_info (AudioExportSpecification& spec, SF_INFO& sfinfo)
index 6fab01ec9dd243c06cd7ffc32d9ae11f1cc3a4df..1fd8389e117a27c230c0393b4f6f56321068c5c6 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <glibmm/thread.h>
 
-#include <pbd/error.h>
 #include <pbd/pthread_utils.h>
 
 #include <ardour/configuration.h>
index d081e3606e4a7aebf21b61db2be31ff42f34182b..bd68d24517f43882f330aa6e407b2fa01f59386d 100644 (file)
@@ -47,7 +47,7 @@
 
 using namespace std;
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 using namespace MIDI;
 
 MachineControl::CommandSignature MMC_CommandSignature;
@@ -660,7 +660,6 @@ Session::mmc_pause (MIDI::MachineControl &mmc)
 static bool step_queued = false;
 
 void
-
 Session::mmc_step (MIDI::MachineControl &mmc, int steps)
 {
        if (!mmc_control) {
index daa3a1d380a4493ea65da0e93325e08109c11857..23e7757c9d670661a26e91c2a3e1aa37b32c34d6 100644 (file)
@@ -42,7 +42,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 using namespace std;
 
 void
index edcc52d729d12dff9f47445fb8dbe5e1c882da86..12092b1badfba4fe28a038e979e27b3ce3965f39 100644 (file)
@@ -87,6 +87,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 void
 Session::first_stage_init (string fullpath, string snapshot_name)
@@ -269,7 +270,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        AudioSource::AudioSourceCreated.connect (mem_fun (*this, &Session::add_audio_source));
        Playlist::PlaylistCreated.connect (mem_fun (*this, &Session::add_playlist));
        Redirect::RedirectCreated.connect (mem_fun (*this, &Session::add_redirect));
-       AudioDiskstream::AudioDiskstreamCreated.connect (mem_fun (*this, &Session::add_diskstream));
+       AudioDiskstream::DiskstreamCreated.connect (mem_fun (*this, &Session::add_diskstream));
        NamedSelection::NamedSelectionCreated.connect (mem_fun (*this, &Session::add_named_selection));
 
        IO::MoreOutputs.connect (mem_fun (*this, &Session::ensure_passthru_buffers));
index d597860a5e799e9f53779b8d4e67cbff876bb571..0db3afcee69b662844f7ad764f7ab6f9e6da2807 100644 (file)
@@ -37,7 +37,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
 
 /* BBT TIME*/
 
index ee751b9af7c73aeb11ae1ebe97b1b54b8c5baba5..7eec1e578ba2b2c6e50d8e4c105c7343b088615a 100644 (file)
@@ -33,6 +33,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace soundtouch;
 
 AudioRegion*
index ec8f3e24b7296f6808c2bcb068dc270caf77987d..d7ab60f3fb835b46d5f9941c32a7a2e3eef62582 100644 (file)
@@ -46,6 +46,7 @@
 using namespace std;
 using namespace ARDOUR;
 using namespace sigc;
+using namespace PBD;
 
 void
 Session::request_input_change_handling ()
@@ -78,7 +79,7 @@ Session::request_transport_speed (float speed)
 }
 
 void
-Session::request_diskstream_speed (AudioDiskstream& ds, float speed)
+Session::request_diskstream_speed (Diskstream& ds, float speed)
 {
        Event* ev = new Event (Event::SetDiskstreamSpeed, Event::Add, Event::Immediate, 0, speed);
        ev->set_ptr (&ds);
@@ -1045,7 +1046,7 @@ Session::reverse_diskstream_buffers ()
 }
 
 void
-Session::set_diskstream_speed (AudioDiskstream* stream, float speed)
+Session::set_diskstream_speed (Diskstream* stream, float speed)
 {
        if (stream->realtime_set_speed (speed, false)) {
                post_transport_work = PostTransportWork (post_transport_work | PostTransportSpeed);
index 6ea0929ae0a4b3d90dc21482c646c7946ed1bea1..24a70f636be085987cb11987989d5f0c865ad51b 100644 (file)
@@ -32,6 +32,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 SndFileSource::SndFileSource (const XMLNode& node)
        : AudioFileSource (node)
index bb24c8eb583cd53a371a931bc49d396050fea910..bcffe381c382be341f3ef1b90c7d89b82f4383f2 100644 (file)
@@ -5,6 +5,7 @@
 
 using namespace ARDOUR;
 using namespace std;
+using namespace PBD;
 
 bool StateManager::_allow_save = true;
 sigc::signal<void,const char*> StateManager::SaveAllowed;
index d08be38ecd5b570839a7d2646fa0e65c3d1fa258..b8e301b2739f0501ce8a5f62fdc64fa4628d86ce 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "i18n.h"
 
+using namespace PBD;
+
 Stateful::Stateful ()
 {
        _extra_xml = 0;
index 64964b29dd6bdcb04f1a0837a4bee8909e0df749..c0e52279e1bd7280633b38eddd6371ddb23471c7 100644 (file)
@@ -35,6 +35,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 /* _default tempo is 4/4 qtr=120 */
 
index 2d9fccf9d74691c289f52171b9b5c1c5dd8768d3..9adc7c72cd39f2cac11afc9f38634516570dec60 100644 (file)
@@ -42,6 +42,7 @@
 
 using namespace ARDOUR;
 using namespace std;
+using namespace PBD;
 
 void
 elapsed_time_to_str (char *buf, uint32_t seconds)
index 2f3653a16af626a1788a24184cfbc542fc7dd0fc..80c36dab950450ed48b6e423eff9d94934d1a63c 100644 (file)
@@ -54,6 +54,7 @@
 #include <locale.h>
 
 using namespace ARDOUR;
+using namespace PBD;
 using std::min;
 using std::max;
 
diff --git a/libs/fst/SConscript b/libs/fst/SConscript
new file mode 100644 (file)
index 0000000..0499f11
--- /dev/null
@@ -0,0 +1,27 @@
+# -*- python -*-
+
+import os
+import os.path
+import glob
+
+fst_src = glob.glob('*.c')
+
+Import('env install_prefix')
+fst = env.Copy(CC="winegcc")
+fst.Append (CPPPATH=".")
+
+hackSDK = fst.Command('vst/aeffectx.h', 'vstsdk2.3/source/common/aeffectx.h', [
+    Delete ('${TARGET.dir}'),
+    Copy ('${TARGET.dir}', '${SOURCE.dir}'),
+    "sed -i '/struct VstFileType\|struct VstFileSelect/,/};/d' $TARGET"
+])
+
+a = fst.Object ('fst', 'fst.c')
+b = fst.Object ('fstinfofile', 'fstinfofile.c')
+c = fst.Object ('vstwin', 'vstwin.c')
+d = fst.Object ('vsti', 'vsti.c')
+
+Default([hackSDK,a,b,c,d])
+
+env.Alias('tarball', env.Distribute (env['DISTTREE'], fst_src + ['SConscript'] ))
+
diff --git a/libs/fst/fst.c b/libs/fst/fst.c
new file mode 100644 (file)
index 0000000..8547357
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "fst.h"
+
+
+void 
+default_fst_error_callback (const char *desc)
+{
+       fprintf(stderr, "%s\n", desc);
+}
+
+void (*fst_error_callback)(const char *desc) = &default_fst_error_callback;
+
+void 
+fst_error (const char *fmt, ...)
+{
+       va_list ap;
+       char buffer[512];
+
+       va_start (ap, fmt);
+       vsnprintf (buffer, sizeof(buffer), fmt, ap);
+       fst_error_callback (buffer);
+       va_end (ap);
+}
+
+
diff --git a/libs/fst/fst.h b/libs/fst/fst.h
new file mode 100644 (file)
index 0000000..9055eac
--- /dev/null
@@ -0,0 +1,108 @@
+#ifndef __fst_fst_h__
+#define __fst_fst_h__
+
+#include <setjmp.h>
+#include <signal.h>
+#include <pthread.h>
+
+/**
+ * Display FST error message.
+ *
+ * @param fmt printf-style formatting specification
+ */
+extern void fst_error (const char *fmt, ...);
+
+/**
+ * Set the @ref fst_error_callback for error message display.
+ *
+ * The FST library provides two built-in callbacks for this purpose:
+ * default_fst_error_callback().
+ *
+ * The default will print the message (plus a newline) to stderr.
+ *
+ */
+void fst_set_error_function (void (*func)(const char *));
+
+#include <vst/AEffect.h>
+
+typedef struct _FST FST;
+typedef struct _FSTHandle FSTHandle;
+typedef struct _FSTInfo FSTInfo;
+
+struct _FSTInfo 
+{
+    char *name;
+    int UniqueID;
+    char *Category;
+    
+    int numInputs;
+    int numOutputs;
+    int numParams;
+
+    int wantMidi;
+    int wantEvents;
+    int hasEditor;
+    int canProcessReplacing; // what do we need this for ?
+
+    // i think we should save the parameter Info Stuff soon.
+    // struct VstParameterInfo *infos;
+    char **ParamNames;
+    char **ParamLabels;
+};
+
+struct _FSTHandle
+{
+    void*    dll;
+    char*    name;
+    char*    nameptr; /* ptr returned from strdup() etc. */
+    AEffect* (*main_entry)(audioMasterCallback);
+
+    int plugincnt;
+};
+
+struct _FST 
+{
+    AEffect*    plugin;
+    void*       window; /* win32 HWND */
+    int         xid; /* X11 XWindow */
+    FSTHandle*  handle;
+    int        width;
+    int        height;
+    int         destroy;
+
+    struct _FST* next;
+
+    pthread_mutex_t lock;
+    pthread_cond_t  window_status_change;
+    int             been_activated;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int  fst_init ();
+
+extern FSTHandle* fst_load (const char*);
+extern int        fst_unload (FSTHandle*);
+
+extern FST*       fst_instantiate (FSTHandle*, audioMasterCallback amc, void* userptr);
+extern void       fst_close (FST*);
+
+extern void fst_event_loop_remove_plugin (FST* fst);
+extern void fst_event_loop_add_plugin (FST* fst);
+
+extern int  fst_run_editor (FST*);
+extern void  fst_destroy_editor (FST*);
+extern int  fst_get_XID (FST*);
+
+extern void fst_signal_handler (int sig, siginfo_t* info, void* context);
+
+extern FSTInfo *fst_get_info( char *dllpathname );
+extern void fst_free_info( FSTInfo *info );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __fst_fst_h__ */
diff --git a/libs/fst/fstinfofile.c b/libs/fst/fstinfofile.c
new file mode 100644 (file)
index 0000000..7cc98d2
--- /dev/null
@@ -0,0 +1,266 @@
+
+#include "fst.h"
+#include "vst/aeffectx.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define MAX_STRING_LEN 256
+
+#define FALSE 0
+#define TRUE !FALSE
+
+static char *read_string( FILE *fp ) {
+    char buf[MAX_STRING_LEN];
+
+    fgets( buf, MAX_STRING_LEN, fp );
+    if( strlen( buf ) < MAX_STRING_LEN ) {
+       
+       if( strlen(buf) )
+           buf[strlen(buf)-1] = 0;
+
+       return strdup( buf );
+    } else {
+       return NULL;
+    }
+}
+
+static FSTInfo *load_fst_info_file( char *filename ) {
+
+    FSTInfo *info = (FSTInfo *) malloc( sizeof( FSTInfo ) );
+    FILE *fp;
+    int i;
+
+
+    if( info == NULL )
+       return NULL;
+
+    fp = fopen( filename, "r" );
+    
+    if( fp == NULL ) {
+       free( info );
+       return NULL;
+    }
+
+    if( (info->name = read_string( fp )) == NULL ) goto error;
+    if( 1 != fscanf( fp, "%d\n", &info->UniqueID ) ) goto error;
+    if( (info->Category = read_string( fp )) == NULL ) goto error;
+    if( 1 != fscanf( fp, "%d\n", &info->numInputs ) ) goto error;
+    if( 1 != fscanf( fp, "%d\n", &info->numOutputs ) ) goto error;
+    if( 1 != fscanf( fp, "%d\n", &info->numParams ) ) goto error;
+    if( 1 != fscanf( fp, "%d\n", &info->wantMidi ) ) goto error;
+    if( 1 != fscanf( fp, "%d\n", &info->hasEditor ) ) goto error;
+    if( 1 != fscanf( fp, "%d\n", &info->canProcessReplacing ) ) goto error;
+
+    if( (info->ParamNames = (char **) malloc( sizeof( char * ) * info->numParams )) == NULL ) goto error;
+    for( i=0; i<info->numParams; i++ ) {
+       if( (info->ParamNames[i] = read_string( fp )) == NULL ) goto error;
+    }
+    if( (info->ParamLabels = (char **) malloc( sizeof( char * ) * info->numParams )) == NULL ) goto error;
+    for( i=0; i<info->numParams; i++ ) {
+       if( (info->ParamLabels[i] = read_string( fp )) == NULL ) goto error;
+    }
+       
+
+    fclose( fp );
+    return info;
+
+error:
+    fclose( fp );
+    free( info );
+    return NULL;
+}
+
+static int save_fst_info_file( FSTInfo *info, char *filename ) {
+
+    FILE *fp;
+    int i;
+
+
+    if( info == NULL ) {
+       fst_error( "info is NULL\n" );
+       return TRUE;
+    }
+
+    fp = fopen( filename, "w" );
+    
+    if( fp == NULL ) {
+       fst_error( "Cant write info file %s\n", filename );
+       return TRUE;
+    }
+
+    fprintf( fp, "%s\n", info->name );
+    fprintf( fp, "%d\n", info->UniqueID );
+    fprintf( fp, "%s\n", info->Category );
+    fprintf( fp, "%d\n", info->numInputs );
+    fprintf( fp, "%d\n", info->numOutputs );
+    fprintf( fp, "%d\n", info->numParams );
+    fprintf( fp, "%d\n", info->wantMidi );
+    fprintf( fp, "%d\n", info->hasEditor );
+    fprintf( fp, "%d\n", info->canProcessReplacing );
+
+    for( i=0; i<info->numParams; i++ ) {
+       fprintf( fp, "%s\n", info->ParamNames[i] );
+    }
+    for( i=0; i<info->numParams; i++ ) {
+       fprintf( fp, "%s\n", info->ParamLabels[i] );
+    }
+       
+
+    fclose( fp );
+
+    return FALSE;
+}
+
+static char *fst_dllpath_to_infopath( char *dllpath ) {
+    char *retval;
+    if( strstr( dllpath, ".dll" ) == NULL ) return NULL;
+    
+    retval = strdup( dllpath );
+    sprintf( retval + strlen(retval) - 4, ".fst" );
+    return retval;
+}
+
+static int fst_info_file_is_valid( char *dllpath ) {
+    struct stat dllstat, fststat;
+    char *fstpath = fst_dllpath_to_infopath( dllpath );
+
+    if( !fstpath ) return FALSE;
+    
+    if( stat( dllpath, &dllstat ) ){ fst_error( "dll path %s invalid\n", dllpath );  return TRUE; }
+    if( stat( fstpath, &fststat ) ) return FALSE;
+
+    free( fstpath );
+    if( dllstat.st_mtime > fststat.st_mtime )
+       return FALSE;
+    else 
+       return TRUE;
+}
+
+static int fst_can_midi( FST *fst ) {
+       AEffect *plugin = fst->plugin;
+       int vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0.0f);
+
+       if (vst_version >= 2) {
+               
+                /* should we send it VST events (i.e. MIDI) */
+               
+               if ((plugin->flags & effFlagsIsSynth) ||
+                   (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "receiveVstEvents", 0.0f) > 0))
+                   return TRUE;
+       }
+       return FALSE;
+
+}
+static FSTInfo *fst_info_from_plugin( FST *fst ) {
+    FSTInfo *info = (FSTInfo *) malloc( sizeof( FSTInfo ) );
+    AEffect *plugin;
+    int i;
+
+    if( ! fst ) {
+       fst_error( "fst is NULL\n" );
+       return NULL;
+    }
+
+    if( ! info ) return NULL;
+    
+    plugin = fst->plugin;
+    
+
+    info->name = strdup(fst->handle->name ); 
+    info->UniqueID = plugin->uniqueID;
+    info->Category = strdup( "None" );          // FIXME:  
+    info->numInputs = plugin->numInputs;
+    info->numOutputs = plugin->numOutputs;
+    info->numParams = plugin->numParams;
+    info->wantMidi = fst_can_midi( fst ); 
+    info->hasEditor = plugin->flags & effFlagsHasEditor ? TRUE : FALSE;
+    info->canProcessReplacing = plugin->flags & effFlagsCanReplacing ? TRUE : FALSE;
+
+    info->ParamNames = (char **) malloc( sizeof( char * ) * info->numParams );
+    info->ParamLabels = (char **) malloc( sizeof( char * ) * info->numParams );
+    for( i=0; i<info->numParams; i++ ) {
+       char name[20];
+       char label[9];
+               plugin->dispatcher (plugin,
+                                   effGetParamName,
+                                   i, 0, name, 0);
+               
+               plugin->dispatcher (plugin,
+                                   effGetParamLabel,
+                                   i, 0, label, 0);
+
+       info->ParamNames[i] = strdup( name );
+       info->ParamLabels[i] = strdup( label );
+    }
+    return info;
+}
+
+// most simple one :) could be sufficient.... 
+static long simple_master_callback( AEffect *fx, long opcode, long index, long value, void *ptr, float opt ) {
+    if( opcode == audioMasterVersion )
+       return 2;
+    else
+       return 0;
+}
+
+FSTInfo *fst_get_info( char *dllpath ) {
+
+    if( fst_info_file_is_valid( dllpath ) ) {
+       FSTInfo *info;
+       char *fstpath = fst_dllpath_to_infopath( dllpath );
+
+       info = load_fst_info_file( fstpath );
+       free( fstpath );
+       return info;
+
+    } else {
+
+       FSTHandle *h;
+       FST *fst;
+       FSTInfo *info;
+       char *fstpath;
+
+       if( !(h = fst_load( dllpath )) ) return NULL;
+       if( !(fst = fst_instantiate( h, simple_master_callback, NULL )) ) {
+           fst_unload( h );
+           fst_error( "instantiate failed\n" );
+           return NULL;
+       }
+       fstpath = fst_dllpath_to_infopath( dllpath );
+       if( !fstpath ) {
+           fst_close( fst );
+           fst_unload( h );
+           fst_error( "get fst filename failed\n" );
+           return NULL;
+       }
+       info = fst_info_from_plugin( fst );
+       save_fst_info_file( info, fstpath );
+
+       free( fstpath );
+       fst_close( fst );
+       fst_unload( h );
+       return info;
+    }
+}
+
+void fst_free_info( FSTInfo *info ) {
+
+    int i;
+
+    for( i=0; i<info->numParams; i++ ) {
+       free( info->ParamNames[i] );
+       free( info->ParamLabels[i] );
+    }
+    free( info->name );
+    free( info->Category );
+    free( info );
+}
+
+
diff --git a/libs/fst/jackvst.h b/libs/fst/jackvst.h
new file mode 100644 (file)
index 0000000..abb9e22
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef __jack_vst_h__
+#define __jack_vst_h__
+
+#include </usr/include/sys/types.h>
+#include </usr/include/sys/time.h>
+#include <jack/jack.h>
+#include <jack/ringbuffer.h>
+#include <fst.h>
+#include <alsa/asoundlib.h>
+
+typedef struct _JackVST JackVST;
+
+struct _JackVST {
+    jack_client_t *client;
+    FSTHandle*     handle;
+    FST*           fst;
+    float        **ins;
+    float        **outs;
+    jack_port_t  **inports;
+    jack_port_t  **outports;
+    void*          userdata;
+    int            bypassed;
+    int            muted;
+
+    int                   resume_called;
+    /* For VST/i support */
+
+    pthread_t          midi_thread;
+    snd_seq_t*         seq;
+    int                midiquit;
+    jack_ringbuffer_t* event_queue;
+    struct VstEvents*  events;
+};
+
+#endif /* __jack_vst_h__ */
diff --git a/libs/fst/vsti.c b/libs/fst/vsti.c
new file mode 100644 (file)
index 0000000..f6d8725
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ *   VST instrument support
+ *
+ *   Derived from code that was marked:    
+ *   Copyright (C) Kjetil S. Matheussen 2004 (k.s.matheussen@notam02.no)
+ *   Alsa-seq midi-code made by looking at the jack-rack source made by Bob Ham.
+ *    
+ *   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.
+ *
+ *   $Id: vsti.c,v 1.2 2004/04/07 01:56:23 pauld Exp $
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <jackvst.h>
+#include <vst/aeffectx.h>
+
+snd_seq_t *
+create_sequencer (const char* client_name, bool isinput)
+{
+       snd_seq_t * seq;
+       int err;
+       
+       if ((err = snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, 0)) != 0) {
+               fst_error ("Could not open ALSA sequencer, aborting\n\n%s\n\n"
+                          "Make sure you have configure ALSA properly and that\n"
+                          "/proc/asound/seq/clients exists and contains relevant\n"
+                          "devices (%s).", 
+                          snd_strerror (err));
+               return NULL;
+       }
+       
+       snd_seq_set_client_name (seq, client_name);
+       
+       if ((err = snd_seq_create_simple_port (seq, isinput? "Input" : "Output",
+                                              (isinput? SND_SEQ_PORT_CAP_WRITE: SND_SEQ_PORT_CAP_READ)| SND_SEQ_PORT_CAP_DUPLEX |
+                                              SND_SEQ_PORT_CAP_SUBS_READ|SND_SEQ_PORT_CAP_SUBS_WRITE,
+                                              SND_SEQ_PORT_TYPE_APPLICATION|SND_SEQ_PORT_TYPE_SPECIFIC)) != 0) {
+               fst_error ("Could not create ALSA port: %s", snd_strerror (err));
+               snd_seq_close(seq);
+               return NULL;
+       }
+       
+       return seq;
+}
+
+static void 
+queue_midi (JackVST *jvst, int val1, int val2, int val3)
+{
+       struct VstMidiEvent *pevent;
+       jack_ringbuffer_data_t vec[2];
+
+       jack_ringbuffer_get_write_vector (jvst->event_queue, vec);
+
+       if (vec[0].len < sizeof (struct VstMidiEvent)) {
+               fst_error ("event queue has no write space");
+               return;
+       }
+               
+       pevent = (struct VstMidiEevent *) vec[0].buf;
+
+       //  printf("note: %d\n",note);
+       
+       pevent->type = kVstMidiType;
+       pevent->byteSize = 24;
+       pevent->deltaFrames = 0;
+       pevent->flags = 0;
+       pevent->detune = 0;
+       pevent->noteLength = 0;
+       pevent->noteOffset = 0;
+       pevent->reserved1 = 0;
+       pevent->reserved2 = 0;
+       pevent->noteOffVelocity = 0;
+       pevent->midiData[0] = val1;
+       pevent->midiData[1] = val2;
+       pevent->midiData[2] = val3;
+       pevent->midiData[3] = 0;
+       
+       //printf("Sending: %x %x %x\n",val1,val2,val3);
+
+       jack_ringbuffer_write_advance (jvst->event_queue, sizeof (struct VstMidiEvent));
+}
+
+void *midireceiver(void *arg)
+{
+       snd_seq_event_t *event;
+       JackVST *jvst = (JackVST* )arg;
+       int val;
+
+       while (1) {
+
+               snd_seq_event_input (jvst->seq, &event);
+
+               if (jvst->midiquit) {
+                       break;
+               }
+
+               switch(event->type){
+               case SND_SEQ_EVENT_NOTEON:
+                       queue_midi(jvst,0x90+event->data.note.channel,event->data.note.note,event->data.note.velocity);
+                       //printf("Noteon, channel: %d note: %d vol: %d\n",event->data.note.channel,event->data.note.note,event->data.note.velocity);
+                       break;
+               case SND_SEQ_EVENT_NOTEOFF:
+                       queue_midi(jvst,0x80+event->data.note.channel,event->data.note.note,0);
+                       //printf("Noteoff, channel: %d note: %d vol: %d\n",event->data.note.channel,event->data.note.note,event->data.note.velocity);
+                       break;
+               case SND_SEQ_EVENT_KEYPRESS:
+                       //printf("Keypress, channel: %d note: %d vol: %d\n",event->data.note.channel,event->data.note.note,event->data.note.velocity);
+                       queue_midi(jvst,0xa0+event->data.note.channel,event->data.note.note,event->data.note.velocity);
+                       break;
+               case SND_SEQ_EVENT_CONTROLLER:
+                       queue_midi(jvst,0xb0+event->data.control.channel,event->data.control.param,event->data.control.value);
+                       //printf("Control: %d %d %d\n",event->data.control.channel,event->data.control.param,event->data.control.value);
+                       break;
+               case SND_SEQ_EVENT_PITCHBEND:
+                       val=event->data.control.value + 0x2000;
+                       queue_midi(jvst,0xe0+event->data.control.channel,val&127,val>>7);
+                       //printf("Pitch: %d %d %d\n",event->data.control.channel,event->data.control.param,event->data.control.value);
+                       break;
+               case SND_SEQ_EVENT_CHANPRESS:
+                       //printf("chanpress: %d %d %d\n",event->data.control.channel,event->data.control.param,event->data.control.value);
+                       queue_midi(jvst,0xd0+event->data.control.channel,event->data.control.value,0);
+                       break;
+               case SND_SEQ_EVENT_PGMCHANGE:
+                       //printf("pgmchange: %d %d %d\n",event->data.control.channel,event->data.control.param,event->data.control.value);
+                       queue_midi(jvst,0xc0+event->data.control.channel,event->data.control.value,0);
+                       break;
+               default:
+                       //printf("Unknown type: %d\n",event->type);
+                       break;
+               }
+       }
+       
+       return NULL;
+}
+
+void stop_midireceiver (JackVST *jvst)
+{
+       int err; 
+       snd_seq_event_t event;
+       snd_seq_t *seq2 = create_sequencer ("jfstquit", true);
+       
+       jvst->midiquit = 1;
+       
+       snd_seq_connect_to (seq2, 0, snd_seq_client_id (jvst->seq),0);
+       snd_seq_ev_clear      (&event);
+       snd_seq_ev_set_direct (&event);
+       snd_seq_ev_set_subs   (&event);
+       snd_seq_ev_set_source (&event, 0);
+       snd_seq_ev_set_controller (&event,1,0x80,50);
+       
+       if ((err = snd_seq_event_output (seq2, &event)) < 0) {
+               fst_error ("cannot send stop event to midi thread: %s\n",
+                          snd_strerror (err));
+       }
+
+       snd_seq_drain_output (seq2);
+       snd_seq_close (seq2);
+       pthread_join (jvst->midi_thread,NULL);
+       snd_seq_close (jvst->seq);
+}
+
+
+
diff --git a/libs/fst/vstwin.c b/libs/fst/vstwin.c
new file mode 100644 (file)
index 0000000..8911ff4
--- /dev/null
@@ -0,0 +1,583 @@
+#include <stdio.h>
+#include <libgen.h>
+#include <windows.h>
+#include <winnt.h>
+#include <wine/exception.h>
+#include <pthread.h>
+#include <signal.h>
+
+//#include <x11/xlib.h>
+//#include <x11/xresource.h>
+//#include <x11/xutil.h>
+//#include <x11/xatom.h>
+
+#include "fst.h"
+
+
+struct ERect{
+    short top;
+    short left;
+    short bottom;
+    short right;
+};
+
+static pthread_mutex_t plugin_mutex = PTHREAD_MUTEX_INITIALIZER;
+static FST* fst_first = NULL;
+
+DWORD  gui_thread_id = 0;
+
+static char* message_name (int message)
+{
+       switch (message) {
+       case 0x0000:
+               return "WM_NULL";
+
+       case 0x0001:
+               return "WM_CREATE";
+
+       case 0x0002:
+               return "WM_DESTROY";
+
+       case 0x0003:
+               return "WM_MOVE";
+
+       case 0x0004:
+               return "WM_SIZEWAIT";
+
+       case 0x0005:
+               return "WM_SIZE";
+
+       case 0x0006:
+               return "WM_ACTIVATE";
+
+       case 0x0007:
+               return "WM_SETFOCUS";
+
+       case 0x0008:
+               return "WM_KILLFOCUS";
+
+       case 0x0009:
+               return "WM_SETVISIBLE";
+
+       case 0x000a:
+               return "WM_ENABLE";
+
+       case 0x000b:
+               return "WM_SETREDRAW";
+
+       case 0x000c:
+               return "WM_SETTEXT";
+
+       case 0x000d:
+               return "WM_GETTEXT";
+
+       case 0x000e:
+               return "WM_GETTEXTLENGTH";
+
+       case 0x000f:
+               return "WM_PAINT";
+
+       case 0x0010:
+               return "WM_CLOSE";
+
+       case 0x0011:
+               return "WM_QUERYENDSESSION";
+
+       case 0x0012:
+               return "WM_QUIT";
+
+       case 0x0013:
+               return "WM_QUERYOPEN";
+
+       case 0x0014:
+               return "WM_ERASEBKGND";
+
+       case 0x0015:
+               return "WM_SYSCOLORCHANGE";
+
+       case 0x0016:
+               return "WM_ENDSESSION";
+
+       case 0x0017:
+               return "WM_SYSTEMERROR";
+
+       case 0x0018:
+               return "WM_SHOWWINDOW";
+
+       case 0x0019:
+               return "WM_CTLCOLOR";
+
+       case 0x001a:
+               return "WM_WININICHANGE";
+
+       case 0x001b:
+               return "WM_DEVMODECHANGE";
+
+       case 0x001c:
+               return "WM_ACTIVATEAPP";
+
+       case 0x001d:
+               return "WM_FONTCHANGE";
+
+       case 0x001e:
+               return "WM_TIMECHANGE";
+
+       case 0x001f:
+               return "WM_CANCELMODE";
+
+       case 0x0020:
+               return "WM_SETCURSOR";
+
+       case 0x0021:
+               return "WM_MOUSEACTIVATE";
+
+       case 0x0022:
+               return "WM_CHILDACTIVATE";
+
+       case 0x0023:
+               return "WM_QUEUESYNC";
+
+       case 0x0024:
+               return "WM_GETMINMAXINFO";
+
+       default:
+               break;
+       }
+       return "--- OTHER ---";
+}
+       
+static LRESULT WINAPI 
+my_window_proc (HWND w, UINT msg, WPARAM wp, LPARAM lp)
+{
+       FST* fst;
+
+//     if (msg != WM_TIMER) {
+//             fst_error ("window callback handler, msg = 0x%x (%s) win=%p\n", msg, message_name (msg), w);
+//     }
+
+       switch (msg) {
+       case WM_KEYUP:
+       case WM_KEYDOWN:
+               break;
+
+       case WM_CLOSE:
+               PostQuitMessage (0);
+
+       case WM_DESTROY:
+       case WM_NCDESTROY:
+               /* we should never get these */
+               //return 0;
+               break;
+
+       case WM_PAINT:
+               if ((fst = GetPropA (w, "fst_ptr")) != NULL) {
+                       if (fst->window && !fst->been_activated) {
+                               fst->been_activated = TRUE;
+                               pthread_cond_signal (&fst->window_status_change);
+                               pthread_mutex_unlock (&fst->lock);
+                       }
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       return DefWindowProcA (w, msg, wp, lp );
+}
+
+static FST* 
+fst_new ()
+{
+       FST* fst = (FST*) calloc (1, sizeof (FST));
+
+       pthread_mutex_init (&fst->lock, NULL);
+       pthread_cond_init (&fst->window_status_change, NULL);
+
+       return fst;
+}
+
+static FSTHandle* 
+fst_handle_new ()
+{
+       FSTHandle* fst = (FSTHandle*) calloc (1, sizeof (FSTHandle));
+       return fst;
+}
+
+int
+fst_create_editor (FST* fst)
+{
+       HMODULE hInst;
+       HWND window;
+
+       /* "guard point" to trap errors that occur during plugin loading */
+
+       /* Note: fst->lock is held while this function is called */
+
+       if (!(fst->plugin->flags & effFlagsHasEditor)) {
+               fst_error ("Plugin \"%s\" has no editor", fst->handle->name);
+               return -1;
+       }
+
+       if ((hInst = GetModuleHandleA (NULL)) == NULL) {
+               fst_error ("can't get module handle");
+               return 1;
+       }
+       
+//     if ((window = CreateWindowExA (WS_EX_TOOLWINDOW | WS_EX_TRAYWINDOW, "FST", fst->handle->name,
+       if ((window = CreateWindowExA (0, "FST", fst->handle->name,
+                                      (WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX),
+                                      0, 0, 1, 1,
+                                      NULL, NULL,
+                                      hInst,
+                                      NULL)) == NULL) {
+               fst_error ("cannot create editor window");
+               return 1;
+       }
+
+       if (!SetPropA (window, "fst_ptr", fst)) {
+               fst_error ("cannot set fst_ptr on window");
+       }
+
+       fst->window = window;
+       fst->xid = (int) GetPropA (window, "__wine_x11_whole_window");
+
+       {
+               struct ERect* er;
+
+               ShowWindow (fst->window, SW_SHOW);
+       
+               fst->plugin->dispatcher (fst->plugin, effEditOpen, 0, 0, fst->window, 0 );
+               fst->plugin->dispatcher (fst->plugin, effEditGetRect, 0, 0, &er, 0 );
+               
+               fst->width =  er->right-er->left;
+               fst->height =  er->bottom-er->top;
+               
+               SetWindowPos (fst->window, 0, 0, 0, er->right-er->left+8, er->bottom-er->top+26, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER);
+       }
+
+       return 0;
+}
+
+void
+fst_destroy_editor (FST* fst)
+{
+       pthread_mutex_lock (&fst->lock);
+       if (fst->window) {
+               fst->destroy = TRUE;
+               if (!PostThreadMessageA (gui_thread_id, WM_USER, 0, 0)) {
+                       fst_error ("could not post message to gui thread");
+               }
+               pthread_cond_wait (&fst->window_status_change, &fst->lock);
+
+       }
+       pthread_mutex_unlock (&fst->lock);
+}
+
+void
+fst_event_loop_remove_plugin (FST* fst)
+{
+       FST* p;
+       FST* prev;
+
+       for (p = fst_first, prev = NULL; p->next; prev = p, p = p->next) {
+               if (p == fst) {
+                       if (prev) {
+                               prev->next = p->next;
+                       }
+               }
+       }
+
+       if (fst_first == fst) {
+               fst_first = fst_first->next;
+       }
+
+}
+
+void debreak( void ) { printf( "debreak\n" ); }
+
+DWORD WINAPI gui_event_loop (LPVOID param)
+{
+       MSG msg;
+       FST* fst;
+       HMODULE hInst;
+       HWND window;
+
+       gui_thread_id = GetCurrentThreadId ();
+
+       /* create a dummy window for timer events */
+
+       if ((hInst = GetModuleHandleA (NULL)) == NULL) {
+               fst_error ("can't get module handle");
+               return 1;
+       }
+       
+       if ((window = CreateWindowExA (0, "FST", "dummy",
+                                      WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX,
+                                      CW_USEDEFAULT, CW_USEDEFAULT,
+                                      CW_USEDEFAULT, CW_USEDEFAULT,
+                                      NULL, NULL,
+                                      hInst,
+                                      NULL )) == NULL) {
+               fst_error ("cannot create dummy timer window");
+       }
+
+       if (!SetTimer (window, 1000, 100, NULL)) {
+               fst_error ("cannot set timer on dummy window");
+       }
+
+       while (GetMessageA (&msg, NULL, 0,0)) {
+               
+           if( msg.message == WM_KEYDOWN ) debreak();
+               TranslateMessage( &msg );
+               DispatchMessageA (&msg);
+
+               /* handle window creation requests, destroy requests, 
+                  and run idle callbacks 
+               */
+               
+
+               if( msg.message == WM_TIMER ) {
+                   pthread_mutex_lock (&plugin_mutex);
+again:
+                   for (fst = fst_first; fst; fst = fst->next) {
+
+                       if (fst->destroy) {
+                           if (fst->window) {
+                               fst->plugin->dispatcher( fst->plugin, effEditClose, 0, 0, NULL, 0.0 );
+                               CloseWindow (fst->window);
+                               fst->window = NULL;
+                               fst->destroy = FALSE;
+                           }
+                           fst_event_loop_remove_plugin (fst);
+                           fst->been_activated = FALSE;
+                           pthread_mutex_lock (&fst->lock);
+                           pthread_cond_signal (&fst->window_status_change);
+                           pthread_mutex_unlock (&fst->lock);
+                           goto again;
+                       } 
+
+                       if (fst->window == NULL) {
+                           pthread_mutex_lock (&fst->lock);
+                           if (fst_create_editor (fst)) {
+                               fst_error ("cannot create editor for plugin %s", fst->handle->name);
+                               fst_event_loop_remove_plugin (fst);
+                               pthread_cond_signal (&fst->window_status_change);
+                               pthread_mutex_unlock (&fst->lock);
+                               goto again;
+                           }
+                           /* condition/unlock handled when we receive WM_ACTIVATE */
+                       }
+
+                       fst->plugin->dispatcher (fst->plugin, effEditIdle, 0, 0, NULL, 0);
+                   }
+                   pthread_mutex_unlock (&plugin_mutex);
+               }
+       }
+       fst_error ("FST GUI event loop has quit!");
+       return 0;
+}
+
+int
+fst_init ()
+{
+       WNDCLASSA wc;
+       HMODULE hInst;
+
+       if ((hInst = GetModuleHandleA (NULL)) == NULL) {
+               fst_error ("can't get module handle");
+               return -1;
+       }
+       wc.style = 0;
+       wc.lpfnWndProc = my_window_proc;
+       wc.cbClsExtra = 0;
+       wc.cbWndExtra = 0;
+       wc.hInstance = hInst;
+       wc.hIcon = LoadIconA( hInst, "FST");
+       wc.hCursor = LoadCursorA( NULL, IDI_APPLICATION );
+       wc.hbrBackground = GetStockObject( BLACK_BRUSH );
+       wc.lpszMenuName = "MENU_FST";
+       wc.lpszClassName = "FST";
+
+       if (!RegisterClassA(&wc)){
+               return 1;
+       }
+
+       if (CreateThread (NULL, 0, gui_event_loop, NULL, 0, NULL) == NULL) {
+               fst_error ("could not create new thread proxy");
+               return -1;
+       }
+
+       return 0;
+}
+
+int
+fst_run_editor (FST* fst)
+{
+       /* Add the FST to the list of all that should be handled by the GUI thread */
+
+       pthread_mutex_lock (&plugin_mutex);
+
+       if (fst_first == NULL) {
+               fst_first = fst;
+       } else {
+               FST* p = fst_first;
+               while (p->next) {
+                       p = p->next;
+               }
+               p->next = fst;
+       }
+
+       if (!PostThreadMessageA (gui_thread_id, WM_USER, 0, 0)) {
+               fst_error ("could not post message to gui thread");
+               return -1;
+       }
+
+       pthread_mutex_unlock (&plugin_mutex);
+
+       /* wait for the plugin editor window to be created (or not) */
+
+       pthread_mutex_lock (&fst->lock);
+       if (!fst->window) {
+               pthread_cond_wait (&fst->window_status_change, &fst->lock);
+       } 
+       pthread_mutex_unlock (&fst->lock);
+
+       if (!fst->window) {
+               fst_error ("no window created for VST plugin editor");
+               return -1;
+       }
+
+       return 0;
+}
+
+FSTHandle*
+fst_load (const char *path)
+{
+       char* buf;
+       FSTHandle* fhandle;
+       char* period;
+
+       fhandle = fst_handle_new ();
+       
+       // XXX: Would be nice to find the correct call for this.
+       //      if the user does not configure Z: to be / we are doomed :(
+
+       if (strstr (path, ".dll") == NULL) {
+
+               buf = (char *) malloc (strlen (path) + 7);
+
+               if( path[0] == '/' ) {
+                   sprintf (buf, "Z:%s.dll", path);
+               } else {
+                   sprintf (buf, "%s.dll", path);
+               }
+
+               fhandle->nameptr = strdup (path);
+
+       } else {
+
+               buf = (char *) malloc (strlen (path) + 3);
+
+               if( path[0] == '/' ) {
+                   sprintf (buf, "Z:%s", path);
+               } else {
+                   sprintf (buf, "%s", path);
+               }
+
+               fhandle->nameptr = strdup (path);
+       }
+       
+       fhandle->name = basename (fhandle->nameptr);
+
+       /* strip off .dll */
+
+       if ((period = strrchr (fhandle->name, '.')) != NULL) {
+               *period = '\0';
+       }
+
+       if ((fhandle->dll = LoadLibraryA (buf)) == NULL) {
+               fst_unload (fhandle);
+               return NULL;
+       }
+
+       if ((fhandle->main_entry = GetProcAddress (fhandle->dll, "main")) == NULL) {
+               fst_unload (fhandle);
+               return NULL;
+       }
+
+       return fhandle;
+}
+
+int
+fst_unload (FSTHandle* fhandle)
+{
+       if (fhandle->plugincnt) {
+               return -1;
+       }
+
+       if (fhandle->dll) {
+               FreeLibrary (fhandle->dll);
+               fhandle->dll = NULL;
+       }
+
+       if (fhandle->nameptr) {
+               free (fhandle->nameptr);
+               fhandle->name = NULL;
+       }
+       
+       free (fhandle);
+       return 0;
+}
+
+FST*
+fst_instantiate (FSTHandle* fhandle, audioMasterCallback amc, void* userptr)
+{
+       FST* fst = fst_new ();
+
+       if( fhandle == NULL ) {
+           fst_error( "the handle was NULL\n" );
+           return NULL;
+       }
+
+       if ((fst->plugin = fhandle->main_entry (amc)) == NULL)  {
+               fst_error ("%s could not be instantiated\n", fhandle->name);
+               free (fst);
+               return NULL;
+       }
+       
+       fst->handle = fhandle;
+       fst->plugin->user = userptr;
+               
+       if (fst->plugin->magic != kEffectMagic) {
+               fst_error ("%s is not a VST plugin\n", fhandle->name);
+               free (fst);
+               return NULL;
+       }
+       
+       fst->plugin->dispatcher (fst->plugin, effOpen, 0, 0, 0, 0);
+       //fst->plugin->dispatcher (fst->plugin, effMainsChanged, 0, 0, NULL, 0);
+
+       fst->handle->plugincnt++;
+
+       return fst;
+}
+
+void
+fst_close (FST* fst)
+{
+       fst_destroy_editor (fst);
+
+       fst->plugin->dispatcher (fst->plugin, effMainsChanged, 0, 0, NULL, 0);
+       fst->plugin->dispatcher (fst->plugin, effClose, 0, 0, 0, 0);
+
+       if (fst->handle->plugincnt) {
+               --fst->handle->plugincnt;
+       }
+}
+
+int
+fst_get_XID (FST* fst)
+{
+       return fst->xid;
+}
index 50d6114deeb492eb172f301da255f17c3b3cdb7e..55a6bebb02ba1313a48543054f118e9b39bbe730 100644 (file)
@@ -43,6 +43,7 @@
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace Glib;
+using namespace PBD;
 using std::map;
 
 pthread_t UI::gui_thread;
index 00db129d6be3893ddc0b83eeb5aaf1161e56dfbd..7302de66e72f82bb9817de8872ecd79773c8243f 100644 (file)
@@ -25,7 +25,6 @@
 #include <gtkmm2ext/selector.h>
 #include <gtkmm2ext/utils.h>
 #include <pbd/pathscanner.h>
-#include <pbd/error.h>
 
 using namespace std;
 using namespace Gtkmm2ext;
index ef387e7c49745cf477baf06ebd7bbd11ea5267f2..81d81c8558cffe83c0343dde69ea158582b8fbd6 100644 (file)
@@ -29,6 +29,7 @@
 
 using namespace std;
 using namespace MIDI;
+using namespace PBD;
 
 string *FD_MidiPort::midi_dirpath = 0;
 string *FD_MidiPort::midi_filename_pattern = 0;
index 24bc38125500d7352fad5a6875b7b75aa8304cd9..bb9867885449cc8a7dd81405815a29dc818bf8b3 100644 (file)
@@ -26,6 +26,7 @@
 
 using namespace sigc;
 using namespace MIDI;
+using namespace PBD;
 
 Controllable::Controllable (Port *p, bool is_bistate)
 {
index 8282ed04982dad631339f2ccae32ddc535690678..bfe8f147b68874b5964169ac0b47420806d81c5f 100644 (file)
@@ -31,6 +31,7 @@
 
 using namespace std;
 using namespace MIDI;
+using namespace PBD;
 
 Manager *Manager::theManager = 0;
 
index 3e1aefd4ebffe47ed86e1fa9507aff7cf3e8fb2e..61c47e856f96d82edd7e21ab74b6d17ccc40c116 100644 (file)
@@ -27,6 +27,7 @@
 
 using namespace std;
 using namespace MIDI;
+using namespace PBD;
 
 static std::map<int,string> mmc_cmd_map;
 static void build_mmc_cmd_map ()
index 25ea964dedf4c47e0c0dfbeb506a3e18e1655109..36fbd61124d9e1321e6205fe754378a954f29ca2 100644 (file)
@@ -16,6 +16,7 @@ TextReceiver text_receiver ("mmctest");
 #include "midi++/mmc.h"
 
 using namespace MIDI;
+using namespace PBD;
 
 Port *port;
 PortRequest midi_device;
index 4d1b2a8681b9c16fb69e00c88a237d84803a60e6..2766b3c5eda15f62027acbdf12164f6cf936c314 100644 (file)
@@ -10,7 +10,7 @@ pbd3 = env.Copy()
 
 domain = 'libpbd'
 
-pbd3.Append(DOMAIN=domain,MAJOR=3,MINOR=2,MICRO=0)
+pbd3.Append(DOMAIN=domain,MAJOR=4,MINOR=0,MICRO=0)
 pbd3.Append(CXXFLAGS="-DPACKAGE=\\\"" + domain + "\\\"")
 pbd3.Append(CXXFLAGS="-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE")
 pbd3.Append(CXXFLAGS="-DLIBSIGC_DISABLE_DEPRECATED")
@@ -21,8 +21,8 @@ pbd3_files = Split("""
 basename.cc
 base_ui.cc
 convert.cc
-dirname.cc
 dmalloc.cc
+error.cc
 mountpoint.cc
 pathscanner.cc
 pool.cc
@@ -33,7 +33,6 @@ strsplit.cc
 textreceiver.cc
 transmitter.cc
 undo.cc
-unescape.cc
 version.cc
 whitespace.cc
 xml++.cc
@@ -46,7 +45,7 @@ if conf.CheckCHeader('execinfo.h'):
     conf.env.Append(CXXFLAGS="-DHAVE_EXECINFO")
 pbd3 = conf.Finish()
 
-pbd3.Merge ([ libraries['sigc2'], libraries['xml'] ])
+pbd3.Merge ([ libraries['sigc2'], libraries['xml'], libraries['glibmm2'], libraries['glib2'] ])
 
 pbd3.VersionBuild(['version.cc','pbd/version.h'], 'SConscript')
 
@@ -60,7 +59,7 @@ if env['NLS']:
 env.Alias('install', env.Install(os.path.join(install_prefix, 'lib/ardour2'), libpbd3))
 
 env.Alias('tarball', env.Distribute (env['DISTTREE'],
-                                     [ 'SConscript', 'i18n.h' ] +
+                                     [ 'SConscript', 'i18n.h', 'gettext.h', 'pbd/abstract_ui.cc' ] +
                                      pbd3_files +
                                      glob.glob('po/*.po') +
                                      glob.glob('pbd/*.h')))
index 5598b20021d8f2b735ea9ae470c8c841ce6f231a..d3c8d5e4c77ca436b2253fbce44ae8d52473a5f8 100644 (file)
@@ -11,6 +11,7 @@
 #include "i18n.h"
 
 using namespace std;
+using namespace PBD;
        
 uint32_t BaseUI::rt_bit = 1;
 BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type();
index b8c5c64d91f6f7139bff5fded0319fdf0961b057..a51e393b78498845a671a60244a888b8a16a9e52 100644 (file)
@@ -2,37 +2,10 @@
 #include <string.h>
 #include <pbd/basename.h>
 
-char *
-PBD::basename (const char *path)
-
-{
-       char *slash;
-
-       if ((slash = strrchr (path, '/')) == 0) {
-               return strdup (path);
-       }
-       
-       if (*(slash+1) == '\0') {
-               return strdup ("");
-       }
-       
-       return strdup (slash+1);
-}
-
-std::string 
-PBD::basename (const std::string str)
-{
-       std::string::size_type slash = str.find_last_of ('/');
-
-       if (slash == std::string::npos) {
-               return str;
-       } 
-
-       return str.substr (slash+1);
-}
 
+// implement this using Glib::path_get_basename
 std::string 
-PBD::basename_nosuffix (const std::string str)
+PBD::basename_nosuffix (const std::string& str)
 {
        std::string::size_type slash = str.find_last_of ('/');
        std::string noslash;
index 5b96284a901ea5d6a0714e74b4cf9aceb146c231..2af227a3a03743935bde875aa592df7c9ca668ff 100644 (file)
@@ -27,6 +27,8 @@
 #include <pbd/pathscanner.h>
 #include <pbd/stl_delete.h>
 
+using namespace PBD;
+
 vector<string *> *
 PathScanner::operator() (const string &dirpath, const string &regexp,
                         bool match_fullpath, bool return_fullpath, 
index 06cf1665a3a4e99fcee8fe21b7b5ad4f4891ea6b..0e34787a2dbee8a4931217f34e1088d021e27b11 100644 (file)
@@ -29,7 +29,7 @@ AbstractUI<RequestObject>::register_thread_with_request_count (pthread_t thread_
        RequestBuffer* b = new RequestBuffer (num_requests);
 
        {
-               PBD::LockMonitor lm (request_buffer_map_lock, __LINE__, __FILE__);
+        Glib::Mutex::Lock lm (request_buffer_map_lock);
                request_buffers[thread_id] = b;
        }
 
index 98f077cb485fb677545d4a0644fd69461bb835ca..f80db7bf1a155341c0209f486ef2f9fc7e2fe2d5 100644 (file)
@@ -27,8 +27,9 @@
 
 #include <sigc++/sigc++.h>
 
+#include <glibmm/thread.h>
+
 #include <pbd/receiver.h>
-#include <pbd/lockmonitor.h>
 #include <pbd/ringbufferNPT.h>
 #include <pbd/base_ui.h>
 
@@ -62,7 +63,7 @@ class AbstractUI : public BaseUI
        typedef typename RequestBuffer::rw_vector RequestBufferVector;
        typedef typename std::map<pthread_t,RequestBuffer*>::iterator RequestBufferMapIterator;
 
-       PBD::Lock request_buffer_map_lock;
+    Glib::Mutex request_buffer_map_lock;
        typedef std::map<pthread_t,RequestBuffer*> RequestBufferMap;
        RequestBufferMap request_buffers;
        pthread_key_t thread_request_buffer_key;
index 01f40b6b6ac4f171c7a60154b18ef2ac6ae44a08..35aebe166c1da5d75a4c360a728619f8dca5fee2 100644 (file)
@@ -6,9 +6,7 @@
 namespace PBD
 {
        
-extern char *basename (const char *);
-extern std::string basename (const std::string);
-extern std::string basename_nosuffix (const std::string);
+extern std::string basename_nosuffix (const std::string&);
 
 };
 
index cb822e6210888ad8702bdbca6c3b9fe72c62b095..4136f02ee225d1e02fc3adfb625a0f810576db5f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 1998-99 Paul Barton-Davis
+    Copyright (C) 1998-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
 
     $Id$
 */
-#ifndef __libmisc_error_h__
-#define __libmisc_error_h__
+#ifndef __libpbd_error_h__
+#define __libpbd_error_h__
 
 #include "transmitter.h"
 
-extern Transmitter error;
-extern Transmitter info;
-extern Transmitter warning;
-extern Transmitter fatal;
+namespace PBD {
+       extern Transmitter error;
+       extern Transmitter info;
+       extern Transmitter warning;
+       extern Transmitter fatal;
+}
 
-#endif  // __libmisc_error_h__
+#endif  // __libpbd_error_h__
index c8e9740acd4b81d8dcaaf183de0f92984b9e28d1..f8e19e72fb9281ec360026693062a330dd2a06cd 100644 (file)
@@ -23,7 +23,9 @@
 
 #include <vector>
 #include <string>
-#include <pthread.h>
+
+#include <glibmm/thread.h>
+
 #include <pbd/ringbuffer.h>
 
 class Pool 
@@ -53,7 +55,7 @@ class SingleAllocMultiReleasePool : public Pool
        virtual void release (void *);
 
   private:
-       pthread_mutex_t lock;
+    Glib::Mutex* m_lock;
 };
 
 
@@ -67,8 +69,7 @@ class MultiAllocSingleReleasePool : public Pool
        virtual void release (void *);
 
   private:
-       pthread_mutex_t lock;
+    Glib::Mutex* m_lock;
 };
 
-
 #endif // __qm_pool_h__
index d276d190863286368179bacd463f4352b2546cde..1d9c9b04e333990d2ba610e8cab6dcb170506d55 100644 (file)
@@ -21,8 +21,9 @@
 #ifndef ringbuffer_h
 #define ringbuffer_h
 
-#include <sys/mman.h>
-#include <pbd/atomic.h>
+//#include <sys/mman.h>
+
+#include <glib.h>
 
 template<class T>
 class RingBuffer 
@@ -47,14 +48,14 @@ class RingBuffer
 
        void reset () {
                /* !!! NOT THREAD SAFE !!! */
-               atomic_set (&write_ptr, 0);
-               atomic_set (&read_ptr, 0);
+               g_atomic_int_set (&write_ptr, 0);
+               g_atomic_int_set (&read_ptr, 0);
        }
 
        void set (size_t r, size_t w) {
                /* !!! NOT THREAD SAFE !!! */
-               atomic_set (&write_ptr, w);
-               atomic_set (&read_ptr, r);
+               g_atomic_int_set (&write_ptr, w);
+               g_atomic_int_set (&read_ptr, r);
        }
        
        size_t  read  (T *dest, size_t cnt);
@@ -69,22 +70,22 @@ class RingBuffer
        void get_write_vector (rw_vector *);
        
        void decrement_read_ptr (size_t cnt) {
-               atomic_set (&read_ptr, (atomic_read(&read_ptr) - cnt) & size_mask);
+               g_atomic_int_set (&read_ptr, (g_atomic_int_get(&read_ptr) - cnt) & size_mask);
        }                
 
        void increment_read_ptr (size_t cnt) {
-               atomic_set (&read_ptr, (atomic_read(&read_ptr) + cnt) & size_mask);
+               g_atomic_int_set (&read_ptr, (g_atomic_int_get(&read_ptr) + cnt) & size_mask);
        }                
 
        void increment_write_ptr (size_t cnt) {
-               atomic_set (&write_ptr,  (atomic_read(&write_ptr) + cnt) & size_mask);
+               g_atomic_int_set (&write_ptr,  (g_atomic_int_get(&write_ptr) + cnt) & size_mask);
        }                
 
        size_t write_space () {
                size_t w, r;
                
-               w = atomic_read (&write_ptr);
-               r = atomic_read (&read_ptr);
+               w = g_atomic_int_get (&write_ptr);
+               r = g_atomic_int_get (&read_ptr);
                
                if (w > r) {
                        return ((r - w + size) & size_mask) - 1;
@@ -98,8 +99,8 @@ class RingBuffer
        size_t read_space () {
                size_t w, r;
                
-               w = atomic_read (&write_ptr);
-               r = atomic_read (&read_ptr);
+               w = g_atomic_int_get (&write_ptr);
+               r = g_atomic_int_get (&read_ptr);
                
                if (w > r) {
                        return w - r;
@@ -109,8 +110,8 @@ class RingBuffer
        }
 
        T *buffer () { return buf; }
-       size_t get_write_ptr () const { return atomic_read (&write_ptr); }
-       size_t get_read_ptr () const { return atomic_read (&read_ptr); }
+       size_t get_write_ptr () const { return g_atomic_int_get (&write_ptr); }
+       size_t get_read_ptr () const { return g_atomic_int_get (&read_ptr); }
        size_t bufsize () const { return size; }
 
   protected:
@@ -130,7 +131,7 @@ RingBuffer<T>::read (T *dest, size_t cnt)
         size_t n1, n2;
         size_t priv_read_ptr;
 
-        priv_read_ptr=atomic_read(&read_ptr);
+        priv_read_ptr=g_atomic_int_get(&read_ptr);
 
         if ((free_cnt = read_space ()) == 0) {
                 return 0;
@@ -156,7 +157,7 @@ RingBuffer<T>::read (T *dest, size_t cnt)
                 priv_read_ptr = n2;
         }
 
-        atomic_set(&read_ptr, priv_read_ptr);
+        g_atomic_int_set(&read_ptr, priv_read_ptr);
         return to_read;
 }
 
@@ -170,7 +171,7 @@ RingBuffer<T>::write (T *src, size_t cnt)
         size_t n1, n2;
         size_t priv_write_ptr;
 
-        priv_write_ptr=atomic_read(&write_ptr);
+        priv_write_ptr=g_atomic_int_get(&write_ptr);
 
         if ((free_cnt = write_space ()) == 0) {
                 return 0;
@@ -196,7 +197,7 @@ RingBuffer<T>::write (T *src, size_t cnt)
                 priv_write_ptr = n2;
         }
 
-        atomic_set(&write_ptr, priv_write_ptr);
+        g_atomic_int_set(&write_ptr, priv_write_ptr);
         return to_write;
 }
 
@@ -208,8 +209,8 @@ RingBuffer<T>::get_read_vector (RingBuffer<T>::rw_vector *vec)
        size_t cnt2;
        size_t w, r;
        
-       w = atomic_read (&write_ptr);
-       r = atomic_read (&read_ptr);
+       w = g_atomic_int_get (&write_ptr);
+       r = g_atomic_int_get (&read_ptr);
        
        if (w > r) {
                free_cnt = w - r;
@@ -248,8 +249,8 @@ RingBuffer<T>::get_write_vector (RingBuffer<T>::rw_vector *vec)
        size_t cnt2;
        size_t w, r;
        
-       w = atomic_read (&write_ptr);
-       r = atomic_read (&read_ptr);
+       w = g_atomic_int_get (&write_ptr);
+       r = g_atomic_int_get (&read_ptr);
        
        if (w > r) {
                free_cnt = ((r - w + size) & size_mask) - 1;
index ccfcae42a55e07c44620936ada7f787c894c23c3..fee2efce3d8c78c4900eb09d0cb08580bf04c456 100644 (file)
 #ifndef ringbuffer_npt_h
 #define ringbuffer_npt_h
 
-#include <sys/mman.h>
-#include <pbd/atomic.h>
+//#include <sys/mman.h>
+
+#include <glib.h>
+
+/* ringbuffer class where the element size is not required to be a power of two */
 
-/** Ringbuffer class where the element size is not required to be a
- * power of two.
- */
 template<class T>
 class RingBufferNPT
 {
@@ -44,14 +44,14 @@ class RingBufferNPT
 
        void reset () {
                /* !!! NOT THREAD SAFE !!! */
-               atomic_set (&write_ptr, 0);
-               atomic_set (&read_ptr, 0);
+               g_atomic_int_set (&write_ptr, 0);
+               g_atomic_int_set (&read_ptr, 0);
        }
 
        void set (size_t r, size_t w) {
                /* !!! NOT THREAD SAFE !!! */
-               atomic_set (&write_ptr, w);
-               atomic_set (&read_ptr, r);
+               g_atomic_int_set (&write_ptr, w);
+               g_atomic_int_set (&read_ptr, r);
        }
        
        size_t  read  (T *dest, size_t cnt);
@@ -66,22 +66,22 @@ class RingBufferNPT
        void get_write_vector (rw_vector *);
        
        void decrement_read_ptr (size_t cnt) {
-               atomic_set (&read_ptr, (atomic_read(&read_ptr) - cnt) % size);
+               g_atomic_int_set (&read_ptr, (g_atomic_int_get(&read_ptr) - cnt) % size);
        }                
 
        void increment_read_ptr (size_t cnt) {
-               atomic_set (&read_ptr, (atomic_read(&read_ptr) + cnt) % size);
+               g_atomic_int_set (&read_ptr, (g_atomic_int_get(&read_ptr) + cnt) % size);
        }                
 
        void increment_write_ptr (size_t cnt) {
-               atomic_set (&write_ptr,  (atomic_read(&write_ptr) + cnt) % size);
+               g_atomic_int_set (&write_ptr,  (g_atomic_int_get(&write_ptr) + cnt) % size);
        }                
 
        size_t write_space () {
                size_t w, r;
                
-               w = atomic_read (&write_ptr);
-               r = atomic_read (&read_ptr);
+               w = g_atomic_int_get (&write_ptr);
+               r = g_atomic_int_get (&read_ptr);
                
                if (w > r) {
                        return ((r - w + size) % size) - 1;
@@ -95,8 +95,8 @@ class RingBufferNPT
        size_t read_space () {
                size_t w, r;
                
-               w = atomic_read (&write_ptr);
-               r = atomic_read (&read_ptr);
+               w = g_atomic_int_get (&write_ptr);
+               r = g_atomic_int_get (&read_ptr);
                
                if (w > r) {
                        return w - r;
@@ -106,8 +106,8 @@ class RingBufferNPT
        }
 
        T *buffer () { return buf; }
-       size_t get_write_ptr () const { return atomic_read (&write_ptr); }
-       size_t get_read_ptr () const { return atomic_read (&read_ptr); }
+       size_t get_write_ptr () const { return g_atomic_int_get (&write_ptr); }
+       size_t get_read_ptr () const { return g_atomic_int_get (&read_ptr); }
        size_t bufsize () const { return size; }
 
   protected:
@@ -126,7 +126,7 @@ RingBufferNPT<T>::read (T *dest, size_t cnt)
         size_t n1, n2;
         size_t priv_read_ptr;
 
-        priv_read_ptr=atomic_read(&read_ptr);
+        priv_read_ptr=g_atomic_int_get(&read_ptr);
 
         if ((free_cnt = read_space ()) == 0) {
                 return 0;
@@ -152,7 +152,7 @@ RingBufferNPT<T>::read (T *dest, size_t cnt)
                 priv_read_ptr = n2;
         }
 
-        atomic_set(&read_ptr, priv_read_ptr);
+        g_atomic_int_set(&read_ptr, priv_read_ptr);
         return to_read;
 }
 
@@ -165,7 +165,7 @@ RingBufferNPT<T>::write (T *src, size_t cnt)
         size_t n1, n2;
         size_t priv_write_ptr;
 
-        priv_write_ptr=atomic_read(&write_ptr);
+        priv_write_ptr=g_atomic_int_get(&write_ptr);
 
         if ((free_cnt = write_space ()) == 0) {
                 return 0;
@@ -191,7 +191,7 @@ RingBufferNPT<T>::write (T *src, size_t cnt)
                 priv_write_ptr = n2;
         }
 
-        atomic_set(&write_ptr, priv_write_ptr);
+        g_atomic_int_set(&write_ptr, priv_write_ptr);
         return to_write;
 }
 
@@ -202,8 +202,8 @@ RingBufferNPT<T>::get_read_vector (RingBufferNPT<T>::rw_vector *vec)
        size_t cnt2;
        size_t w, r;
        
-       w = atomic_read (&write_ptr);
-       r = atomic_read (&read_ptr);
+       w = g_atomic_int_get (&write_ptr);
+       r = g_atomic_int_get (&read_ptr);
        
        if (w > r) {
                free_cnt = w - r;
@@ -241,8 +241,8 @@ RingBufferNPT<T>::get_write_vector (RingBufferNPT<T>::rw_vector *vec)
        size_t cnt2;
        size_t w, r;
        
-       w = atomic_read (&write_ptr);
-       r = atomic_read (&read_ptr);
+       w = g_atomic_int_get (&write_ptr);
+       r = g_atomic_int_get (&read_ptr);
        
        if (w > r) {
                free_cnt = ((r - w + size) % size) - 1;
index 07fc266bcefdcb425b6e6d7eec44c8349363aab2..357cb9965fcffc6be67d7ea5f3ef1977c12c17d5 100644 (file)
@@ -104,6 +104,7 @@ endmsg (std::ostream &ostr)
        return ostr;
 }
 
+
 extern "C" { void pbd_c_error (const char *); }
 
 #endif // __libmisc_transmitter_h__
index f05d88381c2912ded9a1b90377aa48c21fbdccda..089766482d0c7c54500358b038219344f301fa96 100644 (file)
 */
 
 #include <iostream>
-#include <sys/mman.h>
 #include <vector>
 
 #include <pbd/pool.h>
 #include <pbd/error.h>
-#include <pbd/stl_delete.h>
-#include <pbd/pthread_utils.h>
 
 using namespace std;
+using namespace PBD;
 
 Pool::Pool (string n, unsigned long item_size, unsigned long nitems)
 {
@@ -84,32 +82,39 @@ Pool::release (void *ptr)
 /*---------------------------------------------*/
 
 MultiAllocSingleReleasePool::MultiAllocSingleReleasePool (string n, unsigned long isize, unsigned long nitems) 
-       : Pool (n, isize, nitems)
+       : Pool (n, isize, nitems),
+        m_lock(0)
 {
-       pthread_mutex_init (&lock, 0);
 }
 
 MultiAllocSingleReleasePool::~MultiAllocSingleReleasePool ()
 {
+    if(m_lock) delete m_lock;
 }
 
 SingleAllocMultiReleasePool::SingleAllocMultiReleasePool (string n, unsigned long isize, unsigned long nitems) 
-       : Pool (n, isize, nitems)
+       : Pool (n, isize, nitems),
+    m_lock(0)
 {
-       pthread_mutex_init (&lock, 0);
 }
 
 SingleAllocMultiReleasePool::~SingleAllocMultiReleasePool ()
 {
+    if(m_lock) delete m_lock;
 }
 
 void*
 MultiAllocSingleReleasePool::alloc ()
 {
        void *ptr;
-       pthread_mutex_lock (&lock);
+    if(!m_lock) {
+        m_lock = new Glib::Mutex();
+        // umm, I'm not sure that this doesn't also allocate memory.
+        if(!m_lock) error << "cannot create Glib::Mutex in pool.cc" << endmsg;
+    }
+    
+    Glib::Mutex::Lock guard(*m_lock);
        ptr = Pool::alloc ();
-       pthread_mutex_unlock (&lock);
        return ptr;
 }
 
@@ -128,8 +133,12 @@ SingleAllocMultiReleasePool::alloc ()
 void
 SingleAllocMultiReleasePool::release (void* ptr)
 {
-       pthread_mutex_lock (&lock);
+    if(!m_lock) {
+        m_lock = new Glib::Mutex();
+        // umm, I'm not sure that this doesn't also allocate memory.
+        if(!m_lock) error << "cannot create Glib::Mutex in pool.cc" << endmsg;
+    }
+    Glib::Mutex::Lock guard(*m_lock);
        Pool::release (ptr);
-       pthread_mutex_unlock (&lock);
 }
 
index 63f676a04fe7b64c3c636b6fec3592751c59a62b..876a9d86e5353cb70e7abcc0f40dc09f36ed31d3 100644 (file)
 #include <string>
 
 #include <pbd/transmitter.h>
+#include <pbd/error.h>
 
 using std::string;
 using std::ios;
 
-Transmitter  error (Transmitter::Error);
-Transmitter  info (Transmitter::Info);
-Transmitter  fatal (Transmitter::Fatal);
-Transmitter  warning (Transmitter::Warning);
-
 Transmitter::Transmitter (Channel c)
-
 {
        channel = c;
        switch (c) {
@@ -110,11 +105,11 @@ Transmitter::does_not_return ()
        }
 }
 
+
 extern "C" {
   void pbd_c_error (const char *str)
  
   {
-       extern Transmitter error;
-       error << str << endmsg;
+       PBD::error << str << endmsg;
   }
 }
index 0af1cc2e7a54ce13ce95eea40c6c17ae0658116c..f2f11b1c5cc3fc4b9546f50ebafc89ca76a92540 100644 (file)
@@ -77,6 +77,7 @@ UndoCommand::clear ()
 void
 UndoCommand::undo ()
 {
+       cerr << "Undo " << _name << endl;
        for (list<UndoAction>::reverse_iterator i = undo_actions.rbegin(); i != undo_actions.rend(); ++i) {
                (*i)();
        }
@@ -85,6 +86,7 @@ UndoCommand::undo ()
 void
 UndoCommand::redo ()
 {
+       cerr << "Redo " << _name << endl;
        for (list<UndoAction>::iterator i = redo_actions.begin(); i != redo_actions.end(); ++i) {
                (*i)();
        }
index 619f65678a21f03341ed0de9c992fa6ada2a40a6..ee8fa95bc262d51f904a47d4d62435feb5719ebd 100644 (file)
@@ -41,6 +41,7 @@
 using namespace ARDOUR;
 using namespace std;
 using namespace sigc;
+using namespace PBD;
 
 #include "i18n.h"
 
diff --git a/vst/SConscript b/vst/SConscript
new file mode 100644 (file)
index 0000000..fead9ba
--- /dev/null
@@ -0,0 +1,54 @@
+# -*- python -*-
+
+import os
+import os.path
+import glob
+
+Import('env install_prefix final_prefix config_prefix libraries')
+
+ardour_vst = env.Copy()
+
+sources = Split ("""
+winmain.c
+#libs/fst/fst.o
+#libs/fst/fstinfofile.o
+#libs/fst/vstwin.o
+#libs/fst/vsti.o
+"""
+)
+
+ardour_vst.Append (CCFLAGS="-DVST_SUPPORT", CPPPATH="#libs/fst", LIBPATH='#gtk2_ardour')
+ardour_vst.Append (LINKFLAGS='-L/usr/X11R6/lib -lasound -lardourgtk -lX11 -lpthread') 
+ardour_vst["CC"] ="winegcc"
+ardour_vst["LINK"] ="wineg++ -mwindows"
+
+ardour_vst.Merge ([
+    libraries['ardour'],
+    libraries['ardour_cp'],
+    libraries['gtkmm2ext'],
+    libraries['midi++2'],
+    libraries['pbd3'],
+    libraries['gtkmm2'],
+    libraries['glib2'],
+    libraries['libgnomecanvas2'],
+    libraries['libgnomecanvasmm'],
+    libraries['sysmidi'],
+    libraries['sndfile'],
+    libraries['flac'],
+    libraries['lrdf'],
+    libraries['glibmm2'],
+    libraries['pangomm'],
+    libraries['atkmm'],
+    libraries['gdkmm2'],
+    libraries['sigc2'],
+    libraries['gtk2'],
+    libraries['xml'],
+    libraries['xslt'],
+    libraries['soundtouch'],
+    libraries['samplerate'],
+    libraries['jack']
+])
+
+wine_executable = ardour_vst.Program (target = 'ardour_vst', source = sources)
+
+Default(wine_executable)
diff --git a/vst/winmain.c b/vst/winmain.c
new file mode 100644 (file)
index 0000000..c2ad5fc
--- /dev/null
@@ -0,0 +1,17 @@
+#include <limits.h>
+#include <unistd.h>
+#include <stdio.h>
+
+extern int ardour_main(int argc, char* argv[]);
+
+int
+main (int argc, char* argv[]) 
+{
+    // call the user specified main function    
+    
+       int result = ardour_main(argc, argv);
+       printf ("main returned %d\n", result);
+       
+       return result;
+
+}