Convert some error output to debug output in PortaudioBackend
[ardour.git] / libs / surfaces / control_protocol / basic_ui.cc
index 3d00b6283f4c6025d33f62544f38e6712acb64ce..bf6bb25f2cac17fd7900078299c0e8bef08dde75 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include "pbd/pthread_utils.h"
+#include "pbd/memento_command.h"
 
 #include "ardour/session.h"
 #include "ardour/location.h"
@@ -28,7 +29,6 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
-using ARDOUR::nframes_t;
 
 PBD::Signal2<void,std::string,std::string> BasicUI::AccessAction;
 
@@ -79,6 +79,20 @@ BasicUI::loop_toggle ()
        }
 }
 
+void
+BasicUI::loop_location (framepos_t start, framepos_t end)
+{
+       Location* tll;
+       if ((tll = session->locations()->auto_loop_location()) == 0) {
+               Location* loc = new Location (*session, start, end, _("Loop"),  Location::IsAutoLoop);
+               session->locations()->add (loc, true);
+               session->set_auto_loop_location (loc);
+       } else {
+               tll->set_hidden (false, this);
+               tll->set (start, end);
+       }
+}
+
 void
 BasicUI::goto_start ()
 {
@@ -92,22 +106,28 @@ BasicUI::goto_end ()
 }
 
 void       
-BasicUI::add_marker ()
+BasicUI::add_marker (const std::string& markername)
 {
-       nframes_t when = session->audible_frame();
-       session->locations()->add (new Location (*session, when, when, _("unnamed"), Location::IsMark));
+       framepos_t where = session->audible_frame();
+       Location *location = new Location (*session, where, where, markername, Location::IsMark);
+       session->begin_reversible_command (_("add marker"));
+       XMLNode &before = session->locations()->get_state();
+       session->locations()->add (location, true);
+       XMLNode &after = session->locations()->get_state();
+       session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
+       session->commit_reversible_command ();
 }
 
 void
 BasicUI::rewind ()
 {
-       session->request_transport_speed (-2.0f);
+       session->request_transport_speed (session->transport_speed() - 1.5);
 }
 
 void
 BasicUI::ffwd ()
 {
-       session->request_transport_speed (2.0f);
+       session->request_transport_speed (session->transport_speed() + 1.5);
 }
 
 void
@@ -165,10 +185,10 @@ BasicUI::save_state ()
 void
 BasicUI::prev_marker ()
 {
-       Location *location = session->locations()->first_location_before (session->transport_frame());
+       framepos_t pos = session->locations()->first_mark_before (session->transport_frame());
        
-       if (location) {
-               session->request_locate (location->start(), session->transport_rolling());
+       if (pos >= 0) {
+               session->request_locate (pos, session->transport_rolling());
        } else {
                session->goto_start ();
        }
@@ -177,12 +197,12 @@ BasicUI::prev_marker ()
 void
 BasicUI::next_marker ()
 {
-       Location *location = session->locations()->first_location_after (session->transport_frame());
+       framepos_t pos = session->locations()->first_mark_after (session->transport_frame());
 
-       if (location) {
-               session->request_locate (location->start(), session->transport_rolling());
+       if (pos >= 0) {
+               session->request_locate (pos, session->transport_rolling());
        } else {
-               session->request_locate (session->current_end_frame());
+               session->goto_end();
        }
 }
 
@@ -248,14 +268,14 @@ BasicUI::set_record_enable (bool yn)
        }
 }
 
-nframes_t
+framepos_t
 BasicUI::transport_frame ()
 {
        return session->transport_frame();
 }
 
 void
-BasicUI::locate (nframes_t where, bool roll_after_locate)
+BasicUI::locate (framepos_t where, bool roll_after_locate)
 {
        session->request_locate (where, roll_after_locate);
 }
@@ -272,26 +292,26 @@ BasicUI::locked ()
        return session->transport_locked ();
 }
 
-nframes_t
+ARDOUR::framecnt_t
 BasicUI::timecode_frames_per_hour ()
 {
        return session->timecode_frames_per_hour ();
 }
 
 void
-BasicUI::timecode_time (nframes_t where, Timecode::Time& timecode)
+BasicUI::timecode_time (framepos_t where, Timecode::Time& timecode)
 {
        session->timecode_time (where, *((Timecode::Time *) &timecode));
 }
 
 void 
-BasicUI::timecode_to_sample (Timecode::Time& timecode, int64_t& sample, bool use_offset, bool use_subframes) const
+BasicUI::timecode_to_sample (Timecode::Time& timecode, framepos_t & sample, bool use_offset, bool use_subframes) const
 {
        session->timecode_to_sample (*((Timecode::Time*)&timecode), sample, use_offset, use_subframes);
 }
 
 void 
-BasicUI::sample_to_timecode (int64_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes) const
+BasicUI::sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes) const
 {
        session->sample_to_timecode (sample, *((Timecode::Time*)&timecode), use_offset, use_subframes);
 }