Changeset 4313:293eb8eb58d7 in roaraudio
- Timestamp:
- 09/07/10 14:32:37 (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/notify.h
r4306 r4313 41 41 #define ROAR_EVENT_FLAG_NONE 0x00000000 42 42 #define ROAR_EVENT_FLAG_NETTRANS 0x00000001 43 #define ROAR_EVENT_FLAG_PROXYEVENT 0x00000002 43 44 44 45 struct roar_event { 45 46 uint32_t flags; 46 47 uint32_t event; 48 uint32_t event_proxy; 47 49 int emitter; 48 50 int target; … … 57 59 struct roar_notify_core; 58 60 61 #define ROAR_EVENT_GET_TYPE(x) ((x) == NULL ? -1 : ((x)->flags & ROAR_EVENT_FLAG_PROXYEVENT ? (x)->event_proxy : (x)->event)) 62 59 63 struct roar_notify_core * roar_notify_core_new(ssize_t lists); 60 64 int roar_notify_core_ref(struct roar_notify_core * core); 61 65 int roar_notify_core_unref(struct roar_notify_core * core); 62 66 #define roar_notify_core_free(x) roar_notify_core_unref((x)) 67 68 int 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); 63 69 64 70 struct 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 54 54 size_t listc; 55 55 struct roar_subscriber ** lists; 56 void (*proxy)(struct roar_notify_core * core, struct roar_event * event, void * userdata); 57 void * proxy_userdata; 56 58 }; 57 59 … … 107 109 core->listc = lists; 108 110 core->lists = roar_mm_malloc(lists*sizeof(struct roar_subscriber *)); 111 core->proxy = NULL; 112 core->proxy_userdata = NULL; 109 113 110 114 if ( core->lists == NULL ) { … … 158 162 return 0; 159 163 } 164 165 int 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 160 174 161 175 struct 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) { … … 246 260 } 247 261 262 if ( core->proxy != NULL ) { 263 core->proxy(core, event, core->proxy_userdata); 264 } 265 248 266 cur = core->lists[_hash_event(core, event)]; 249 267 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.