gnome-edu r22 - in trunk/garfunkel: . sound src
- From: brunobol svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-edu r22 - in trunk/garfunkel: . sound src
- Date: Thu, 8 Jan 2009 02:19:14 +0000 (UTC)
Author: brunobol
Date: Thu Jan 8 02:19:14 2009
New Revision: 22
URL: http://svn.gnome.org/viewvc/gnome-edu?rev=22&view=rev
Log:
2009-01-07 Bruno Boaventura <brunobol gnome org>
* configure.ac:
* Makefile.am:
* src/Makefile.am:
* sound/Makefile.am:
* sound/test.ogg:
* src/main.c:
* src/garfunkel.c:
* src/garfunkel-sound.c:
* src/garfunkel-sound.h:
Add GStreamer dependency, sound directory and files.
Add initial support to play sounds with GStreamer.
Added:
trunk/garfunkel/sound/
trunk/garfunkel/sound/Makefile.am
trunk/garfunkel/sound/test.ogg (contents, props changed)
trunk/garfunkel/src/garfunkel-sound.c
trunk/garfunkel/src/garfunkel-sound.h
Modified:
trunk/garfunkel/ChangeLog
trunk/garfunkel/Makefile.am
trunk/garfunkel/configure.ac
trunk/garfunkel/src/Makefile.am
trunk/garfunkel/src/garfunkel.c
trunk/garfunkel/src/main.c
Modified: trunk/garfunkel/Makefile.am
==============================================================================
--- trunk/garfunkel/Makefile.am (original)
+++ trunk/garfunkel/Makefile.am Thu Jan 8 02:19:14 2009
@@ -1,3 +1,3 @@
-SUBDIRS = src pixmaps
+SUBDIRS = src pixmaps sound
EXTRA_DIST = HACKING
CLEANFILES = *~
Modified: trunk/garfunkel/configure.ac
==============================================================================
--- trunk/garfunkel/configure.ac (original)
+++ trunk/garfunkel/configure.ac Thu Jan 8 02:19:14 2009
@@ -14,6 +14,7 @@
gtk+-2.0 >= 2.10
gthread-2.0
librsvg-2.0
+ gstreamer-0.10
])
AC_SUBST(GARFUNKEL_CFLAGS)
AC_SUBST(GARFUNKEL_LIBS)
@@ -25,6 +26,7 @@
pixmaps/Makefile
pixmaps/default/Makefile
pixmaps/gnome-foot/Makefile
+ sound/Makefile
src/Makefile
])
AC_OUTPUT
Added: trunk/garfunkel/sound/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/garfunkel/sound/Makefile.am Thu Jan 8 02:19:14 2009
@@ -0,0 +1,6 @@
+sounddir = $(datadir)/garfunkel/sound
+sound_DATA = \
+ test.ogg
+
+EXTRA_DIST = $(sound_DATA)
+
Added: trunk/garfunkel/sound/test.ogg
==============================================================================
Binary file. No diff available.
Modified: trunk/garfunkel/src/Makefile.am
==============================================================================
--- trunk/garfunkel/src/Makefile.am (original)
+++ trunk/garfunkel/src/Makefile.am Thu Jan 8 02:19:14 2009
@@ -10,6 +10,7 @@
-DDEFAULT_THEME_DIR=\""$(datadir)/garfunkel/pixmaps/default"\" \
-DGNOMEFOOT_THEME_DIR=\""$(datadir)/garfunkel/pixmaps/gnome-foot"\" \
-DDATADIR=\"$(pkgdatadir)\" \
+ -DSOUND_DIR=\""$(datadir)/garfunkel/sound"\" \
-I$(top_srcdir)
LIBS += $(GARFUNKEL_LIBS)
@@ -17,7 +18,9 @@
bin_PROGRAMS = garfunkel
garfunkel_SOURCES = main.c \
garfunkel.c \
- garfunkel.h
+ garfunkel.h \
+ garfunkel-sound.c \
+ garfunkel-sound.h
CLEANFILES = *~
Added: trunk/garfunkel/src/garfunkel-sound.c
==============================================================================
--- (empty file)
+++ trunk/garfunkel/src/garfunkel-sound.c Thu Jan 8 02:19:14 2009
@@ -0,0 +1,97 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+/*
+ * garfunkel-sound.c
+ * This file is part of Garfunkel
+ *
+ * Copyright (C) 2009 - Bruno Boaventura <brunobol gnome org>
+ *
+ * Garfunkel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Garfunkel 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Garfunkel; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+/* This code is based on "libgames-support/games-sound.c" fom Andreas RÃsdal */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include <gst/gst.h>
+
+#include "garfunkel-sound.h"
+
+static gboolean sound_init = FALSE;
+
+static GstElement *pipeline;
+
+static void
+garfunkel_sound_init (void)
+{
+ GError *err = NULL;
+
+ g_assert (g_thread_supported ());
+
+ pipeline = gst_element_factory_make ("playbin", "playbin");
+
+ sound_init = TRUE;
+}
+
+void
+garfunkel_sound_play (const gchar * filename)
+{
+ GError *err = NULL;
+
+ if (!sound_init)
+ garfunkel_sound_init ();
+
+ char *uri;
+
+ gboolean done = FALSE;
+
+ GstBus *bus;
+
+ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+
+ uri = g_strdup_printf ("file:///%s", filename);
+
+ g_object_set (G_OBJECT (pipeline), "uri", uri, NULL);
+
+ g_free (uri);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ do
+ {
+ GstMessage *message;
+
+ message = gst_bus_timed_pop (bus, GST_CLOCK_TIME_NONE);
+
+ switch (GST_MESSAGE_TYPE (message))
+ {
+ case GST_MESSAGE_EOS:
+ done = TRUE;
+ break;
+ default:
+ break;
+ }
+
+ gst_message_unref (message);
+
+ } while (!done);
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+}
+
Added: trunk/garfunkel/src/garfunkel-sound.h
==============================================================================
--- (empty file)
+++ trunk/garfunkel/src/garfunkel-sound.h Thu Jan 8 02:19:14 2009
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+/*
+ * garfunkel-sound.h
+ * This file is part of Garfunkel
+ *
+ * Copyright (C) 2009 - Bruno Boaventura <brunobol gnome org>
+ *
+ * Garfunkel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Garfunkel 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Garfunkel; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+/* This code is based on "libgames-support/games-sound.c" fom Andreas RÃsdal */
+
+#ifndef __GARFUNKEL_SOUND_H__
+#define __GARFUNKEL_SOUND_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void garfunkel_sound_play (const gchar *filename);
+
+G_END_DECLS
+
+#endif /* __GARFUNKEL_SOUND_H__ */
Modified: trunk/garfunkel/src/garfunkel.c
==============================================================================
--- trunk/garfunkel/src/garfunkel.c (original)
+++ trunk/garfunkel/src/garfunkel.c Thu Jan 8 02:19:14 2009
@@ -32,8 +32,9 @@
#include <glib-2.0/glib.h>
#include "garfunkel.h"
+#include "garfunkel-sound.h"
-#define GFK_BLINK_TIME 500000
+#define GFK_BLINK_TIME 300000
#define THEME_FILENAME "garfunkel.svg"
G_DEFINE_TYPE (Garfunkel, garfunkel, GTK_TYPE_DRAWING_AREA);
@@ -62,8 +63,6 @@
static gboolean garfunkel_expose (GtkWidget *widget, GdkEventExpose *event);
static void garfunkel_redraw (Garfunkel *garfunkel);
static void garfunkel_blink (Garfunkel *garfunkel, GarfunkelLights light);
-static gboolean garfunkel_key_press (GtkWidget *widget, GdkEventKey *event);
-static gboolean garfunkel_button_press (GtkWidget *widget, GdkEventButton *event);
static void garfunkel_sequence_increment (Garfunkel *garfunkel);
static void garfunkel_sequence_drop (Garfunkel *garfunkel);
static void garfunkel_sequence_blink (Garfunkel *garfunkel);
@@ -71,6 +70,9 @@
static void garfunkel_blink_once (Garfunkel *garfunkel, GarfunkelLights light);
static void garfunkel_blink_once_thread (gpointer data);
+static gboolean garfunkel_key_press (GtkWidget *widget, GdkEventKey *event);
+static gboolean garfunkel_button_press (GtkWidget *widget, GdkEventButton *event);
+
static void
garfunkel_init (Garfunkel* garfunkel)
@@ -253,6 +255,14 @@
garfunkel_redraw (garfunkel);
+ gchar *filename;
+
+ filename = g_build_filename (SOUND_DIR, "test.ogg", NULL);
+
+ garfunkel_sound_play (filename);
+
+ g_free (filename);
+
g_usleep (GFK_BLINK_TIME);
gp->lights = 0;
Modified: trunk/garfunkel/src/main.c
==============================================================================
--- trunk/garfunkel/src/main.c (original)
+++ trunk/garfunkel/src/main.c Thu Jan 8 02:19:14 2009
@@ -26,6 +26,7 @@
#include "config.h"
#endif
+#include <gst/gst.h>
#include "garfunkel.h"
int
@@ -40,6 +41,8 @@
gtk_set_locale ();
gtk_init (&argc, &argv);
+ gst_init (&argc, &argv);
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]