don't popup import progress window until we give import a chance to fail first; sndfi...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 27 Feb 2008 14:40:59 +0000 (14:40 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 27 Feb 2008 14:40:59 +0000 (14:40 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3127 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_audio_import.cc
libs/ardour/coreaudiosource.cc
libs/ardour/session.cc
libs/ardour/sndfilesource.cc

index 2391eae9276df01bf94c44d35de92610f8b4d022..0ecf360db48649344019d5552c55522e35fa4e0d 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/time.h>
 #include <errno.h>
 #include <unistd.h>
+#include <algorithm>
 
 #include <sndfile.h>
 
@@ -309,7 +310,6 @@ Editor::_do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mo
                build_interthread_progress_window ();
        }
 
-
        if (chns == Editing::ImportMergeFiles) {
                /* create 1 region from all paths, add to 1 track,
                   ignore "track"
@@ -496,7 +496,6 @@ Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality qual
 
        interthread_progress_window->set_title (title.get_string());
        interthread_progress_window->set_position (Gtk::WIN_POS_MOUSE);
-       interthread_progress_window->show_all ();
        interthread_progress_bar.set_fraction (0.0f);
        interthread_cancel_label.set_text (_("Cancel Import"));
        current_interthread_info = &import_status;
@@ -510,7 +509,7 @@ Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality qual
        import_status.replace_existing_source = replace;
 
        interthread_progress_connection = Glib::signal_timeout().connect 
-               (bind (mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 100);
+               (bind (mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 500);
        
        track_canvas->get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
        ARDOUR_UI::instance()->flush_pending ();
@@ -880,6 +879,13 @@ Editor::import_thread ()
 gint
 Editor::import_progress_timeout (void *arg)
 {
+       bool reset = false;
+
+       if (!interthread_progress_window->is_visible()) {
+               interthread_progress_window->show_all ();
+               reset = true;
+       }
+
        interthread_progress_label.set_text (import_status.doing_what);
 
        if (import_status.freeze) {
@@ -892,9 +898,20 @@ Editor::import_progress_timeout (void *arg)
                interthread_progress_bar.pulse ();
                return FALSE;
        } else {
-               interthread_progress_bar.set_fraction (import_status.progress);
+               float val = import_status.progress;
+               interthread_progress_bar.set_fraction (min (max (0.0f, val), 1.0f));
        }
 
-       return !(import_status.done || import_status.cancel);
+       if (reset) {
+
+               /* the window is now visible, speed up the updates */
+               
+               interthread_progress_connection.disconnect ();
+               interthread_progress_connection = Glib::signal_timeout().connect 
+                       (bind (mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 100);
+               return false;
+       } else {
+               return !(import_status.done || import_status.cancel);
+       }
 }
 
index 011bcce337d400d0ff3aa88a4cb5c58b591694d7..4383f1a6965dd0fe5a9777bb97739fef6618044a 100644 (file)
@@ -76,7 +76,9 @@ CoreAudioSource::init ()
                af.SetClientFormat (client_format);
 
        } catch (CAXException& cax) {
-               error << string_compose ("CoreAudioSource: %1 (%2)", cax.mOperation, name()) << endmsg;
+               
+               error << string_compose(_("CoreAudioSource: cannot open file \"%1\" for %2"), 
+                                       _path, (writable() ? "read+write" : "reading")) << endmsg;
                throw failed_constructor ();
        }
 }
index 35eb10ccf0b123bb6cc0af12faa03f68b818df37..a084a16574103cc807eb16f1bdabd5500b9781e6 100644 (file)
@@ -482,7 +482,7 @@ Session::destroy ()
 
        // auditioner.reset ();
        
-#define TRACK_DESTRUCTION
+#undef TRACK_DESTRUCTION
 #ifdef TRACK_DESTRUCTION
        cerr << "delete named selections\n";
 #endif /* TRACK_DESTRUCTION */
index b6f3accd4e92f0c88a0fa0d349cac1cd3a1a1564..46ccdf5e9ea5815765792d63facf954c03ebfd40 100644 (file)
@@ -218,13 +218,21 @@ SndFileSource::open ()
        if ((sf = sf_open (_path.c_str(), (writable() ? SFM_RDWR : SFM_READ), &_info)) == 0) {
                char errbuf[256];
                sf_error_str (0, errbuf, sizeof (errbuf) - 1);
+#ifndef HAVE_COREAUDIO
+               /* if we have CoreAudio, we will be falling back to that if libsndfile fails,
+                  so we don't want to see this message.
+               */
+
                error << string_compose(_("SndFileSource: cannot open file \"%1\" for %2 (%3)"), 
                                        _path, (writable() ? "read+write" : "reading"), errbuf) << endmsg;
+#endif
                return -1;
        }
 
        if (_channel >= _info.channels) {
+#ifndef HAVE_COREAUDIO
                error << string_compose(_("SndFileSource: file only contains %1 channels; %2 is invalid as a channel number"), _info.channels, _channel) << endmsg;
+#endif
                sf_close (sf);
                sf = 0;
                return -1;