fix errors in multi-range export (and possibly other export styles); compiler warning...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 16 Mar 2007 21:44:10 +0000 (21:44 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 16 Mar 2007 21:44:10 +0000 (21:44 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1605 d708f5d6-7413-0410-9779-e7cbd77b26cf

15 files changed:
gtk2_ardour/export_dialog.cc
gtk2_ardour/export_range_markers_dialog.cc
libs/ardour/ardour/export.h
libs/ardour/ardour/session.h
libs/ardour/audiosource.cc
libs/ardour/import.cc
libs/ardour/mix.cc
libs/ardour/session.cc
libs/ardour/session_export.cc
libs/pbd/pbd/abstract_ui.cc
libs/pbd/stacktrace.cc
libs/pbd/strsplit.cc
libs/soundtouch/RateTransposer.cpp
libs/soundtouch/RateTransposer.h
libs/soundtouch/TDStretch.cpp

index 8902391b0b1f2b0b5c210520b23e53ee69ebd72d..75b0f8c1e9d1c65fd2e9d8c543cca86eb0087b7c 100644 (file)
@@ -916,7 +916,6 @@ ExportDialog::do_export ()
 void
 ExportDialog::end_dialog ()
 {
-
        if (spec.running) {
                spec.stop = true;
 
@@ -929,7 +928,7 @@ ExportDialog::end_dialog ()
                }
        }
 
-       session->engine().freewheel (false);
+       session->finalize_audio_export ();
 
        hide_all ();
 
index b6bd25a60d2993152041964e0a1137dcba1a43b4..1184294a6712e6f5fd6314f80ade182486650ba9 100644 (file)
@@ -65,7 +65,7 @@ ExportRangeMarkersDialog::process_range_markers_export(Locations::LocationList&
        Locations::LocationList::iterator locationIter;
        current_range_marker_index = 0;
        init_progress_computing(locations);
-       
+
        for (locationIter = locations.begin(); locationIter != locations.end(); ++locationIter) {
                Location *currentLocation = (*locationIter);
 
@@ -90,7 +90,8 @@ ExportRangeMarkersDialog::process_range_markers_export(Locations::LocationList&
 
                        // wait until export of this range finished
                        gtk_main_iteration();
-                       while(spec.running){
+
+                       while (spec.running){
                                if(gtk_events_pending()){
                                        gtk_main_iteration();
                                }else {
@@ -197,12 +198,6 @@ ExportRangeMarkersDialog::progress_timeout ()
 {
        double progress = 0.0;
 
-       cerr << "Progress timeout, total = " << total_duration << " index = " << current_range_marker_index
-            << " current = " << range_markers_durations[current_range_marker_index]
-            << " agg = " << range_markers_durations_aggregated[current_range_marker_index]
-            << " prog = " << spec.progress
-            << endl;
-       
        if (current_range_marker_index >= range_markers_durations.size()){
                progress = 1.0;
        } else{
index f66acec893ac9b3f0d264de05599f615b04a05dc..66e5b1b7d55ac216a24355f817198b4125039372 100644 (file)
@@ -76,9 +76,9 @@ namespace ARDOUR
 
            /* shared between UI thread and audio thread */
 
-           float progress;  /* audio thread sets this */
-           bool  stop;      /* UI sets this */
-           bool  running;   /* audio thread sets to false when export is done */
+           volatile float progress;  /* audio thread sets this */
+           volatile bool  stop;      /* UI sets this */
+           volatile bool  running;   /* audio thread sets to false when export is done */
 
            int   status;
 
index 919d9a81620bd4d561059f2637c1c88c7c00269b..5beaee8e331d95f66e66c80fa1925e66811ed53f 100644 (file)
@@ -575,7 +575,8 @@ class Session : public PBD::StatefulDestructible
 
        int start_audio_export (ARDOUR::AudioExportSpecification&);
        int stop_audio_export (ARDOUR::AudioExportSpecification&);
-       
+       void finalize_audio_export ();
+
        void add_source (boost::shared_ptr<Source>);
        void remove_source (boost::weak_ptr<Source>);
 
index dfe88ace7895ef2f38f6b780afe9658e4c949575..0043df7d2ee8419da8a461cdfca8200b205b8e09 100644 (file)
@@ -671,7 +671,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe
        Sample* buf2 = 0;
        nframes_t to_do;
        uint32_t  peaks_computed;
-       PeakData* peakbuf;
+       PeakData* peakbuf = 0;
        int ret = -1;
        nframes_t current_frame;
        nframes_t frames_done;
index b81f438490497b96356a3a09cdf4da3082b57698..712b9a35e464ee206c890e98936bd5ad9ac072e6 100644 (file)
@@ -117,7 +117,6 @@ Session::import_audiofile (import_status& status)
        float *data = 0;
        Sample **channel_data = 0;
        long nfiles = 0;
-       long n;
        string basepath;
        string sounds_dir;
        nframes_t so_far;
@@ -143,14 +142,14 @@ Session::import_audiofile (import_status& status)
                importable = new ImportableSource (in, &info);
        }
 
-       for (n = 0; n < info.channels; ++n) {
+       for (int n = 0; n < info.channels; ++n) {
                newfiles.push_back (boost::shared_ptr<AudioFileSource>());
        }
 
        sounds_dir = discover_best_sound_dir ();
        basepath = PBD::basename_nosuffix (status.paths.front());
 
-       for (n = 0; n < info.channels; ++n) {
+       for (int n = 0; n < info.channels; ++n) {
 
                bool goodfile = false;
 
@@ -162,7 +161,7 @@ Session::import_audiofile (import_status& status)
                                        snprintf (buf, sizeof(buf), "%s/%s-R.wav", sounds_dir.c_str(), basepath.c_str());
                                }
                        } else if (info.channels > 1) {
-                               snprintf (buf, sizeof(buf), "%s/%s-c%lu.wav", sounds_dir.c_str(), basepath.c_str(), n+1);
+                               snprintf (buf, sizeof(buf), "%s/%s-c%d.wav", sounds_dir.c_str(), basepath.c_str(), n+1);
                        } else {
                                snprintf (buf, sizeof(buf), "%s/%s.wav", sounds_dir.c_str(), basepath.c_str());
                        }
@@ -199,7 +198,7 @@ Session::import_audiofile (import_status& status)
        data = new float[nframes * info.channels];
        channel_data = new Sample * [ info.channels ];
        
-       for (n = 0; n < info.channels; ++n) {
+       for (int n = 0; n < info.channels; ++n) {
                channel_data[n] = new Sample[nframes];
        }
 
@@ -222,7 +221,8 @@ Session::import_audiofile (import_status& status)
                /* de-interleave */
                                
                for (chn = 0; chn < info.channels; ++chn) {
-                       
+
+                       nframes_t n;
                        for (x = chn, n = 0; n < nfread; x += info.channels, ++n) {
                                channel_data[chn][n] = (Sample) data[x];
                        }
@@ -257,7 +257,7 @@ Session::import_audiofile (import_status& status)
        if (status.multichan) {
                /* all sources are used in a single multichannel region */
 
-               for (n = 0; n < nfiles && !status.cancel; ++n) {
+               for (int n = 0; n < nfiles && !status.cancel; ++n) {
                        /* flush the final length to the header */
                        newfiles[n]->update_header(0, *now, xnow);
                        sources.push_back(newfiles[n]);
@@ -274,7 +274,7 @@ Session::import_audiofile (import_status& status)
                status.new_regions.push_back (r);
 
        } else {
-               for (n = 0; n < nfiles && !status.cancel; ++n) {
+               for (int n = 0; n < nfiles && !status.cancel; ++n) {
 
                        /* flush the final length to the header */
 
@@ -309,7 +309,7 @@ Session::import_audiofile (import_status& status)
        }
        
        if (channel_data) {
-               for (n = 0; n < info.channels; ++n) {
+               for (int n = 0; n < info.channels; ++n) {
                        delete [] channel_data[n];
                }
                delete [] channel_data;
index a32c274b7c93fd159c354b828bd8607db3d3e357..2d31c8ccc89fa0b5ab433d384c05b792a2dc9f05 100644 (file)
@@ -92,7 +92,7 @@ compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current)
 void
 find_peaks (ARDOUR::Sample *buf, nframes_t nframes, float *min, float *max)
 {
-       long i;
+       nframes_t i;
        float a, b;
 
        a = *max;
index 129fa5f7431c06c6cf867b89c6cbe69a9f242515..b496afe9d622ff1fa37a3219b36eb3d0714441df 100644 (file)
@@ -3626,7 +3626,6 @@ Session::next_insert_id ()
                for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < insert_bitset.size(); ++n) {
                        if (!insert_bitset[n]) {
                                insert_bitset[n] = true;
-                               cerr << "Returning " << n << " as insert ID\n";
                                return n;
                                
                        }
@@ -3647,7 +3646,6 @@ Session::next_send_id ()
                for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < send_bitset.size(); ++n) {
                        if (!send_bitset[n]) {
                                send_bitset[n] = true;
-                               cerr << "Returning " << n << " as send ID\n";
                                return n;
                                
                        }
index 82dd23f72498c4a3d150b021ebb4f15b4616c67b..87bf5a5b034b6c1e049faaee7cf75d777caac1a1 100644 (file)
@@ -267,7 +267,7 @@ AudioExportSpecification::process (nframes_t nframes)
        char errbuf[256];
        nframes_t to_write = 0;
        int cnt = 0;
-
+       
        do {
 
                /* now do sample rate conversion */
@@ -427,8 +427,6 @@ AudioExportSpecification::process (nframes_t nframes)
 int
 Session::start_audio_export (AudioExportSpecification& spec)
 {
-       int ret;
-
        if (spec.prepare (current_block_size, frame_rate())) {
                return -1;
        }
@@ -436,40 +434,21 @@ Session::start_audio_export (AudioExportSpecification& spec)
        spec.pos = spec.start_frame;
        spec.end_frame = spec.end_frame;
        spec.total_frames = spec.end_frame - spec.start_frame;
+       spec.running = true; 
+       spec.do_freewheel = false; /* force a call to ::prepare_to_export() before proceeding to normal operation */
 
        spec.freewheel_connection = _engine.Freewheel.connect (sigc::bind (mem_fun (*this, &Session::process_export), &spec));
 
-       if ((ret = _engine.freewheel (true)) == 0) {
-               spec.running = true; 
-               spec.do_freewheel = false;
-       }
-
-       return ret;
+       return _engine.freewheel (true);
 }
 
 int
 Session::stop_audio_export (AudioExportSpecification& spec)
 {
-       /* can't use stop_transport() here because we need
-          an immediate halt and don't require all the declick
-          stuff that stop_transport() implements.
-       */
-
-       realtime_stop (true);
-       schedule_butler_transport_work ();
-
-       /* restart slaving */
+       /* don't stop freewheeling but do stop paying attention to it for now */
 
-       if (post_export_slave != None) {
-               Config->set_slave_source (post_export_slave);
-       } else {
-               locate (post_export_position, false, false, false);
-       }
-
-       spec.clear ();
-       _exporting = false;
-
-       spec.running = false;
+       spec.freewheel_connection.disconnect ();
+       spec.clear (); /* resets running/stop etc */
 
        return 0;
 }
@@ -639,3 +618,25 @@ Session::process_export (nframes_t nframes, AudioExportSpecification* spec)
        return ret;
 }
 
+void
+Session::finalize_audio_export ()
+{
+       _engine.freewheel (false);
+       _exporting = false;
+
+       /* can't use stop_transport() here because we need
+          an immediate halt and don't require all the declick
+          stuff that stop_transport() implements.
+       */
+
+       realtime_stop (true);
+       schedule_butler_transport_work ();
+
+       /* restart slaving */
+
+       if (post_export_slave != None) {
+               Config->set_slave_source (post_export_slave);
+       } else {
+               locate (post_export_position, false, false, false);
+       }
+}
index 6c3f0bac7f110ac8fa1e480be15413dff1de6a2e..97f19e1fe5d66d2c317241aee17e4a6c88270022 100644 (file)
@@ -54,6 +54,8 @@ AbstractUI<RequestObject>::get_request (RequestType rt)
        }
        
        RequestBufferVector vec;
+       vec.buf[0] = 0;
+       vec.buf[1] = 0;
        
        rbuf->get_write_vector (&vec);
 
index 64950097655375a85e679dbb880ce1ffd4561775..8a6eb606b219cbab981b3b85db2bdadec1ad581b 100644 (file)
@@ -23,7 +23,7 @@ PBD::stacktrace (std::ostream& out, int levels)
 
                printf ("Obtained %zd stack frames.\n", size);
                
-               for (i = 0; i < size && (levels == 0 || i < levels); i++) {
+               for (i = 0; i < size && (levels == 0 || i < size_t(levels)); i++) {
                        out << strings[i] << std::endl;
                }
                
index 80da357cc05fcc7e64c498e1fb2afd23efb1eb9d..1fb61121501d63419ae6f27f2db6162920727ab9 100644 (file)
@@ -56,7 +56,7 @@ split (ustring str, vector<ustring>& result, char splitchar)
        }
 
        for (ustring::size_type n = 0; n < len; ++n) {
-               if (str[n] == splitchar) {
+               if (str[n] == gunichar(splitchar)) {
                        cnt++;
                }
        }
index 740d099239d815dfa10c6ae681c4d88880702c1f..493d5326f20ab529364ce2538fcc08f178eff3d6 100644 (file)
@@ -339,7 +339,7 @@ void RateTransposer::clear()
 
 
 // Returns nonzero if there aren't any samples available for outputting.
-uint RateTransposer::isEmpty()
+int RateTransposer::isEmpty() const
 {
     int res;
 
index f7c03f759e657ef740d2ae27a546c7b449b30295..5315d6fec3ca8a3269aad4a8dd3eb63cca95236d 100644 (file)
@@ -150,7 +150,7 @@ public:
     void clear();
 
     /// Returns nonzero if there aren't any samples available for outputting.
-    uint isEmpty();
+    int isEmpty() const;
 };
 
 }
index f1b85b5f177c78731f7879e397a2b1761023f132..c71c65967f8ae0673e8df3e61b4404709bd14d06 100644 (file)
@@ -114,13 +114,6 @@ TDStretch::~TDStretch()
 
 
     
-// Calculates the x having the closest 2^x value for the given value
-static int _getClosest2Power(double value)
-{
-    return (int)(log(value) / log(2.0) + 0.5);
-}
-
-
 
 // Sets routine control parameters. These control are certain time constants
 // defining how the sound is stretched to the desired duration.