Changeset 4818:3bee704d266e in roaraudio for roarclients
- Timestamp:
- 03/28/11 11:56:33 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarctl.c
r4740 r4818 48 48 int g_verbose = 0; 49 49 50 void display_client (struct roar_connection * con, int id); 51 void display_stream (struct roar_connection * con, int id); 50 52 int display_mixer (struct roar_connection * con, int stream); 51 53 int show_meta_all (struct roar_connection * con, int id); … … 117 119 " serveroinfo - Gets Information about server output\n" 118 120 " serveroinfo2 DIR - Gets Information about server output for stream direction dir\n" 121 "\n" 119 122 " serverstandards - Gets list of server supported standards\n" 123 "\n" 120 124 " listclients - Gets Information about clients\n" 125 " clientinfo ID - Gets Information about client ID\n" 121 126 " liststreams - Gets Information about streams\n" 127 " streaminfo ID - Gets Information about stream ID\n" 122 128 " allinfo - Get all infos\n" 123 129 ); … … 317 323 int i; 318 324 int num; 325 int id[ROAR_CLIENTS_MAX]; 326 327 if ( (num = roar_list_clients(con, id, ROAR_CLIENTS_MAX)) == -1 ) { 328 fprintf(stderr, "Error: can not get client list\n"); 329 return; 330 } 331 332 for (i = 0; i < num; i++) { 333 display_client(con, id[i]); 334 } 335 } 336 337 void display_client (struct roar_connection * con, int id) { 338 static int self_id = -1; 339 static struct roar_client self_client_store; 340 static struct roar_client * self_client = NULL; 341 struct roar_client c; 342 char tmp[80]; 319 343 int h; 320 int id[ROAR_CLIENTS_MAX];321 char tmp[80];322 int self_id;323 struct roar_client self_client;324 struct roar_client c;325 344 #ifdef _POSIX_USERS 326 345 struct group * grp = NULL; … … 328 347 #endif 329 348 330 if ( (self_id = roar_get_clientid(con)) != -1 ) { 331 if ( roar_get_client(con, &self_client, self_id) == -1 ) 332 self_id = -1; 333 } 334 335 if ( (num = roar_list_clients(con, id, ROAR_CLIENTS_MAX)) == -1 ) { 336 fprintf(stderr, "Error: can not get client list\n"); 349 if ( self_id == -1 ) { 350 if ( (self_id = roar_get_clientid(con)) != -1 ) { 351 if ( roar_get_client(con, &self_client_store, self_id) == -1 ) { 352 self_id = -1; 353 } else { 354 self_client = &self_client_store; 355 } 356 } 357 } 358 359 printf("client %i:\n", id); 360 if ( roar_get_client(con, &c, id) == -1 ) { 361 fprintf(stderr, "Error: can not get client info\n"); 337 362 return; 338 363 } 339 364 340 for (i = 0; i < num; i++) { 341 printf("client %i:\n", id[i]); 342 if ( roar_get_client(con, &c, id[i]) == -1 ) { 343 fprintf(stderr, "Error: can not get client info\n"); 344 continue; 345 } 346 347 if ( c.name[0] != '\0' ) 348 printf("Client name : %s\n", c.name); 349 365 if ( c.name[0] != '\0' ) 366 printf("Client name : %s\n", c.name); 350 367 if ( roar_nnode_get_socktype(&(c.nnode)) != ROAR_SOCKET_TYPE_UNKNOWN ) { 351 352 353 354 355 356 357 if ( self_id != -1 && roar_nnode_cmp(&(self_client.nnode), &(c.nnode)) == 0 ) {358 359 360 361 362 363 368 if ( roar_nnode_to_str(&(c.nnode), tmp, 80) == 0 ) { 369 printf("Client network node : %s\n", tmp); 370 } 371 } 372 373 if ( c.pid != -1 ) { 374 if ( self_id != -1 && roar_nnode_cmp(&(self_client->nnode), &(c.nnode)) == 0 ) { 375 printf("Client PID : %i(%s)\n", c.pid, proc_name(c.pid)); 376 } else { 377 printf("Client PID : %i\n", c.pid); 378 } 379 } 380 if ( c.uid != -1 ) { 364 381 #ifdef _POSIX_USERS 365 if ( self_id != -1 && roar_nnode_cmp(&(self_client.nnode), &(c.nnode)) == 0 ) {366 367 368 369 382 if ( self_id != -1 && roar_nnode_cmp(&(self_client->nnode), &(c.nnode)) == 0 ) { 383 pwd = getpwuid(c.uid); 384 grp = getgrgid(c.gid); 385 printf("Client UID/GID : %i(%s)/%i(%s)\n", c.uid, pwd ? pwd->pw_name : "?", c.gid, grp ? grp->gr_name : "?"); 386 } else { 370 387 #else 371 388 if ( 1 ) { 372 389 #endif 373 printf("Client UID/GID : %i/%i\n", c.uid, c.gid); 374 } 375 } 376 377 if ( g_verbose && c.proto != ROAR_PROTO_NONE ) { 378 printf("Client Protocol : %s\n", roar_proto2str(c.proto)); 379 } 380 381 if ( g_verbose && c.byteorder != ROAR_BYTEORDER_UNKNOWN ) { 382 if ( c.byteorder == ROAR_BYTEORDER_NETWORK ) { 383 strcpy(tmp, " (network byteorder"); 384 } else { 385 *tmp = 0; 386 } 387 388 if ( c.byteorder == ROAR_BYTEORDER_NATIVE ) { 389 if ( *tmp ) { 390 strcat(tmp, ", native"); 391 } else { 392 strcpy(tmp, " (native"); 393 } 394 } 395 396 if ( *tmp ) 397 strcat(tmp, ")"); 398 399 printf("Client Byteorder : %s%s\n", roar_byteorder2str(c.byteorder), tmp); 400 } 401 402 if ( c.execed != -1 ) 403 printf("Execed stream : %i\n", c.execed); 404 405 for (h = 0; h < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; h++) 406 if ( c.streams[h] != -1 ) 407 printf("stream : %i\n", c.streams[h]); 408 } 409 390 printf("Client UID/GID : %i/%i\n", c.uid, c.gid); 391 } 392 } 393 394 if ( g_verbose && c.proto != ROAR_PROTO_NONE ) { 395 printf("Client Protocol : %s\n", roar_proto2str(c.proto)); 396 } 397 398 if ( g_verbose && c.byteorder != ROAR_BYTEORDER_UNKNOWN ) { 399 if ( c.byteorder == ROAR_BYTEORDER_NETWORK ) { 400 strcpy(tmp, " (network byteorder"); 401 } else { 402 *tmp = 0; 403 } 404 405 if ( c.byteorder == ROAR_BYTEORDER_NATIVE ) { 406 if ( *tmp ) { 407 strcat(tmp, ", native"); 408 } else { 409 strcpy(tmp, " (native"); 410 } 411 } 412 413 if ( *tmp ) 414 strcat(tmp, ")"); 415 416 printf("Client Byteorder : %s%s\n", roar_byteorder2str(c.byteorder), tmp); 417 } 418 419 if ( c.execed != -1 ) 420 printf("Execed stream : %i\n", c.execed); 421 422 for (h = 0; h < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; h++) 423 if ( c.streams[h] != -1 ) 424 printf("stream : %i\n", c.streams[h]); 410 425 } 411 426 … … 414 429 int num; 415 430 int id[ROAR_STREAMS_MAX]; 431 432 if ( (num = roar_list_streams(con, id, ROAR_STREAMS_MAX)) == -1 ) { 433 fprintf(stderr, "Error: can not get stream list\n"); 434 return; 435 } 436 437 for (i = 0; i < num; i++) { 438 display_stream(con, id[i]); 439 } 440 } 441 442 void display_stream (struct roar_connection * con, int id) { 416 443 char chanmap[ROAR_MAX_CHANNELS]; 417 444 struct roar_stream s; … … 424 451 size_t len; 425 452 426 427 if ( (num = roar_list_streams(con, id, ROAR_STREAMS_MAX)) == -1 ) {428 fprintf(stderr, "Error: can not get stream list\n");453 printf("stream %i:\n", id); 454 if ( roar_get_stream(con, &s, id) == -1 ) { 455 fprintf(stderr, "Error: can not get stream info\n"); 429 456 return; 430 457 } 431 432 for (i = 0; i < num; i++) { 433 printf("stream %i:\n", id[i]);434 if ( roar_get_stream(con, &s, id[i]) == -1 ) {435 fprintf(stderr, "Error: can not get stream info\n"); 436 continue;437 }438 printf("Stream direction : %s\n", roar_dir2str(s.dir));439 440 if ( roar_stream_get_name(con, &s, name, 1024) == 0 )441 printf("Stream name : %s\n", name);442 443 if ( (int)s.pos_rel_id ==-1 ) {444 printf("Relativ position id : none (stream not synchronized)\n");445 } else if ( (int)s.pos_rel_id == id[i] ) {446 printf("Relativ position id : %i (self synchronized)\n", s.pos_rel_id);458 printf("Stream direction : %s\n", roar_dir2str(s.dir)); 459 460 if ( roar_stream_get_name(con, &s, name, 1024) == 0 ) 461 printf("Stream name : %s\n", name); 462 463 if ( (int)s.pos_rel_id == -1 ) { 464 printf("Relativ position id : none (stream not synchronized)\n"); 465 } else if ( (int)s.pos_rel_id == id ) { 466 printf("Relativ position id : %i (self synchronized)\n", s.pos_rel_id); 467 } else { 468 printf("Relativ position id : %i (synchronized)\n", s.pos_rel_id); 469 } 470 if ( g_verbose > 1 && s.pos != (uint32_t)-1 ) { 471 if ( s.info.rate && s.info.channels ) { 472 printf("Position : %lu S (%.3fs)\n", (unsigned long int) s.pos, 473 (float)s.pos/(s.info.rate*s.info.channels)); 447 474 } else { 448 printf("Relativ position id : %i (synchronized)\n", s.pos_rel_id); 449 } 450 if ( g_verbose > 1 && s.pos != (uint32_t)-1 ) { 451 if ( s.info.rate && s.info.channels ) { 452 printf("Position : %lu S (%.3fs)\n", (unsigned long int) s.pos, 453 (float)s.pos/(s.info.rate*s.info.channels)); 454 } else { 455 printf("Position : %lu S\n", (unsigned long int) s.pos); 456 } 457 } 458 459 switch (s.dir) { 460 case ROAR_DIR_MIDI_IN: 461 case ROAR_DIR_MIDI_OUT: 462 infotext = " ticks/s"; 463 break; 464 case ROAR_DIR_LIGHT_IN: 465 case ROAR_DIR_LIGHT_OUT: 466 infotext = " updates/s"; 467 break; 468 default: 469 infotext = " Hz"; 470 } 471 if ( s.info.rate ) 472 printf("Stream sample rate : %i%s\n", s.info.rate, infotext); 473 if ( s.info.bits ) 474 printf("Stream bits : %i\n", s.info.bits); 475 if ( s.info.channels ) 475 printf("Position : %lu S\n", (unsigned long int) s.pos); 476 } 477 } 478 479 switch (s.dir) { 480 case ROAR_DIR_MIDI_IN: 481 case ROAR_DIR_MIDI_OUT: 482 infotext = " ticks/s"; 483 break; 484 case ROAR_DIR_LIGHT_IN: 485 case ROAR_DIR_LIGHT_OUT: 486 infotext = " updates/s"; 487 break; 488 default: 489 infotext = " Hz"; 490 } 491 if ( s.info.rate ) 492 printf("Stream sample rate : %i%s\n", s.info.rate, infotext); 493 if ( s.info.bits ) 494 printf("Stream bits : %i\n", s.info.bits); 495 if ( s.info.channels ) 476 496 printf("Stream channels : %i\n", s.info.channels); 477 497 478 mime = roar_codec2mime(s.info.codec); 479 printf("Stream codec : %2i (%s%s%s%s)\n", s.info.codec, roar_codec2str(s.info.codec), 480 s.info.codec == ROAR_CODEC_DEFAULT ? " native" : "", 481 mime == NULL ? "" : " mimetype:", 482 mime == NULL ? "" : mime 483 ); 484 if ( roar_stream_get_info(con, &s, &info) != -1 ) { 485 if ( info.codec != s.info.codec ) { 486 mime = roar_codec2mime(info.codec); 487 printf("Streamed codec : %2i (%s%s%s%s)\n", info.codec, roar_codec2str(info.codec), 488 info.codec == ROAR_CODEC_DEFAULT ? " native" : "", 489 mime == NULL ? "" : " mimetype:", 490 mime == NULL ? "" : mime 491 ); 492 } 493 494 if ( g_verbose ) { 495 if ( info.block_size ) 496 printf("Stream block size : %i Byte\n", info.block_size); 497 498 printf("Underruns pre/post : %i/%i\n", info.pre_underruns, info.post_underruns); 499 if ( g_verbose > 1 ) 500 printf("Stream delay : %ims (%.2fm)\n", (int)info.delay/1000, (info.delay*(float)_SPEED_OF_SOUND)); 501 502 if ( g_verbose > 1 ) 503 printf("Stream mixer : %i\n", info.mixer); 504 505 if ( g_verbose > 1 ) 506 printf("Stream state : %s\n", roar_streamstate2str(info.state)); 507 508 if ( g_verbose > 1 ) 509 printf("Stream role : %s\n", roar_role2str(info.role)); 510 511 *flags = 0; 512 if ( info.flags & ROAR_FLAG_PRIMARY ) 513 strcat(flags, "primary "); 514 if ( info.flags & ROAR_FLAG_SYNC ) 515 strcat(flags, "sync "); 516 if ( info.flags & ROAR_FLAG_OUTPUT ) 517 strcat(flags, "output "); 518 if ( info.flags & ROAR_FLAG_SOURCE ) 519 strcat(flags, "source "); 520 if ( info.flags & ROAR_FLAG_META ) 521 strcat(flags, "meta "); 522 if ( info.flags & ROAR_FLAG_AUTOCONF ) 523 strcat(flags, "autoconf "); 524 if ( info.flags & ROAR_FLAG_CLEANMETA ) 525 strcat(flags, "cleanmeta "); 526 if ( info.flags & ROAR_FLAG_HWMIXER ) 527 strcat(flags, "hwmixer "); 528 if ( info.flags & ROAR_FLAG_PAUSE ) 529 strcat(flags, "pause "); 530 if ( info.flags & ROAR_FLAG_MUTE ) 531 strcat(flags, "mute "); 532 if ( info.flags & ROAR_FLAG_MMAP ) 533 strcat(flags, "mmap "); 534 if ( info.flags & ROAR_FLAG_ANTIECHO ) 535 strcat(flags, "antiecho "); 536 if ( info.flags & ROAR_FLAG_VIRTUAL ) 537 strcat(flags, "virtual "); 538 if ( info.flags & ROAR_FLAG_RECSOURCE ) 539 strcat(flags, "recsource "); 540 if ( info.flags & ROAR_FLAG_PASSMIXER ) 541 strcat(flags, "passmixer "); 542 if ( info.flags & ROAR_FLAG_PRETHRU ) 543 strcat(flags, "prethru "); 544 if ( info.flags & ROAR_FLAG_IMMUTABLE ) 545 strcat(flags, "immutable "); 546 if ( info.flags & ROAR_FLAG_ENHANCE ) 547 strcat(flags, "enhance "); 548 if ( info.flags & ROAR_FLAG_SINGLESINK ) 549 strcat(flags, "singlesink "); 550 551 printf("Flags : %s\n", flags); 552 } 498 mime = roar_codec2mime(s.info.codec); 499 printf("Stream codec : %2i (%s%s%s%s)\n", s.info.codec, roar_codec2str(s.info.codec), 500 s.info.codec == ROAR_CODEC_DEFAULT ? " native" : "", 501 mime == NULL ? "" : " mimetype:", 502 mime == NULL ? "" : mime 503 ); 504 if ( roar_stream_get_info(con, &s, &info) != -1 ) { 505 if ( info.codec != s.info.codec ) { 506 mime = roar_codec2mime(info.codec); 507 printf("Streamed codec : %2i (%s%s%s%s)\n", info.codec, roar_codec2str(info.codec), 508 info.codec == ROAR_CODEC_DEFAULT ? " native" : "", 509 mime == NULL ? "" : " mimetype:", 510 mime == NULL ? "" : mime 511 ); 553 512 } 554 513 555 514 if ( g_verbose ) { 556 len = ROAR_MAX_CHANNELS; 557 if ( roar_stream_get_chanmap(con, &s, chanmap, &len) == -1 ) { 558 fprintf(stderr, "Error: can not get stream channel map\n"); 559 } else { 560 if ( roardsp_chanlist2str(chanmap, len, buffer, 1024) == -1 ) { 561 fprintf(stderr, "Error: can not convert channel map into string\n"); 562 } else { 563 printf("Channel Map : %s\n", buffer); 564 } 565 } 566 } 567 568 if ( s.dir != ROAR_DIR_THRU ) { 569 display_mixer(con, id[i]); 570 show_meta_all(con, id[i]); 571 } 572 } 573 515 if ( info.block_size ) 516 printf("Stream block size : %i Byte\n", info.block_size); 517 518 printf("Underruns pre/post : %i/%i\n", info.pre_underruns, info.post_underruns); 519 if ( g_verbose > 1 ) 520 printf("Stream delay : %ims (%.2fm)\n", (int)info.delay/1000, (info.delay*(float)_SPEED_OF_SOUND)); 521 522 if ( g_verbose > 1 ) 523 printf("Stream mixer : %i\n", info.mixer); 524 525 if ( g_verbose > 1 ) 526 printf("Stream state : %s\n", roar_streamstate2str(info.state)); 527 528 if ( g_verbose > 1 ) 529 printf("Stream role : %s\n", roar_role2str(info.role)); 530 531 *flags = 0; 532 if ( info.flags & ROAR_FLAG_PRIMARY ) 533 strcat(flags, "primary "); 534 if ( info.flags & ROAR_FLAG_SYNC ) 535 strcat(flags, "sync "); 536 if ( info.flags & ROAR_FLAG_OUTPUT ) 537 strcat(flags, "output "); 538 if ( info.flags & ROAR_FLAG_SOURCE ) 539 strcat(flags, "source "); 540 if ( info.flags & ROAR_FLAG_META ) 541 strcat(flags, "meta "); 542 if ( info.flags & ROAR_FLAG_AUTOCONF ) 543 strcat(flags, "autoconf "); 544 if ( info.flags & ROAR_FLAG_CLEANMETA ) 545 strcat(flags, "cleanmeta "); 546 if ( info.flags & ROAR_FLAG_HWMIXER ) 547 strcat(flags, "hwmixer "); 548 if ( info.flags & ROAR_FLAG_PAUSE ) 549 strcat(flags, "pause "); 550 if ( info.flags & ROAR_FLAG_MUTE ) 551 strcat(flags, "mute "); 552 if ( info.flags & ROAR_FLAG_MMAP ) 553 strcat(flags, "mmap "); 554 if ( info.flags & ROAR_FLAG_ANTIECHO ) 555 strcat(flags, "antiecho "); 556 if ( info.flags & ROAR_FLAG_VIRTUAL ) 557 strcat(flags, "virtual "); 558 if ( info.flags & ROAR_FLAG_RECSOURCE ) 559 strcat(flags, "recsource "); 560 if ( info.flags & ROAR_FLAG_PASSMIXER ) 561 strcat(flags, "passmixer "); 562 if ( info.flags & ROAR_FLAG_PRETHRU ) 563 strcat(flags, "prethru "); 564 if ( info.flags & ROAR_FLAG_IMMUTABLE ) 565 strcat(flags, "immutable "); 566 if ( info.flags & ROAR_FLAG_ENHANCE ) 567 strcat(flags, "enhance "); 568 if ( info.flags & ROAR_FLAG_SINGLESINK ) 569 strcat(flags, "singlesink "); 570 571 printf("Flags : %s\n", flags); 572 } 573 } 574 575 if ( g_verbose ) { 576 len = ROAR_MAX_CHANNELS; 577 if ( roar_stream_get_chanmap(con, &s, chanmap, &len) == -1 ) { 578 fprintf(stderr, "Error: can not get stream channel map\n"); 579 } else { 580 if ( roardsp_chanlist2str(chanmap, len, buffer, 1024) == -1 ) { 581 fprintf(stderr, "Error: can not convert channel map into string\n"); 582 } else { 583 printf("Channel Map : %s\n", buffer); 584 } 585 } 586 } 587 588 if ( s.dir != ROAR_DIR_THRU ) { 589 display_mixer(con, id); 590 show_meta_all(con, id); 591 } 574 592 } 575 593 … … 1108 1126 } else if ( !strcmp(k, "listclients") ) { 1109 1127 list_clients(&con); 1128 } else if ( !strcmp(k, "clientinfo") ) { 1129 display_client(&con, atoi(argv[++i])); 1110 1130 } else if ( !strcmp(k, "liststreams") ) { 1111 1131 list_streams(&con); 1132 } else if ( !strcmp(k, "streaminfo") ) { 1133 display_stream(&con, atoi(argv[++i])); 1112 1134 } else if ( !strcmp(k, "allinfo") ) { 1113 1135 server_oinfo(&con, -1);
Note: See TracChangeset
for help on using the changeset viewer.