fix unset timeline position for destructive sources; fix duplicate, unmanaged wavevie...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 2 Nov 2006 16:03:58 +0000 (16:03 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 2 Nov 2006 16:03:58 +0000 (16:03 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1060 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_region_view.cc
gtk2_ardour/canvas-waveview.c
libs/ardour/audiosource.cc
libs/ardour/destructive_filesource.cc
libs/ardour/io.cc
libs/ardour/session_state.cc

index c7bb048945d107711e60a62a351060a357ce65e9..6de409b7ec08dd2d50e08c69b409171fc6d2c0ce 100644 (file)
@@ -847,6 +847,9 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
                waves = tmp_waves;
                tmp_waves.clear ();
 
+               /* all waves created, don't hook into peaks ready anymore */
+               data_ready_connection.disconnect ();            
+
                if (!zero_line) {
                        zero_line = new ArdourCanvas::SimpleLine (*group);
                        zero_line->property_x1() = (gdouble) 1.0;
@@ -861,7 +864,6 @@ 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 */
                data_ready_connection.disconnect ();            
index 48834f37da396a5724e5907a90caedc1327067fa..080f6871fa1705bb6f1d9231a17fb8881365400c 100644 (file)
@@ -977,7 +977,7 @@ gnome_canvas_waveview_render (GnomeCanvasItem *item,
 
 #if 0
        printf ("0x%x r (%d..%d)(%d..%d) bbox (%d..%d)(%d..%d)"
-               " b/e %d..%d s= %lu..%lu\n",
+               " b/e %d..%d s= %lu..%lu @ %f\n",
                waveview,
                buf->rect.x0,
                buf->rect.x1,
@@ -987,7 +987,8 @@ gnome_canvas_waveview_render (GnomeCanvasItem *item,
                waveview->bbox_lrx,
                waveview->bbox_uly,
                waveview->bbox_lry,
-               begin, end, s1, s2);
+               begin, end, s1, s2,
+               waveview->samples_per_unit);
 #endif
 
        /* now ensure that the cache is full and properly
index 0ad9cc68b7fc29f10f7cf6c7c7f26c5b3fb1ec58..cd8c192d131d43f401a13f38524c80048f1a3b79 100644 (file)
@@ -704,7 +704,7 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr
        return ret;
 }
 
-#define DEBUG_PEAK_BUILD
+#undef DEBUG_PEAK_BUILD
 
 int
 AudioSource::build_peaks ()
index cc607bc3688dd750af952888f47600f5d003d893..2f2e85ed5a088652ad7cd59f3c09de66af79d502 100644 (file)
@@ -55,6 +55,7 @@ typedef off_t off64_t;
 #include <fcntl.h>
 
 #include <pbd/error.h>
+#include <pbd/stacktrace.h>
 #include <ardour/destructive_filesource.h>
 #include <ardour/utils.h>
 #include <ardour/session.h>
@@ -290,7 +291,7 @@ DestructiveFileSource::write_unlocked (Sample* data, nframes_t cnt)
                _capture_end = false;
                
                /* move to the correct location place */
-               file_pos = capture_start_frame;
+               file_pos = capture_start_frame - timeline_position;
                
                // split cnt in half
                nframes_t subcnt = cnt / 2;
@@ -344,13 +345,12 @@ DestructiveFileSource::write_unlocked (Sample* data, nframes_t cnt)
        } else {
 
                /* in the middle of recording */
-               
 
                if (write_float (data, file_pos, cnt) != cnt) {
                        return 0;
                }
        }
-       
+
        old_file_pos = file_pos;
        update_length (file_pos, cnt);
        file_pos += cnt;
@@ -418,6 +418,7 @@ DestructiveFileSource::set_timeline_position (nframes_t pos)
 int
 DestructiveFileSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nframes_t cnt, double samples_per_unit) const
 {
+       // cerr << _name << " read peaks at " << start << " for " << cnt << " tpos = " << timeline_position << endl;
        return AudioFileSource::read_peaks (peaks, npeaks, start, cnt, samples_per_unit);
 }
        
index 0804369b94e2fcc218330a4089b7e249f56e3d18..897589fc77cecc97e8941414df96a10ebcc2b8fb 100644 (file)
@@ -170,7 +170,6 @@ IO::IO (Session& s, const XMLNode& node, DataType dt)
 
        _session.add_controllable (&_gain_control);
 }
-       
 
 IO::~IO ()
 {
index c69908285c0f2b6103bcf6f9741e1586fe82eac6..d9c82f546b12f3302da3e9b915b024773cda59b6 100644 (file)
@@ -1039,11 +1039,11 @@ Session::set_state (const XMLNode& node)
        Path
        extra
        Options/Config
+       Locations
        Sources
        AudioRegions
        AudioDiskstreams
        Connections
-       Locations
        Routes
        EditGroups
        MixGroups
@@ -1066,6 +1066,39 @@ Session::set_state (const XMLNode& node)
                error << _("Session: XML state has no options section") << endmsg;
        }
 
+       if ((child = find_named_node (node, "Locations")) == 0) {
+               error << _("Session: XML state has no locations section") << endmsg;
+               goto out;
+       } else if (_locations.set_state (*child)) {
+               goto out;
+       }
+
+       Location* location;
+
+       if ((location = _locations.auto_loop_location()) != 0) {
+               set_auto_loop_location (location);
+       }
+
+       if ((location = _locations.auto_punch_location()) != 0) {
+               set_auto_punch_location (location);
+       }
+
+       if ((location = _locations.end_location()) == 0) {
+               _locations.add (end_location);
+       } else {
+               delete end_location;
+               end_location = location;
+       }
+
+       if ((location = _locations.start_location()) == 0) {
+               _locations.add (start_location);
+       } else {
+               delete start_location;
+               start_location = location;
+       }
+
+       AudioFileSource::set_header_position_offset (start_location->start());
+
        if ((child = find_named_node (node, "Sources")) == 0) {
                error << _("Session: XML state has no sources section") << endmsg;
                goto out;
@@ -1113,37 +1146,6 @@ Session::set_state (const XMLNode& node)
                goto out;
        }
 
-       if ((child = find_named_node (node, "Locations")) == 0) {
-               error << _("Session: XML state has no locations section") << endmsg;
-               goto out;
-       } else if (_locations.set_state (*child)) {
-               goto out;
-       }
-
-       Location* location;
-
-       if ((location = _locations.auto_loop_location()) != 0) {
-               set_auto_loop_location (location);
-       }
-
-       if ((location = _locations.auto_punch_location()) != 0) {
-               set_auto_punch_location (location);
-       }
-
-       if ((location = _locations.end_location()) == 0) {
-               _locations.add (end_location);
-       } else {
-               delete end_location;
-               end_location = location;
-       }
-
-       if ((location = _locations.start_location()) == 0) {
-               _locations.add (start_location);
-       } else {
-               delete start_location;
-               start_location = location;
-       }
-
        if ((child = find_named_node (node, "EditGroups")) == 0) {
                error << _("Session: XML state has no edit groups section") << endmsg;
                goto out;