Changeset 79c75fd07bec3ba6e33dcb5fce11aba37a20e601

Show
Ignore:
Timestamp:
11/07/10 19:52:08 (3 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
eb866bf6e8302d2fc26ac8c490d28ba9adc6bd67
Parents:
7d3acd7331866af33e845d1b35fbe4a4d599a5b8
git-author:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-11-07T19:42:12Z+0200
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-11-07T19:52:08Z+0200
Message:

ladishd: properly handle stopping and removal of apps with a2j ports

Location:
daemon
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • daemon/graph.c

    r222dec6 r79c75fd0  
    17851785 
    17861786  return port_ptr->port; 
     1787} 
     1788 
     1789bool ladish_graph_client_has_visible_app_port(ladish_graph_handle graph_handle, ladish_client_handle client_handle, const uuid_t app_uuid) 
     1790{ 
     1791  struct ladish_graph_client * client_ptr; 
     1792  struct list_head * node_ptr; 
     1793  struct ladish_graph_port * port_ptr; 
     1794 
     1795  client_ptr = ladish_graph_find_client(graph_ptr, client_handle); 
     1796  if (client_ptr == NULL) 
     1797  { 
     1798    ASSERT_NO_PASS; 
     1799    return false; 
     1800  } 
     1801 
     1802  list_for_each(node_ptr, &client_ptr->ports) 
     1803  { 
     1804    port_ptr = list_entry(node_ptr, struct ladish_graph_port, siblings_client); 
     1805    if (port_ptr->hidden) 
     1806    { 
     1807      continue; 
     1808    } 
     1809 
     1810    if (ladish_port_belongs_to_app(port_ptr->port, app_uuid)) 
     1811    { 
     1812      ASSERT(!client_ptr->hidden); 
     1813      return true; 
     1814    } 
     1815  } 
     1816 
     1817  return false; 
    17871818} 
    17881819 
  • daemon/graph.h

    r2eac623 r79c75fd0  
    175175void ladish_graph_hide_non_virtual(ladish_graph_handle graph_handle); 
    176176void ladish_graph_get_port_uuid(ladish_graph_handle graph, ladish_port_handle port, uuid_t uuid_ptr); 
     177bool ladish_graph_client_has_visible_app_port(ladish_graph_handle graph, ladish_client_handle client, const uuid_t app_uuid); 
    177178 
    178179void ladish_graph_dump(ladish_graph_handle graph_handle); 
  • daemon/port.c

    r2eac623 r79c75fd0  
    3232  int refcount; 
    3333  uuid_t uuid;                             /* The UUID of the port */ 
     34  uuid_t app_uuid;                         /* The UUID of the app that owns this client */ 
    3435  bool link;                               /* Whether the port is studio-room link port */ 
    3536  uint64_t jack_id;                        /* JACK port ID. */ 
     
    7273  } 
    7374 
     75  uuid_clear(port_ptr->app_uuid); 
     76 
    7477  port_ptr->jack_id = 0; 
    7578  port_ptr->jack_id_room = 0; 
     
    170173} 
    171174 
     175void ladish_port_set_app(ladish_port_handle port_handle, const uuid_t app_uuid) 
     176{ 
     177  uuid_copy(port_ptr->app_uuid, app_uuid); 
     178} 
     179 
     180bool ladish_port_get_app(ladish_port_handle port_handle, uuid_t app_uuid) 
     181{ 
     182  if (uuid_is_null(port_ptr->app_uuid)) 
     183  { 
     184    return false; 
     185  } 
     186 
     187  uuid_copy(app_uuid, port_ptr->app_uuid); 
     188  return true; 
     189} 
     190 
     191bool ladish_port_has_app(ladish_port_handle port_handle) 
     192{ 
     193  return !uuid_is_null(port_ptr->app_uuid); 
     194} 
     195 
     196bool ladish_port_belongs_to_app(ladish_port_handle port_handle, const uuid_t app_uuid) 
     197{ 
     198  if (uuid_is_null(port_ptr->app_uuid)) 
     199  { 
     200    return false; 
     201  } 
     202 
     203  return uuid_compare(port_ptr->app_uuid, app_uuid) == 0; 
     204} 
     205 
    172206#undef port_ptr 
  • daemon/port.h

    r2eac623 r79c75fd0  
    5151void * ladish_port_get_vgraph(ladish_port_handle port_handle); 
    5252 
     53void ladish_port_set_app(ladish_port_handle port, const uuid_t app_uuid); 
     54bool ladish_port_get_app(ladish_port_handle port, uuid_t app_uuid); 
     55bool ladish_port_has_app(ladish_port_handle port); 
     56bool ladish_port_belongs_to_app(ladish_port_handle port, const uuid_t app_uuid); 
     57 
    5358#endif /* #ifndef PORT_H__62F81E7C_91FA_44AB_94A9_E0E2D226ED58__INCLUDED */ 
  • daemon/virtualizer.c

    r7d3acd7 r79c75fd0  
    217217{ 
    218218  ladish_port_handle port; 
    219   ladish_client_handle jclient; 
    220219  ladish_graph_handle vgraph; 
    221220 
     
    227226  } 
    228227 
    229   jclient = ladish_graph_get_port_client(virtualizer_ptr->jack_graph, port); 
    230   if (jclient == NULL) 
    231   { 
    232     log_error("Port %"PRIu64" without jack client was (dis)connected", port_id); 
    233     return false; 
    234   } 
    235  
    236   vgraph = ladish_client_get_vgraph(jclient); 
     228  vgraph = ladish_port_get_vgraph(port); 
    237229  if (vgraph == NULL) 
    238230  { 
     
    628620    } 
    629621 
     622    /* for normal ports, one can find the app_uuid through the jack client, 
     623       but for a2j ports the jack client is shared between graphs */ 
     624    if (has_app) 
     625    { 
     626      ladish_port_set_app(port, app_uuid); 
     627    } 
     628 
    630629    ladish_client_set_jack_id(vclient, client_id); 
    631630    ladish_graph_adjust_port(vgraph, port, type, flags); 
     
    643642  ladish_port_set_jack_id(port, port_id); 
    644643 
    645   /* for normal ports, one can find the vgraph through the jack client, 
     644  /* for normal ports, one can find the vgraph and app_uuid through the jack client, 
    646645     but for a2j ports the jack client is shared between graphs */ 
    647646  ladish_port_set_vgraph(port, vgraph); 
     647  if (has_app) 
     648  { 
     649    ladish_port_set_app(port, app_uuid); 
     650  } 
    648651 
    649652  if (!ladish_graph_add_port(virtualizer_ptr->jack_graph, jack_client, port, jack_port_name, type, flags, false)) 
     
    11001103} 
    11011104 
     1105static bool app_has_a2j_ports(ladish_graph_handle jack_graph, const uuid_t app_uuid) 
     1106{ 
     1107  ladish_client_handle a2jclient; 
     1108 
     1109  a2jclient = ladish_graph_find_client_by_uuid(jack_graph, g_a2j_uuid); 
     1110  if (a2jclient == NULL) 
     1111  { 
     1112    return false; 
     1113  } 
     1114 
     1115  return ladish_graph_client_has_visible_app_port(jack_graph, a2jclient, app_uuid); 
     1116} 
     1117 
    11021118bool 
    11031119ladish_virtualizer_is_hidden_app( 
     
    11161132  //ladish_graph_dump(g_studio.jack_graph); 
    11171133 
     1134  if (app_has_a2j_ports(jack_graph, app_uuid)) 
     1135  { 
     1136    log_info("app '%s' still has a2j ports", app_name); 
     1137    return false; 
     1138  } 
     1139 
    11181140  jclient = ladish_graph_find_client_by_app(jack_graph, app_uuid); 
    11191141  if (jclient == NULL) 
     
    11771199  return true; 
    11781200} 
     1201 
     1202struct app_remove_context 
     1203{ 
     1204  uuid_t app_uuid; 
     1205  const char * app_name; 
     1206}; 
     1207 
     1208#define app_info_ptr ((struct app_remove_context *)context) 
     1209 
     1210static 
     1211bool 
     1212remove_app_port( 
     1213  void * context, 
     1214  ladish_graph_handle graph_handle, 
     1215  void * client_iteration_context_ptr, 
     1216  ladish_client_handle client_handle, 
     1217  const char * client_name, 
     1218  ladish_port_handle port_handle, 
     1219  const char * port_name, 
     1220  uint32_t port_type, 
     1221  uint32_t port_flags) 
     1222{ 
     1223  ladish_graph_handle vgraph; 
     1224  ladish_client_handle vclient; 
     1225 
     1226  if (!ladish_port_belongs_to_app(port_handle, app_info_ptr->app_uuid)) 
     1227  { 
     1228    return true; 
     1229  } 
     1230 
     1231  //log_info("removing port '%s':'%s' (JACK) of app '%s'", client_name, port_name, app_info_ptr->app_name); 
     1232 
     1233  vgraph = ladish_port_get_vgraph(port_handle); 
     1234  if (vgraph == NULL) 
     1235  { 
     1236    log_error("port '%s':'%s' of app '5s' has no vgraph", client_name, port_name, app_info_ptr->app_name); 
     1237    ASSERT_NO_PASS; 
     1238    return true; 
     1239  } 
     1240 
     1241  vclient = ladish_graph_get_port_client(vgraph, port_handle); 
     1242  if (vgraph == NULL) 
     1243  { 
     1244    log_error("app port '%s':'%s' not found in vgraph '%s'", client_name, port_name, ladish_graph_get_description(vgraph)); 
     1245    ASSERT_NO_PASS; 
     1246    return true; 
     1247  } 
     1248 
     1249  log_info( 
     1250    "removing %s %s port %p of app '%s' ('%s':'%s' in %s)", 
     1251    port_type == JACKDBUS_PORT_TYPE_AUDIO ? "audio" : "midi", 
     1252    JACKDBUS_PORT_IS_INPUT(port_flags) ? "input" : "output", 
     1253    port_handle, 
     1254    app_info_ptr->app_name, 
     1255    ladish_graph_get_client_name(vgraph, vclient), 
     1256    ladish_graph_get_port_name(vgraph, port_handle), 
     1257    ladish_graph_get_description(vgraph)); 
     1258 
     1259  return true; 
     1260} 
     1261 
     1262#undef app_info_ptr 
    11791263 
    11801264void 
     
    11911275  uuid_t jclient_uuid; 
    11921276  bool is_a2j; 
     1277  struct app_remove_context ctx; 
    11931278 
    11941279  //ladish_graph_dump(g_studio.jack_graph); 
     1280 
     1281  uuid_copy(ctx.app_uuid, app_uuid); 
     1282  ctx.app_name = app_name; 
     1283 
     1284  ladish_graph_iterate_nodes(jack_graph, false, NULL, &ctx, NULL, remove_app_port, NULL); 
    11951285 
    11961286  jclient = ladish_graph_find_client_by_app(jack_graph, app_uuid);