Changeset 4313:293eb8eb58d7 in roaraudio


Ignore:
Timestamp:
09/07/10 14:32:37 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support for proxy

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/notify.h

    r4306 r4313  
    4141#define ROAR_EVENT_FLAG_NONE        0x00000000 
    4242#define ROAR_EVENT_FLAG_NETTRANS    0x00000001 
     43#define ROAR_EVENT_FLAG_PROXYEVENT  0x00000002 
    4344 
    4445struct roar_event { 
    4546 uint32_t flags; 
    4647 uint32_t event; 
     48 uint32_t event_proxy; 
    4749 int emitter; 
    4850 int target; 
     
    5759struct roar_notify_core; 
    5860 
     61#define ROAR_EVENT_GET_TYPE(x) ((x) == NULL ? -1 : ((x)->flags & ROAR_EVENT_FLAG_PROXYEVENT ? (x)->event_proxy : (x)->event)) 
     62 
    5963struct roar_notify_core * roar_notify_core_new(ssize_t lists); 
    6064int roar_notify_core_ref(struct roar_notify_core * core); 
    6165int roar_notify_core_unref(struct roar_notify_core * core); 
    6266#define roar_notify_core_free(x) roar_notify_core_unref((x)) 
     67 
     68int roar_notify_core_register_proxy(struct roar_notify_core * core, void (*cb)(struct roar_notify_core * core, struct roar_event * event, void * userdata), void * userdata); 
    6369 
    6470struct roar_subscriber * roar_notify_core_subscribe(struct roar_notify_core * core, struct roar_event * event, void (*cb)(struct roar_notify_core * core, struct roar_event * event, void * userdata), void * userdata); 
  • libroar/notify.c

    r4310 r4313  
    5454 size_t listc; 
    5555 struct roar_subscriber ** lists; 
     56 void (*proxy)(struct roar_notify_core * core, struct roar_event * event, void * userdata); 
     57 void * proxy_userdata; 
    5658}; 
    5759 
     
    107109 core->listc = lists; 
    108110 core->lists = roar_mm_malloc(lists*sizeof(struct roar_subscriber *)); 
     111 core->proxy = NULL; 
     112 core->proxy_userdata = NULL; 
    109113 
    110114 if ( core->lists == NULL ) { 
     
    158162 return 0; 
    159163} 
     164 
     165int roar_notify_core_register_proxy(struct roar_notify_core * core, void (*cb)(struct roar_notify_core * core, struct roar_event * event, void * userdata), void * userdata) { 
     166 _CKICORE(); 
     167 
     168 core->proxy = cb; 
     169 core->proxy_userdata = userdata; 
     170 
     171 return 0; 
     172} 
     173 
    160174 
    161175struct roar_subscriber * roar_notify_core_subscribe(struct roar_notify_core * core, struct roar_event * event, void (*cb)(struct roar_notify_core * core, struct roar_event * event, void * userdata), void * userdata) { 
     
    246260 } 
    247261 
     262 if ( core->proxy != NULL ) { 
     263  core->proxy(core, event, core->proxy_userdata); 
     264 } 
     265 
    248266 cur = core->lists[_hash_event(core, event)]; 
    249267 ROAR_DBG("roar_notify_core_emit(core=%p, event=%p): cur=%p", core, event, cur); 
Note: See TracChangeset for help on using the changeset viewer.