[gtk-vnc] Introduce a basic impl of audio handler
- From: Daniel P. Berrange <dberrange src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-vnc] Introduce a basic impl of audio handler
- Date: Fri, 9 Dec 2011 17:41:24 +0000 (UTC)
commit 16e9c9778e4610d60fc1620aa4e762b3eb2a4ddd
Author: Daniel P. Berrange <berrange redhat com>
Date: Fri Dec 9 14:50:37 2011 +0000
Introduce a basic impl of audio handler
Introduce a basic implementation of the audio handler which
emits a signal for each method. This enables apps to support
audio playback without needing to create subclasses. It also
isolates subclasses from extensions in the interface
* src/Makefile.am, src/libgvnc_sym.version,
src/vncbaseaudio.c, src/vncbaseaudio.h: Introduce basic
audio handler
src/Makefile.am | 3 +
src/libgvnc_sym.version | 3 +
src/vncbaseaudio.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
src/vncbaseaudio.h | 73 +++++++++++++++++++++++++
4 files changed, 213 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 94df157..0f25863 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -58,6 +58,7 @@ gvnc_include_HEADERS = \
vncaudioformat.h \
vncaudiosample.h \
vncaudio.h \
+ vncbaseaudio.h \
vncframebuffer.h \
vncbaseframebuffer.h \
vnccursor.h \
@@ -74,6 +75,7 @@ libgvnc_1_0_la_SOURCES = \
vncaudioformat.h vncaudioformat.c \
vncaudiosample.h vncaudiosample.c \
vncaudio.h vncaudio.c \
+ vncbaseaudio.h vncbaseaudio.c \
vncframebuffer.h vncframebuffer.c \
vncbaseframebufferblt.h \
vncbaseframebuffer.h vncbaseframebuffer.c \
@@ -295,6 +297,7 @@ GVNC_INTROSPECTION_SRCS = \
$(srcdir)/vncaudioformat.h $(srcdir)/vncaudioformat.c \
$(srcdir)/vncaudiosample.h $(srcdir)/vncaudiosample.c \
$(srcdir)/vncaudio.h $(srcdir)/vncaudio.c \
+ $(srcdir)/vncbaseaudio.h $(srcdir)/vncbaseaudio.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 7554e23..2efcec5 100644
--- a/src/libgvnc_sym.version
+++ b/src/libgvnc_sym.version
@@ -15,6 +15,9 @@
vnc_audio_sample_free;
vnc_audio_sample_get_type;
+ vnc_base_audio_new;
+ vnc_base_audio_get_type;
+
vnc_cursor_get_type;
vnc_cursor_new;
vnc_cursor_get_data;
diff --git a/src/vncbaseaudio.c b/src/vncbaseaudio.c
new file mode 100644
index 0000000..47e81a9
--- /dev/null
+++ b/src/vncbaseaudio.c
@@ -0,0 +1,134 @@
+/*
+ * 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 "vncbaseaudio.h"
+#include "vncutil.h"
+#include "coroutine.h"
+
+#define VNC_BASE_AUDIO_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), VNC_TYPE_BASE_AUDIO, VncBaseAudioPrivate))
+
+struct _VncBaseAudioPrivate {
+ gboolean unused;
+};
+
+
+static void vnc_base_audio_interface_init(gpointer g_iface,
+ gpointer iface_data);
+
+G_DEFINE_TYPE_EXTENDED(VncBaseAudio, vnc_base_audio, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE(VNC_TYPE_AUDIO, vnc_base_audio_interface_init));
+
+
+static void vnc_base_audio_class_init(VncBaseAudioClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_signal_new("vnc-audio-playback-start",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (VncBaseAudioClass, playback_start),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE,
+ 1,
+ VNC_TYPE_AUDIO_FORMAT);
+
+ g_signal_new("vnc-audio-playback-stop",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (VncBaseAudioClass, playback_stop),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_signal_new("vnc-audio-playback-data",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (VncBaseAudioClass, playback_data),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE,
+ 1,
+ VNC_TYPE_AUDIO_SAMPLE);
+
+ g_type_class_add_private(klass, sizeof(VncBaseAudioPrivate));
+}
+
+
+void vnc_base_audio_init(VncBaseAudio *fb)
+{
+ VncBaseAudioPrivate *priv;
+
+ priv = fb->priv = VNC_BASE_AUDIO_GET_PRIVATE(fb);
+
+ memset(priv, 0, sizeof(*priv));
+}
+
+
+VncBaseAudio *vnc_base_audio_new(void)
+{
+ return VNC_BASE_AUDIO(g_object_new(VNC_TYPE_BASE_AUDIO,
+ NULL));
+}
+
+
+static gboolean vnc_base_audio_playback_start(VncAudio *audio,
+ VncAudioFormat *format)
+{
+ g_signal_emit_by_name(audio, "vnc-audio-playback-start", format);
+ return TRUE;
+}
+
+static gboolean vnc_base_audio_playback_stop(VncAudio *audio)
+{
+ g_signal_emit_by_name(audio, "vnc-audio-playback-stop");
+ return TRUE;
+}
+
+static gboolean vnc_base_audio_playback_data(VncAudio *audio,
+ VncAudioSample *sample)
+{
+ g_signal_emit_by_name(audio, "vnc-audio-playback-data", sample);
+ return TRUE;
+}
+
+static void vnc_base_audio_interface_init(gpointer g_iface,
+ gpointer iface_data G_GNUC_UNUSED)
+{
+ VncAudioInterface *iface = g_iface;
+
+ iface->playback_start = vnc_base_audio_playback_start;
+ iface->playback_stop = vnc_base_audio_playback_stop;
+ iface->playback_data = vnc_base_audio_playback_data;
+}
+
+/*
+ * Local variables:
+ * c-indent-level: 8
+ * c-basic-offset: 8
+ * tab-width: 8
+ * End:
+ */
diff --git a/src/vncbaseaudio.h b/src/vncbaseaudio.h
new file mode 100644
index 0000000..1890226
--- /dev/null
+++ b/src/vncbaseaudio.h
@@ -0,0 +1,73 @@
+/*
+ * 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_BASE_AUDIO_H
+#define VNC_BASE_AUDIO_H
+
+#include <glib-object.h>
+
+#include <vncaudio.h>
+
+G_BEGIN_DECLS
+
+#define VNC_TYPE_BASE_AUDIO (vnc_base_audio_get_type ())
+#define VNC_BASE_AUDIO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VNC_TYPE_BASE_AUDIO, VncBaseAudio))
+#define VNC_BASE_AUDIO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VNC_TYPE_BASE_AUDIO, VncBaseAudioClass))
+#define VNC_IS_BASE_AUDIO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VNC_TYPE_BASE_AUDIO))
+#define VNC_IS_BASE_AUDIO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VNC_TYPE_BASE_AUDIO))
+#define VNC_BASE_AUDIO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VNC_TYPE_BASE_AUDIO, VncBaseAudioClass))
+
+
+typedef struct _VncBaseAudio VncBaseAudio;
+typedef struct _VncBaseAudioPrivate VncBaseAudioPrivate;
+typedef struct _VncBaseAudioClass VncBaseAudioClass;
+
+struct _VncBaseAudio
+{
+ GObject parent;
+
+ VncBaseAudioPrivate *priv;
+};
+
+struct _VncBaseAudioClass
+{
+ GObjectClass parent_class;
+
+ gboolean (*playback_start)(VncBaseAudio *audio, VncAudioFormat *format);
+ gboolean (*playback_stop)(VncBaseAudio *audio);
+ gboolean (*playback_data)(VncBaseAudio *audio, VncAudioSample *sample);
+};
+
+
+GType vnc_base_audio_get_type(void) G_GNUC_CONST;
+
+VncBaseAudio *vnc_base_audio_new(void);
+
+G_END_DECLS
+
+#endif /* VNC_BASE_AUDIO_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]