Changeset 00cc1087dcb51865c1a9da89fcb190f8e21ed23d
- Timestamp:
- 07/21/10 05:53:48 (7 weeks ago)
- Children:
- 6842854e8c7927836816199ec029d4638dd39251
- Parents:
- 5bb96d51e76bb0e2e2b41f5d3b3027aefefab452
- git-committer:
- Nedko Arnaudov <nedko@arnaudov.name> / 2010-07-21T05:53:48Z+0300
- Location:
- daemon
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
daemon/cmd_load_studio.c
r535a28b r00cc108 53 53 #define PARSE_CONTEXT_APPLICATIONS 13 54 54 #define PARSE_CONTEXT_APPLICATION 14 55 #define PARSE_CONTEXT_ROOMS 15 56 #define PARSE_CONTEXT_ROOM 16 55 57 56 58 #define MAX_STACK_DEPTH 10 … … 68 70 ladish_port_handle port; 69 71 ladish_dict_handle dict; 72 ladish_room_handle room; 70 73 uint64_t connection_id; 71 74 bool terminal; … … 74 77 }; 75 78 76 static const char * get_string_attribute (const char * const * attr, const char * key)79 static const char * get_string_attribute_internal(const char * const * attr, const char * key, bool optional) 77 80 { 78 81 while (attr[0] != NULL) … … 86 89 } 87 90 88 log_error("attribute \"%s\" is missing"); 91 if (!optional) 92 { 93 log_error("attribute \"%s\" is missing", key); 94 } 95 89 96 return NULL; 90 97 } 91 98 92 static const char * get_uuid_attribute(const char * const * attr, const char * key, uuid_t uuid) 99 static const char * get_string_attribute(const char * const * attr, const char * key) 100 { 101 return get_string_attribute_internal(attr, key, false); 102 } 103 104 static const char * get_uuid_attribute(const char * const * attr, const char * key, uuid_t uuid, bool optional) 93 105 { 94 106 const char * value; 95 107 96 value = get_string_attribute (attr, key);108 value = get_string_attribute_internal(attr, key, optional); 97 109 if (value == NULL) 98 110 { … … 184 196 } 185 197 186 uuid_str = get_uuid_attribute(attr, "uuid", uuid );198 uuid_str = get_uuid_attribute(attr, "uuid", uuid, false); 187 199 if (uuid_str == NULL) 188 200 { … … 194 206 *uuid_str_ptr = uuid_str; 195 207 return true; 208 } 209 210 static 211 bool 212 parse_port_type_and_direction_attributes( 213 const char * element_description, 214 const char * const * attr, 215 uint32_t * type_ptr, 216 uint32_t * flags_ptr) 217 { 218 const char * type_str; 219 const char * direction_str; 220 221 type_str = get_string_attribute(attr, "type"); 222 if (type_str == NULL) 223 { 224 log_error("%s \"type\" attribute is not available", element_description); 225 return false; 226 } 227 228 direction_str = get_string_attribute(attr, "direction"); 229 if (direction_str == NULL) 230 { 231 log_error("%s \"direction\" attribute is not available", element_description); 232 return false; 233 } 234 235 if (strcmp(type_str, "midi") == 0) 236 { 237 *type_ptr = JACKDBUS_PORT_TYPE_MIDI; 238 } 239 else if (strcmp(type_str, "audio") == 0) 240 { 241 *type_ptr = JACKDBUS_PORT_TYPE_AUDIO; 242 } 243 else 244 { 245 log_error("%s \"type\" attribute contains unknown value \"%s\"", element_description, type_str); 246 return false; 247 } 248 249 if (strcmp(direction_str, "playback") == 0) 250 { 251 *flags_ptr = 0; 252 JACKDBUS_PORT_SET_INPUT(*flags_ptr); 253 } 254 else if (strcmp(direction_str, "capture") == 0) 255 { 256 *flags_ptr = 0; 257 JACKDBUS_PORT_SET_OUTPUT(*flags_ptr); 258 } 259 else 260 { 261 log_error("%s \"direction\" attribute contains unknown value \"%s\"", element_description, direction_str); 262 return false; 263 } 264 265 return true; 266 } 267 268 static void dump_element_stack(struct parse_context * context_ptr) 269 { 270 signed int depth; 271 const char * descr; 272 273 log_info("depth=%d", context_ptr->depth); 274 275 for (depth = context_ptr->depth; depth >= 0; depth--) 276 { 277 switch (context_ptr->element[depth]) 278 { 279 case PARSE_CONTEXT_ROOT: 280 descr = "root"; 281 break; 282 case PARSE_CONTEXT_STUDIO: 283 descr = "studio"; 284 break; 285 case PARSE_CONTEXT_JACK: 286 descr = "jack"; 287 break; 288 case PARSE_CONTEXT_CONF: 289 descr = "conf"; 290 break; 291 case PARSE_CONTEXT_PARAMETER: 292 descr = "parameter"; 293 break; 294 case PARSE_CONTEXT_CLIENTS: 295 descr = "clients"; 296 break; 297 case PARSE_CONTEXT_CLIENT: 298 descr = "client"; 299 break; 300 case PARSE_CONTEXT_PORTS: 301 descr = "ports"; 302 break; 303 case PARSE_CONTEXT_PORT: 304 descr = "port"; 305 break; 306 case PARSE_CONTEXT_DICT: 307 descr = "dict"; 308 break; 309 case PARSE_CONTEXT_KEY: 310 descr = "key"; 311 break; 312 case PARSE_CONTEXT_CONNECTIONS: 313 descr = "connections"; 314 break; 315 case PARSE_CONTEXT_CONNECTION: 316 descr = "connection"; 317 break; 318 case PARSE_CONTEXT_APPLICATIONS: 319 descr = "applications"; 320 break; 321 case PARSE_CONTEXT_APPLICATION: 322 descr = "application"; 323 break; 324 case PARSE_CONTEXT_ROOMS: 325 descr = "rooms"; 326 break; 327 case PARSE_CONTEXT_ROOM: 328 descr = "room"; 329 break; 330 default: 331 descr = "?"; 332 } 333 334 log_info("%d - %u (%s)", depth, context_ptr->element[depth], descr); 335 } 196 336 } 197 337 … … 231 371 ladish_port_handle port1; 232 372 ladish_port_handle port2; 373 uint32_t port_type; 374 uint32_t port_flags; 233 375 234 376 if (context_ptr->error) … … 293 435 //log_info("<clients>"); 294 436 context_ptr->element[++context_ptr->depth] = PARSE_CONTEXT_CLIENTS; 437 return; 438 } 439 440 if (strcmp(el, "rooms") == 0) 441 { 442 //log_info("<rooms>"); 443 context_ptr->element[++context_ptr->depth] = PARSE_CONTEXT_ROOMS; 444 return; 445 } 446 447 if (strcmp(el, "room") == 0) 448 { 449 //log_info("<room>"); 450 context_ptr->element[++context_ptr->depth] = PARSE_CONTEXT_ROOM; 451 452 if (context_ptr->room != NULL) 453 { 454 log_error("nested rooms"); 455 context_ptr->error = XML_TRUE; 456 return; 457 } 458 459 if (context_ptr->depth == 2 && 460 context_ptr->element[0] == PARSE_CONTEXT_STUDIO && 461 context_ptr->element[1] == PARSE_CONTEXT_ROOMS) 462 { 463 if (!get_name_and_uuid_attributes("/studio/rooms/room", attr, &name, &uuid_str, uuid)) 464 { 465 context_ptr->error = XML_TRUE; 466 return; 467 } 468 469 if (!ladish_room_create(uuid, name, NULL, g_studio.studio_graph, &context_ptr->room)) 470 { 471 log_error("ladish_room_create() failed."); 472 context_ptr->error = XML_TRUE; 473 ASSERT(context_ptr->room == NULL); 474 return; 475 } 476 477 return; 478 } 479 480 log_error("ignoring <room> element in wrong context"); 295 481 return; 296 482 } … … 350 536 log_info("studio client \"%s\" with uuid %s", name, uuid_str); 351 537 538 context_ptr->client = ladish_graph_find_client_by_uuid(g_studio.studio_graph, uuid); 539 if (context_ptr->client != NULL) 540 { 541 log_info("Found existing client"); 542 return; 543 } 544 352 545 if (!ladish_client_create(uuid, &context_ptr->client)) 353 546 { … … 390 583 } 391 584 392 if (context_ptr->client == NULL) 393 { 585 if (context_ptr->depth >= 3 && 586 context_ptr->element[context_ptr->depth - 3] == PARSE_CONTEXT_CLIENTS && 587 context_ptr->element[context_ptr->depth - 2] == PARSE_CONTEXT_CLIENT && 588 context_ptr->element[context_ptr->depth - 1] == PARSE_CONTEXT_PORTS) 589 { 590 //log_info("client port"); 591 if (context_ptr->client == NULL) 592 { 394 593 log_error("client-less port"); 395 594 context_ptr->error = XML_TRUE; 396 595 return; 397 } 398 399 if (context_ptr->depth == 5 && 400 context_ptr->element[0] == PARSE_CONTEXT_STUDIO && 401 context_ptr->element[1] == PARSE_CONTEXT_JACK && 402 context_ptr->element[2] == PARSE_CONTEXT_CLIENTS && 403 context_ptr->element[3] == PARSE_CONTEXT_CLIENT && 404 context_ptr->element[4] == PARSE_CONTEXT_PORTS) 405 { 406 if (!get_name_and_uuid_attributes("/studio/jack/clients/client/ports/port", attr, &name, &uuid_str, uuid)) 407 { 408 context_ptr->error = XML_TRUE; 409 return; 410 } 411 412 log_info("jack port \"%s\" with uuid %s", name, uuid_str); 413 414 if (!ladish_port_create(uuid, false, &context_ptr->port)) 415 { 416 log_error("ladish_port_create() failed."); 417 return; 418 } 419 420 if (!ladish_graph_add_port(g_studio.jack_graph, context_ptr->client, context_ptr->port, name, 0, 0, true)) 421 { 422 log_error("ladish_graph_add_port() failed."); 423 ladish_port_destroy(context_ptr->port); 596 } 597 598 if (context_ptr->depth == 5 && context_ptr->element[0] == PARSE_CONTEXT_STUDIO && context_ptr->element[1] == PARSE_CONTEXT_JACK) 599 { 600 if (!get_name_and_uuid_attributes("/studio/jack/clients/client/ports/port", attr, &name, &uuid_str, uuid)) 601 { 602 context_ptr->error = XML_TRUE; 603 return; 604 } 605 606 log_info("jack port \"%s\" with uuid %s", name, uuid_str); 607 608 if (!ladish_port_create(uuid, false, &context_ptr->port)) 609 { 610 log_error("ladish_port_create() failed."); 611 return; 612 } 613 614 if (!ladish_graph_add_port(g_studio.jack_graph, context_ptr->client, context_ptr->port, name, 0, 0, true)) 615 { 616 log_error("ladish_graph_add_port() failed."); 617 ladish_port_destroy(context_ptr->port); 618 context_ptr->port = NULL; 619 } 620 621 return; 622 } 623 else if (context_ptr->depth == 4 && context_ptr->element[0] == PARSE_CONTEXT_STUDIO) 624 { 625 if (!get_name_and_uuid_attributes("/studio/clients/client/ports/port", attr, &name, &uuid_str, uuid)) 626 { 627 context_ptr->error = XML_TRUE; 628 return; 629 } 630 631 uuid2_str = get_uuid_attribute(attr, "link_uuid", uuid2, true); 632 633 log_info("studio port \"%s\" with uuid %s (%s)", name, uuid_str, uuid_str == NULL ? "normal" : "room link"); 634 635 if (uuid2_str == NULL) 636 { /* normal studio port */ 637 context_ptr->port = ladish_graph_find_port_by_uuid(g_studio.jack_graph, uuid, false); 638 if (context_ptr->port == NULL) 639 { 640 log_error("studio client with non-jack port %s", uuid_str); 641 context_ptr->error = XML_TRUE; 642 return; 643 } 644 645 if (!ladish_graph_add_port(g_studio.studio_graph, context_ptr->client, context_ptr->port, name, 0, 0, true)) 646 { 647 log_error("ladish_graph_add_port() failed."); 648 ladish_port_destroy(context_ptr->port); 649 context_ptr->port = NULL; 650 return; 651 } 652 653 return; 654 } 655 656 /* room link port */ 657 context_ptr->port = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid2, false); 658 if (context_ptr->port == NULL) 659 { 660 log_error("room link port not found"); 661 context_ptr->port = NULL; 662 } 663 664 ladish_graph_set_link_port_override_uuid(g_studio.studio_graph, uuid2, uuid); 665 666 return; 667 } 668 } 669 else if (context_ptr->depth == 3 && 670 context_ptr->element[0] == PARSE_CONTEXT_STUDIO && 671 context_ptr->element[1] == PARSE_CONTEXT_ROOMS && 672 context_ptr->element[2] == PARSE_CONTEXT_ROOM) 673 { 674 ASSERT(context_ptr->room != NULL); 675 //log_info("room port"); 676 677 if (!get_name_and_uuid_attributes("/studio/rooms/room/port", attr, &name, &uuid_str, uuid)) 678 { 679 context_ptr->error = XML_TRUE; 680 return; 681 } 682 683 log_info("room port \"%s\" with uuid %s", name, uuid_str); 684 685 if (!parse_port_type_and_direction_attributes("/studio/rooms/room/port", attr, &port_type, &port_flags)) 686 { 687 context_ptr->error = XML_TRUE; 688 return; 689 } 690 691 context_ptr->port = ladish_room_add_port(context_ptr->room, uuid, name, port_type, port_flags); 692 if (context_ptr->port == NULL) 693 { 694 log_error("ladish_room_add_port() failed."); 424 695 context_ptr->port = NULL; 425 return; 426 } 427 } 428 else if (context_ptr->depth == 4 && 429 context_ptr->element[0] == PARSE_CONTEXT_STUDIO && 430 context_ptr->element[1] == PARSE_CONTEXT_CLIENTS && 431 context_ptr->element[2] == PARSE_CONTEXT_CLIENT && 432 context_ptr->element[3] == PARSE_CONTEXT_PORTS) 433 { 434 if (!get_name_and_uuid_attributes("/studio/clients/client/ports/port", attr, &name, &uuid_str, uuid)) 435 { 436 context_ptr->error = XML_TRUE; 437 return; 438 } 439 440 log_info("studio port \"%s\" with uuid %s", name, uuid_str); 441 442 context_ptr->port = ladish_graph_find_port_by_uuid(g_studio.jack_graph, uuid, false); 443 if (context_ptr->port == NULL) 444 { 445 log_error("studio client with non-jack port %s", uuid_str); 446 context_ptr->error = XML_TRUE; 447 return; 448 } 449 450 if (!ladish_graph_add_port(g_studio.studio_graph, context_ptr->client, context_ptr->port, name, 0, 0, true)) 451 { 452 log_error("ladish_graph_add_port() failed."); 453 ladish_port_destroy(context_ptr->port); 454 context_ptr->port = NULL; 455 return; 456 } 457 } 458 696 } 697 698 return; 699 } 700 701 log_error("port element in wrong place"); 702 dump_element_stack(context_ptr); 703 context_ptr->error = XML_TRUE; 459 704 return; 460 705 } … … 472 717 context_ptr->element[++context_ptr->depth] = PARSE_CONTEXT_CONNECTION; 473 718 474 uuid_str = get_uuid_attribute(attr, "port1", uuid );719 uuid_str = get_uuid_attribute(attr, "port1", uuid, false); 475 720 if (uuid_str == NULL) 476 721 { … … 480 725 } 481 726 482 uuid2_str = get_uuid_attribute(attr, "port2", uuid2 );727 uuid2_str = get_uuid_attribute(attr, "port2", uuid2, false); 483 728 if (uuid2_str == NULL) 484 729 { … … 490 735 log_info("studio connection between port %s and port %s", uuid_str, uuid2_str); 491 736 492 port1 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid, false);737 port1 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid, true); 493 738 if (port1 == NULL) 494 739 { … … 498 743 } 499 744 500 port2 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid2, false);745 port2 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid2, true); 501 746 if (port2 == NULL) 502 747 { … … 801 1046 } 802 1047 } 1048 else if (context_ptr->element[context_ptr->depth] == PARSE_CONTEXT_ROOM) 1049 { 1050 //log_info("</room>"); 1051 ASSERT(context_ptr->room != NULL); 1052 context_ptr->room = NULL; 1053 } 803 1054 else if (context_ptr->element[context_ptr->depth] == PARSE_CONTEXT_DICT) 804 1055 { … … 980 1231 parse_context.port = NULL; 981 1232 parse_context.dict = NULL; 1233 parse_context.room = NULL; 982 1234 983 1235 XML_SetElementHandler(parser, callback_elstart, callback_elend); -
daemon/control.c
r5bb96d5 r00cc108 136 136 ladish_client_handle client; 137 137 138 playback = (flags & JACKDBUS_PORT_FLAG_INPUT) != 0;139 ASSERT(playback || (flags & JACKDBUS_PORT_FLAG_OUTPUT) != 0); /* playback or capture */140 ASSERT(!(playback && (flags & JACKDBUS_PORT_FLAG_OUTPUT) != 0)); /* but not both */138 playback = JACKDBUS_PORT_IS_INPUT(flags); 139 ASSERT(playback || JACKDBUS_PORT_IS_OUTPUT(flags)); /* playback or capture */ 140 ASSERT(!(playback && JACKDBUS_PORT_IS_OUTPUT(flags))); /* but not both */ 141 141 client = playback ? room_descriptor_ptr->playback : room_descriptor_ptr->capture; 142 142 -
daemon/graph.c
rc291a60 r00cc108 102 102 } 103 103 104 static struct ladish_graph_port * 105 ladish_graph_find_port_by_uuid_internal( 106 struct ladish_graph * graph_ptr, 107 const uuid_t uuid, 108 bool use_link_override_uuids) 109 { 110 struct list_head * node_ptr; 111 struct ladish_graph_port * port_ptr; 112 uuid_t current_uuid; 113 /* char uuid1_str[37]; */ 114 /* char uuid2_str[37]; */ 115 116 /* log_info("searching by uuid for port in graph %s", ladish_graph_get_description(graph_handle)); */ 117 /* uuid_unparse(uuid, uuid1_str); */ 118 119 list_for_each(node_ptr, &graph_ptr->ports) 120 { 121 port_ptr = list_entry(node_ptr, struct ladish_graph_port, siblings_graph); 122 123 /* if (port_ptr->link) */ 124 /* { */ 125 /* uuid_unparse(port_ptr->link_uuid_override, uuid2_str); */ 126 /* log_info("comparing link uuid %s with %s", uuid2_str, uuid1_str); */ 127 /* } */ 128 129 if (use_link_override_uuids && port_ptr->link && uuid_compare(port_ptr->link_uuid_override, uuid) == 0) 130 { 131 /* log_info("found port %p of client '%s'", port_ptr->port, port_ptr->client_ptr->name); */ 132 return port_ptr; 133 } 134 135 ladish_port_get_uuid(port_ptr->port, current_uuid); 136 /* uuid_unparse(current_uuid, uuid2_str); */ 137 /* log_info("comparing port uuid %s with %s", uuid2_str, uuid1_str); */ 138 if (uuid_compare(current_uuid, uuid) == 0) 139 { 140 return port_ptr; 141 } 142 } 143 144 return NULL; 145 } 146 104 147 static struct ladish_graph_connection * ladish_graph_find_connection_by_id(struct ladish_graph * graph_ptr, uint64_t connection_id) 105 148 { … … 1608 1651 ladish_port_handle ladish_graph_find_port_by_uuid(ladish_graph_handle graph_handle, const uuid_t uuid, bool use_link_override_uuids) 1609 1652 { 1610 struct list_head * node_ptr;1611 1653 struct ladish_graph_port * port_ptr; 1612 uuid_t current_uuid; 1613 /* char uuid1_str[37]; */ 1614 /* char uuid2_str[37]; */ 1615 1616 /* log_info("searching by uuid for port in graph %s", ladish_graph_get_description(graph_handle)); */ 1617 /* uuid_unparse(uuid, uuid1_str); */ 1618 1619 list_for_each(node_ptr, &graph_ptr->ports) 1620 { 1621 port_ptr = list_entry(node_ptr, struct ladish_graph_port, siblings_graph); 1622 1623 /* if (port_ptr->link) */ 1624 /* { */ 1625 /* uuid_unparse(port_ptr->link_uuid_override, uuid2_str); */ 1626 /* log_info("comparing link uuid %s with %s", uuid2_str, uuid1_str); */ 1627 /* } */ 1628 1629 if (port_ptr->link && uuid_compare(port_ptr->link_uuid_override, uuid) == 0) 1630 { 1631 /* log_info("found port %p of client '%s'", port_ptr->port, port_ptr->client_ptr->name); */ 1632 return port_ptr->port; 1633 } 1634 1635 ladish_port_get_uuid(port_ptr->port, current_uuid); 1636 /* uuid_unparse(current_uuid, uuid2_str); */ 1637 /* log_info("comparing port uuid %s with %s", uuid2_str, uuid1_str); */ 1638 if (uuid_compare(current_uuid, uuid) == 0) 1639 { 1640 return port_ptr->port; 1641 } 1654 1655 port_ptr = ladish_graph_find_port_by_uuid_internal(graph_ptr, uuid, use_link_override_uuids); 1656 if (port_ptr != NULL) 1657 { 1658 return port_ptr->port; 1642 1659 } 1643 1660 … … 2024 2041 2025 2042 return port_ptr->name; 2043 } 2044 2045 void ladish_graph_set_link_port_override_uuid(ladish_graph_handle graph_handle, const uuid_t uuid, const uuid_t override_uuid) 2046 { 2047 struct ladish_graph_port * port_ptr; 2048 2049 port_ptr = ladish_graph_find_port_by_uuid_internal(graph_ptr, uuid, false); 2050 ASSERT(ladish_port_is_link(port_ptr->port)); 2051 uuid_copy(port_ptr->link_uuid_override, override_uuid); 2026 2052 } 2027 2053 -
daemon/graph.h
rc291a60 r00cc108 160 160 void ladish_graph_hide_non_virtual(ladish_graph_handle graph_handle); 161 161 void ladish_graph_get_port_uuid(ladish_graph_handle graph, ladish_port_handle port, uuid_t uuid_ptr); 162 void ladish_graph_set_link_port_override_uuid(ladish_graph_handle graph_handle, const uuid_t uuid, const uuid_t override_uuid); 162 163 163 164 void ladish_graph_dump(ladish_graph_handle graph_handle); -
daemon/room.c
r5bb96d5 r00cc108 55 55 void ladish_on_app_renamed(void * context, const char * old_name, const char * new_app_name); 56 56 57 static bool get_port_direction(uint32_t port_flags, bool * room_input_ptr) 58 { 59 if (JACKDBUS_PORT_IS_INPUT(port_flags)) 60 { 61 *room_input_ptr = true; 62 return true; 63 } 64 65 if (JACKDBUS_PORT_IS_OUTPUT(port_flags)) 66 { 67 *room_input_ptr = false; 68 return true; 69 } 70 71 log_error("room link port with bad flags %"PRIu32, port_flags); 72 return false; 57 static bool port_is_input(uint32_t flags) 58 { 59 bool playback; 60 61 playback = JACKDBUS_PORT_IS_INPUT(flags); 62 ASSERT(playback || JACKDBUS_PORT_IS_OUTPUT(flags)); /* playback or capture */ 63 ASSERT(!(playback && JACKDBUS_PORT_IS_OUTPUT(flags))); /* but not both */ 64 65 return playback; 73 66 } 74 67 … … 146 139 uint32_t port_flags) 147 140 { 148 bool room_input;149 150 141 //log_info("Studio room port \"%s\"", port_name); 151 142 152 if (!get_port_direction(port_flags, &room_input)) 153 { 154 return false; 155 } 156 157 if (room_input) 143 if (port_is_input(port_flags)) 158 144 { 159 145 JACKDBUS_PORT_CLEAR_INPUT(port_flags); … … 188 174 char uuid_in_owner_str[37]; 189 175 char uuid_in_room_str[37]; 190 bool room_input;191 176 const char * input_port; 192 177 const char * output_port; … … 194 179 //log_info("Room port \"%s\"", port_name); 195 180 196 if (!get_port_direction(port_flags, &room_input))197 {198 return false;199 }200 201 181 ladish_graph_get_port_uuid(room_ptr->graph, port_handle, uuid_in_room); 202 182 ladish_graph_get_port_uuid(room_ptr->owner, port_handle, uuid_in_owner); … … 205 185 uuid_unparse(uuid_in_owner, uuid_in_owner_str); 206 186 207 if ( room_input)187 if (port_is_input(port_flags)) 208 188 { 209 189 input_port = uuid_in_room_str; … … 302 282 303 283 room_ptr->index = index; 304 ladish_room_get_uuid(template, room_ptr->template_uuid);305 284 room_ptr->owner = owner; 306 285 room_ptr->started = false; 307 286 308 if (!ladish_graph_copy(ladish_room_get_graph(template), room_ptr->graph, false)) 309 { 310 goto destroy; 287 if (template != NULL) 288 { 289 ladish_room_get_uuid(template, room_ptr->template_uuid); 290 if (!ladish_graph_copy(ladish_room_get_graph(template), room_ptr->graph, false)) 291 { 292 goto destroy; 293 } 294 } 295 else 296 { 297 uuid_clear(room_ptr->template_uuid); 311 298 } 312 299 … … 400 387 ladish_graph_remove_client(room_ptr->owner, room_ptr->client); 401 388 ladish_client_destroy(room_ptr->client); 402 403 ladish_studio_room_disappeared((ladish_room_handle)room_ptr); 404 ladish_studio_release_room_index(room_ptr->index);405 }389 } 390 391 ladish_studio_room_disappeared((ladish_room_handle)room_ptr); 392 ladish_studio_release_room_index(room_ptr->index); 406 393 407 394 ladish_graph_destroy(room_ptr->graph); … … 604 591 } 605 592 593 ladish_port_handle 594 ladish_room_add_port( 595 ladish_room_handle room_handle, 596 const uuid_t uuid_ptr, 597 const char * name, 598 uint32_t type, 599 uint32_t flags) 600 { 601 ladish_port_handle port; 602 bool playback; 603 ladish_client_handle client; 604 const char * client_name; 605 uuid_t client_uuid; 606 bool new_client; 607 608 playback = port_is_input(flags); 609 610 ASSERT(!uuid_is_null(uuid_ptr)); 611 if (!ladish_port_create(uuid_ptr, true, &port)) 612 { 613 log_error("Creation of room port \"%s\" failed.", name); 614 goto fail; 615 } 616 617 client_name = playback ? "Playback" : "Capture"; 618 uuid_copy(client_uuid, playback ? ladish_wkclient_playback : ladish_wkclient_capture); 619 620 /* if client is not found, create it and add it to graph */ 621 client = ladish_graph_find_client_by_uuid(room_ptr->graph, client_uuid); 622 new_client = client == NULL; 623 if (new_client) 624 { 625 if (!ladish_client_create(client_uuid, &client)) 626 { 627 log_error("ladish_client_create() failed to create %s room client.", playback ? "playback" : "capture"); 628 goto fail_destroy_port; 629 } 630 631 if (!ladish_graph_add_client(room_ptr->graph, client, client_name, true)) 632 { 633 log_error("ladish_graph_add_client() failed to add %s room client to room graph.", playback ? "playback" : "capture"); 634 goto fail_destroy_client; 635 } 636 } 637 638 if (!ladish_graph_add_port(room_ptr->graph, client, port, name, type, flags, true)) 639 { 640 log_error("ladish_graph_add_port() failed to add %s room port \"%s\" to room graph.", playback ? "playback" : "capture", name); 641 goto fail_destroy_client; 642 } 643 644 if (!create_shadow_port(room_ptr, port, name, type, flags)) 645 { 646 log_error("ladish_graph_add_port() failed to add port \"%s\" to room owner graph.", name); 647 goto fail_remove_port; 648 } 649 650 return port; 651 652 fail_remove_port: 653 ASSERT(client != NULL); 654 if (ladish_graph_remove_port(room_ptr->graph, port) != client) 655 { 656 ASSERT_NO_PASS; 657 } 658 fail_destroy_client: 659 if (new_client) 660 { 661 ladish_client_destroy(client); 662 } 663 fail_destroy_port: 664 ladish_port_destroy(port); 665 fail: 666 return NULL; 667 } 668 606 669 #undef room_ptr 607 670 -
daemon/room.h
r5bb96d5 r00cc108 79 79 bool ladish_room_stopped(ladish_room_handle room_handle); 80 80 81 ladish_port_handle 82 ladish_room_add_port( 83 ladish_room_handle room_handle, 84 const uuid_t uuid_ptr, 85 const char * name, 86 uint32_t type, 87 uint32_t flags); 88 81 89 #endif /* #ifndef ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED */ -
daemon/studio.c
r5bb96d5 r00cc108 230 230 void ladish_studio_room_appeared(ladish_room_handle room) 231 231 { 232 log_info("Room \"%s\" appeared", ladish_room_get_name(room)); 232 233 list_add_tail(ladish_room_get_list_node(room), &g_studio.rooms); 233 234 ladish_studio_emit_room_appeared(room); … … 236 237 void ladish_studio_room_disappeared(ladish_room_handle room) 237 238 { 239 log_info("Room \"%s\" disappeared", ladish_room_get_name(room)); 238 240 list_del(ladish_room_get_list_node(room)); 239 241 ladish_studio_emit_room_disappeared(room);
