summaryrefslogtreecommitdiff
path: root/libs/ardour/engine_slave.cc
blob: 12b7d313a259031fb201340e956cb5a5640baa5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
    Copyright (C) 2004 Paul Davis

    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>
#include <cerrno>

#include "ardour/audioengine.h"
#include "ardour/audio_backend.h"
#include "ardour/session.h"
#include "ardour/transport_master.h"

#include "pbd/i18n.h"

using namespace std;
using namespace ARDOUR;

Engine_TransportMaster::Engine_TransportMaster (AudioEngine& e)
	: TransportMaster (Engine, X_("JACK"))
	, engine (e)
	, _starting (false)
{
	check_backend ();
}

Engine_TransportMaster::~Engine_TransportMaster ()
{
}

void
Engine_TransportMaster::init ()
{
}

void
Engine_TransportMaster::check_backend()
{
	if (AudioEngine::instance()->current_backend_name() == X_("JACK")) {
		_connected = true;
	} else {
		_connected = false;
	}
}

bool
Engine_TransportMaster::locked() const
{
	return true;
}

bool
Engine_TransportMaster::ok() const
{
	return true;
}

void
Engine_TransportMaster::pre_process (pframes_t, samplepos_t, boost::optional<samplepos_t>)
{
	/* nothing to do */
}

bool
Engine_TransportMaster::speed_and_position (double& sp, samplepos_t& position, samplepos_t /* now */)
{
	boost::shared_ptr<AudioBackend> backend = engine.current_backend();

	/* 3rd argument (now) doesn't matter here because we're always being
	 * called synchronously with the engine.
	 */

	if (backend && backend->speed_and_position (sp, position)) {
		return true;
	}

	_current_delta = 0;

	return false;
}

std::string
Engine_TransportMaster::position_string () const
{
	if (_session) {
		return PBD::to_string (_session->audible_sample());
	}

	return std::string();
}

std::string
Engine_TransportMaster::delta_string () const
{
	return string ("0");
}

bool
Engine_TransportMaster::allow_request (TransportRequestSource src, TransportRequestType type) const
{
	if (_session) {
		if (_session->config.get_jack_time_master()) {
			return true;
		} else {
			return false;
		}
	}

	return true;
}