-arestore jack timebase master and jack session callback functionality (moved into the JACK backend)

This commit is contained in:
Paul Davis
2013-10-08 14:01:43 -04:00
parent c94f0b6298
commit 7e077bdeba
2 changed files with 100 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 1999-2013 Paul Davis
Copyright (C) 2013 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
@@ -18,16 +18,11 @@
*/
#ifdef WAF_BUILD
#include "libardour-config.h"
#endif
#include <time.h>
#include <glibmm/miscutils.h>
#include "jack/jack.h"
#include "jack/session.h"
#include <jack/jack.h>
#include "ardour/audioengine.h"
#include "ardour/filename_extensions.h"
@@ -35,12 +30,22 @@
#include "ardour/session_directory.h"
#include "ardour/tempo.h"
#include "jack_session.h"
using namespace ARDOUR;
using std::string;
#ifdef HAVE_JACK_SESSION
JACKSession::JACKSession (Session* s)
: SessionHandlePtr (s)
{
}
JACKSession::~JACKSession ()
{
}
void
Session::jack_session_event (jack_session_event_t* event)
JACKSession::session_event (jack_session_event_t* event)
{
char timebuf[128], *tmp;
time_t n;
@@ -54,7 +59,7 @@ Session::jack_session_event (jack_session_event_t* event)
if (event->type == JackSessionSaveTemplate)
{
if (save_template( timebuf )) {
if (_session->save_template( timebuf )) {
event->flags = JackSessionSaveError;
} else {
string cmd ("ardour3 -P -U ");
@@ -67,10 +72,10 @@ Session::jack_session_event (jack_session_event_t* event)
}
else
{
if (save_state (timebuf)) {
if (_session->save_state (timebuf)) {
event->flags = JackSessionSaveError;
} else {
std::string xml_path (_session_dir->root_path());
std::string xml_path (_session->session_directory().root_path());
std::string legalized_filename = legalize_for_path (timebuf) + statefile_suffix;
xml_path = Glib::build_filename (xml_path, legalized_filename);
@@ -95,66 +100,69 @@ Session::jack_session_event (jack_session_event_t* event)
}
if (event->type == JackSessionSaveAndQuit) {
Quit (); /* EMIT SIGNAL */
_session->Quit (); /* EMIT SIGNAL */
}
jack_session_event_free( event );
jack_session_event_free (event);
}
#endif
void
Session::jack_timebase_callback (jack_transport_state_t /*state*/,
JACKSession::timebase_callback (jack_transport_state_t /*state*/,
pframes_t /*nframes*/,
jack_position_t* pos,
int /*new_position*/)
{
Timecode::BBT_Time bbt;
TempoMap& tempo_map (_session->tempo_map());
framepos_t tf = _session->transport_frame ();
/* BBT info */
if (_tempo_map) {
TempoMetric metric (_tempo_map->metric_at (_transport_frame));
try {
_tempo_map->bbt_time_rt (_transport_frame, bbt);
pos->bar = bbt.bars;
pos->beat = bbt.beats;
pos->tick = bbt.ticks;
// XXX still need to set bar_start_tick
pos->beats_per_bar = metric.meter().divisions_per_bar();
pos->beat_type = metric.meter().note_divisor();
pos->ticks_per_beat = Timecode::BBT_Time::ticks_per_beat;
pos->beats_per_minute = metric.tempo().beats_per_minute();
pos->valid = jack_position_bits_t (pos->valid | JackPositionBBT);
} catch (...) {
/* no message */
}
TempoMetric metric (tempo_map.metric_at (tf));
try {
tempo_map.bbt_time_rt (tf, bbt);
pos->bar = bbt.bars;
pos->beat = bbt.beats;
pos->tick = bbt.ticks;
// XXX still need to set bar_start_tick
pos->beats_per_bar = metric.meter().divisions_per_bar();
pos->beat_type = metric.meter().note_divisor();
pos->ticks_per_beat = Timecode::BBT_Time::ticks_per_beat;
pos->beats_per_minute = metric.tempo().beats_per_minute();
pos->valid = jack_position_bits_t (pos->valid | JackPositionBBT);
} catch (...) {
/* no message */
}
#ifdef HAVE_JACK_VIDEO_SUPPORT
//poke audio video ratio so Ardour can track Video Sync
pos->audio_frames_per_video_frame = frame_rate() / timecode_frames_per_second();
pos->audio_frames_per_video_frame = _session->frame_rate() / _session->timecode_frames_per_second();
pos->valid = jack_position_bits_t (pos->valid | JackAudioVideoRatio);
#endif
#if 0
#ifdef HAVE_JACK_TIMCODE_SUPPORT
/* This is not yet defined in JACK */
/* Timecode info */
pos->timecode_offset = config.get_timecode_offset();
t.timecode_frame_rate = timecode_frames_per_second();
pos->valid = jack_position_bits_t (pos->valid | JackPositionTimecode;
pos->timecode_offset = _session->config.get_timecode_offset();
t.timecode_frame_rate = _session->timecode_frames_per_second();
pos->valid = jack_position_bits_t (pos->valid | JackPositionTimecode);
#endif
#ifdef HAVE_JACK_LOOPING_SUPPORT
/* This is not yet defined in JACK */
if (_transport_speed) {
if (play_loop) {
Location* location = _locations.auto_loop_location();
Location* location = _session->locations()->auto_loop_location();
if (location) {

View File

@@ -0,0 +1,47 @@
/*
Copyright (C) 2013 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.
*/
#ifndef __ardour_jack_audiobackend_jack_session_h__
#define __ardour_jack_audiobackend_jack_session_h__
#include <jack/session.h>
#include <jack/transport.h>
#include "ardour/types.h"
#include "ardour/session_handle.h"
namespace ARDOUR {
class Session;
class JACKSession : public ARDOUR::SessionHandlePtr
{
public:
JACKSession (ARDOUR::Session* s);
~JACKSession ();
void session_event (jack_session_event_t* event);
void timebase_callback (jack_transport_state_t /*state*/,
ARDOUR::pframes_t /*nframes*/,
jack_position_t* pos,
int /*new_position*/);
};
} /* namespace */
#endif /* __ardour_jack_audiobackend_jack_session_h__ */