Changeset 4101:42b7ee5d2f76 in roaraudio


Ignore:
Timestamp:
07/25/10 16:56:11 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

some work to support counters

Location:
roard
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • roard/clients.c

    r4020 r4101  
    8181    g_clients[i] = n; 
    8282 
     83    counters_inc(clients, 1); 
    8384    ROAR_DBG("clients_new(void) = %i", i); 
    8485    return i; 
     
    128129 
    129130 ROAR_DBG("clients_delete(id=%i) = ?", id); 
     131 
     132 counters_inc(clients, -1); 
    130133 
    131134 _CHECK_CID(id); 
  • roard/include/roard.h

    r3977 r4101  
    183183} * g_config; 
    184184 
     185struct _counters { 
     186 size_t clients, streams, 
     187        samples, 
     188        sources, outputs, 
     189        mixers, bridges, 
     190        listens; 
     191}; 
     192 
     193struct { 
     194 struct _counters cur, sum; 
     195} g_counters; 
     196 
     197 
     198#define counters_init() memset(&g_counters, 0, sizeof(g_counters)) 
     199//#define counters_inc(c,i) do { signed long int __i = (i); if ( __i < 0 && __i > (g_counters.cur.c) ) { ROAR_WARN("counters_inc(c=%s, i=%li): Decrement request bigger than current counter value. Counter out of syn!", )  } while (0) 
     200#define counters_inc(c,i) do { signed long int __i = (i); g_counters.cur.c += __i; if ( __i > 0 ) g_counters.sum.c += __i; } while (0) 
     201 
     202#define counters_get(g,c) ((g_counters.g.c)) 
     203 
     204void counters_print(int type, int force); 
     205 
    185206#endif 
    186207 
  • roard/roard.c

    r4058 r4101  
    236236#endif 
    237237 
     238#define _pmsg(format, args...) roar_debug_msg(type, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) 
     239#define _pmsgc(group, counter, name) _pmsg("  Counter %-10s: %llu", (name), (long long unsigned int)counters_get(group, counter)) 
     240void counters_print(int type, int force) { 
     241 if ( type != ROAR_DEBUG_TYPE_INFO || force || (ROAR_DBG_INFOVAR) >= ROAR_DBG_INFO_INFO ) { 
     242  _pmsg("--- Counter Listing ---"); 
     243  _pmsg(" Current:"); 
     244  _pmsgc(cur, clients, "Clients"); 
     245  _pmsgc(cur, streams, "Streams"); 
     246  _pmsg(" Total:"); 
     247  _pmsgc(sum, clients, "Clients"); 
     248  _pmsgc(sum, streams, "Streams"); 
     249  _pmsg("--- End of Counter Listing ---"); 
     250 } 
     251} 
     252#undef _pmsgc 
     253#undef _pmsg 
     254 
    238255int restart_server (char * server, int terminate) { 
    239256 struct roar_connection con; 
     
    12391256 memcpy(g_max_sa, g_sa, sizeof(max_sa)); 
    12401257 
     1258 counters_init(); 
     1259 
    12411260 g_config = &config; 
    12421261 
     
    22192238 ROAR_INFO("Shuting down", ROAR_DBG_INFO_INFO); 
    22202239 
     2240 counters_print(ROAR_DEBUG_TYPE_INFO, 0); 
     2241 
    22212242 clean_quit_prep(); 
    22222243// driver_close(drvinst, drvid); 
  • roard/streams.c

    r4099 r4101  
    135135 
    136136   g_streams[i] = s; 
     137   counters_inc(streams, 1); 
    137138   ROAR_DBG("streams_new(void): n->id=%i", n->id); 
    138139   ROAR_DBG("streams_new(void) = %i", i); 
     
    164165 
    165166 s->state = ROAR_STREAMSTATE_CLOSING; 
     167 
     168 counters_inc(streams, -1); 
    166169 
    167170 if ( streams_get_flag(id, ROAR_FLAG_RECSOURCE) == 1 ) 
Note: See TracChangeset for help on using the changeset viewer.