diff --git a/gtk2_ardour/ardbg b/gtk2_ardour/ardbg index ab99296f45..063b2b1b6d 100755 --- a/gtk2_ardour/ardbg +++ b/gtk2_ardour/ardbg @@ -2,4 +2,4 @@ dir=`dirname "$0"` . $dir/ardev_common.sh LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH -exec gdb $EXECUTABLE $* +exec gdb $EXECUTABLE "$@" diff --git a/gtk2_ardour/ardev b/gtk2_ardour/ardev index 5dd8fc9d13..7980c43d93 100755 --- a/gtk2_ardour/ardev +++ b/gtk2_ardour/ardev @@ -1,4 +1,4 @@ #!/bin/sh . `dirname "$0"`/ardev_common.sh LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH -exec $EXECUTABLE $* +exec $EXECUTABLE "$@" diff --git a/gtk2_ardour/ardour.sh.in b/gtk2_ardour/ardour.sh.in index c661467d01..557ba23479 100644 --- a/gtk2_ardour/ardour.sh.in +++ b/gtk2_ardour/ardour.sh.in @@ -13,6 +13,6 @@ if [ "$MLOCK_LIMIT" != "unlimited" ]; then fi -exec %INSTALL_PREFIX%/%LIBDIR%/ardour2/ardour-%VERSION% $* +exec %INSTALL_PREFIX%/%LIBDIR%/ardour2/ardour-%VERSION% "$@" diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 4777617a77..e22e8b8a62 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -788,6 +788,7 @@ ARDOUR_UI::setup_clock () big_clock_window = new Window (WINDOW_TOPLEVEL); + big_clock_window->set_keep_above (true); big_clock_window->set_border_width (0); big_clock_window->add (big_clock); diff --git a/gtk2_ardour/arprof b/gtk2_ardour/arprof index 05a469cb17..47c11cdb99 100755 --- a/gtk2_ardour/arprof +++ b/gtk2_ardour/arprof @@ -6,4 +6,4 @@ if [ gprofhelper.c -nt gprofhelper.so ] ; then fi . ardev_common.sh -LDPRELOAD=./gprofhelper.so $EXECUTABLE $* +LDPRELOAD=./gprofhelper.so $EXECUTABLE "$@" diff --git a/gtk2_ardour/arval b/gtk2_ardour/arval index 920e7cb1a8..5661b4cd11 100755 --- a/gtk2_ardour/arval +++ b/gtk2_ardour/arval @@ -1,4 +1,4 @@ #!/bin/sh . ardev_common.sh export ARDOUR_RUNNING_UNDER_VALGRIND=TRUE -exec valgrind --num-callers=50 --tool=memcheck $EXECUTABLE --novst $* +exec valgrind --num-callers=50 --tool=memcheck $EXECUTABLE --novst "$@" diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 794f8dc34b..44330e0af5 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -783,10 +783,14 @@ AudioRegionView::create_waves () wave_caches.push_back (WaveView::create_cache ()); if (wait_for_data) { + if (audio_region()->source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) { create_one_wave (n, true); } else { + // we'll get a PeaksReady signal from the source in the future + // and will call create_one_wave(n) then. } + } else { create_one_wave (n, true); } diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 6a482b5438..0633b5ccaf 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -589,8 +590,6 @@ Editor::add_sources (vector paths, SourceList& sources, nframes64 region_name = region_name_from_path (afs->path(), false, true, sources.size(), n); - cerr << "got region name " << region_name << endl; - regions.push_back (boost::dynamic_pointer_cast (RegionFactory::create (just_one, 0, (*x)->length(), region_name, 0, Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External)))); @@ -619,7 +618,7 @@ Editor::add_sources (vector paths, SourceList& sources, nframes64 for (vector >::iterator r = regions.begin(); r != regions.end(); ++r, ++n) { finish_bringing_in_audio (*r, input_chan, output_chan, pos, mode, track); - + if (target_tracks != 1) { track.reset (); } else { @@ -627,6 +626,12 @@ Editor::add_sources (vector paths, SourceList& sources, nframes64 } } + /* setup peak file building in another thread */ + + for (SourceList::iterator x = sources.begin(); x != sources.end(); ++x) { + SourceFactory::setup_peakfile (*x, true); + } + return 0; } @@ -634,7 +639,6 @@ int Editor::finish_bringing_in_audio (boost::shared_ptr region, uint32_t in_chans, uint32_t out_chans, nframes64_t& pos, ImportMode mode, boost::shared_ptr& existing_track) { - switch (mode) { case ImportAsRegion: /* relax, its been done */ diff --git a/gtk2_ardour/new_session_dialog.cc b/gtk2_ardour/new_session_dialog.cc index 627fc566a0..7c90abcb6f 100644 --- a/gtk2_ardour/new_session_dialog.cc +++ b/gtk2_ardour/new_session_dialog.cc @@ -511,7 +511,7 @@ NewSessionDialog::session_folder() const } else { if (m_treeview->get_selection()->count_selected_rows() == 0) { - return Glib::filename_from_utf8(m_open_filechooser->get_current_folder()); + return Glib::filename_from_utf8(m_open_filechooser->get_filename()); } Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected(); return (*i)[recent_columns.fullpath]; diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h index db9f6dfd5a..df336f52da 100644 --- a/libs/ardour/ardour/source_factory.h +++ b/libs/ardour/ardour/source_factory.h @@ -55,8 +55,6 @@ class SourceFactory { static Glib::StaticMutex peak_building_lock; static std::list > files_with_peaks; - private: - static int setup_peakfile (boost::shared_ptr, bool async); }; diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index a2a457b023..f373f1d3d8 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include #include @@ -153,7 +155,15 @@ AudioFileSource::init (ustring pathstr, bool must_exist) ustring AudioFileSource::peak_path (ustring audio_path) { - return _session.peak_path_from_audio_path (audio_path); + ustring res; + + res = _session.peak_dir (); + res += PBD::basename_nosuffix (audio_path); + res += '%'; + res += (char) ('A' + _channel); + res += ".peak"; + + return res; } ustring diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index c8a557808c..787ac8be08 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -30,6 +30,8 @@ #include #include +#include + #include #include @@ -136,7 +138,7 @@ AudioSource::peaks_ready (sigc::slot the_slot, sigc::connection& conn) con if (!(ret = _peaks_built)) { conn = PeaksReady.connect (the_slot); } - + return ret; } @@ -187,7 +189,7 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path) used libsndfile for all audio files. */ - if (!newfile && access (peakpath.c_str(), R_OK) != 0) { + if (!newfile && !Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) { ustring str = old_peak_path (audio_path); if (access (str.c_str(), R_OK) == 0) { peakpath = str; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 7399ef19ed..7f7fbaa817 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -1736,7 +1737,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod << endmsg; goto failed; } - + if (nphysical_in) { for (uint32_t x = 0; x < track->n_inputs() && x < nphysical_in; ++x) { @@ -1779,6 +1780,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod new_routes.push_back (track); ret.push_back (track); + } catch (failed_constructor &err) { diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index dbb437edaa..5f140f706d 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -53,9 +53,11 @@ peak_thread_work () while (true) { SourceFactory::peak_building_lock.lock (); - + wait: - SourceFactory::PeaksToBuild->wait (SourceFactory::peak_building_lock); + if (SourceFactory::files_with_peaks.empty()) { + SourceFactory::PeaksToBuild->wait (SourceFactory::peak_building_lock); + } if (SourceFactory::files_with_peaks.empty()) { goto wait; @@ -94,7 +96,7 @@ SourceFactory::setup_peakfile (boost::shared_ptr s, bool async) Glib::Mutex::Lock lm (peak_building_lock); files_with_peaks.push_back (boost::weak_ptr (as)); - PeaksToBuild->signal (); + PeaksToBuild->broadcast (); } else { @@ -118,12 +120,14 @@ SourceFactory::createSilent (Session& s, const XMLNode& node, nframes_t nframes, #ifdef HAVE_COREAUDIO boost::shared_ptr -SourceFactory::create (Session& s, const XMLNode& node, bool async) +SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) { try { boost::shared_ptr ret (new CoreAudioSource (s, node)); - if (setup_peakfile (ret)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } SourceCreated (ret); return ret; @@ -135,8 +139,10 @@ SourceFactory::create (Session& s, const XMLNode& node, bool async) /* this is allowed to throw */ boost::shared_ptr ret (new SndFileSource (s, node)); - if (setup_peakfile (ret, async)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } SourceCreated (ret); return ret; @@ -148,14 +154,16 @@ SourceFactory::create (Session& s, const XMLNode& node, bool async) #else boost::shared_ptr -SourceFactory::create (Session& s, const XMLNode& node, bool async) +SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) { /* this is allowed to throw */ boost::shared_ptr ret (new SndFileSource (s, node)); - if (setup_peakfile (ret, async)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } SourceCreated (ret); @@ -166,14 +174,16 @@ SourceFactory::create (Session& s, const XMLNode& node, bool async) #ifdef HAVE_COREAUDIO boost::shared_ptr -SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool async) +SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks) { if (!(flags & Destructive)) { try { boost::shared_ptr ret (new CoreAudioSource (s, path, chn, flags)); - if (setup_peakfile (ret, async)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } if (announce) { SourceCreated (ret); @@ -186,8 +196,10 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource /* this is allowed to throw */ boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); - if (setup_peakfile (ret)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } if (announce) { SourceCreated (ret); @@ -198,8 +210,10 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource } else { boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); - if (setup_peakfile (ret, async)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } if (announce) { SourceCreated (ret); @@ -213,12 +227,14 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource #else boost::shared_ptr -SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool async) +SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks) { boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); - if (setup_peakfile (ret, async)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } if (announce) { @@ -231,7 +247,7 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource #endif // HAVE_COREAUDIO boost::shared_ptr -SourceFactory::createWritable (Session& s, std::string path, bool destructive, nframes_t rate, bool announce, bool async) +SourceFactory::createWritable (Session& s, std::string path, bool destructive, nframes_t rate, bool announce, bool defer_peaks) { /* this might throw failed_constructor(), which is OK */ @@ -243,9 +259,12 @@ SourceFactory::createWritable (Session& s, std::string path, bool destructive, n (destructive ? AudioFileSource::Flag (SndFileSource::default_writable_flags | AudioFileSource::Destructive) : SndFileSource::default_writable_flags))); - if (setup_peakfile (ret, async)) { - return boost::shared_ptr(); + if (!defer_peaks) { + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); + } } + if (announce) { SourceCreated (ret); }