fix problem with attempting to set virtual keyboard port pretty name from a port registration callback

The JACK API doesn't allow server calls from inside a server callback, even though JACK2 doesn't enforce this.

It would be nice to find a way to NOT call Session::setup_bundles() from every port registration callback, too.
This commit is contained in:
Paul Davis 2021-02-09 15:42:05 -07:00
parent f9b8b761e0
commit 220706459f
3 changed files with 21 additions and 1 deletions

View File

@ -2234,6 +2234,8 @@ private:
bool _had_destructive_tracks;
std::string unnamed_file_name () const;
gint _update_pretty_names;
};

View File

@ -327,6 +327,7 @@ Session::Session (AudioEngine &eng,
, _selection (new CoreSelection (*this))
, _global_locate_pending (false)
, _had_destructive_tracks (false)
, _update_pretty_names (0)
{
created_with = string_compose ("%1 %2", PROGRAM_NAME, revision);
@ -7147,6 +7148,15 @@ Session::auto_connect_thread_run ()
}
}
if (_midi_ports && g_atomic_int_get (&_update_pretty_names)) {
boost::shared_ptr<Port> ap = boost::dynamic_pointer_cast<Port> (vkbd_output_port ());
if (ap->pretty_name () != _("Virtual Keyboard")) {
ap->set_pretty_name (_("Virtual Keyboard"));
}
g_atomic_int_set (&_update_pretty_names, 0);
}
if (_engine.port_deletions_pending ().read_space () > 0) {
// this may call ARDOUR::Port::drop ... jack_port_unregister ()
// jack1 cannot cope with removing ports while processing

View File

@ -125,7 +125,15 @@ Session::setup_bundles ()
if (_midi_ports) {
boost::shared_ptr<Port> ap = boost::dynamic_pointer_cast<Port> (vkbd_output_port ());
inputs[DataType::MIDI].push_back (AudioEngine::instance()->make_port_name_non_relative (ap->name ()));
ap->set_pretty_name (_("Virtual Keyboard"));
/* JACK semantics prevent us directly calling the
pretty-name/metadata API from a server callback, and this is
called from a port registration callback. So defer to the
auto-connect thread, which does this sort of thing anyway.
*/
g_atomic_int_set (&_update_pretty_names, 1);
auto_connect_thread_wakeup ();
}
/* Create a set of Bundle objects that map