From ac1a2557065726e31a4c9dfaec97b29393e043d8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 15 Jan 2008 17:23:57 +0000 Subject: [PATCH] Merge with trunk R2920. git-svn-id: svn://localhost/ardour2/trunk@2921 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 7 ++- gtk2_ardour/editor_canvas_events.cc | 4 +- gtk2_ardour/editor_mouse.cc | 6 +- gtk2_ardour/editor_ops.cc | 8 ++- gtk2_ardour/engine_dialog.cc | 94 +++++++++++++++++++---------- gtk2_ardour/engine_dialog.h | 2 +- gtk2_ardour/plugin_ui.cc | 5 ++ gtk2_ardour/selection.cc | 62 ++++++++++++------- libs/ardour/configuration.cc | 63 +++++++++++++------ libs/ardour/session.cc | 50 +++++++-------- libs/ardour/session_state.cc | 9 ++- svn_revision.h | 2 +- 12 files changed, 202 insertions(+), 110 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index ca77ccb903..44a3d171c6 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -239,7 +239,10 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) /* lets get this party started */ try { - ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization); + if (ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization)) { + throw failed_constructor (); + } + setup_gtk_ardour_enums (); Config->set_current_owner (ConfigVariableBase::Interface); setup_profile (); @@ -247,7 +250,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) } catch (failed_constructor& err) { error << _("could not initialize Ardour.") << endmsg; // pass it on up - throw err; + throw; } /* we like keyboards */ diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index ec43d1bac0..a69dcf935a 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -133,7 +133,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) break; case GDK_SCROLL_LEFT: - xdelta = (current_page_frames() / 2); + xdelta = (current_page_frames() / 8); if (leftmost_frame > xdelta) { reset_x_origin (leftmost_frame - xdelta); } else { @@ -142,7 +142,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) break; case GDK_SCROLL_RIGHT: - xdelta = (current_page_frames() / 2); + xdelta = (current_page_frames() / 8); if (max_frames - xdelta > leftmost_frame) { reset_x_origin (leftmost_frame + xdelta); } else { diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 048277fea7..06f0243805 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -3072,7 +3072,7 @@ Editor::possibly_copy_regions_during_grab (GdkEvent* event) /* reset selection to new regionviews */ selection->set (new_regionviews); - + /* reset drag_info data to reflect the fact that we are dragging the copies */ drag_info.data = new_regionviews.front(); @@ -3471,7 +3471,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) pair >::iterator,bool> insert_result; const list& layered_regions = selection->regions.by_layer(); - + for (list::const_iterator i = layered_regions.begin(); i != layered_regions.end(); ++i) { RegionView* rv = (*i); @@ -3866,7 +3866,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event sigc::connection c = rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view)); to_playlist->add_region (newregion, (nframes_t) (where * rtv->get_diskstream()->speed())); c.disconnect (); - + if (!latest_regionviews.empty()) { // XXX why just the first one ? we only expect one rtv->reveal_dependent_views (*latest_regionviews.front()); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 7df3d1dfe9..9f5cb638dd 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1515,6 +1515,12 @@ Editor::temporal_zoom (gdouble fpu) double nfpu; double l; + /* XXX this limit is also in ::set_frames_per_unit() */ + + if (frames_per_unit <= 2.0 && fpu <= frames_per_unit) { + return; + } + nfpu = fpu; new_page_size = (nframes_t) floor (canvas_width * nfpu); @@ -1549,7 +1555,7 @@ Editor::temporal_zoom (gdouble fpu) where = playhead_cursor->current_frame; l = - ((new_page_size * ((where - current_leftmost)/(double)current_page)) - where); - + if (l < 0) { leftmost_after_zoom = 0; } else if (l > max_frames) { diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index c1ffcefb2b..f7f8d4a67b 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -122,9 +122,6 @@ EngineControl::EngineControl () set_popdown_strings (driver_combo, strings); driver_combo.set_active_text (strings.front()); - /* figure out available devices and set up interface_combo */ - - enumerate_devices (); driver_combo.signal_changed().connect (mem_fun (*this, &EngineControl::driver_changed)); driver_changed (); @@ -428,10 +425,20 @@ EngineControl::build_command_line (vector& cmd) cmd.push_back ("netjack"); } else if (driver == X_("FFADO")) { using_ffado = true; - cmd.push_back ("ffado"); + + /* do this until FFADO becomes the standard */ + + char* hack = getenv ("ARDOUR_FIREWIRE_DRIVER_NAME"); + + if (hack) { + cmd.push_back (hack); + } else { + cmd.push_back ("freebob"); + } + } else if ( driver == X_("Dummy")) { - using_dummy = true; - cmd.push_back ("dummy"); + using_dummy = true; + cmd.push_back ("dummy"); } /* driver arguments */ @@ -456,10 +463,10 @@ EngineControl::build_command_line (vector& cmd) cmd.push_back ("-C"); } - if (! using_dummy ) { - cmd.push_back ("-n"); - cmd.push_back (to_string ((uint32_t) floor (periods_spinner.get_value()), std::dec)); - } + if (! using_dummy ) { + cmd.push_back ("-n"); + cmd.push_back (to_string ((uint32_t) floor (periods_spinner.get_value()), std::dec)); + } } cmd.push_back ("-r"); @@ -567,18 +574,29 @@ EngineControl::realtime_changed () } void -EngineControl::enumerate_devices () +EngineControl::enumerate_devices (const string& driver) { /* note: case matters for the map keys */ -#ifdef __APPLE__ - devices["CoreAudio"] = enumerate_coreaudio_devices (); + if (driver == "CoreAudio") { +#ifdef __APPLE__ + devices[driver] = enumerate_coreaudio_devices (); +#endif + +#ifndef __APPLE__ + } else if (driver == "ALSA") { + devices[driver] = enumerate_alsa_devices (); + } else if (driver == "FFADO") { + devices[driver] = enumerate_ffado_devices (); + } else if (driver == "OSS") { + devices[driver] = enumerate_oss_devices (); + } else if (driver == "Dummy") { + devices[driver] = enumerate_dummy_devices (); + } else if (driver == "NetJACK") { + devices[driver] = enumerate_netjack_devices (); + } #else - devices["ALSA"] = enumerate_alsa_devices (); - devices["FFADO"] = enumerate_ffado_devices (); - devices["OSS"] = enumerate_oss_devices (); - devices["Dummy"] = enumerate_dummy_devices (); - devices["NetJACK"] = enumerate_netjack_devices (); + } #endif } @@ -669,6 +687,7 @@ EngineControl::enumerate_coreaudio_devices () delete [] coreDeviceIDs; } + if (devs.size() == 0) { MessageDialog msg (_("\ You do not have any audio devices capable of\n\ @@ -689,6 +708,7 @@ Ardour and choose the relevant device then." exit (1); } + return devs; } #else @@ -757,8 +777,10 @@ vector EngineControl::enumerate_ffado_devices () { vector devs; + backend_devs.clear (); return devs; } + vector EngineControl::enumerate_freebob_devices () { @@ -789,11 +811,19 @@ void EngineControl::driver_changed () { string driver = driver_combo.get_active_text(); - vector& strings = devices[driver]; string::size_type maxlen = 0; int maxindex = -1; int n = 0; + enumerate_devices (driver); + + vector& strings = devices[driver]; + + if (strings.empty()) { + error << string_compose (_("No devices found for driver \"%1\""), driver) << endmsg; + return; + } + for (vector::iterator i = strings.begin(); i != strings.end(); ++i, ++n) { if ((*i).length() > maxlen) { maxlen = (*i).length(); @@ -1067,19 +1097,18 @@ EngineControl::set_state (const XMLNode& root) XMLNodeConstIterator citer; XMLNode* child; XMLProperty* prop; - - bool using_dummy = false; - + bool using_dummy = false; + int val; string strval; - - if ( (child = root.child("driver"))){ - prop = child->property("val"); - if (prop && (prop->value() == "Dummy") ) { - using_dummy = true; - } - } - + + if ( (child = root.child ("driver"))){ + prop = child->property("val"); + if (prop && (prop->value() == "Dummy") ) { + using_dummy = true; + } + } + clist = root.children(); for (citer = clist.begin(); citer != clist.end(); ++citer) { @@ -1089,8 +1118,9 @@ EngineControl::set_state (const XMLNode& root) prop = child->property ("val"); if (!prop || prop->value().empty()) { - if ( using_dummy && ( child->name() == "interface" || child->name() == "inputdevice" || child->name() == "outputdevice" )) - continue; + + if ( using_dummy && ( child->name() == "interface" || child->name() == "inputdevice" || child->name() == "outputdevice" )) + continue; error << string_compose (_("AudioSetup value for %1 is missing data"), child->name()) << endmsg; continue; } diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index c9851c89cc..d9741e3765 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -83,7 +83,7 @@ class EngineControl : public Gtk::VBox { std::map > devices; std::vector backend_devs; - void enumerate_devices (); + void enumerate_devices (const string& driver); #ifdef __APPLE__ std::vector enumerate_coreaudio_devices (); diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index 0f2eedb080..66a1427763 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -277,5 +277,10 @@ PlugUIBase::bypass_toggled () if ((x = bypass_button.get_active()) == insert->active()) { insert->set_active (!x); + if (insert->active()) { + bypass_button.set_label (_("Bypass")); + } else { + bypass_button.set_label (_("Active")); + } } } diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index fac18393af..910cebc7fe 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -295,12 +295,48 @@ Selection::add (TimeAxisView* track) } } +void +Selection::add (vector& v) +{ + /* XXX This method or the add (const RegionSelection&) needs to go + */ + + bool changed = false; + + for (vector::iterator i = v.begin(); i != v.end(); ++i) { + if (find (regions.begin(), regions.end(), (*i)) == regions.end()) { + changed = regions.add ((*i)); + if (Config->get_link_region_and_track_selection() && changed) { + add (&(*i)->get_trackview()); + } + } + } + + if (changed) { + RegionsChanged (); + } +} + void Selection::add (const RegionSelection& rs) { - if (!rs.empty()) { - regions.insert (regions.end(), rs.begin(), rs.end()); - RegionsChanged(); /* EMIT SIGNAL */ + /* XXX This method or the add (const vector&) needs to go + */ + + bool changed = false; + + for (RegionSelection::const_iterator i = rs.begin(); i != rs.end(); ++i) { + if (find (regions.begin(), regions.end(), (*i)) == regions.end()) { + changed = regions.add ((*i)); + if (Config->get_link_region_and_track_selection() && changed) { + add (&(*i)->get_trackview()); + } + } + } + + if (changed) { + select_edit_group_regions (); + RegionsChanged (); } } @@ -316,26 +352,6 @@ Selection::add (RegionView* r) } } -void -Selection::add (vector& v) -{ - bool changed = false; - - for (vector::iterator i = v.begin(); i != v.end(); ++i) { - if (find (regions.begin(), regions.end(), (*i)) == regions.end()) { - changed = regions.add ((*i)); - if (Config->get_link_region_and_track_selection() && changed) { - add (&(*i)->get_trackview()); - } - } - } - - if (changed) { - select_edit_group_regions (); - RegionsChanged (); - } -} - long Selection::add (nframes_t start, nframes_t end) { diff --git a/libs/ardour/configuration.cc b/libs/ardour/configuration.cc index 1460491180..b164d418ab 100644 --- a/libs/ardour/configuration.cc +++ b/libs/ardour/configuration.cc @@ -20,6 +20,9 @@ #include #include /* for snprintf, grrr */ +#include +#include /* for g_stat() */ + #include #include #include @@ -80,7 +83,8 @@ Configuration::load_state () bool found = false; sys::path system_rc_file; - + struct stat statbuf; + /* load system configuration first */ if ( find_file_in_search_path (ardour_search_path() + system_config_search_path(), @@ -91,18 +95,28 @@ Configuration::load_state () string rcfile = system_rc_file.to_string(); - cerr << string_compose (_("loading system configuration file %1"), rcfile) << endl; + /* stupid XML Parser hates empty files */ - if (!tree.read (rcfile.c_str())) { - error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg; + if (g_stat (rcfile.c_str(), &statbuf)) { return -1; } - current_owner = ConfigVariableBase::System; - - if (set_state (*tree.root())) { - error << string_compose(_("Ardour: system configuration file \"%1\" not loaded successfully."), rcfile) << endmsg; - return -1; + if (statbuf.st_size != 0) { + cerr << string_compose (_("loading system configuration file %1"), rcfile) << endl; + + if (!tree.read (rcfile.c_str())) { + error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg; + return -1; + } + + current_owner = ConfigVariableBase::System; + + if (set_state (*tree.root())) { + error << string_compose(_("Ardour: system configuration file \"%1\" not loaded successfully."), rcfile) << endmsg; + return -1; + } + } else { + error << _("your system Ardour configuration file is empty. This probably means that there as an error installing Ardour") << endmsg; } } @@ -114,23 +128,32 @@ Configuration::load_state () "ardour.rc", user_rc_file)) { XMLTree tree; - found = true; - + string rcfile = user_rc_file.to_string(); - cerr << string_compose (_("loading user configuration file %1"), rcfile) << endl; + /* stupid XML parser hates empty files */ - if (!tree.read (rcfile)) { - error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg; + if (g_stat (rcfile.c_str(), &statbuf)) { return -1; } - current_owner = ConfigVariableBase::Config; - - if (set_state (*tree.root())) { - error << string_compose(_("Ardour: user configuration file \"%1\" not loaded successfully."), rcfile) << endmsg; - return -1; - } + if (statbuf.st_size != 0) { + cerr << string_compose (_("loading user configuration file %1"), rcfile) << endl; + + if (!tree.read (rcfile)) { + error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg; + return -1; + } + + current_owner = ConfigVariableBase::Config; + + if (set_state (*tree.root())) { + error << string_compose(_("Ardour: user configuration file \"%1\" not loaded successfully."), rcfile) << endmsg; + return -1; + } + } else { + warning << _("your Ardour configuration file is empty. This is not normal.") << endmsg; + } } if (!found) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 19d562f844..dbec881b0b 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2542,40 +2542,42 @@ Session::region_name (string& result, string base, bool newlevel) const void Session::add_region (boost::shared_ptr region) { - boost::shared_ptr other; bool added = false; { Glib::Mutex::Lock lm (region_lock); - RegionList::iterator x; + if (region == 0) { + error << _("Session::add_region() ignored a null region. Warning: you might have lost a region.") << endmsg; + } else { - for (x = regions.begin(); x != regions.end(); ++x) { + RegionList::iterator x; - other = x->second; + for (x = regions.begin(); x != regions.end(); ++x) { - if (region->region_list_equivalent (other)) { - break; + if (region->region_list_equivalent (x->second)) { + break; + } } + + if (x == regions.end()) { + + pair entry; + + entry.first = region->id(); + entry.second = region; + + pair x = regions.insert (entry); + + + if (!x.second) { + return; + } + + added = true; + } + } - - if (x == regions.end()) { - - pair entry; - - entry.first = region->id(); - entry.second = region; - - pair x = regions.insert (entry); - - - if (!x.second) { - return; - } - - added = true; - } - } /* mark dirty because something has changed even if we didn't diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index d8d3d82810..4b7e0875ee 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1398,7 +1398,14 @@ Session::load_regions (const XMLNode& node) for (niter = nlist.begin(); niter != nlist.end(); ++niter) { if ((region = XMLRegionFactory (**niter, false)) == 0) { - error << _("Session: cannot create Region from XML description.") << endmsg; + error << _("Session: cannot create Region from XML description."); + const XMLProperty *name = (**niter).property("name"); + + if (name) { + error << " " << string_compose (_("Can not load state for region '%1'"), name->value()); + } + + error << endmsg; } } diff --git a/svn_revision.h b/svn_revision.h index fc376f4016..d417a995ab 100644 --- a/svn_revision.h +++ b/svn_revision.h @@ -1,4 +1,4 @@ #ifndef __ardour_svn_revision_h__ #define __ardour_svn_revision_h__ -static const char* ardour_svn_revision = "2884"; +static const char* ardour_svn_revision = "2914"; #endif