2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2004 Paul Davis
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2009-12-03 13:44:06 -05:00
|
|
|
#include <cerrno>
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
#include <jack/jack.h>
|
|
|
|
#include <jack/transport.h>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/slave.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2008-06-02 17:41:35 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
|
|
|
|
JACK_Slave::JACK_Slave (jack_client_t* j)
|
|
|
|
: jack (j)
|
|
|
|
{
|
2009-01-09 04:18:24 -05:00
|
|
|
double x;
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t p;
|
2008-06-02 17:41:35 -04:00
|
|
|
/* call this to initialize things */
|
|
|
|
speed_and_position (x, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
JACK_Slave::~JACK_Slave ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
JACK_Slave::reset_client (jack_client_t* j)
|
|
|
|
{
|
|
|
|
jack = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
JACK_Slave::locked() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
JACK_Slave::ok() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
bool
|
2010-09-17 14:20:37 -04:00
|
|
|
JACK_Slave::speed_and_position (double& sp, framepos_t& position)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
jack_position_t pos;
|
|
|
|
jack_transport_state_t state;
|
2009-11-08 11:28:21 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
state = jack_transport_query (jack, &pos);
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case JackTransportStopped:
|
|
|
|
speed = 0;
|
|
|
|
_starting = false;
|
|
|
|
break;
|
|
|
|
case JackTransportRolling:
|
|
|
|
speed = 1.0;
|
|
|
|
_starting = false;
|
|
|
|
break;
|
|
|
|
case JackTransportLooping:
|
|
|
|
speed = 1.0;
|
|
|
|
_starting = false;
|
|
|
|
break;
|
|
|
|
case JackTransportStarting:
|
|
|
|
_starting = true;
|
|
|
|
// don't adjust speed here, just leave it as it was
|
|
|
|
break;
|
2008-09-21 12:17:02 -04:00
|
|
|
default:
|
|
|
|
cerr << "WARNING: Unknown JACK transport state: " << state << endl;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sp = speed;
|
|
|
|
position = pos.frame;
|
|
|
|
return true;
|
|
|
|
}
|