Changeset 6c2201b933ebc1d6c4049a3138d2e46aae3e56d7

Show
Ignore:
Timestamp:
11/08/10 01:19:02 (3 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
bea7c694e008ff9095e18e746d1c6bdd9e0f5ec8
Parents:
8aebce6821ae5d0266dcbc3de61ad34fe83e39e3
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-11-08T01:19:02Z+0200
Message:

ladishd: save [only] relevant a2j ports for the vgraph being saved

For studio saves, save only studio vgraph a2j ports.
For room project saves, save only room vgraph a2j ports.
If there is not a2j ports for the vgraph being saved, an empty a2j client will not be saved anymore

Location:
daemon
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • daemon/graph.c

    r79c75fd0 r6c2201b  
    21712171  ladish_graph_handle graph_handle, 
    21722172  bool skip_hidden, 
    2173   void * vgraph_filter, 
    21742173  void * callback_context, 
    21752174  bool 
     
    22042203  struct list_head * port_node_ptr; 
    22052204  struct ladish_graph_port * port_ptr; 
    2206   void * vgraph; 
    22072205 
    22082206  list_for_each(client_node_ptr, &graph_ptr->clients) 
     
    22132211    { 
    22142212      continue; 
    2215     } 
    2216  
    2217     if (vgraph_filter != NULL) 
    2218     { 
    2219       vgraph = ladish_client_get_vgraph(client_ptr->client); 
    2220       if (vgraph != vgraph_filter) 
    2221       { 
    2222         continue; 
    2223       } 
    22242213    } 
    22252214 
     
    25902579    src, 
    25912580    skip_hidden, 
    2592     NULL, 
    25932581    dest, 
    25942582    ladish_graph_copy_client_begin_callback, 
  • daemon/graph.h

    r79c75fd0 r6c2201b  
    183183  ladish_graph_handle graph_handle, 
    184184  bool skip_hidden, 
    185   void * vgraph_filter, 
    186185  void * callback_context, 
    187186  bool 
  • daemon/load.c

    r5b12bd5 r6c2201b  
    359359  ctx.app_supervisor = app_supervisor; 
    360360 
    361   ladish_graph_iterate_nodes(ladish_studio_get_jack_graph(), false, NULL, &ctx, interlink_client, NULL, NULL); 
    362 } 
     361  ladish_graph_iterate_nodes(ladish_studio_get_jack_graph(), false, &ctx, interlink_client, NULL, NULL); 
     362} 
  • daemon/room.c

    r78e99c4 r6c2201b  
    538538    room_ptr->graph, 
    539539    false, 
    540     NULL, 
    541540    &context, 
    542541    ladish_room_iterate_link_ports_client_callback, 
     
    575574  } 
    576575 
    577   ladish_graph_iterate_nodes(room_ptr->graph, false, NULL, room_ptr, NULL, destroy_port_link, NULL); 
     576  ladish_graph_iterate_nodes(room_ptr->graph, false, room_ptr, NULL, destroy_port_link, NULL); 
    578577  ladish_app_supervisor_stop(room_ptr->app_supervisor); 
    579578} 
  • daemon/save.c

    reb866bf r6c2201b  
    610610} 
    611611 
     612#undef indent 
     613#undef fd 
     614 
     615bool ladish_write_dict(int fd, int indent, ladish_dict_handle dict) 
     616{ 
     617  struct ladish_write_context context; 
     618 
     619  if (ladish_dict_is_empty(dict)) 
     620  { 
     621    return true; 
     622  } 
     623 
     624  context.fd = fd; 
     625  context.indent = indent + 1; 
     626 
     627  if (!ladish_write_indented_string(fd, indent, "<dict>\n")) 
     628  { 
     629    return false; 
     630  } 
     631 
     632  if (!ladish_dict_iterate(dict, &context, write_dict_entry)) 
     633  { 
     634    return false; 
     635  } 
     636 
     637  if (!ladish_write_indented_string(fd, indent, "</dict>\n")) 
     638  { 
     639    return false; 
     640  } 
     641 
     642  return true; 
     643} 
     644 
     645bool ladish_write_vgraph(int fd, int indent, ladish_graph_handle vgraph, ladish_app_supervisor_handle app_supervisor) 
     646{ 
     647  struct ladish_write_context context; 
     648 
     649  context.fd = fd; 
     650  context.indent = indent + 1; 
     651 
     652  if (!ladish_write_indented_string(fd, indent, "<clients>\n")) 
     653  { 
     654    return false; 
     655  } 
     656 
     657  if (!ladish_graph_iterate_nodes( 
     658        vgraph, 
     659        true, 
     660        &context, 
     661        ladish_save_vgraph_client_begin, 
     662        ladish_save_vgraph_port, 
     663        ladish_save_vgraph_client_end)) 
     664  { 
     665    log_error("ladish_graph_iterate_nodes() failed"); 
     666    return false; 
     667  } 
     668 
     669  if (!ladish_write_indented_string(fd, indent, "</clients>\n")) 
     670  { 
     671    return false; 
     672  } 
     673 
     674  if (!ladish_write_indented_string(fd, indent, "<connections>\n")) 
     675  { 
     676    return false; 
     677  } 
     678 
     679  if (!ladish_graph_iterate_connections(vgraph, true, &context, ladish_save_vgraph_connection)) 
     680  { 
     681    log_error("ladish_graph_iterate_connections() failed"); 
     682    return false; 
     683  } 
     684 
     685  if (!ladish_write_indented_string(fd, indent, "</connections>\n")) 
     686  { 
     687    return false; 
     688  } 
     689 
     690  if (!ladish_write_indented_string(fd, indent, "<applications>\n")) 
     691  { 
     692    return false; 
     693  } 
     694 
     695  if (!ladish_app_supervisor_enum(app_supervisor, &context, ladish_save_app)) 
     696  { 
     697    return false; 
     698  } 
     699 
     700  if (!ladish_write_indented_string(fd, indent, "</applications>\n")) 
     701  { 
     702    return false; 
     703  } 
     704 
     705  return true; 
     706} 
     707 
     708bool ladish_write_room_link_ports(int fd, int indent, ladish_room_handle room) 
     709{ 
     710  struct ladish_write_context context; 
     711 
     712  context.fd = fd; 
     713  context.indent = indent; 
     714 
     715  if (!ladish_room_iterate_link_ports(room, &context, ladish_write_room_port)) 
     716  { 
     717    log_error("ladish_room_iterate_link_ports() failed"); 
     718    return false; 
     719  } 
     720 
     721  return true; 
     722} 
     723 
     724/********************/ 
     725/* write jack graph */ 
     726/********************/ 
     727 
     728struct ladish_write_jack_context 
     729{ 
     730  int fd; 
     731  int indent; 
     732  ladish_graph_handle vgraph_filter; 
     733  bool client_vgraph_match; 
     734  bool a2j; 
     735  bool client_visible; 
     736}; 
     737 
     738static bool ladish_save_jack_client_write_prolog(int fd, int indent, ladish_client_handle client_handle, const char * client_name) 
     739{ 
     740  uuid_t uuid; 
     741  char str[37]; 
     742 
     743  ladish_client_get_uuid(client_handle, uuid); 
     744  uuid_unparse(uuid, str); 
     745 
     746  log_info("saving jack client '%s' (%s)", client_name, str); 
     747 
     748  if (!ladish_write_indented_string(fd, indent, "<client name=\"")) 
     749  { 
     750    return false; 
     751  } 
     752 
     753  if (!ladish_write_string(fd, client_name)) 
     754  { 
     755    return false; 
     756  } 
     757 
     758  if (!ladish_write_string(fd, "\" uuid=\"")) 
     759  { 
     760    return false; 
     761  } 
     762 
     763  if (!ladish_write_string(fd, str)) 
     764  { 
     765    return false; 
     766  } 
     767 
     768  if (!ladish_write_string(fd, "\">\n")) 
     769  { 
     770    return false; 
     771  } 
     772 
     773  if (!ladish_write_indented_string(fd, indent + 1, "<ports>\n")) 
     774  { 
     775    return false; 
     776  } 
     777 
     778  return true; 
     779} 
     780 
     781#define fd (((struct ladish_write_jack_context *)context)->fd) 
     782#define indent (((struct ladish_write_jack_context *)context)->indent) 
     783#define ctx_ptr ((struct ladish_write_jack_context *)context) 
     784 
    612785static 
    613786bool 
     
    619792  void ** client_iteration_context_ptr_ptr) 
    620793{ 
    621   uuid_t uuid; 
    622   char str[37]; 
    623  
    624   ladish_client_get_uuid(client_handle, uuid); 
    625   uuid_unparse(uuid, str); 
    626  
    627   log_info("saving jack client '%s' (%s)", client_name, str); 
    628  
    629   if (!ladish_write_indented_string(fd, indent, "<client name=\"")) 
    630   { 
    631     return false; 
    632   } 
    633  
    634   if (!ladish_write_string(fd, client_name)) 
    635   { 
    636     return false; 
    637   } 
    638  
    639   if (!ladish_write_string(fd, "\" uuid=\"")) 
    640   { 
    641     return false; 
    642   } 
    643  
    644   if (!ladish_write_string(fd, str)) 
    645   { 
    646     return false; 
    647   } 
    648  
    649   if (!ladish_write_string(fd, "\">\n")) 
    650   { 
    651     return false; 
    652   } 
    653  
    654   if (!ladish_write_indented_string(fd, indent + 1, "<ports>\n")) 
    655   { 
    656     return false; 
    657   } 
    658  
    659   return true; 
     794  void * vgraph; 
     795 
     796  vgraph = ladish_client_get_vgraph(client_handle); 
     797  ctx_ptr->client_vgraph_match = vgraph == ctx_ptr->vgraph_filter; 
     798  ctx_ptr->a2j = ladish_virtualizer_is_a2j_client(client_handle); 
     799 
     800  /* for the a2j client vgraph is always the studio graph. 
     801     However if studio has no a2j ports, lets not write a2j client. 
     802     If there is a a2j port that matched the vgraph, the prolog will get written anyway */ 
     803  ctx_ptr->client_visible = ctx_ptr->client_vgraph_match && !ctx_ptr->a2j; 
     804 
     805  if (!ctx_ptr->client_visible) 
     806  { 
     807    return true; 
     808  } 
     809 
     810  return ladish_save_jack_client_write_prolog(fd, indent, client_handle, client_name); 
    660811} 
    661812 
     
    669820  void * client_iteration_context_ptr) 
    670821{ 
     822  if (!ctx_ptr->client_visible) 
     823  { 
     824    return true; 
     825  } 
     826 
    671827  if (!ladish_write_indented_string(fd, indent + 1, "</ports>\n")) 
    672828  { 
     
    698854  char str[37]; 
    699855 
     856  /* check vgraph for a2j ports */ 
     857  if (ctx_ptr->a2j && ctx_ptr->vgraph_filter == ladish_port_get_vgraph(port_handle)) 
     858  { 
     859    if (!ctx_ptr->client_visible) 
     860    { 
     861      if (!ladish_save_jack_client_write_prolog(fd, indent, client_handle, client_name)) 
     862      { 
     863        return false; 
     864      } 
     865 
     866      ctx_ptr->client_visible = true; 
     867    } 
     868  } 
     869 
     870  if (!ctx_ptr->client_visible) 
     871  { 
     872    return true; 
     873  } 
     874 
    700875  ladish_port_get_uuid(port_handle, uuid); 
    701876  uuid_unparse(uuid, str); 
     
    731906} 
    732907 
     908#undef ctx_ptr 
    733909#undef indent 
    734910#undef fd 
    735911 
    736 bool ladish_write_dict(int fd, int indent, ladish_dict_handle dict) 
    737 { 
    738   struct ladish_write_context context; 
    739  
    740   if (ladish_dict_is_empty(dict)) 
    741   { 
    742     return true; 
     912bool ladish_write_jgraph(int fd, int indent, ladish_graph_handle vgraph) 
     913{ 
     914  struct ladish_write_jack_context context; 
     915 
     916  if (!ladish_write_indented_string(fd, indent, "<clients>\n")) 
     917  { 
     918    return false; 
    743919  } 
    744920 
    745921  context.fd = fd; 
    746922  context.indent = indent + 1; 
    747  
    748   if (!ladish_write_indented_string(fd, indent, "<dict>\n")) 
    749   { 
    750     return false; 
    751   } 
    752  
    753   if (!ladish_dict_iterate(dict, &context, write_dict_entry)) 
    754   { 
    755     return false; 
    756   } 
    757  
    758   if (!ladish_write_indented_string(fd, indent, "</dict>\n")) 
    759   { 
    760     return false; 
    761   } 
    762  
    763   return true; 
    764 } 
    765  
    766 bool ladish_write_vgraph(int fd, int indent, ladish_graph_handle vgraph, ladish_app_supervisor_handle app_supervisor) 
    767 { 
    768   struct ladish_write_context context; 
    769  
    770   context.fd = fd; 
    771   context.indent = indent + 1; 
    772  
    773   if (!ladish_write_indented_string(fd, indent, "<clients>\n")) 
    774   { 
    775     return false; 
    776   } 
    777  
    778   if (!ladish_graph_iterate_nodes( 
    779         vgraph, 
    780         true, 
    781         NULL, 
    782         &context, 
    783         ladish_save_vgraph_client_begin, 
    784         ladish_save_vgraph_port, 
    785         ladish_save_vgraph_client_end)) 
    786   { 
    787     log_error("ladish_graph_iterate_nodes() failed"); 
    788     return false; 
    789   } 
    790  
    791   if (!ladish_write_indented_string(fd, indent, "</clients>\n")) 
    792   { 
    793     return false; 
    794   } 
    795  
    796   if (!ladish_write_indented_string(fd, indent, "<connections>\n")) 
    797   { 
    798     return false; 
    799   } 
    800  
    801   if (!ladish_graph_iterate_connections(vgraph, true, &context, ladish_save_vgraph_connection)) 
    802   { 
    803     log_error("ladish_graph_iterate_connections() failed"); 
    804     return false; 
    805   } 
    806  
    807   if (!ladish_write_indented_string(fd, indent, "</connections>\n")) 
    808   { 
    809     return false; 
    810   } 
    811  
    812   if (!ladish_write_indented_string(fd, indent, "<applications>\n")) 
    813   { 
    814     return false; 
    815   } 
    816  
    817   if (!ladish_app_supervisor_enum(app_supervisor, &context, ladish_save_app)) 
    818   { 
    819     return false; 
    820   } 
    821  
    822   if (!ladish_write_indented_string(fd, indent, "</applications>\n")) 
    823   { 
    824     return false; 
    825   } 
    826  
    827   return true; 
    828 } 
    829  
    830 bool ladish_write_room_link_ports(int fd, int indent, ladish_room_handle room) 
    831 { 
    832   struct ladish_write_context context; 
    833  
    834   context.fd = fd; 
    835   context.indent = indent; 
    836  
    837   if (!ladish_room_iterate_link_ports(room, &context, ladish_write_room_port)) 
    838   { 
    839     log_error("ladish_room_iterate_link_ports() failed"); 
    840     return false; 
    841   } 
    842  
    843   return true; 
    844 } 
    845  
    846 bool ladish_write_jgraph(int fd, int indent, ladish_graph_handle vgraph) 
    847 { 
    848   struct ladish_write_context context; 
    849  
    850   if (!ladish_write_indented_string(fd, indent, "<clients>\n")) 
    851   { 
    852     return false; 
    853   } 
    854  
    855   context.fd = fd; 
    856   context.indent = indent + 1; 
     923  context.vgraph_filter = vgraph; 
    857924 
    858925  if (!ladish_graph_iterate_nodes( 
    859926        ladish_studio_get_jack_graph(), 
    860927        true, 
    861         vgraph, 
    862928        &context, 
    863929        ladish_save_jack_client_begin, 
  • daemon/virtualizer.c

    r8aebce6 r6c2201b  
    443443  const char * vclient_name; 
    444444  bool is_a2j; 
    445   uuid_t jclient_uuid; 
    446445  uuid_t vclient_uuid; 
    447446  pid_t pid; 
     
    526525  jack_client_name = ladish_graph_get_client_name(virtualizer_ptr->jack_graph, jack_client); 
    527526 
    528   ladish_client_get_uuid(jack_client, jclient_uuid); 
    529   is_a2j = uuid_compare(jclient_uuid, g_a2j_uuid) == 0; 
     527  is_a2j = ladish_virtualizer_is_a2j_client(jack_client); 
    530528  if (is_a2j) 
    531529  { 
     
    11261124  uuid_t vclient_uuid; 
    11271125  ladish_client_handle vclient; 
    1128   uuid_t jclient_uuid; 
    11291126 
    11301127  //ladish_graph_dump(g_studio.jack_graph); 
     
    11431140  } 
    11441141 
    1145   ladish_client_get_uuid(jclient, jclient_uuid); 
    1146   ASSERT(uuid_compare(jclient_uuid, g_a2j_uuid) != 0); /* a2j client has no app associated */ 
     1142  ASSERT(!ladish_virtualizer_is_a2j_client(jclient)); /* a2j client has no app associated */ 
    11471143 
    11481144  vgraph = ladish_client_get_vgraph(jclient); 
     
    12641260  ladish_client_handle vclient; 
    12651261  bool is_empty; 
    1266   uuid_t jclient_uuid; 
    12671262  struct app_remove_context ctx; 
    12681263 
     
    12721267  ctx.app_name = app_name; 
    12731268 
    1274   ladish_graph_iterate_nodes(jack_graph, false, NULL, &ctx, NULL, remove_app_port, NULL); 
     1269  ladish_graph_iterate_nodes(jack_graph, false, &ctx, NULL, remove_app_port, NULL); 
    12751270 
    12761271  jclient = ladish_graph_find_client_by_app(jack_graph, app_uuid); 
     
    12811276  } 
    12821277 
    1283   ladish_client_get_uuid(jclient, jclient_uuid); 
    1284   ASSERT(uuid_compare(jclient_uuid, g_a2j_uuid) != 0); /* a2j client has no app associated */ 
     1278  ASSERT(!ladish_virtualizer_is_a2j_client(jclient)); /* a2j client has no app associated */ 
    12851279 
    12861280  vgraph = ladish_client_get_vgraph(jclient); 
     
    13791373  return false; 
    13801374} 
     1375 
     1376bool ladish_virtualizer_is_a2j_client(ladish_client_handle jclient) 
     1377{ 
     1378  uuid_t jclient_uuid; 
     1379 
     1380  ladish_client_get_uuid(jclient, jclient_uuid); 
     1381  return uuid_compare(jclient_uuid, g_a2j_uuid) == 0; 
     1382} 
  • daemon/virtualizer.h

    re06f5b7 r6c2201b  
    7272  uuid_t uuid); 
    7373 
     74bool 
     75ladish_virtualizer_is_a2j_client( 
     76  ladish_client_handle jclient); 
     77 
    7478void 
    7579ladish_virtualizer_destroy(