diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-05-03 07:57:47 +0900 |
---|---|---|
committer | 坂本 貴史 <o-takashi@sakamocchi.jp> | 2022-05-03 08:31:29 +0900 |
commit | c4788482d3ca6b2c597e09aac270fe19944dfddf (patch) | |
tree | 00800bca2b8e7646e25678543a9b278268569f15 | |
parent | 104401505ab30fa0317e6b878f9bf5bba1404096 (diff) | |
download | libhinoko-c4788482d3ca6b2c597e09aac270fe19944dfddf.tar.gz |
fw_iso_resource: don't dispatch event recursively
Linux FireWire subsystem don't copy multiple event data in one call.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | src/fw_iso_resource.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/fw_iso_resource.c b/src/fw_iso_resource.c index 8d88374..97cdd71 100644 --- a/src/fw_iso_resource.c +++ b/src/fw_iso_resource.c @@ -266,8 +266,8 @@ void hinoko_fw_iso_resource_ioctl(HinokoFwIsoResource *self, } } -static void handle_iso_resource_event(HinokoFwIsoResource *self, - struct fw_cdev_event_iso_resource *ev) +static void handle_fw_iso_resource_event(HinokoFwIsoResource *self, + const struct fw_cdev_event_iso_resource *ev) { guint channel; guint bandwidth; @@ -326,7 +326,7 @@ static gboolean dispatch_src(GSource *gsrc, GSourceFunc cb, gpointer user_data) hinoko_fw_iso_resource_get_instance_private(self); GIOCondition condition; ssize_t len; - guint8 *buf; + const union fw_cdev_event *ev; if (priv->fd < 0) return G_SOURCE_REMOVE; @@ -343,26 +343,16 @@ static gboolean dispatch_src(GSource *gsrc, GSourceFunc cb, gpointer user_data) return G_SOURCE_REMOVE; } - buf = src->buf; - while (len > 0) { - union fw_cdev_event *ev = (union fw_cdev_event *)buf; - size_t size = 0; - - switch (ev->common.type) { - case FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED: - case FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED: - handle_iso_resource_event(self, &ev->iso_resource); - size = sizeof(ev->iso_resource); - break; - default: - break; - } - - len -= size; - buf += size; + ev = (const union fw_cdev_event *)src->buf; + switch (ev->common.type) { + case FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED: + case FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED: + handle_fw_iso_resource_event(self, &ev->iso_resource); + break; + default: + break; } - // Just be sure to continue to process this source. return G_SOURCE_CONTINUE; } |