OSC: New personal monitor buses no longer need to be hidden
[ardour.git] / libs / surfaces / tranzport / init.cc
index 3a01185407e8636feda85cf5ad9cf0de84a5d3ba..56501b2c2cbb8d38e0c878670057bb0f2258595f 100644 (file)
@@ -26,7 +26,7 @@ using namespace std;
 using namespace sigc;
 using namespace PBD;
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 #include <pbd/abstract_ui.cc>
 
@@ -43,16 +43,12 @@ TranzportControlProtocol::~TranzportControlProtocol ()
 
 int TranzportControlProtocol::rtpriority_set(int priority)
 {
-       struct sched_param rtparam;
-       int err;
        char *a = (char*) alloca(4096*2); a[0] = 'a'; a[4096] = 'b';
-       memset (&rtparam, 0, sizeof (rtparam));
-       rtparam.sched_priority = priority; /* XXX should be relative to audio (JACK) thread */
        // Note - try SCHED_RR with a low limit
        // - we don't care if we can't write everything this ms
        // and it will help if we lose the device
-       if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) {
-               PBD::info << string_compose (_("%1: thread not running with realtime scheduling (%2)"), name(), strerror (errno)) << endmsg;
+       if (set_thread_priority (SCHED_FIFO, priority)) {
+               PBD::info << string_compose (_("%1: thread not running with realtime scheduling."), name(), strerror (errno)) << endmsg;
                return 1;
        }
        return 0;
@@ -65,7 +61,7 @@ int TranzportControlProtocol::rtpriority_unset(int priority)
        struct sched_param rtparam;
        int err;
        memset (&rtparam, 0, sizeof (rtparam));
-       rtparam.sched_priority = priority;      
+       rtparam.sched_priority = priority;
        if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) {
                PBD::info << string_compose (_("%1: can't stop realtime scheduling (%2)"), name(), strerror (errno)) << endmsg;
                return 1;
@@ -127,7 +123,7 @@ TranzportControlProtocol::TranzportControlProtocol (Session& s)
        _device_status = STATUS_OFFLINE;
        udev = 0;
        current_track_id = 0;
-       last_where = max_frames;
+       last_where = max_samples;
        wheel_mode = WheelTimeline;
        wheel_shift_mode = WheelShiftGain;
        wheel_increment = WheelIncrScreen;
@@ -208,7 +204,7 @@ TranzportControlProtocol::monitor_work ()
                case 3: val = read(buf,DEFAULT_USB_TIMEOUT*2); break; // Hoo, boy, we're in trouble
                default: break; // not reached
                }
-       
+
 #if DEBUG_TRANZPORT_BITS > 9
                if(_device_status != STATUS_OFFLINE && _device_status != STATUS_ONLINE && _device_status != STATUS_OK) {
                        printf("The device has more status bits than off or online: %d\n",_device_status);
@@ -265,7 +261,7 @@ TranzportControlProtocol::monitor_work ()
                                printf("OFFLINE  : %02x %02x %02x %02x %02x %02x %02x %02x\n",
                                       buf[0],buf[1],buf[2], buf[3], buf[4], buf[5],buf[6],buf[7]);
                        }
-       
+
                        if(_device_status == STATUS_OK) {
                                printf("OK       : %02x %02x %02x %02x %02x %02x %02x %02x\n",
                                       buf[0],buf[1],buf[2], buf[3], buf[4], buf[5],buf[6],buf[7]);