[libgnome-volume-control] Gvc: make GvcMixerStreamPort a boxed type
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnome-volume-control] Gvc: make GvcMixerStreamPort a boxed type
- Date: Sat, 8 Dec 2012 14:55:50 +0000 (UTC)
commit 740bab171443cda76d27ca77ac31717475ad51dd
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Thu Oct 18 19:45:56 2012 +0200
Gvc: make GvcMixerStreamPort a boxed type
It's a prerequisite for accessing it from JS
https://bugzilla.gnome.org/show_bug.cgi?id=675902
gvc-mixer-control.c | 4 ++--
gvc-mixer-stream.c | 32 ++++++++++++++++++++++++--------
gvc-mixer-stream.h | 3 ++-
3 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/gvc-mixer-control.c b/gvc-mixer-control.c
index 3492925..b6f6a39 100644
--- a/gvc-mixer-control.c
+++ b/gvc-mixer-control.c
@@ -1470,7 +1470,7 @@ update_sink (GvcMixerControl *control,
for (i = 0; i < info->n_ports; i++) {
GvcMixerStreamPort *port;
- port = g_new0 (GvcMixerStreamPort, 1);
+ port = g_slice_new0 (GvcMixerStreamPort);
port->port = g_strdup (info->ports[i]->name);
port->human_port = g_strdup (info->ports[i]->description);
port->priority = info->ports[i]->priority;
@@ -1598,7 +1598,7 @@ update_source (GvcMixerControl *control,
for (i = 0; i < info->n_ports; i++) {
GvcMixerStreamPort *port;
- port = g_new0 (GvcMixerStreamPort, 1);
+ port = g_slice_new0 (GvcMixerStreamPort);
port->port = g_strdup (info->ports[i]->name);
port->human_port = g_strdup (info->ports[i]->description);
port->priority = info->ports[i]->priority;
diff --git a/gvc-mixer-stream.c b/gvc-mixer-stream.c
index 5a5c8e6..d3e01b6 100644
--- a/gvc-mixer-stream.c
+++ b/gvc-mixer-stream.c
@@ -88,6 +88,30 @@ static void gvc_mixer_stream_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (GvcMixerStream, gvc_mixer_stream, G_TYPE_OBJECT)
+static void
+free_port (GvcMixerStreamPort *p)
+{
+ g_free (p->port);
+ g_free (p->human_port);
+ g_slice_free (GvcMixerStreamPort, p);
+}
+
+static GvcMixerStreamPort *
+dup_port (GvcMixerStreamPort *p)
+{
+ GvcMixerStreamPort *m;
+
+ m = g_slice_new (GvcMixerStreamPort);
+
+ *m = *p;
+ m->port = g_strdup (p->port);
+ m->human_port = g_strdup (p->human_port);
+
+ return m;
+}
+
+G_DEFINE_BOXED_TYPE (GvcMixerStreamPort, gvc_mixer_stream_port, dup_port, free_port)
+
static guint32
get_next_stream_serial (void)
{
@@ -946,14 +970,6 @@ gvc_mixer_stream_init (GvcMixerStream *stream)
}
static void
-free_port (GvcMixerStreamPort *p)
-{
- g_free (p->port);
- g_free (p->human_port);
- g_free (p);
-}
-
-static void
gvc_mixer_stream_finalize (GObject *object)
{
GvcMixerStream *mixer_stream;
diff --git a/gvc-mixer-stream.h b/gvc-mixer-stream.h
index 846f2e0..435f933 100644
--- a/gvc-mixer-stream.h
+++ b/gvc-mixer-stream.h
@@ -64,7 +64,8 @@ typedef struct
gboolean available;
} GvcMixerStreamPort;
-GType gvc_mixer_stream_get_type (void);
+GType gvc_mixer_stream_port_get_type (void) G_GNUC_CONST;
+GType gvc_mixer_stream_get_type (void) G_GNUC_CONST;
guint gvc_mixer_stream_get_index (GvcMixerStream *stream);
guint gvc_mixer_stream_get_id (GvcMixerStream *stream);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]