Merging from trunk
[ardour.git] / gtk2_ardour / regionview.cc
index d7c87ae1c4cb2c9ad53b048e6f4165c309e077a4..114aaf5da37f2232d66c512c404bb47f3fddda87 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <ardour/playlist.h>
 #include <ardour/audioregion.h>
-#include <ardour/sndfilesource.h>
-#include <ardour/diskstream.h>
+#include <ardour/audiosource.h>
+#include <ardour/audio_diskstream.h>
 
 #include "streamview.h"
 #include "regionview.h"
@@ -49,6 +49,7 @@
 
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Editing;
 using namespace ArdourCanvas;
 
@@ -866,11 +867,15 @@ AudioRegionView::region_renamed ()
                str = region.name();
        }
 
+       if (region.speed_mismatch (trackview.session().frame_rate())) {
+               str = string ("*") + str;
+       }
+
        if (region.muted()) {
                str = string ("!") + str;
        }
 
-       set_item_name (region.name(), this);
+       set_item_name (str, this);
        set_name_text (str);
 }
 
@@ -987,12 +992,10 @@ AudioRegionView::create_waves ()
 
        uint32_t nchans = atv.get_diskstream()->n_channels();
        
-//     if (wait_for_waves) {
-               /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
-               for (uint32_t n = 0; n < nchans; ++n) {
-                       tmp_waves.push_back (0);
-               }
-//     }
+       /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
+       for (uint32_t n = 0; n < nchans; ++n) {
+               tmp_waves.push_back (0);
+       }
        
        for (uint32_t n = 0; n < nchans; ++n) {
                
@@ -1003,7 +1006,7 @@ AudioRegionView::create_waves ()
                wave_caches.push_back (WaveView::create_cache ());
 
                if (wait_for_waves) {
-                       if (region.source(n).peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n))) {
+                       if (region.source(n).peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), peaks_ready_connection)) {
                                create_one_wave (n, true);
                        } else {
                                create_zero_line = false;
@@ -1080,32 +1083,13 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
                }
        }
        
-       cerr << "wave ready, n = " << n << " nwaves = " << nwaves << " new wave = " << wave 
-            << " tmp[" << which << "] = " << tmp_waves[which] << endl;
-       
        if (n == nwaves && waves.empty()) {
                /* all waves are ready */
                tmp_waves.resize(nwaves);
 
-
-               for (uint32_t x = 0; x < tmp_waves.size(); ++x) {
-                       cerr << "tmp_waves[" << x << "] = " << tmp_waves[x] << endl;
-               }
-
                waves = tmp_waves;
                tmp_waves.clear ();
 
-               cerr << "all waves ready, copied over ...\n";
-
-               for (uint32_t x = 0; x < waves.size(); ++x) {
-                       cerr << "waves[" << x << "] = " << waves[x] << endl;
-               }
-               
-               for (vector<WaveView*>::iterator i = waves.begin(); i != waves.end(); ++i) {
-                       cerr << "iterator[" << distance (i, waves.begin()) << "] = " << (*i) << endl;
-               }
-               cerr << "--------\n";
-               
                if (!zero_line) {
                        zero_line = new ArdourCanvas::SimpleLine (*group);
                        zero_line->property_x1() = (gdouble) 1.0;
@@ -1114,13 +1098,17 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
                        manage_zero_line ();
                }
        }
-       cerr << "done that time\n";
 }
 
 void
 AudioRegionView::peaks_ready_handler (uint32_t which)
 {
        Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
+
+       if (!waves.empty()) {
+               /* all waves created, don't hook into peaks ready anymore */
+               peaks_ready_connection.disconnect ();           
+       }
 }
 
 void
@@ -1247,12 +1235,6 @@ AudioRegionView::set_waveform_shape (WaveformShape shape)
        }
 }
 
-std::string
-AudioRegionView::get_item_name ()
-{
-       return region.name();
-}
-
 void
 AudioRegionView::move (double x_delta, double y_delta)
 {