provide support for playhead-to-next/previous-region-boundary actions, and bindings...
[ardour.git] / libs / ardour / diskstream.cc
index 5124621e40aee353b7fc85cf216dbfddd4192a55..2a307b1f31eec914132f33232b2bb221b3d63d3c 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: diskstream.cc 567 2006-06-07 14:54:12Z trutkin $
 */
 
 #include <fstream>
@@ -110,11 +109,13 @@ Diskstream::init (Flag f)
        speed_buffer_size = 0;
        last_phase = 0;
        phi = (uint64_t) (0x1000000);
+       target_phi = phi;
        file_frame = 0;
        playback_sample = 0;
        playback_distance = 0;
        _read_data_count = 0;
        _write_data_count = 0;
+       commit_should_unlock = false;
 
        pending_overwrite = false;
        overwrite_frame = 0;
@@ -126,9 +127,6 @@ Diskstream::init (Flag f)
 
 Diskstream::~Diskstream ()
 {
-       // Taken by derived class destrctors.. should assure locked here somehow?
-       //Glib::Mutex::Lock lm (state_lock);
-
        if (_playlist)
                _playlist->release ();
 }
@@ -154,8 +152,7 @@ Diskstream::handle_input_change (IOChange change, void *src)
 void
 Diskstream::non_realtime_set_speed ()
 {
-       if (_buffer_reallocation_required)
-       {
+       if (_buffer_reallocation_required) {
                Glib::Mutex::Lock lm (state_lock);
                allocate_temporary_buffers ();
 
@@ -195,7 +192,7 @@ Diskstream::realtime_set_speed (double sp, bool global)
                }
                
                _actual_speed = new_speed;
-               phi = (uint64_t) (0x1000000 * fabs(_actual_speed));
+               target_phi = (uint64_t) (0x1000000 * fabs(_actual_speed));
        }
 
        if (changed) {
@@ -218,7 +215,9 @@ Diskstream::prepare ()
 void
 Diskstream::recover ()
 {
-       state_lock.unlock();
+       if (commit_should_unlock) {
+               state_lock.unlock();
+       }
        _processed = false;
 }