possibly fix deadlocking issues with tempo map by rearranging code and adding RT...
[ardour.git] / libs / ardour / session_time.cc
index 0543fe2d021fea6de9b8fa4251478095f0ccee0c..38eb0b4b28859005a5f42f9a440e136169db7a1d 100644 (file)
@@ -484,20 +484,26 @@ Session::jack_timebase_callback (jack_transport_state_t /*state*/,
        if (_tempo_map) {
 
                TempoMetric metric (_tempo_map->metric_at (_transport_frame));
-               _tempo_map->bbt_time_with_metric (_transport_frame, bbt, metric);
 
-               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);
+               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_bar_division;
+                       pos->beats_per_minute = metric.tempo().beats_per_minute();
+                       
+                       pos->valid = jack_position_bits_t (pos->valid | JackPositionBBT);
+
+               } catch (...) {
+                       warning << _("failed to set tempo map information for JACK due to issues with tempo map") << endmsg;
+               }
        }
 
 #ifdef HAVE_JACK_VIDEO_SUPPORT
@@ -553,7 +559,7 @@ Session::convert_to_frames (AnyTime const & position)
 
        switch (position.type) {
        case AnyTime::BBT:
-               return _tempo_map->frame_time (position.bbt);
+               return _tempo_map->frame_time_rt (position.bbt);
                break;
 
        case AnyTime::Timecode: