diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 6231f9fc49..95a90166a0 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -584,6 +584,7 @@ ARDOUR_UI::engine_running (uint32_t cnt) update_cpu_load (); update_sample_rate (); update_timecode_format (); + session_latency_updated (true); update_peak_thread_work (); ActionManager::set_sensitive (ActionManager::engine_sensitive_actions, true); ActionManager::set_sensitive (ActionManager::engine_opposite_sensitive_actions, false); @@ -1443,6 +1444,35 @@ ARDOUR_UI::update_timecode_format () } +void +ARDOUR_UI::session_latency_updated (bool for_playback) +{ + if (!for_playback) { + /* latency updates happen in pairs, in the following order: + * - for capture + * - for playback + */ + return; + } + + if (!_session) { + pdc_info_label.set_text ("PDC: --"); + latency_info_label.set_text ("I/O Latency: --"); + } else { + samplecnt_t wrl = _session->worst_route_latency (); + samplecnt_t iol = _session->io_latency (); + float rate = _session->nominal_sample_rate (); + + pdc_info_label.set_text (string_compose ("PDC: %1", samples_as_time_string (wrl, rate))); + + if (_session->engine().check_for_ambiguous_latency (true)) { + latency_info_label.set_markup ("I/O Latency: ambiguous"); + } else { + latency_info_label.set_text (string_compose ("I/O Latency: %1", samples_as_time_string (iol, rate))); + } + } +} + gint ARDOUR_UI::update_wall_clock () { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index defaedaa1a..d9b4503670 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -564,6 +564,10 @@ private: Gtk::Label timecode_format_label; void update_timecode_format (); + Gtk::Label latency_info_label; + Gtk::Label pdc_info_label; + void session_latency_updated (bool); + Gtk::Label dsp_load_label; void update_cpu_load (); diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index fbdcbf48fb..f8e5482fb5 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -194,6 +194,7 @@ ARDOUR_UI::set_session (Session *s) _session->RecordStateChanged.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::record_state_changed, this), gui_context()); _session->TransportStateChange.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::map_transport_state, this), gui_context()); _session->DirtyChanged.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::session_dirty_changed, this), gui_context()); + _session->LatencyUpdated.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::session_latency_updated, this, _1), gui_context()); _session->PunchLoopConstraintChange.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::set_punch_sensitivity, this), gui_context()); _session->auto_punch_location_changed.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::set_punch_sensitivity, this), gui_context ()); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 58be43ee6a..c81b156744 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -779,17 +779,21 @@ ARDOUR_UI::build_menu_bar () ev->show (); EventBox* ev_dsp = manage (new EventBox); + EventBox* ev_pdc = manage (new EventBox); EventBox* ev_path = manage (new EventBox); EventBox* ev_name = manage (new EventBox); EventBox* ev_audio = manage (new EventBox); EventBox* ev_format = manage (new EventBox); + EventBox* ev_latency = manage (new EventBox); EventBox* ev_timecode = manage (new EventBox); ev_dsp->set_name ("MainMenuBar"); + ev_pdc->set_name ("MainMenuBar"); ev_path->set_name ("MainMenuBar"); ev_name->set_name ("MainMenuBar"); ev_audio->set_name ("MainMenuBar"); ev_format->set_name ("MainMenuBar"); + ev_latency->set_name ("MainMenuBar"); ev_timecode->set_name ("MainMenuBar"); Gtk::HBox* hbox = manage (new Gtk::HBox); @@ -811,16 +815,20 @@ ARDOUR_UI::build_menu_bar () format_label.set_use_markup (); ev_dsp->add (dsp_load_label); + ev_pdc->add (pdc_info_label); ev_path->add (session_path_label); ev_name->add (snapshot_name_label); ev_audio->add (sample_rate_label); ev_format->add (format_label); + ev_latency->add (latency_info_label); ev_timecode->add (timecode_format_label); ev_dsp->show (); + ev_pdc->show (); ev_path->show (); ev_audio->show (); ev_format->show (); + ev_latency->show (); ev_timecode->show (); #ifdef __APPLE__ @@ -836,6 +844,8 @@ ARDOUR_UI::build_menu_bar () hbox->pack_end (disk_space_label, false, false, 6); hbox->pack_end (*ev_audio, false, false, 6); hbox->pack_end (*ev_timecode, false, false, 6); + hbox->pack_end (*ev_pdc, false, false, 6); + hbox->pack_end (*ev_latency, false, false, 6); hbox->pack_end (*ev_format, false, false, 6); hbox->pack_end (peak_thread_work_label, false, false, 6); hbox->pack_end (*ev_name, false, false, 6); @@ -850,6 +860,8 @@ ARDOUR_UI::build_menu_bar () _status_bar_visibility.add (&snapshot_name_label ,X_("Name"), _("Snapshot Name and Modified Indicator"), false); _status_bar_visibility.add (&peak_thread_work_label,X_("Peakfile"), _("Active Peak-file Work"), false); _status_bar_visibility.add (&format_label, X_("Format"), _("File Format"), false); + _status_bar_visibility.add (&latency_info_label, X_("Latency"), _("Total I/O Latency"), !Profile->get_small_screen()); + _status_bar_visibility.add (&pdc_info_label, X_("PDC"), _("Plugin Latency"), !Profile->get_small_screen()); _status_bar_visibility.add (&timecode_format_label, X_("TCFormat"), _("Timecode Format"), false); _status_bar_visibility.add (&sample_rate_label, X_("Audio"), _("Audio"), true); _status_bar_visibility.add (&disk_space_label, X_("Disk"), _("Disk Space"), !Profile->get_small_screen());