don't popup import progress window until we give import a chance to fail first; sndfile doesn't print open() errors if HAVE_COREAUDIO is set since we fall back to CoreAudio then

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3127 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-02-27 14:40:59 +00:00
parent 3188ad3ab0
commit b6776d1102
4 changed files with 34 additions and 7 deletions

View 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);
}
}

View 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 ();
}
}

View 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 */

View 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;