diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-22 22:18:08 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-22 22:18:08 +0000 |
commit | f9ee71f60e06d5138f1e452e0f4896fac1fc32b3 (patch) | |
tree | f7573696331d9a8b644a6fde0924673aceb793a9 /gtk2_ardour | |
parent | 3aa346b253d515c3d0715ec5e0fa8b6ad477c4e5 (diff) |
gcc4 fix for new import/embed code, plus inline reject_if_rate_differs() function
git-svn-id: svn://localhost/trunk/ardour2@417 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor.h | 5 | ||||
-rw-r--r-- | gtk2_ardour/editor_audio_import.cc | 138 |
2 files changed, 62 insertions, 81 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index dbc76993d9..632b52832c 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -972,11 +972,10 @@ class Editor : public PublicEditor void bring_in_external_audio (Editing::ImportMode mode, ARDOUR::AudioTrack*, jack_nframes_t& pos, bool prompt); void do_import (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, jack_nframes_t&, bool); void do_embed (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, jack_nframes_t&, bool); - void import_sndfile (Glib::ustring path, Editing::ImportMode mode, ARDOUR::AudioTrack* track, jack_nframes_t& pos); - void embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, + int import_sndfile (Glib::ustring path, Editing::ImportMode mode, ARDOUR::AudioTrack* track, jack_nframes_t& pos); + int embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, ARDOUR::AudioTrack* track, jack_nframes_t& pos, bool prompt); int finish_bringing_in_audio (ARDOUR::AudioRegion& region, uint32_t, uint32_t, ARDOUR::AudioTrack* track, jack_nframes_t& pos, Editing::ImportMode mode); - int reject_because_rate_differs (Glib::ustring path, ARDOUR::SoundFileInfo& finfo, const string & action, bool multiple_pending); /* generic interthread progress window */ diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 658bb6fe74..0797e291c0 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -121,15 +121,22 @@ Editor::do_embed (vector<Glib::ustring> paths, bool split, ImportMode mode, Audi { bool multiple_files = paths.size() > 1; bool check_sample_rate = true; + vector<Glib::ustring>::iterator i; - for (vector<Glib::ustring>::iterator i = paths.begin(); i != paths.end(); ++i) { - embed_sndfile (*i, split, multiple_files, check_sample_rate, mode, track, pos, prompt); + for (i = paths.begin(); i != paths.end(); ++i) { + int ret = embed_sndfile (*i, split, multiple_files, check_sample_rate, mode, track, pos, prompt); + + if (ret < -1) { + break; + } } - session->save_state (""); + if (i == paths.end()) { + session->save_state (""); + } } -void +int Editor::import_sndfile (Glib::ustring path, ImportMode mode, AudioTrack* track, jack_nframes_t& pos) { interthread_progress_window->set_title (string_compose (_("ardour: importing %1"), path)); @@ -173,9 +180,10 @@ Editor::import_sndfile (Glib::ustring path, ImportMode mode, AudioTrack* track, } track_canvas.get_window()->set_cursor (*current_canvas_cursor); + return 0; } -void +int Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool& check_sample_rate, ImportMode mode, AudioTrack* track, jack_nframes_t& pos, bool prompt) { @@ -185,6 +193,8 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool string linked_path; SoundFileInfo finfo; string region_name; + uint32_t input_chan; + uint32_t output_chan; track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH)); ARDOUR_UI::instance()->flush_pending (); @@ -211,28 +221,43 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool if (!ExternalSource::get_soundfile_info (path, finfo, error_msg)) { error << string_compose(_("Editor: cannot open file \"%1\", (%2)"), selection, error_msg ) << endmsg; - return; + return 0; } - if (check_sample_rate) { - switch (reject_because_rate_differs (path, finfo, "Embed", multiple_files)) { - case 0: + if (check_sample_rate && (finfo.samplerate != (int) session->frame_rate())) { + vector<string> choices; + + choices.push_back (_("Embed it anyway")); + + if (multiple_files) { + choices.push_back (_("Don't embed it")); + choices.push_back (_("Embed all without questions")); + choices.push_back (_("Cancel entire import")); + } else { + choices.push_back (_("Cancel")); + } + + Gtkmm2ext::Choice rate_choice ( + string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path), + choices, false); + + switch (rate_choice.run()) { + case 0: /* do it */ break; - case 1: - return; - case -1: + case 1: /* don't import this one */ + return -1; + case 2: /* do it, and the rest without asking */ check_sample_rate = false; break; - - case -2: + case 3: /* stop a multi-file import */ default: - return; + return -2; } } - + track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH)); ARDOUR_UI::instance()->flush_pending (); - + /* make the proper number of channels in the region */ for (int n = 0; n < finfo.channels; ++n) @@ -244,27 +269,26 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool source = ExternalSource::create (idspec.c_str()); sources.push_back(source); } - - catch (failed_constructor& err) { - error << string_compose(_("could not open %1"), path) << endmsg; - goto out; - } - - ARDOUR_UI::instance()->flush_pending (); + + catch (failed_constructor& err) { + error << string_compose(_("could not open %1"), path) << endmsg; + goto out; + } + + ARDOUR_UI::instance()->flush_pending (); } - + if (sources.empty()) { goto out; } - + region_name = PBD::basename_nosuffix (path); region_name += "-0"; AudioRegion* region = new AudioRegion (sources, 0, sources[0]->length(), region_name, 0, Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External)); - uint32_t input_chan = finfo.channels; - uint32_t output_chan; + input_chan = finfo.channels; if (session->get_output_auto_connect() & Session::AutoConnectMaster) { output_chan = (session->master_out() ? session->master_out()->n_inputs() : input_chan); @@ -273,18 +297,19 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool } finish_bringing_in_audio (*region, input_chan, output_chan, track, pos, mode); - + out: track_canvas.get_window()->set_cursor (*current_canvas_cursor); + return 0; } int -Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32_t out_chans, AudioTrack* track, jack_nframes_t& pos, ImportMode mode) -{ - switch (mode) { - case ImportAsRegion: - /* relax, its been done */ - break; + Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32_t out_chans, AudioTrack* track, jack_nframes_t& pos, ImportMode mode) + { + switch (mode) { + case ImportAsRegion: + /* relax, its been done */ + break; case ImportToTrack: if (track) { @@ -311,49 +336,6 @@ Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32 return 0; } -int -Editor::reject_because_rate_differs (Glib::ustring path, SoundFileInfo& finfo, const string & action, bool multiple_pending) -{ - if (!session) { - return 1; - } - - if (finfo.samplerate != (int) session->frame_rate()) { - vector<string> choices; - - choices.push_back (string_compose (_("%1 it anyway"), action)); - - if (multiple_pending) { - /* XXX assumptions about sentence structure - here for translators. Sorry. - */ - choices.push_back (string_compose (_("Don't %1 it"), action)); - choices.push_back (string_compose (_("%1 all without questions"), action)); - choices.push_back (_("Cancel entire import")); - } else { - choices.push_back (_("Cancel")); - } - - Gtkmm2ext::Choice rate_choice ( - string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path), - choices, false); - - switch (rate_choice.run()) { - case 0: /* do it anyway */ - return 0; - case 1: /* don't import this one */ - return 1; - case 2: /* do the rest without asking */ - return -1; - case 3: /* stop a multi-file import */ - default: - return -2; - } - } - - return 0; -} - void * Editor::_import_thread (void *arg) { |