diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-11 02:57:05 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-11 02:57:05 +0000 |
commit | 7933b74f419a5f859ef64c8002b5effb686d8196 (patch) | |
tree | 3f4bf414b2e648b46ddeb505ae802a16f535e3b1 | |
parent | 93dc1bc0d6aea354e75712896416b8b9e0236eed (diff) |
try to fix async peaks issue; fix crasher caused by previous lock changes in AudioSource; unselect everything after Apply; save tags correctly (?)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2450 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/ardour_ui_ed.cc | 39 | ||||
-rw-r--r-- | gtk2_ardour/editor_audio_import.cc | 1 | ||||
-rw-r--r-- | gtk2_ardour/opts.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/sfdb_ui.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/sfdb_ui.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/audiosource.h | 2 | ||||
-rw-r--r-- | libs/ardour/audiofilesource.cc | 4 | ||||
-rw-r--r-- | libs/ardour/audiosource.cc | 27 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 15 | ||||
-rw-r--r-- | libs/ardour/sndfilesource.cc | 1 | ||||
-rw-r--r-- | libs/ardour/source_factory.cc | 5 |
11 files changed, 74 insertions, 38 deletions
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index b5a6281c1b..4777617a77 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -423,22 +423,41 @@ ARDOUR_UI::install_actions () RadioAction::Group denormal_group; ActionManager::register_toggle_action (option_actions, X_("DenormalProtection"), _("Use DC bias"), mem_fun (*this, &ARDOUR_UI::toggle_denormal_protection)); - - FPU fpu; ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalNone"), _("No processor handling"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalNone)); - act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalFTZ"), _("Use FlushToZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalFTZ)); - if (!fpu.has_flush_to_zero()) { + // as of September 10th 2007, Valgrind cannot handle various FPU flag setting instructions + // so avoid them + + if (getenv ("ARDOUR_RUNNING_UNDER_VALGRIND")) { + + /* we still need these actions to exist, but make them all insensitive */ + + act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalFTZ"), _("Use FlushToZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalFTZ)); act->set_sensitive (false); - } - act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalDAZ"), _("Use DenormalsAreZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalDAZ)); - if (!fpu.has_denormals_are_zero()) { + act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalDAZ"), _("Use DenormalsAreZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalDAZ)); act->set_sensitive (false); - } - act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalFTZDAZ"), _("Use FlushToZero & DenormalsAreZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalFTZDAZ)); - if (!fpu.has_flush_to_zero() || !fpu.has_denormals_are_zero()) { + act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalFTZDAZ"), _("Use FlushToZero & DenormalsAreZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalFTZDAZ)); act->set_sensitive (false); + + } else { + + FPU fpu; + + act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalFTZ"), _("Use FlushToZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalFTZ)); + if (!fpu.has_flush_to_zero()) { + act->set_sensitive (false); + } + + act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalDAZ"), _("Use DenormalsAreZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalDAZ)); + if (!fpu.has_denormals_are_zero()) { + act->set_sensitive (false); + } + + act = ActionManager::register_radio_action (option_actions, denormal_group, X_("DenormalFTZDAZ"), _("Use FlushToZero & DenormalsAreZero"), bind (mem_fun (*this, &ARDOUR_UI::set_denormal_model), DenormalFTZDAZ)); + if (!fpu.has_flush_to_zero() || !fpu.has_denormals_are_zero()) { + act->set_sensitive (false); + } } act = ActionManager::register_toggle_action (option_actions, X_("DoNotRunPluginsWhileRecording"), _("Do not run plugins while recording"), mem_fun (*this, &ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording)); diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index ac29b5264e..a4a9a7a420 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -135,6 +135,7 @@ Editor::external_audio_dialog () } if (response == RESPONSE_APPLY) { + sfbrowser->clear_selection (); goto again; } } diff --git a/gtk2_ardour/opts.cc b/gtk2_ardour/opts.cc index e9be9e49ec..6a78be9cb9 100644 --- a/gtk2_ardour/opts.cc +++ b/gtk2_ardour/opts.cc @@ -91,7 +91,7 @@ ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[]) { "novst", 0, 0, 'V' }, { "new", 1, 0, 'N' }, { "no-hw-optimizations", 0, 0, 'O' }, - { "sync", 0, 0, 'O' }, + { "sync", 0, 0, 'S' }, { "curvetest", 1, 0, 'C' }, { "sillyAppleUndocumentedFinderFeature", 1, 0, 'p' }, { 0, 0, 0, 0 } diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index e239f432d5..af950d8e6e 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -175,7 +175,7 @@ SoundFileBox::set_session(Session* s) bool SoundFileBox::setup_labels (const ustring& filename) { - if (path.empty()) { + if (!path.empty()) { // save existing tags tags_changed (); } @@ -407,6 +407,13 @@ SoundFileBrowser::~SoundFileBrowser () } void +SoundFileBrowser::clear_selection () +{ + chooser.unselect_all (); + found_list_view.get_selection()->unselect_all (); +} + +void SoundFileBrowser::chooser_file_activated () { preview.audition (); @@ -499,13 +506,13 @@ SoundFileBrowser::get_paths () if (n == 0) { vector<ustring> filenames = chooser.get_filenames(); vector<ustring>::iterator i; + for (i = filenames.begin(); i != filenames.end(); ++i) { struct stat buf; if ((!stat((*i).c_str(), &buf)) && S_ISREG(buf.st_mode)) { results.push_back (*i); } } - return results; } else { @@ -518,8 +525,9 @@ SoundFileBrowser::get_paths () results.push_back (str); } - return results; } + + return results; } void diff --git a/gtk2_ardour/sfdb_ui.h b/gtk2_ardour/sfdb_ui.h index 4670796700..ec057814be 100644 --- a/gtk2_ardour/sfdb_ui.h +++ b/gtk2_ardour/sfdb_ui.h @@ -122,6 +122,8 @@ class SoundFileBrowser : public ArdourDialog virtual void set_session (ARDOUR::Session*); std::vector<Glib::ustring> get_paths (); + void clear_selection (); + Gtk::FileChooserWidget chooser; Gtk::TreeView found_list_view; diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index fefc5d8964..fd97ae8377 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -115,7 +115,7 @@ const nframes_t frames_per_peak = 256; static bool _build_peakfiles; bool _peaks_built; - mutable Glib::RWLock _lock; + mutable Glib::Mutex _lock; mutable Glib::Mutex _peaks_ready_lock; nframes_t _length; ustring peakpath; diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 39b0228791..a2a457b023 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -269,7 +269,7 @@ AudioFileSource::mark_streaming_write_completed () but we must hold a solid lock on PeaksReady. */ - Glib::RWLock::WriterLock lm (_lock); + Glib::Mutex::Lock lm (_lock); if (_peaks_built) { PeaksReady (); /* EMIT SIGNAL */ @@ -568,7 +568,7 @@ AudioFileSource::set_allow_remove_if_empty (bool yn) int AudioFileSource::set_name (ustring newname, bool destructive) { - Glib::RWLock::WriterLock lm (_lock); + Glib::Mutex::Lock lm (_lock); ustring oldpath = _path; ustring newpath = Session::change_audio_path_by_name (oldpath, _name, newname, destructive); diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index b0bab54559..c8a557808c 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -246,21 +246,21 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path) nframes_t AudioSource::read (Sample *dst, nframes_t start, nframes_t cnt) const { - Glib::RWLock::ReaderLock lm (_lock); + Glib::Mutex::Lock lm (_lock); return read_unlocked (dst, start, cnt); } nframes_t AudioSource::write (Sample *dst, nframes_t cnt) { - Glib::RWLock::WriterLock lm (_lock); + Glib::Mutex::Lock lm (_lock); return write_unlocked (dst, cnt); } int AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nframes_t cnt, double samples_per_visual_peak) const { - Glib::RWLock::ReaderLock lm (_lock); + Glib::Mutex::Lock lm (_lock); double scale; double expected_peaks; PeakData::PeakDatum xmax; @@ -584,14 +584,15 @@ AudioSource::build_peaks_from_scratch () nframes_t cnt; Sample* buf = 0; nframes_t frames_read; - nframes_t frames_to_read = 65536; // 256kB reads from disk, roughly ideal + nframes_t frames_to_read; + const nframes_t bufsize = 65536; // 256kB per disk read for mono data is about ideal int ret = -1; { /* hold lock while building peaks */ - Glib::RWLock::ReaderLock lp (_lock); + Glib::Mutex::Lock lp (_lock); if (prepare_for_peakfile_writes ()) { goto out; @@ -600,18 +601,18 @@ AudioSource::build_peaks_from_scratch () current_frame = 0; cnt = _length; _peaks_built = false; - buf = new Sample[frames_to_read]; + buf = new Sample[bufsize]; while (cnt) { - frames_to_read = min (frames_per_peak, cnt); + frames_to_read = min (bufsize, cnt); if ((frames_read = read_unlocked (buf, current_frame, frames_to_read)) != frames_to_read) { error << string_compose(_("%1: could not write read raw data for peak computation (%2)"), _name, strerror (errno)) << endmsg; done_with_peakfile_writes (false); goto out; } - + if (compute_and_write_peaks (buf, current_frame, frames_read, true, false)) { break; } @@ -623,10 +624,9 @@ AudioSource::build_peaks_from_scratch () if (cnt == 0) { /* success */ truncate_peakfile(); - _peaks_built = true; } - done_with_peakfile_writes (); + done_with_peakfile_writes ((cnt == 0)); } { @@ -724,9 +724,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe PeakRangeReady (peak_leftover_frame, peak_leftover_cnt); /* EMIT SIGNAL */ if (intermediate_peaks_ready) { PeaksReady (); /* EMIT SIGNAL */ - } else { - cerr << "Skip PR at A\n"; - } + } } /* left overs are done */ @@ -838,10 +836,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe PeakRangeReady (first_frame, frames_done); /* EMIT SIGNAL */ if (intermediate_peaks_ready) { PeaksReady (); /* EMIT SIGNAL */ - } else { - cerr << "Skip PR at A\n"; } - } ret = 0; diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index e5c9d27d5e..b4286c089f 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -206,10 +206,11 @@ void setup_hardware_optimization (bool try_optimization) { bool generic_mix_functions = true; - FPU fpu; if (try_optimization) { + FPU fpu; + #if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS) if (fpu.has_sse()) { @@ -245,6 +246,10 @@ setup_hardware_optimization (bool try_optimization) info << "Apple VecLib H/W specific optimizations in use" << endmsg; } #endif + + /* consider FPU denormal handling to be "h/w optimization" */ + + setup_fpu (); } if (generic_mix_functions) { @@ -258,8 +263,6 @@ setup_hardware_optimization (bool try_optimization) info << "No H/W specific optimizations in use" << endmsg; } - setup_fpu (); - } int @@ -518,6 +521,12 @@ ARDOUR::LocaleGuard::~LocaleGuard () void ARDOUR::setup_fpu () { + if (getenv ("ARDOUR_RUNNING_UNDER_VALGRIND")) { + // valgrind doesn't understand this assembler stuff + // September 10th, 2007 + return; + } + #if defined(ARCH_X86) && defined(USE_XMMINTRIN) int MXCSR; diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 0ed8c9cc34..9b0d5fabb3 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -25,6 +25,7 @@ #include <sys/stat.h> #include <glibmm/miscutils.h> +#include <pbd/stacktrace.h> #include <ardour/sndfilesource.h> #include <ardour/sndfile_helpers.h> diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 405f0a064f..dbb437edaa 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -54,10 +54,11 @@ peak_thread_work () SourceFactory::peak_building_lock.lock (); + wait: SourceFactory::PeaksToBuild->wait (SourceFactory::peak_building_lock); if (SourceFactory::files_with_peaks.empty()) { - continue; + goto wait; } boost::shared_ptr<AudioSource> as (SourceFactory::files_with_peaks.front().lock()); @@ -67,7 +68,7 @@ peak_thread_work () if (!as) { continue; } - + as->setup_peakfile (); } } |