diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-04-25 11:18:25 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-04-25 11:18:25 +0200 |
commit | 7f3a56fc5886e2017423783d2cc5230ea7865a94 (patch) | |
tree | 08b1a9fabc61575c4f13e367a09234e9c8b3b444 | |
parent | 81989944e6947176541acb10d45db658595eb61c (diff) |
wfdevent: Allowed attributes depend on the current event type
-rw-r--r-- | src/wfdevent.c | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/src/wfdevent.c b/src/wfdevent.c index 96ed851..5d0afc5 100644 --- a/src/wfdevent.c +++ b/src/wfdevent.c @@ -68,6 +68,8 @@ struct wfd_event { int source_bind_event_queue_fd; GQueue *bind_event_queue; + + WFDEventType current_event_type; }; void @@ -179,6 +181,7 @@ wfd_create_event(struct wfd_device *device, event->bind_event_queue = g_queue_new(); event->device = device; + event->current_event_type = WFD_EVENT_NONE; return event; } @@ -189,17 +192,49 @@ wfd_event_get_attribi(struct wfd_device *device, WFDEventAttrib attribute) { switch (attribute) { - case WFD_EVENT_PIPELINE_BIND_PIPELINE_ID: - return event->bind.pipeline_id; - case WFD_EVENT_PIPELINE_BIND_TIME_EXT: - return event->bind.time; + case WFD_EVENT_TYPE: + return event->current_event_type; + case WFD_EVENT_PIPELINE_BIND_QUEUE_SIZE: case WFD_EVENT_PORT_ATTACH_PORT_ID: - return event->attach_port_id; case WFD_EVENT_PORT_ATTACH_STATE: - return event->attach_state; + case WFD_EVENT_PORT_PROTECTION_PORT_ID: + case WFD_EVENT_PIPELINE_BIND_PIPELINE_ID: + case WFD_EVENT_PIPELINE_BIND_SOURCE: + case WFD_EVENT_PIPELINE_BIND_MASK: + case WFD_EVENT_PIPELINE_BIND_QUEUE_OVERFLOW: + break; default: wfd_device_set_error(device, WFD_ERROR_BAD_ATTRIBUTE); - break; + return 0; + } + + switch (event->current_event_type) { + case WFD_EVENT_PORT_ATTACH_DETACH: + switch (attribute) { + case WFD_EVENT_PORT_ATTACH_PORT_ID: + return event->attach_port_id; + case WFD_EVENT_PORT_ATTACH_STATE: + return event->attach_state; + default: + wfd_device_set_error(device, + WFD_ERROR_ILLEGAL_ARGUMENT); + return 0; + } + + case WFD_EVENT_PIPELINE_BIND_SOURCE_COMPLETE: + switch (attribute) { + case WFD_EVENT_PIPELINE_BIND_PIPELINE_ID: + return event->bind.pipeline_id; + case WFD_EVENT_PIPELINE_BIND_TIME_EXT: + return event->bind.time; + default: + wfd_device_set_error(device, + WFD_ERROR_ILLEGAL_ARGUMENT); + return 0; + } + default: + wfd_device_set_error(device, WFD_ERROR_ILLEGAL_ARGUMENT); + return 0; } return 0; @@ -322,6 +357,8 @@ wfd_event_wait(struct wfd_device *device, udev_device_unref(u_event); } + event->current_event_type = event_type; + return event_type; } |