diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-04-18 07:22:29 +0900 |
---|---|---|
committer | 坂本 貴史 <o-takashi@sakamocchi.jp> | 2022-04-18 07:25:16 +0900 |
commit | edfa5ad1f45d07375a4bee162e349d243e81d83a (patch) | |
tree | c1564e4befb0183928b127ad1a4d37cb37d91888 | |
parent | a4c534692e56fdedf07227fa40f1e29d6ac364cf (diff) | |
download | libhinoko-edfa5ad1f45d07375a4bee162e349d243e81d83a.tar.gz |
fw_iso_resource_once: add derived object to initiate allocation/deallocation by one shot
Current implementataion of Hinoko.FwIsoResource object includes functions
one-shot allocation/deallocation as well as basic functions for derived
objects. It's inconvenient in the derived object side.
This commit adds Hinoko.FwIsoResourceOnce object for future use to move
the one-shot functions.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | src/fw_iso_resource_once.c | 37 | ||||
-rw-r--r-- | src/fw_iso_resource_once.h | 22 | ||||
-rw-r--r-- | src/hinoko.h | 1 | ||||
-rw-r--r-- | src/hinoko.map | 3 | ||||
-rw-r--r-- | src/meson.build | 2 | ||||
-rw-r--r-- | tests/fw-iso-resource-once | 22 | ||||
-rw-r--r-- | tests/meson.build | 1 |
7 files changed, 88 insertions, 0 deletions
diff --git a/src/fw_iso_resource_once.c b/src/fw_iso_resource_once.c new file mode 100644 index 0000000..2f5daac --- /dev/null +++ b/src/fw_iso_resource_once.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +#include "internal.h" + +/** + * HinokoFwIsoResourceOnce: + * An object to initiate requests and listen events of isochronous resource allocation/deallocation + * by one shot. + * + * The [class@FwIsoResourceOnce] is an object to initiate requests and listen events of isochronous + * resource allocation/deallocation by file descriptor owned internally. The allocated resource + * is left even if this object is destroyed, thus application is responsible for deallocation. + */ +G_DEFINE_TYPE(HinokoFwIsoResourceOnce, hinoko_fw_iso_resource_once, HINOKO_TYPE_FW_ISO_RESOURCE) + +static void hinoko_fw_iso_resource_once_class_init(HinokoFwIsoResourceOnceClass *klass) +{ + return; +} + +static void hinoko_fw_iso_resource_once_init(HinokoFwIsoResourceOnce *self) +{ + return; +} + +/** + * hinoko_fw_iso_resource_once_new: + * + * Allocate and return an instance of [class@FwIsoResourceOnce]. + * + * Returns: A [class@FwIsoResourceOnce]. + * + * Sine: 0.7. + */ +HinokoFwIsoResourceOnce *hinoko_fw_iso_resource_once_new() +{ + return g_object_new(HINOKO_TYPE_FW_ISO_RESOURCE_ONCE, NULL); +} diff --git a/src/fw_iso_resource_once.h b/src/fw_iso_resource_once.h new file mode 100644 index 0000000..ab1216b --- /dev/null +++ b/src/fw_iso_resource_once.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +#ifndef __HINOKO_FW_ISO_RESOURCE_ONCE_H__ +#define __HINOKO_FW_ISO_RESOURCE_ONCE_H__ + +#include <hinoko.h> + +G_BEGIN_DECLS + +#define HINOKO_TYPE_FW_ISO_RESOURCE_ONCE (hinoko_fw_iso_resource_once_get_type()) + +G_DECLARE_DERIVABLE_TYPE(HinokoFwIsoResourceOnce, hinoko_fw_iso_resource_once, HINOKO, + FW_ISO_RESOURCE_ONCE, HinokoFwIsoResource); + +struct _HinokoFwIsoResourceOnceClass { + HinokoFwIsoResourceClass parent_class; +}; + +HinokoFwIsoResourceOnce *hinoko_fw_iso_resource_once_new(); + +G_END_DECLS + +#endif diff --git a/src/hinoko.h b/src/hinoko.h index 6de48af..c4a1a46 100644 --- a/src/hinoko.h +++ b/src/hinoko.h @@ -22,5 +22,6 @@ #include <fw_iso_resource.h> #include <fw_iso_resource_auto.h> +#include <fw_iso_resource_once.h> #endif diff --git a/src/hinoko.map b/src/hinoko.map index 07768bf..a3a06fc 100644 --- a/src/hinoko.map +++ b/src/hinoko.map @@ -93,4 +93,7 @@ HINOKO_0_7_0 { global: "hinoko_fw_iso_resource_auto_allocate_sync"; "hinoko_fw_iso_resource_auto_deallocate_sync"; + + "hinoko_fw_iso_resource_once_get_type"; + "hinoko_fw_iso_resource_once_new"; } HINOKO_0_5_0; diff --git a/src/meson.build b/src/meson.build index 34dbae4..dd546a0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -14,6 +14,7 @@ sources = [ 'cycle_timer.c', 'fw_iso_resource.c', 'fw_iso_resource_auto.c', + 'fw_iso_resource_once.c', ] headers = [ @@ -25,6 +26,7 @@ headers = [ 'cycle_timer.h', 'fw_iso_resource.h', 'fw_iso_resource_auto.h', + 'fw_iso_resource_once.h', 'hinoko_enum_types.h' ] diff --git a/tests/fw-iso-resource-once b/tests/fw-iso-resource-once new file mode 100644 index 0000000..2117f15 --- /dev/null +++ b/tests/fw-iso-resource-once @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +from sys import exit +from errno import ENXIO + +from helper import test + +import gi +gi.require_version('Hinoko', '0.0') +from gi.repository import Hinoko + +target = Hinoko.FwIsoResourceOnce() +props = () +methods = ( + 'new', +) +vmethods = () +signals = () + +if not test(target, props, methods, vmethods, signals): + exit(ENXIO) + diff --git a/tests/meson.build b/tests/meson.build index 7d79edf..f7fd634 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -6,6 +6,7 @@ tests = [ 'fw-iso-tx', 'fw-iso-resource', 'fw-iso-resource-auto', + 'fw-iso-resource-once', ] envs = environment() |