[gtk-vnc] Introduce a basic data type for audio samples



commit e8993575c561559dcad68ca59bbd80fb3ab5250d
Author: Daniel P. Berrange <berrange redhat com>
Date:   Fri Dec 9 14:42:09 2011 +0000

    Introduce a basic data type for audio samples
    
    To avoid having to pass around all the parameters individually,
    introduce a boxed data type for audio samples
    
    * src/Makefile.am, src/libgvnc_sym.version,
      src/vncaudiosample.c, src/vncaudiosample.h: Boxed type for
      audio samples

 src/Makefile.am         |    3 ++
 src/libgvnc_sym.version |    5 +++
 src/vncaudiosample.c    |   79 +++++++++++++++++++++++++++++++++++++++++++++++
 src/vncaudiosample.h    |   55 ++++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a81ddbb..60c2cee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,6 +56,7 @@ gvnc_include_HEADERS = \
 			gvnc.h \
 			vncpixelformat.h \
 			vncaudioformat.h \
+			vncaudiosample.h \
 			vncframebuffer.h \
 			vncbaseframebuffer.h \
 			vnccursor.h \
@@ -70,6 +71,7 @@ libgvnc_1_0_la_SOURCES = \
 			dh.h dh.c \
 			vncpixelformat.h vncpixelformat.c \
 			vncaudioformat.h vncaudioformat.c \
+			vncaudiosample.h vncaudiosample.c \
 			vncframebuffer.h vncframebuffer.c \
 			vncbaseframebufferblt.h \
 			vncbaseframebuffer.h vncbaseframebuffer.c \
@@ -289,6 +291,7 @@ if WITH_GOBJECT_INTROSPECTION
 GVNC_INTROSPECTION_SRCS = \
 			$(srcdir)/vncpixelformat.h \
 			$(srcdir)/vncaudioformat.h $(srcdir)/vncaudioformat.c \
+			$(srcdir)/vncaudiosample.h $(srcdir)/vncaudiosample.c \
 			$(srcdir)/vncframebuffer.h $(srcdir)/vncframebuffer.c \
 			$(srcdir)/vncbaseframebuffer.h $(srcdir)/vncbaseframebuffer.c \
 			$(srcdir)/vnccolormap.h $(srcdir)/vnccolormap.c \
diff --git a/src/libgvnc_sym.version b/src/libgvnc_sym.version
index 2d7c8d0..649ca3a 100644
--- a/src/libgvnc_sym.version
+++ b/src/libgvnc_sym.version
@@ -5,6 +5,11 @@
 	vnc_audio_format_free;
 	vnc_audio_format_get_type;
 
+	vnc_audio_sample_new;
+	vnc_audio_sample_copy;
+	vnc_audio_sample_free;
+	vnc_audio_sample_get_type;
+
 	vnc_cursor_get_type;
 	vnc_cursor_new;
 	vnc_cursor_get_data;
diff --git a/src/vncaudiosample.c b/src/vncaudiosample.c
new file mode 100644
index 0000000..993a8c3
--- /dev/null
+++ b/src/vncaudiosample.c
@@ -0,0 +1,79 @@
+/*
+ * GTK VNC Widget
+ *
+ * Copyright (C) 2010 Daniel P. Berrange <dan berrange com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "vncaudiosample.h"
+
+GType vnc_audio_sample_get_type(void)
+{
+	static GType audio_sample_type = 0;
+
+	if (G_UNLIKELY(audio_sample_type == 0)) {
+		audio_sample_type = g_boxed_type_register_static
+			("VncAudioSample",
+			 (GBoxedCopyFunc)vnc_audio_sample_copy,
+			 (GBoxedFreeFunc)vnc_audio_sample_free);
+	}
+
+	return audio_sample_type;
+}
+
+
+VncAudioSample *vnc_audio_sample_new(guint32 capacity)
+{
+	VncAudioSample *sample;
+
+	sample = g_slice_new0(VncAudioSample);
+	sample->length = 0;
+	sample->capacity = capacity;
+	sample->data = g_new0(guint8, capacity);
+
+	return sample;
+}
+
+
+VncAudioSample *vnc_audio_sample_copy(VncAudioSample *srcSample)
+{
+	VncAudioSample *sample;
+
+	sample = g_slice_dup(VncAudioSample, srcSample);
+	sample->data = g_new0(guint8, srcSample->capacity);
+	memcpy(sample->data, srcSample->data, srcSample->length);
+
+	return sample;
+}
+
+
+void vnc_audio_sample_free(VncAudioSample *sample)
+{
+        g_free(sample->data);
+	g_slice_free(VncAudioSample, sample);
+}
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */
diff --git a/src/vncaudiosample.h b/src/vncaudiosample.h
new file mode 100644
index 0000000..ad68053
--- /dev/null
+++ b/src/vncaudiosample.h
@@ -0,0 +1,55 @@
+/*
+ * GTK VNC Widget
+ *
+ * Copyright (C) 2010 Daniel P. Berrange <dan berrange com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef VNC_AUDIO_SAMPLE_H
+#define VNC_AUDIO_SAMPLE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define VNC_TYPE_AUDIO_SAMPLE            (vnc_audio_sample_get_type ())
+
+typedef struct _VncAudioSample VncAudioSample;
+
+struct _VncAudioSample {
+	guint8 *data;
+	guint32 length;
+	guint32 capacity;
+};
+
+GType vnc_audio_sample_get_type(void);
+
+VncAudioSample *vnc_audio_sample_new(guint32 capacity);
+VncAudioSample *vnc_audio_sample_copy(VncAudioSample *sample);
+void vnc_audio_sample_free(VncAudioSample *sample);
+
+G_END_DECLS
+
+#endif /* VNC_AUDIO_SAMPLE_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]