aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-04-11 17:41:05 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-04-12 12:42:41 +0900
commite5e74ae83e99a9ba93ff2eda688a1a4f0aea4386 (patch)
treedc08b2978ac310233c0d304327918e8f32a644ea
parent6204c36aa79bb16b86d2aa534315e3a8ec775690 (diff)
downloadlibhinawa-e5e74ae83e99a9ba93ff2eda688a1a4f0aea4386.tar.gz
snd_unit: use an utility macro to declare GObject-derived object
Since gobject v2.44, an utility macro is available to declare GObject-derived objects. This commit replaces existent boireplates with it. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/snd_unit.c4
-rw-r--r--src/snd_unit.h32
2 files changed, 3 insertions, 33 deletions
diff --git a/src/snd_unit.c b/src/snd_unit.c
index 320251e..6457217 100644
--- a/src/snd_unit.c
+++ b/src/snd_unit.c
@@ -53,13 +53,13 @@ static const char *const err_msgs[] = {
g_set_error(exception, HINAWA_SND_UNIT_ERROR, HINAWA_SND_UNIT_ERROR_FAILED, \
format " %d(%s)", arg, errno, strerror(errno))
-struct _HinawaSndUnitPrivate {
+typedef struct {
int fd;
struct snd_firewire_get_info info;
HinawaFwNode *node;
gboolean streaming;
-};
+} HinawaSndUnitPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(HinawaSndUnit, hinawa_snd_unit, G_TYPE_OBJECT)
typedef struct {
diff --git a/src/snd_unit.h b/src/snd_unit.h
index e524dac..20c870d 100644
--- a/src/snd_unit.h
+++ b/src/snd_unit.h
@@ -8,40 +8,12 @@ G_BEGIN_DECLS
#define HINAWA_TYPE_SND_UNIT (hinawa_snd_unit_get_type())
-#define HINAWA_SND_UNIT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- HINAWA_TYPE_SND_UNIT, \
- HinawaSndUnit))
-#define HINAWA_IS_SND_UNIT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- HINAWA_TYPE_SND_UNIT))
-
-#define HINAWA_SND_UNIT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- HINAWA_TYPE_SND_UNIT, \
- HinawaSndUnitClass))
-#define HINAWA_IS_SND_UNIT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- HINAWA_TYPE_SND_UNIT))
-#define HINAWA_SND_UNIT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- HINAWA_TYPE_SND_UNIT, \
- HinawaSndUnitClass))
+G_DECLARE_DERIVABLE_TYPE(HinawaSndUnit, hinawa_snd_unit, HINAWA, SND_UNIT, GObject);
#define HINAWA_SND_UNIT_ERROR hinawa_snd_unit_error_quark()
GQuark hinawa_snd_unit_error_quark();
-typedef struct _HinawaSndUnit HinawaSndUnit;
-typedef struct _HinawaSndUnitClass HinawaSndUnitClass;
-typedef struct _HinawaSndUnitPrivate HinawaSndUnitPrivate;
-
-struct _HinawaSndUnit {
- GObject parent_instance;
-
- HinawaSndUnitPrivate *priv;
-};
-
struct _HinawaSndUnitClass {
GObjectClass parent_class;
@@ -71,8 +43,6 @@ struct _HinawaSndUnitClass {
void (*disconnected)(HinawaSndUnit *self);
};
-GType hinawa_snd_unit_get_type(void) G_GNUC_CONST;
-
HinawaSndUnit *hinawa_snd_unit_new(void);
void hinawa_snd_unit_open(HinawaSndUnit *self, gchar *path, GError **exception);