Changeset 23b1a8fa1e9204ef6d158984ead16a6c140dd849

Show
Ignore:
Timestamp:
11/28/09 19:46:43 (3 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
effcdfca2735395c8d3c9a6b2f0e1181ab4e47b5
Parents:
5955c05ca0b0a78226476b125dde072e81e7b77c
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2009-11-28T19:46:43Z+0200
Message:

ladishd: implement ports connect

Location:
daemon
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • daemon/graph.c

    r5955c05 r23b1a8f  
    5454}; 
    5555 
     56struct ladish_graph_connection 
     57{ 
     58  struct list_head siblings; 
     59  uint64_t id; 
     60  bool hidden; 
     61  struct ladish_graph_port * port1_ptr; 
     62  struct ladish_graph_port * port2_ptr; 
     63}; 
     64 
    5665struct ladish_graph 
    5766{ 
     
    6069  struct list_head clients; 
    6170  struct list_head ports; 
     71  struct list_head connections; 
    6272  uint64_t graph_version; 
    6373  uint64_t next_client_id; 
     
    135145  struct ladish_graph_port * port_ptr; 
    136146  DBusMessageIter port_struct_iter; 
    137   //DBusMessageIter connection_struct_iter; 
     147  struct list_head * connection_node_ptr; 
     148  struct ladish_graph_connection * connection_ptr; 
     149  DBusMessageIter connection_struct_iter; 
    138150 
    139151  //log_info("get_graph() called"); 
     
    275287  if (known_version < current_version) 
    276288  { 
    277 #if 0 
    278     list_for_each(connection_node_ptr, &patchbay_ptr->graph.connections) 
    279     { 
    280       connection_ptr = list_entry(connection_node_ptr, struct jack_graph_connection, siblings); 
     289    list_for_each(connection_node_ptr, &graph_ptr->connections) 
     290    { 
     291      connection_ptr = list_entry(connection_node_ptr, struct ladish_graph_connection, siblings); 
    281292 
    282293      if (!dbus_message_iter_open_container(&connections_array_iter, DBUS_TYPE_STRUCT, NULL, &connection_struct_iter)) 
     
    285296      } 
    286297 
    287       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port1->client->id)) 
     298      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port1_ptr->client_ptr->id)) 
    288299      { 
    289300        goto nomem_close_connection_struct; 
    290301      } 
    291302 
    292       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port1->client->name)) 
     303      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port1_ptr->client_ptr->name)) 
    293304      { 
    294305        goto nomem_close_connection_struct; 
    295306      } 
    296307 
    297       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port1->id)) 
     308      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port1_ptr->id)) 
    298309      { 
    299310        goto nomem_close_connection_struct; 
    300311      } 
    301312 
    302       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port1->name)) 
     313      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port1_ptr->name)) 
    303314      { 
    304315        goto nomem_close_connection_struct; 
    305316      } 
    306317 
    307       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port2->client->id)) 
     318      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port2_ptr->client_ptr->id)) 
    308319      { 
    309320        goto nomem_close_connection_struct; 
    310321      } 
    311322 
    312       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port2->client->name)) 
     323      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port2_ptr->client_ptr->name)) 
    313324      { 
    314325        goto nomem_close_connection_struct; 
    315326      } 
    316327 
    317       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port2->id)) 
     328      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_UINT64, &connection_ptr->port2_ptr->id)) 
    318329      { 
    319330        goto nomem_close_connection_struct; 
    320331      } 
    321332 
    322       if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port2->name)) 
     333      if (!dbus_message_iter_append_basic(&connection_struct_iter, DBUS_TYPE_STRING, &connection_ptr->port2_ptr->name)) 
    323334      { 
    324335        goto nomem_close_connection_struct; 
     
    335346      } 
    336347    } 
    337 #endif 
    338348  } 
    339349 
     
    345355  return; 
    346356 
    347 #if 0 
    348357nomem_close_connection_struct: 
    349358  dbus_message_iter_close_container(&connections_array_iter, &connection_struct_iter); 
     
    351360nomem_close_connections_array: 
    352361  dbus_message_iter_close_container(&iter, &connections_array_iter); 
    353   goto nomem_unlock; 
    354 #endif 
     362  goto nomem; 
    355363 
    356364nomem_close_port_struct: 
     
    504512  INIT_LIST_HEAD(&graph_ptr->clients); 
    505513  INIT_LIST_HEAD(&graph_ptr->ports); 
     514  INIT_LIST_HEAD(&graph_ptr->connections); 
    506515 
    507516  graph_ptr->graph_version = 1; 
     
    10071016      &flags, 
    10081017      &type); 
     1018  } 
     1019 
     1020  return true; 
     1021} 
     1022 
     1023bool 
     1024ladish_graph_add_connection( 
     1025  ladish_graph_handle graph_handle, 
     1026  ladish_port_handle port1_handle, 
     1027  ladish_port_handle port2_handle, 
     1028  bool hidden) 
     1029{ 
     1030  struct ladish_graph_port * port1_ptr; 
     1031  struct ladish_graph_port * port2_ptr; 
     1032  struct ladish_graph_connection * connection_ptr; 
     1033 
     1034  port1_ptr = ladish_graph_find_port(graph_ptr, port1_handle); 
     1035  ASSERT(port1_ptr != NULL); 
     1036  port2_ptr = ladish_graph_find_port(graph_ptr, port2_handle); 
     1037  ASSERT(port2_ptr != NULL); 
     1038 
     1039  connection_ptr = malloc(sizeof(struct ladish_graph_connection)); 
     1040  if (connection_ptr == NULL) 
     1041  { 
     1042    log_error("malloc() failed for struct ladish_graph_connection"); 
     1043    return false; 
     1044  } 
     1045 
     1046  connection_ptr->id = graph_ptr->next_connection_id++; 
     1047  connection_ptr->port1_ptr = port1_ptr; 
     1048  connection_ptr->port2_ptr = port2_ptr; 
     1049  connection_ptr->hidden = hidden; 
     1050  graph_ptr->graph_version++; 
     1051 
     1052  list_add_tail(&connection_ptr->siblings, &graph_ptr->connections); 
     1053 
     1054  if (!hidden && graph_ptr->opath != NULL) 
     1055  { 
     1056    dbus_signal_emit( 
     1057      g_dbus_connection, 
     1058      graph_ptr->opath, 
     1059      JACKDBUS_IFACE_PATCHBAY, 
     1060      "PortsConnected", 
     1061      "ttstststst", 
     1062      &graph_ptr->graph_version, 
     1063      &port1_ptr->client_ptr->id, 
     1064      &port1_ptr->client_ptr->name, 
     1065      &port1_ptr->id, 
     1066      &port1_ptr->name, 
     1067      &port2_ptr->client_ptr->id, 
     1068      &port2_ptr->client_ptr->name, 
     1069      &port2_ptr->id, 
     1070      &port2_ptr->name, 
     1071      &connection_ptr->id); 
    10091072  } 
    10101073 
  • daemon/graph.h

    r5955c05 r23b1a8f  
    8484  ladish_port_handle port_handle); 
    8585 
     86bool 
     87ladish_graph_add_connection( 
     88  ladish_graph_handle graph_handle, 
     89  ladish_port_handle port1_handle, 
     90  ladish_port_handle port2_handle, 
     91  bool hidden); 
     92 
    8693ladish_client_handle ladish_graph_find_client_by_id(ladish_graph_handle graph_handle, uint64_t client_id); 
    8794ladish_port_handle ladish_graph_find_port_by_id(ladish_graph_handle graph_handle, uint64_t port_id); 
  • daemon/virtualizer.c

    r5955c05 r23b1a8f  
    273273 
    274274  port = ladish_graph_find_port_by_jack_id(virtualizer_ptr->jack_graph, port_id); 
    275   if (client == NULL) 
     275  if (port == NULL) 
    276276  { 
    277277    log_error("Unknown JACK port with id %"PRIu64" disappeared", port_id); 
     
    315315static bool ports_connect_request(void * context, ladish_graph_handle graph_handle, ladish_port_handle port1, ladish_port_handle port2) 
    316316{ 
     317  uint64_t port1_id; 
     318  uint64_t port2_id; 
     319 
    317320  ASSERT(graph_handle == virtualizer_ptr->studio_graph); 
    318321  log_info("virtualizer: ports connect request"); 
    319   return false; 
     322 
     323  port1_id = ladish_port_get_jack_id(port1); 
     324  port2_id = ladish_port_get_jack_id(port2); 
     325 
     326  graph_proxy_connect_ports(virtualizer_ptr->jack_graph_proxy, port1_id, port2_id); 
     327 
     328  return true; 
    320329} 
    321330 
     
    329338static void ports_connected(void * context, uint64_t client1_id, uint64_t port1_id, uint64_t client2_id, uint64_t port2_id) 
    330339{ 
    331   log_info("ports_connected"); 
     340  ladish_port_handle port1; 
     341  ladish_port_handle port2; 
     342 
     343  log_info("ports_connected %"PRIu64":%"PRIu64" %"PRIu64":%"PRIu64"", client1_id, port1_id, client2_id, port2_id); 
     344 
     345  port1 = ladish_graph_find_port_by_jack_id(virtualizer_ptr->jack_graph, port1_id); 
     346  if (port1 == NULL) 
     347  { 
     348    log_error("Unknown JACK port with id %"PRIu64" connected", port1_id); 
     349    return; 
     350  } 
     351 
     352  port2 = ladish_graph_find_port_by_jack_id(virtualizer_ptr->jack_graph, port2_id); 
     353  if (port2 == NULL) 
     354  { 
     355    log_error("Unknown JACK port with id %"PRIu64" connected", port2_id); 
     356    return; 
     357  } 
     358 
     359  ladish_graph_add_connection(virtualizer_ptr->jack_graph, port1, port2, false); 
     360  ladish_graph_add_connection(virtualizer_ptr->studio_graph, port1, port2, false); 
    332361} 
    333362