Changeset 5275:811818eb5b81 in roaraudio for roard/clients.c


Ignore:
Timestamp:
11/19/11 22:54:26 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Improved plugin loader a lot (Closes: #190)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/clients.c

    r5242 r5275  
    3838#ifndef ROAR_WITHOUT_DCOMP_EMUL_ESD 
    3939#ifdef ROAR_HAVE_H_ESD 
    40  {ROAR_PROTO_ESOUND, NULL, emul_esd_check_client, NULL, NULL}, 
     40 {ROAR_PROTO_ESOUND, ROAR_SUBSYS_WAVEFORM, "EsounD emulation", NULL, emul_esd_check_client, NULL, NULL}, 
    4141#endif 
    4242#endif 
    4343#ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY 
    44  {ROAR_PROTO_RPLAY, NULL, emul_rplay_check_client, NULL, NULL}, 
     44 {ROAR_PROTO_RPLAY, ROAR_SUBSYS_WAVEFORM, "RPlay emulation", NULL, emul_rplay_check_client, NULL, NULL}, 
    4545#endif 
    4646#ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER 
    47  {ROAR_PROTO_GOPHER, NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client}, 
    48 #endif 
    49  {-1, NULL} 
     47 {ROAR_PROTO_GOPHER, ROAR_SUBSYS_WAVEFORM, "The Internet Gopher Protocol", NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client}, 
     48#endif 
     49 {-1, 0, NULL, NULL, NULL, NULL, NULL} 
    5050}; 
    5151 
     
    5858 for (i = 0; i < ROAR_CLIENTS_MAX; i++) 
    5959  g_clients[i] = NULL; 
     60 
     61 for (i = 0; g_proto[i].proto != -1; i++); 
     62 
     63 for (; i < MAX_PROTOS; i++) 
     64  g_proto[i].proto = -1; 
    6065 
    6166 return 0; 
     
    826831 memcpy(&(g_proto[i]), proto, sizeof(*g_proto)); 
    827832 
    828  i++; 
    829  
    830  memset(&(g_proto[i]), 0, sizeof(*g_proto)); 
    831  g_proto[i].proto = -1; 
    832  
    833  return 0; 
    834 } 
    835  
     833 return 0; 
     834} 
     835 
     836int clients_unregister_proto(int proto) { 
     837 const size_t len = sizeof(g_proto)/sizeof(*g_proto); 
     838 size_t i; 
     839 
     840 if ( proto < 0 ) { 
     841  roar_err_set(ROAR_ERROR_RANGE); 
     842  return -1; 
     843 } 
     844 
     845 for (i = 0; i < len; i++) { 
     846  if ( g_proto[i].proto == proto ) { 
     847   memset(&(g_proto[i]), 0, sizeof(*g_proto)); 
     848   g_proto[i].proto = -1; 
     849   return 0; 
     850  } 
     851 } 
     852 
     853 roar_err_set(ROAR_ERROR_NOENT); 
     854 return -1; 
     855} 
     856 
     857void print_protolist        (enum output_format format) { 
     858 const size_t len = sizeof(g_proto)/sizeof(*g_proto); 
     859 struct roard_proto * p; 
     860 char subsys[7] = "      "; 
     861 size_t i; 
     862 
     863 switch (format) { 
     864  case FORMAT_NATIVE: 
     865    printf("  Protocol Flag Subsys - Description\n"); 
     866    printf("------------------------------------------------------\n"); 
     867    printf("  roar          WM LRX - RoarAudio native protocol\n"); 
     868#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 
     869    printf("  simple        WM LRX - PulseAudio simple protocol\n"); 
     870#endif 
     871#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 
     872    printf("  rsound        W      - RSound emulation\n"); 
     873#endif 
     874   break; 
     875  case FORMAT_WIKI: 
     876    printf("||=Protocol =||=Flag =||=Subsys =||=Description              =||\n"); 
     877    printf("||roar       ||       ||WM LRX   ||RoarAudio native protocol  ||\n"); 
     878#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 
     879    printf("||simple     ||       ||WM LRX   ||PulseAudio simple protocol ||\n"); 
     880#endif 
     881#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 
     882    printf("||rsound     ||       ||W        ||RSound emulation           ||\n"); 
     883#endif 
     884   break; 
     885  case FORMAT_CSV: 
     886    printf("Protocol,Flag,Subsys,Description\n"); 
     887    printf("roar,,WM LRX,RoarAudio native protocol\n"); 
     888#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 
     889    printf("simple,,WM LRX,PulseAudio simple protocol\n"); 
     890#endif 
     891#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 
     892    printf("rsound,,W,RSound emulation\n"); 
     893#endif 
     894   break; 
     895  default: 
     896    roar_err_set(ROAR_ERROR_NOTSUP); 
     897    return; 
     898 } 
     899 
     900 for (i = 0; i < len; i++) { 
     901  p = &(g_proto[i]); 
     902  if ( p->proto == -1 ) 
     903   continue; 
     904 
     905  strncpy(subsys, "      ", 6); 
     906 
     907  if ( p->subsystems & ROAR_SUBSYS_WAVEFORM ) 
     908   subsys[0] = 'W'; 
     909  if ( p->subsystems & ROAR_SUBSYS_MIDI ) 
     910   subsys[1] = 'M'; 
     911  if ( p->subsystems & ROAR_SUBSYS_CB ) 
     912   subsys[2] = 'C'; 
     913  if ( p->subsystems & ROAR_SUBSYS_LIGHT ) 
     914   subsys[3] = 'L'; 
     915  if ( p->subsystems & ROAR_SUBSYS_RAW ) 
     916   subsys[4] = 'R'; 
     917  if ( p->subsystems & ROAR_SUBSYS_COMPLEX ) 
     918   subsys[5] = 'X'; 
     919 
     920  switch (format) { 
     921   case FORMAT_NATIVE: 
     922     printf("  %-13s %s - %s\n", roar_proto2str(p->proto), subsys, p->description); 
     923    break; 
     924   case FORMAT_WIKI: 
     925     printf("||%s || ||%s ||%s ||\n", roar_proto2str(p->proto), subsys, p->description); 
     926    break; 
     927   case FORMAT_CSV: 
     928     printf("%s,,%s,%s\n", roar_proto2str(p->proto), subsys, p->description); 
     929    break; 
     930  } 
     931 } 
     932} 
    836933 
    837934int client_stream_exec   (int client, int stream) { 
Note: See TracChangeset for help on using the changeset viewer.