[monkey-bubble: 612/753] New files. This is an API rewrite which I did in my local tree, but it's



commit 8962a0eb73d2c44f07e0920ff1e1aebf20aaa8f4
Author: Martin Baulig <baulig suse de>
Date:   Thu Aug 9 21:03:54 2001 +0000

    New files. This is an API rewrite which I did in my local tree, but it's
    
    2001-08-09  Martin Baulig  <baulig suse de>
    
    	* gnome-sound-driver.[ch]: New files.
    	* gnome-sound.c, gnome-sound-csl.c: This is an API rewrite
    	which I did in my local tree, but it's not finished yet and
    	shouldn't be considered as a good API - just wanted to commit
    	this before ..... (see the next ChangeLog entry).

 libgnome/ChangeLog            |    8 +
 libgnome/gnome-sound-csl.c    |  236 +++++++++++++++++++++++++---------
 libgnome/gnome-sound-driver.c |  229 +++++++++++++++++++++++++++++++++
 libgnome/gnome-sound-driver.h |  195 ++++++++++++++++++++++++++++
 libgnome/gnome-sound.c        |  286 +++++++++++++++++------------------------
 libgnome/gnome-sound.h        |  123 ++----------------
 libgnome/test-sound.c         |   27 ++--
 7 files changed, 749 insertions(+), 355 deletions(-)
---
diff --git a/libgnome/ChangeLog b/libgnome/ChangeLog
index 5d75a82..d238e1a 100644
--- a/libgnome/ChangeLog
+++ b/libgnome/ChangeLog
@@ -1,3 +1,11 @@
+2001-08-09  Martin Baulig  <baulig suse de>
+
+	* gnome-sound-driver.[ch]: New files.
+	* gnome-sound.c, gnome-sound-csl.c: This is an API rewrite
+	which I did in my local tree, but it's not finished yet and
+	shouldn't be considered as a good API - just wanted to commit
+	this before ..... (see the next ChangeLog entry).
+
 2001-08-04  Martin Baulig  <baulig suse de>
 
 	* gnome-sound.h (gnome_sound_sample_new_from_file):
diff --git a/libgnome/gnome-sound-csl.c b/libgnome/gnome-sound-csl.c
index e9f49ec..fe93245 100644
--- a/libgnome/gnome-sound-csl.c
+++ b/libgnome/gnome-sound-csl.c
@@ -35,23 +35,90 @@
 #include <csl/csl.h>
 #include <csl/cslsample.h>
 
+typedef struct _GnomeSoundDriverCSL GnomeSoundDriverCSL;
+
+struct _GnomeSoundDriverCSL {
+    GnomeSoundDriver driver;
+
+    GPtrArray *active_samples;
+    CslDriver *csl_driver;
+};
+
 struct _GnomeSoundSample {
     CslSample *sample;
 };
 
-static GPtrArray *active_samples = NULL;
-static CslDriver *gnome_sound_csl_driver = NULL;
+GType type_csl_driver = 0;
+
+static void csl_class_init (GnomeSoundDriverClass *klass);
+static void csl_init (GnomeSoundDriverCSL *driver);
+
+static void
+csl_register_type (GTypeModule *module)
+{
+    static const GTypeInfo object_info = {
+	sizeof (GnomeSoundDriverClass),
+	(GBaseInitFunc) NULL,
+	(GBaseFinalizeFunc) NULL,
+	(GClassInitFunc) csl_class_init,
+	NULL,           /* class_finalize */
+	NULL,           /* class_data */
+	sizeof (GnomeSoundDriverCSL),
+	0,
+	(GInstanceInitFunc) csl_init,
+    };
+
+    type_csl_driver =  g_type_module_register_type
+	(module, GNOME_TYPE_SOUND_DRIVER, "GnomeSoundDriverCSL",
+	 &object_info, 0);
+}
+
+#define GNOME_TYPE_SOUND_DRIVER_CSL              (type_csl_driver)
+#define GNOME_SOUND_DRIVER_CSL(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_SOUND_DRIVER_CSL, GnomeSoundDriverCSL))
+#define GNOME_SOUND_DRIVER_CSL_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_SOUND_DRIVER_CSL, GnomeSoundDriverClass))
+#define GNOME_IS_SOUND_DRIVER_CSL(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_SOUND_DRIVER_CSL))
+#define GNOME_IS_SOUND_DRIVER_CSL_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_SOUND_DRIVER_CSL))
+#define GNOME_SOUND_DRIVER_CSL_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_SOUND_DRIVER_CSL, GnomeSoundDriverClass))
+
+
+static gboolean
+gnome_sound_csl_init (GnomeSoundDriver *driver, const gchar *backend_args, GError **error)
+{
+    GnomeSoundDriverCSL *csl = GNOME_SOUND_DRIVER_CSL (driver);
+    const gchar *name = "arts";
+    CslErrorType err;
+
+    if (csl->csl_driver) {
+	g_warning ("Sound system already initialized!");
+	return TRUE;
+    }
+
+    err = csl_driver_init_mutex (name,
+				 CSL_DRIVER_CAP_PCM|CSL_DRIVER_CAP_SAMPLE,
+				 NULL, &csl->csl_driver);
+
+    if (err) {
+	g_warning ("Failed to initialize %s sound driver: %s (%d)",
+		   name ? name : "auto-selected", csl_strerror (err), err);
+	return FALSE;
+    }
+
+    csl->active_samples = g_ptr_array_new ();
+    return TRUE;
+}
 
 static void
-gnome_sound_csl_play_file (const char *filename, GError **error)
+gnome_sound_csl_play_file (GnomeSoundDriver *driver,
+			   const char *filename, GError **error)
 {
+    GnomeSoundDriverCSL *csl = GNOME_SOUND_DRIVER_CSL (driver);
     CslErrorType err;
     CslSample *sample;
 
-    if (!gnome_sound_csl_driver)
+    if (!csl->csl_driver)
 	return;
 
-    err = csl_sample_new_from_file (gnome_sound_csl_driver, filename,
+    err = csl_sample_new_from_file (csl->csl_driver, filename,
 				    "gnome_sound_csl_play", NULL,
 				    &sample);
     if (err) {
@@ -65,18 +132,20 @@ gnome_sound_csl_play_file (const char *filename, GError **error)
 }
 
 static GnomeSoundSample *
-gnome_sound_csl_sample_new_from_file (const char *name, const char *filename,
+gnome_sound_csl_sample_new_from_file (GnomeSoundDriver *driver,
+				      const char *name, const char *filename,
 				      GError **error)
 {
+    GnomeSoundDriverCSL *csl = GNOME_SOUND_DRIVER_CSL (driver);
+    GnomeSoundSample *retval;
     CslErrorType err;
     CslSample *sample;
-    GnomeSoundSample *retval;
     int fd;
 
-    if (!gnome_sound_csl_driver)
+    if (!csl->csl_driver)
 	return NULL;
 
-    err = csl_sample_new (gnome_sound_csl_driver, name,
+    err = csl_sample_new (csl->csl_driver, name,
 			  "gnome_sound_csl_sample_new", NULL,
 			  &sample);
     if (err) {
@@ -111,22 +180,24 @@ gnome_sound_csl_sample_new_from_file (const char *name, const char *filename,
     retval = g_new0 (GnomeSoundSample, 1);
     retval->sample = sample;
 
-    g_ptr_array_add (active_samples, retval);
+    g_ptr_array_add (csl->active_samples, retval);
 
     return retval;
 }
 
 static GnomeSoundSample *
-gnome_sound_csl_sample_new_from_cache (const char *name, GError **error)
+gnome_sound_csl_sample_new_from_cache (GnomeSoundDriver *driver,
+				       const char *name, GError **error)
 {
+    GnomeSoundDriverCSL *csl = GNOME_SOUND_DRIVER_CSL (driver);
+    GnomeSoundSample *retval;
     CslErrorType err;
     CslSample *sample;
-    GnomeSoundSample *retval;
 
-    if (!gnome_sound_csl_driver)
+    if (!csl->csl_driver)
 	return NULL;
 
-    err = csl_sample_new_from_cache (gnome_sound_csl_driver, name,
+    err = csl_sample_new_from_cache (csl->csl_driver, name,
 				    "gnome_sound_csl_sample_new", NULL,
 				    &sample);
     if (err) {
@@ -138,22 +209,24 @@ gnome_sound_csl_sample_new_from_cache (const char *name, GError **error)
     retval = g_new0 (GnomeSoundSample, 1);
     retval->sample = sample;
 
-    g_ptr_array_add (active_samples, retval);
+    g_ptr_array_add (csl->active_samples, retval);
 
     return retval;
 }
 
 static GnomeSoundSample *
-gnome_sound_csl_sample_new (const char *sample_name, GError **error)
+gnome_sound_csl_sample_new (GnomeSoundDriver *driver,
+			    const char *sample_name, GError **error)
 {
+    GnomeSoundDriverCSL *csl = GNOME_SOUND_DRIVER_CSL (driver);
+    GnomeSoundSample *retval;
     CslErrorType err;
     CslSample *sample;
-    GnomeSoundSample *retval;
 
-    if (!gnome_sound_csl_driver)
+    if (!csl->csl_driver)
 	return NULL;
 
-    err = csl_sample_new (gnome_sound_csl_driver, sample_name,
+    err = csl_sample_new (csl->csl_driver, sample_name,
 			  "gnome_sound_csl_play", NULL,
 			  &sample);
     if (err) {
@@ -165,25 +238,28 @@ gnome_sound_csl_sample_new (const char *sample_name, GError **error)
     retval = g_new0 (GnomeSoundSample, 1);
     retval->sample = sample;
 
-    g_ptr_array_add (active_samples, retval);
+    g_ptr_array_add (csl->active_samples, retval);
 
     return retval;
 }
 
 static void
-gnome_sound_csl_cache_add_sample (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_cache_add_sample (GnomeSoundDriver *driver,
+				  GnomeSoundSample *gs, GError **error)
 {
     csl_sample_cache_add (gs->sample);
 }
 
 static void
-gnome_sound_csl_cache_remove_sample (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_cache_remove_sample (GnomeSoundDriver *driver,
+				     GnomeSoundSample *gs, GError **error)
 {
     csl_sample_cache_remove (gs->sample);
 }
 
 static int
-gnome_sound_csl_sample_write (GnomeSoundSample *gs,
+gnome_sound_csl_sample_write (GnomeSoundDriver *driver,
+			      GnomeSoundSample *gs,
 			      guint n_bytes, gpointer bytes,
 			      GError **error)
 {
@@ -191,49 +267,113 @@ gnome_sound_csl_sample_write (GnomeSoundSample *gs,
 }
 
 static void
-gnome_sound_csl_sample_write_done (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_sample_write_done (GnomeSoundDriver *driver,
+				   GnomeSoundSample *gs, GError **error)
 {
     csl_sample_write_done (gs->sample);
 }
 
 static void
-gnome_sound_csl_sample_play (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_sample_play (GnomeSoundDriver *driver,
+			     GnomeSoundSample *gs, GError **error)
 {
     csl_sample_play (gs->sample);
 }
 
 static gboolean
-gnome_sound_csl_sample_is_playing (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_sample_is_playing (GnomeSoundDriver *driver,
+				   GnomeSoundSample *gs, GError **error)
 {
     return csl_sample_is_playing (gs->sample);
 }
 
 static void
-gnome_sound_csl_sample_stop (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_sample_stop (GnomeSoundDriver *driver,
+			     GnomeSoundSample *gs, GError **error)
 {
     csl_sample_stop (gs->sample);
 }
 
 static void
-gnome_sound_csl_sample_wait_done (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_sample_wait_done (GnomeSoundDriver *driver,
+				  GnomeSoundSample *gs, GError **error)
 {
     csl_sample_wait_done (gs->sample);
 }
 
 static void
-gnome_sound_csl_sample_release (GnomeSoundSample *gs, GError **error)
+gnome_sound_csl_sample_release (GnomeSoundDriver *driver,
+				GnomeSoundSample *gs, GError **error)
 {
+    GnomeSoundDriverCSL *csl = GNOME_SOUND_DRIVER_CSL (driver);
+
     csl_sample_release (gs->sample);
-    g_ptr_array_remove (active_samples, gs);
+    g_ptr_array_remove (csl->active_samples, gs);
     g_free (gs);
 }
 
-static gboolean
-gnome_sound_csl_init (const gchar *backend_args, GError **error)
+static void
+gnome_sound_csl_shutdown (GnomeSoundDriver *driver)
 {
+    GnomeSoundDriverCSL *csl = GNOME_SOUND_DRIVER_CSL (driver);
+
+    while (csl->active_samples->len) {
+	GnomeSoundSample *gs = g_ptr_array_index (csl->active_samples, 0);
+
+	    gnome_sound_csl_sample_stop (driver, gs, NULL);
+	    gnome_sound_csl_sample_release (driver, gs, NULL);
+    }
+
+    csl_driver_shutdown (csl->csl_driver);
+    csl->csl_driver = NULL;
+}
+
+static void
+csl_class_init (GnomeSoundDriverClass *klass)
+{
+    klass->init = gnome_sound_csl_init;
+    klass->shutdown = gnome_sound_csl_shutdown;
+
+    klass->play_file = gnome_sound_csl_play_file;
+    klass->sample_new = gnome_sound_csl_sample_new;
+    klass->sample_write = gnome_sound_csl_sample_write;
+    klass->sample_write_done = gnome_sound_csl_sample_write_done;
+    klass->cache_add_sample = gnome_sound_csl_cache_add_sample;
+    klass->cache_remove_sample = gnome_sound_csl_cache_remove_sample;
+    klass->sample_new_from_file = gnome_sound_csl_sample_new_from_file;
+    klass->sample_new_from_cache = gnome_sound_csl_sample_new_from_cache;
+    klass->sample_play = gnome_sound_csl_sample_play;
+    klass->sample_is_playing = gnome_sound_csl_sample_is_playing;
+    klass->sample_stop = gnome_sound_csl_sample_stop;
+    klass->sample_wait_done = gnome_sound_csl_sample_wait_done;
+    klass->sample_release = gnome_sound_csl_sample_release;
+}
+
+static void
+csl_init (GnomeSoundDriverCSL *driver)
+{
+}
+
+static GnomeSoundDriver *
+gnome_sound_module_csl_init (GTypeModule *module, const gchar *backend_args, GError **error)
+{
+    GnomeSoundDriver *driver;
+#if 0
     CslErrorType err;
     const gchar *name = "arts";
+#endif
+
+    csl_register_type (module);
+
+    driver = g_object_new (type_csl_driver, NULL);
+    if (!GNOME_SOUND_DRIVER_GET_CLASS (driver)->init (driver, backend_args, error)) {
+	g_object_unref (G_OBJECT (driver));
+	return NULL;
+    }
+
+    return driver;
 
+#if 0
     if (gnome_sound_csl_driver) {
 	g_warning ("Sound system already initialized!");
 	return TRUE;
@@ -251,41 +391,17 @@ gnome_sound_csl_init (const gchar *backend_args, GError **error)
 
     active_samples = g_ptr_array_new ();
     return TRUE;
+#endif
 }
 
 static void
-gnome_sound_csl_shutdown (GError **error)
+gnome_sound_module_csl_shutdown (void)
 {
-    if (gnome_sound_csl_driver) {
-
-	while (active_samples->len) {
-	    GnomeSoundSample *gs = g_ptr_array_index (active_samples, 0);
-
-	    gnome_sound_csl_sample_stop (gs, NULL);
-	    gnome_sound_csl_sample_release (gs, NULL);
-	}
-
-	csl_driver_shutdown (gnome_sound_csl_driver);
-	gnome_sound_csl_driver = NULL;
-    }
 }
 
 GnomeSoundPlugin gnome_sound_plugin = {
     GNOME_PLUGIN_SERIAL,
     "gnome-sound-csl",
-    gnome_sound_csl_init,
-    gnome_sound_csl_shutdown,
-    gnome_sound_csl_play_file,
-    gnome_sound_csl_sample_new,
-    gnome_sound_csl_sample_write,
-    gnome_sound_csl_sample_write_done,
-    gnome_sound_csl_cache_add_sample,
-    gnome_sound_csl_cache_remove_sample,
-    gnome_sound_csl_sample_new_from_file,
-    gnome_sound_csl_sample_new_from_cache,
-    gnome_sound_csl_sample_play,
-    gnome_sound_csl_sample_is_playing,
-    gnome_sound_csl_sample_stop,
-    gnome_sound_csl_sample_wait_done,
-    gnome_sound_csl_sample_release
+    gnome_sound_module_csl_init,
+    gnome_sound_module_csl_shutdown
 };
diff --git a/libgnome/gnome-sound-driver.c b/libgnome/gnome-sound-driver.c
new file mode 100644
index 0000000..a5c7908
--- /dev/null
+++ b/libgnome/gnome-sound-driver.c
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 1997-1998 Stuart Parmenter and Elliot Lee
+ * All rights reserved.
+ *
+ * This file is part of the Gnome Library.
+ *
+ * The Gnome Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Gnome 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+/*
+  @NOTATION@
+ */
+
+#include "config.h"
+
+#include <libgnome/gnome-sound-driver.h>
+#include <libgnome/gnome-i18n.h>
+
+#include <gmodule.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+static GObjectClass *parent_class = NULL;
+
+static void
+gnome_sound_driver_finalize (GObject *object)
+{
+    parent_class->finalize (object);
+}
+
+static void
+gnome_sound_driver_class_init (GnomeSoundDriverClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+    parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+  
+    gobject_class->finalize = gnome_sound_driver_finalize;
+}
+
+GType
+gnome_sound_driver_get_type (void)
+{
+    static GType sound_driver_type = 0;
+
+    if (!sound_driver_type) {
+	static const GTypeInfo sound_driver_info = {
+	    sizeof (GnomeSoundDriverClass),
+	    NULL,           /* base_init */
+	    NULL,           /* base_finalize */
+	    (GClassInitFunc) gnome_sound_driver_class_init,
+	    NULL,           /* class_finalize */
+	    NULL,           /* class_data */
+	    sizeof (GnomeSoundDriver),
+	    0,              /* n_preallocs */
+	    NULL,           /* instance_init */
+	};
+
+	sound_driver_type = g_type_register_static (G_TYPE_OBJECT, "GnomeSoundDriver",
+						    &sound_driver_info, 0);
+    }
+  
+    return sound_driver_type;
+}
+
+static void
+_gnome_sound_error_notimplemented (GError **error)
+{
+    g_set_error (error, GNOME_SOUND_ERROR,
+		 GNOME_SOUND_ERROR_NOT_IMPLEMENTED,
+		 _("Function not implemented"));
+}
+
+void 
+gnome_sound_driver_play (GnomeSoundDriver *driver, const char *filename, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->play_file)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->play_file (driver, filename, error);
+    else
+	_gnome_sound_error_notimplemented (error);
+}
+
+void 
+gnome_sound_driver_cache_add_sample (GnomeSoundDriver *driver,
+				     GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->cache_add_sample)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->cache_add_sample (driver, gs, error);
+    else
+	_gnome_sound_error_notimplemented (error);
+}
+
+void 
+gnome_sound_driver_cache_remove_sample (GnomeSoundDriver *driver,
+					GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->cache_remove_sample)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->cache_remove_sample (driver, gs, error);
+    else
+	_gnome_sound_error_notimplemented (error);
+}
+
+GnomeSoundSample *
+gnome_sound_driver_sample_new_from_file (GnomeSoundDriver *driver,
+					 const gchar *name, const char *filename,
+					 GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_new_from_file)
+	return GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_new_from_file (driver, name,
+									    filename, error);
+    else {
+	_gnome_sound_error_notimplemented (error);
+	return NULL;
+    }
+}
+
+GnomeSoundSample *
+gnome_sound_driver_sample_new_from_cache (GnomeSoundDriver *driver,
+					  const char *name, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_new_from_cache)
+	return GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_new_from_cache (driver, name, error);
+    else {
+	_gnome_sound_error_notimplemented (error);
+	return NULL;
+    }
+}
+
+GnomeSoundSample *
+gnome_sound_driver_sample_new (GnomeSoundDriver *driver,
+			       const char *sample_name, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_new)
+	return GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_new (driver, sample_name, error);
+    else {
+	_gnome_sound_error_notimplemented (error);
+	return NULL;
+    }
+}
+
+int
+gnome_sound_driver_sample_write (GnomeSoundDriver *driver, GnomeSoundSample *gs,
+				 guint n_bytes, gpointer bytes,
+				 GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_write)
+	return GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_write (driver, gs, n_bytes, bytes, error);
+    else {
+	_gnome_sound_error_notimplemented (error);
+	return -1;
+    }
+}
+
+void
+gnome_sound_driver_sample_write_done (GnomeSoundDriver *driver,
+				      GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_write_done)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_write_done (driver, gs, error);
+    else
+    _gnome_sound_error_notimplemented (error);
+}
+
+void
+gnome_sound_driver_sample_play (GnomeSoundDriver *driver,
+				GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_play)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_play (driver, gs, error);
+    else
+	_gnome_sound_error_notimplemented (error);
+}
+
+gboolean
+gnome_sound_driver_sample_is_playing (GnomeSoundDriver *driver,
+				      GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_is_playing)
+	return GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_is_playing (driver, gs, error);
+    else {
+	_gnome_sound_error_notimplemented (error);
+	return FALSE;
+    }
+}
+
+void
+gnome_sound_driver_sample_stop (GnomeSoundDriver *driver,
+				GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_stop)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_stop (driver, gs, error);
+    else
+	_gnome_sound_error_notimplemented (error);
+}
+
+void
+gnome_sound_driver_sample_wait_done (GnomeSoundDriver *driver,
+				     GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_wait_done)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_wait_done (driver, gs, error);
+    else
+	_gnome_sound_error_notimplemented (error);
+}
+
+void
+gnome_sound_driver_sample_release (GnomeSoundDriver *driver,
+				   GnomeSoundSample *gs, GError **error)
+{
+    if (GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_release)
+	GNOME_SOUND_DRIVER_GET_CLASS (driver)->sample_release (driver, gs, error);
+    else
+	_gnome_sound_error_notimplemented (error);
+}
diff --git a/libgnome/gnome-sound-driver.h b/libgnome/gnome-sound-driver.h
new file mode 100644
index 0000000..d481708
--- /dev/null
+++ b/libgnome/gnome-sound-driver.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 1997-1998 Stuart Parmenter and Elliot Lee
+ * All rights reserved.
+ *
+ * This file is part of the Gnome Library.
+ *
+ * The Gnome Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Gnome 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+/*
+  @NOTATION@
+ */
+
+#ifndef __GNOME_SOUND_DRIVER_H__
+#define __GNOME_SOUND_DRIVER_H__ 1
+
+#include <glib/gmacros.h>
+#include <glib/gerror.h>
+#include <gobject/gobject.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GnomeSoundDriver             GnomeSoundDriver;
+typedef struct _GnomeSoundDriverClass        GnomeSoundDriverClass;
+
+typedef struct _GnomeSoundSample             GnomeSoundSample;
+
+#define GNOME_TYPE_SOUND_DRIVER              (gnome_sound_driver_get_type ())
+#define GNOME_SOUND_DRIVER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_SOUND_DRIVER, GnomeSoundDriver))
+#define GNOME_SOUND_DRIVER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_SOUND_DRIVER, GnomeSoundDriverClass))
+#define GNOME_IS_SOUND_DRIVER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_SOUND_DRIVER))
+#define GNOME_IS_SOUND_DRIVER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_SOUND_DRIVER))
+#define GNOME_SOUND_DRIVER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_SOUND_DRIVER, GnomeSoundDriverClass))
+
+struct _GnomeSoundDriver {
+    GObject object;
+};
+
+struct _GnomeSoundDriverClass {
+    GObjectClass parent_class;
+
+    gboolean (*init) (GnomeSoundDriver *driver,
+		      const gchar *backend_args,
+		      GError **error);
+
+    void (*shutdown) (GnomeSoundDriver *driver);
+
+    void (*play_file) (GnomeSoundDriver *driver,
+		       const gchar *filename,
+		       GError **error);
+
+    GnomeSoundSample * (*sample_new) (GnomeSoundDriver *driver,
+				      const gchar *name,
+				      GError **error);
+    int (*sample_write) (GnomeSoundDriver *driver,
+			 GnomeSoundSample *gs,
+			 guint n_bytes, gpointer bytes,
+			 GError **error);
+    void (*sample_write_done) (GnomeSoundDriver *driver,
+			       GnomeSoundSample *gs,
+			       GError **error);
+
+    void (*cache_add_sample) (GnomeSoundDriver *driver,
+			      GnomeSoundSample *sample,
+			      GError **error);
+    void (*cache_remove_sample) (GnomeSoundDriver *driver,
+				 GnomeSoundSample *sample,
+				 GError **error);
+
+    GnomeSoundSample * (*sample_new_from_file) (GnomeSoundDriver *driver,
+						const gchar *name,
+						const gchar *filename,
+						GError **error);
+    GnomeSoundSample * (*sample_new_from_cache) (GnomeSoundDriver *driver,
+						 const gchar *name,
+						 GError **error);
+
+    void (*sample_play) (GnomeSoundDriver *driver,
+			 GnomeSoundSample *gs,
+			 GError **error);
+    gboolean (*sample_is_playing) (GnomeSoundDriver *driver,
+				   GnomeSoundSample *gs,
+				   GError **error);
+    void (*sample_stop) (GnomeSoundDriver *driver,
+			 GnomeSoundSample *gs,
+			 GError **error);
+    void (*sample_wait_done) (GnomeSoundDriver *driver,
+			      GnomeSoundSample *gs,
+			      GError **error);
+    void (*sample_release) (GnomeSoundDriver *driver,
+			    GnomeSoundSample *gs,
+			    GError **error);
+};
+
+typedef enum
+{
+    /* no sound driver */
+    GNOME_SOUND_ERROR_NODRIVER,
+    /* not implemented */
+    GNOME_SOUND_ERROR_NOT_IMPLEMENTED,
+    /* device busy */
+    GNOME_SOUND_ERROR_DEVICE_BUSY,
+    /* I/O eror */
+    GNOME_SOUND_ERROR_IO,
+    /* Insufficient permissions */
+    GNOME_SOUND_ERROR_PERMS,
+    /* misc error */
+    GNOME_SOUND_ERROR_MISC
+} GnomeSoundError;
+
+GType gnome_sound_driver_get_type (void) G_GNUC_CONST;
+
+#define GNOME_SOUND_ERROR gnome_sound_error_quark ()
+GQuark gnome_sound_error_quark (void) G_GNUC_CONST;
+
+void
+gnome_sound_driver_play (GnomeSoundDriver *driver,
+			 const char *filename,
+			 GError **error);
+
+void
+gnome_sound_driver_cache_add_sample (GnomeSoundDriver *driver,
+				     GnomeSoundSample *sample, GError **error);
+
+void
+gnome_sound_driver_cache_remove_sample (GnomeSoundDriver *driver,
+					GnomeSoundSample *sample, GError **error);
+
+GnomeSoundSample *
+gnome_sound_driver_sample_new_from_file (GnomeSoundDriver *driver,
+					 const char *name,
+					 const char *filename,
+					 GError **error);
+
+GnomeSoundSample *
+gnome_sound_driver_sample_new_from_cache (GnomeSoundDriver *driver,
+					  const char *name,
+					  GError **error);
+
+GnomeSoundSample *
+gnome_sound_driver_sample_new (GnomeSoundDriver *driver,
+			       const char *sample_name,
+			       GError **error);
+
+int
+gnome_sound_driver_sample_write (GnomeSoundDriver *driver,
+				 GnomeSoundSample *gs,
+				 guint n_bytes, gpointer bytes,
+				 GError **error);
+
+void
+gnome_sound_driver_sample_write_done (GnomeSoundDriver *driver,
+				      GnomeSoundSample *gs,
+				      GError **error);
+
+void
+gnome_sound_driver_sample_play (GnomeSoundDriver *driver,
+				GnomeSoundSample *gs,
+				GError **error);
+
+gboolean
+gnome_sound_driver_sample_is_playing (GnomeSoundDriver *driver,
+				      GnomeSoundSample *gs,
+				      GError **error);
+
+void
+gnome_sound_driver_sample_stop (GnomeSoundDriver *driver,
+				GnomeSoundSample *gs,
+				GError **error);
+
+void
+gnome_sound_driver_sample_wait_done (GnomeSoundDriver *driver,
+				     GnomeSoundSample *gs,
+				     GError **error);
+
+void
+gnome_sound_driver_sample_release (GnomeSoundDriver *driver,
+				   GnomeSoundSample *gs,
+				   GError **error);
+
+G_END_DECLS
+
+#endif /* __GNOME_SOUND_DRIVER_H__ */
diff --git a/libgnome/gnome-sound.c b/libgnome/gnome-sound.c
index 847920f..be0753d 100644
--- a/libgnome/gnome-sound.c
+++ b/libgnome/gnome-sound.c
@@ -35,145 +35,127 @@
 #include <unistd.h>
 #include <time.h>
 
-static const GnomeSoundPlugin *sound_plugin = NULL;
-static GModule *sound_plugin_module = NULL;
+typedef struct _GnomeSoundModule            GnomeSoundModule;
+typedef struct _GnomeSoundModuleClass       GnomeSoundModuleClass;
 
-static void
-_gnome_sound_error_nodriver (GError **error)
-{
-    g_set_error (error, GNOME_SOUND_ERROR,
-		 GNOME_SOUND_ERROR_NODRIVER,
-		 _("No sound driver loaded"));
-}
+#define GNOME_TYPE_SOUND_MODULE             (gnome_sound_module_get_type ())
+#define GNOME_SOUND_MODULE(sound_module)    (G_TYPE_CHECK_INSTANCE_CAST ((sound_module), GNOME_TYPE_SOUND_MODULE, GnomeSoundModule))
+#define GNOME_IS_SOUND_MODULE(sound_module) (G_TYPE_CHECK_INSTANCE_TYPE ((sound_module), GNOME_TYPE_SOUND_MODULE))
 
-void 
-gnome_sound_play (const char *filename, GError **error)
+struct _GnomeSoundModule
 {
-    if (sound_plugin)
-	sound_plugin->play_file (filename, error);
-    else
-	_gnome_sound_error_nodriver (error);
-}
+    GTypeModule parent_instance;
+    GModule *library;
+    gchar *path;
 
-void 
-gnome_sound_cache_add_sample (GnomeSoundSample *gs, GError **error)
-{
-    if (sound_plugin)
-	sound_plugin->cache_add_sample (gs, error);
-    else
-	_gnome_sound_error_nodriver (error);
-}
+    GnomeSoundPlugin *plugin;
+};
 
-void 
-gnome_sound_cache_remove_sample (GnomeSoundSample *gs, GError **error)
+struct _GnomeSoundModuleClass 
 {
-    if (sound_plugin)
-	sound_plugin->cache_remove_sample (gs, error);
-    else
-	_gnome_sound_error_nodriver (error);
-}
+    GTypeModuleClass parent_class;
+};
 
-GnomeSoundSample *
-gnome_sound_sample_new_from_file (const gchar *name, const char *filename,
-				  GError **error)
-{
-    if (sound_plugin)
-	return sound_plugin->sample_new_from_file (name, filename, error);
-    else {
-	_gnome_sound_error_nodriver (error);
-	return NULL;
-    }
-}
+static GObjectClass *module_parent_class = NULL;
+static GnomeSoundModule *sound_module = NULL;
+static GnomeSoundDriver *sound_driver = NULL;
 
-GnomeSoundSample *
-gnome_sound_sample_new_from_cache (const char *name, GError **error)
-{
-    if (sound_plugin)
-	return sound_plugin->sample_new_from_cache (name, error);
-    else {
-	_gnome_sound_error_nodriver (error);
-	return NULL;
-    }
-}
+GType gnome_sound_module_get_type (void);
 
-GnomeSoundSample *
-gnome_sound_sample_new (const char *sample_name, GError **error)
+static gboolean
+gnome_sound_module_load (GTypeModule *module)
 {
-    if (sound_plugin)
-	return sound_plugin->sample_new (sample_name, error);
-    else {
-	_gnome_sound_error_nodriver (error);
-	return NULL;
+    GnomeSoundModule *sound_module = GNOME_SOUND_MODULE (module);
+  
+    sound_module->library = g_module_open (sound_module->path, 0);
+    if (!sound_module->library) {
+	g_warning (g_module_error ());
+	return FALSE;
     }
-}
-
-int
-gnome_sound_sample_write (GnomeSoundSample *gs,
-			  guint n_bytes, gpointer bytes,
-			  GError **error)
-{
-    if (sound_plugin)
-	return sound_plugin->sample_write (gs, n_bytes, bytes, error);
-    else {
-	_gnome_sound_error_nodriver (error);
-	return -1;
+  
+    /* extract symbols from the lib */
+    if (!g_module_symbol (sound_module->library, "gnome_sound_plugin",
+			  (gpointer *)&sound_module->plugin)) {
+	g_warning (g_module_error ());
+	g_module_close (sound_module->library);
+      
+	return FALSE;
     }
-}
 
-void
-gnome_sound_sample_write_done (GnomeSoundSample *gs, GError **error)
-{
-    if (sound_plugin)
-	sound_plugin->sample_write_done (gs, error);
-    else
-    _gnome_sound_error_nodriver (error);
+    return TRUE;
 }
 
-void
-gnome_sound_sample_play (GnomeSoundSample *gs, GError **error)
+static void
+gnome_sound_module_unload (GTypeModule *module)
 {
-    if (sound_plugin)
-	sound_plugin->sample_play (gs, error);
-    else
-	_gnome_sound_error_nodriver (error);
+    GnomeSoundModule *sound_module = GNOME_SOUND_MODULE (module);
+
+#if 0
+    sound_module->exit();
+#endif
+
+    g_module_close (sound_module->library);
+    sound_module->library = NULL;
 }
 
-gboolean
-gnome_sound_sample_is_playing (GnomeSoundSample *gs, GError **error)
+/* This only will ever be called if an error occurs during
+ * initialization
+ */
+static void
+gnome_sound_module_finalize (GObject *object)
 {
-    if (sound_plugin)
-	return sound_plugin->sample_is_playing (gs, error);
-    else {
-	_gnome_sound_error_nodriver (error);
-	return FALSE;
-    }
+    GnomeSoundModule *module = GNOME_SOUND_MODULE (object);
+
+    g_free (module->path);
+
+    module_parent_class->finalize (object);
 }
 
-void
-gnome_sound_sample_stop (GnomeSoundSample *gs, GError **error)
+static void
+gnome_sound_module_class_init (GnomeSoundModuleClass *klass)
 {
-    if (sound_plugin)
-	sound_plugin->sample_stop (gs, error);
-    else
-	_gnome_sound_error_nodriver (error);
+    GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+    module_parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+  
+    module_class->load = gnome_sound_module_load;
+    module_class->unload = gnome_sound_module_unload;
+
+    gobject_class->finalize = gnome_sound_module_finalize;
 }
 
-void
-gnome_sound_sample_wait_done (GnomeSoundSample *gs, GError **error)
+GType
+gnome_sound_module_get_type (void)
 {
-    if (sound_plugin)
-	sound_plugin->sample_wait_done (gs, error);
-    else
-	_gnome_sound_error_nodriver (error);
+    static GType sound_module_type = 0;
+
+    if (!sound_module_type) {
+	static const GTypeInfo sound_module_info = {
+	    sizeof (GnomeSoundModuleClass),
+	    NULL,           /* base_init */
+	    NULL,           /* base_finalize */
+	    (GClassInitFunc) gnome_sound_module_class_init,
+	    NULL,           /* class_finalize */
+	    NULL,           /* class_data */
+	    sizeof (GnomeSoundModule),
+	    0,              /* n_preallocs */
+	    NULL,           /* instance_init */
+	};
+
+	sound_module_type = g_type_register_static (G_TYPE_TYPE_MODULE, "GnomeSoundModule",
+						    &sound_module_info, 0);
+    }
+  
+    return sound_module_type;
 }
 
-void
-gnome_sound_sample_release (GnomeSoundSample *gs, GError **error)
+static void
+_gnome_sound_error_nodriver (GError **error)
 {
-    if (sound_plugin)
-	sound_plugin->sample_release (gs, error);
-    else
-	_gnome_sound_error_nodriver (error);
+    g_set_error (error, GNOME_SOUND_ERROR,
+		 GNOME_SOUND_ERROR_NODRIVER,
+		 _("No sound driver loaded"));
 }
 
 GQuark
@@ -187,74 +169,38 @@ gnome_sound_error_quark (void)
     return q;
 }
 
-void
-gnome_sound_init (const gchar *name, const gchar *backend_args,
-		  const GnomeSoundPlugin *plugin, GError **error)
+GnomeSoundDriver *
+gnome_sound_get_default_driver (void)
 {
-    if (sound_plugin)
-	return;
-
-    if (plugin)
-	sound_plugin = plugin;
-    else {
-	gchar *module_name;
-	gpointer plugin_ptr = NULL;
-	GModule *module;
-
-	module_name = g_strdup_printf (LIBGNOME_SOUNDPLUGINDIR
-				       "/gnomesoundplugin_%s",
-				       name);
-	module = g_module_open (module_name, G_MODULE_BIND_LAZY);
-	if (!module) {
-	    g_warning (G_STRLOC ": Can't open sound plugin `%s': %s",
-		       name, g_module_error ());
-	    return;
-	}
-
-	if (!g_module_symbol (module, "gnome_sound_plugin", &plugin_ptr)) {
-	    g_warning (G_STRLOC ": Not a valid sound plugin: `%s'", name);
-	    g_module_close (module);
-	    return;
-	}
-
-	sound_plugin = plugin_ptr;
-	sound_plugin_module = module;
-    }
-
-    if (sound_plugin->version != GNOME_PLUGIN_SERIAL) {
-	g_warning (G_STRLOC ": Sound plugin `%s' has invalid version %ld",
-		   name, sound_plugin->version);
-	sound_plugin = NULL;
-
-	if (sound_plugin_module) {
-	    g_module_close (sound_plugin_module);
-	    sound_plugin_module = NULL;
-	}
-    }
-
-    if (sound_plugin)
-	sound_plugin->init (backend_args, error);
-    else
-	_gnome_sound_error_nodriver (error);
+    return g_object_ref (G_OBJECT (sound_driver));
 }
 
-void
-gnome_sound_shutdown (GError **error)
+GnomeSoundDriver *
+gnome_sound_init (const gchar *name, const gchar *backend_args, GError **error)
 {
-    if (sound_plugin)
-	sound_plugin->shutdown (error);
-    else
-	_gnome_sound_error_nodriver (error);
+    GnomeSoundDriver *driver = NULL;
+    GnomeSoundModule *module;
+
+    module = g_object_new (GNOME_TYPE_SOUND_MODULE, NULL);
+    module->path = g_strdup_printf (LIBGNOME_SOUNDPLUGINDIR
+				    "/gnomesoundplugin_%s",
+				    name);
+    g_type_module_set_name (G_TYPE_MODULE (module), module->path);
 
-    sound_plugin = NULL;
-    if (sound_plugin_module) {
-	g_module_close (sound_plugin_module);
-	sound_plugin_module = NULL;
+    if (g_type_module_use (G_TYPE_MODULE (module))) {
+	driver = module->plugin->init (G_TYPE_MODULE (module),
+				       backend_args, error);
+	g_type_module_unuse (G_TYPE_MODULE (module));
+    } else {
+	g_warning (G_STRLOC ": Loading sound module '%s' failed", name);
+	_gnome_sound_error_nodriver (error);
     }
+
+    return driver;
 }
 
 gboolean
 gnome_sound_enabled (void)
 {
-    return sound_plugin != NULL;
+    return sound_module != NULL;
 }
diff --git a/libgnome/gnome-sound.h b/libgnome/gnome-sound.h
index ca00bac..d2b659a 100644
--- a/libgnome/gnome-sound.h
+++ b/libgnome/gnome-sound.h
@@ -28,133 +28,32 @@
 
 #include <glib/gmacros.h>
 #include <glib/gerror.h>
+#include <gobject/gtypemodule.h>
+#include <libgnome/gnome-sound-driver.h>
 
 G_BEGIN_DECLS
 
-typedef struct _GnomeSoundSample GnomeSoundSample;
-typedef struct _GnomeSoundPlugin GnomeSoundPlugin;
+typedef struct _GnomeSoundPlugin             GnomeSoundPlugin;
 
 struct _GnomeSoundPlugin {
     gulong version;
     const gchar *name;
 
-    gboolean (*init) (const gchar *backend_args,
-		      GError **error);
-    void (*shutdown) (GError **error);
+    GnomeSoundDriver * (*init) (GTypeModule *module,
+				const gchar *backend_args,
+				GError **error);
 
-    void (*play_file) (const gchar *filename,
-		       GError **error);
-
-    GnomeSoundSample * (*sample_new) (const gchar *name,
-				      GError **error);
-    int (*sample_write) (GnomeSoundSample *gs,
-			 guint n_bytes, gpointer bytes,
-			 GError **error);
-    void (*sample_write_done) (GnomeSoundSample *gs,
-			       GError **error);
-
-    void (*cache_add_sample) (GnomeSoundSample *sample,
-			      GError **error);
-    void (*cache_remove_sample) (GnomeSoundSample *sample,
-				 GError **error);
-
-    GnomeSoundSample * (*sample_new_from_file) (const gchar *name,
-						const gchar *filename,
-						GError **error);
-    GnomeSoundSample * (*sample_new_from_cache) (const gchar *name,
-						 GError **error);
-
-    void (*sample_play) (GnomeSoundSample *gs,
-			 GError **error);
-    gboolean (*sample_is_playing) (GnomeSoundSample *gs,
-				   GError **error);
-    void (*sample_stop) (GnomeSoundSample *gs,
-			 GError **error);
-    void (*sample_wait_done) (GnomeSoundSample *gs,
-			      GError **error);
-    void (*sample_release) (GnomeSoundSample *gs,
-			    GError **error);
+    void (*shutdown) (void);
 };
 
-typedef enum
-{
-    /* no sound driver */
-    GNOME_SOUND_ERROR_NODRIVER,
-    /* not implemented */
-    GNOME_SOUND_ERROR_NOT_IMPLEMENTED,
-    /* device busy */
-    GNOME_SOUND_ERROR_DEVICE_BUSY,
-    /* I/O eror */
-    GNOME_SOUND_ERROR_IO,
-    /* Insufficient permissions */
-    GNOME_SOUND_ERROR_PERMS,
-    /* misc error */
-    GNOME_SOUND_ERROR_MISC
-} GnomeSoundError;
-
-#define GNOME_SOUND_ERROR gnome_sound_error_quark ()
-GQuark gnome_sound_error_quark (void) G_GNUC_CONST;
+GnomeSoundDriver *gnome_sound_get_default_driver (void);
 
-void gnome_sound_init (const gchar *driver_name,
-		       const gchar *backend_args,
-		       const GnomeSoundPlugin *opt_plugin,
-		       GError **error);
-
-void gnome_sound_shutdown (GError **error);
+GnomeSoundDriver *gnome_sound_init (const gchar *driver_name,
+				    const gchar *backend_args,
+				    GError **error);
 
 gboolean gnome_sound_enabled (void);
 
-void gnome_sound_play (const char *filename,
-		       GError **error);
-
-void
-gnome_sound_cache_add_sample (GnomeSoundSample *sample, GError **error);
-
-void
-gnome_sound_cache_remove_sample (GnomeSoundSample *sample, GError **error);
-
-GnomeSoundSample *
-gnome_sound_sample_new_from_file (const char *name,
-				  const char *filename,
-				  GError **error);
-
-GnomeSoundSample *
-gnome_sound_sample_new_from_cache (const char *name,
-				   GError **error);
-
-GnomeSoundSample *
-gnome_sound_sample_new (const char *sample_name,
-			GError **error);
-
-int
-gnome_sound_sample_write (GnomeSoundSample *gs,
-			  guint n_bytes, gpointer bytes,
-			  GError **error);
-
-void
-gnome_sound_sample_write_done (GnomeSoundSample *gs,
-			       GError **error);
-
-void
-gnome_sound_sample_play (GnomeSoundSample *gs,
-			 GError **error);
-
-gboolean
-gnome_sound_sample_is_playing (GnomeSoundSample *gs,
-			       GError **error);
-
-void
-gnome_sound_sample_stop (GnomeSoundSample *gs,
-			 GError **error);
-
-void
-gnome_sound_sample_wait_done (GnomeSoundSample *gs,
-			      GError **error);
-
-void
-gnome_sound_sample_release (GnomeSoundSample *gs,
-			    GError **error);
-
 G_END_DECLS
 
 #endif /* __GNOME_SOUND_H__ */
diff --git a/libgnome/test-sound.c b/libgnome/test-sound.c
index 87d011d..f54ce21 100644
--- a/libgnome/test-sound.c
+++ b/libgnome/test-sound.c
@@ -31,6 +31,7 @@ int
 main (int argc, char **argv)
 {
     struct _GnomeTrigger trig;
+    GnomeSoundDriver *driver;
     GnomeProgram *program;
     GnomeSoundSample *gs;
 
@@ -38,19 +39,19 @@ main (int argc, char **argv)
 				  &libgnome_module_info,
 				  argc, argv, NULL);
 
-    gnome_sound_init ("csl", NULL, NULL, NULL);
+    driver = gnome_sound_init ("csl", NULL, NULL);
 
-    gs = gnome_sound_sample_new_from_file ("gnome/warning",
-					   "/usr/share/sounds/phone.wav",
-					   NULL);
-    gnome_sound_cache_add_sample (gs, NULL);
-    gnome_sound_sample_release (gs, NULL);
+    gs = gnome_sound_driver_sample_new_from_file (driver, "gnome/warning",
+						  "/usr/share/sounds/phone.wav",
+						  NULL);
+    gnome_sound_driver_cache_add_sample (driver, gs, NULL);
+    gnome_sound_driver_sample_release (driver, gs, NULL);
 
-    gs = gnome_sound_sample_new_from_file ("test/one",
-					   "/usr/share/sounds/panel/slide.wav",
-					   NULL);
-    gnome_sound_cache_add_sample (gs, NULL);
-    gnome_sound_sample_release (gs, NULL);
+    gs = gnome_sound_driver_sample_new_from_file (driver, "test/one",
+						  "/usr/share/sounds/panel/slide.wav",
+						  NULL);
+    gnome_sound_driver_cache_add_sample (driver, gs, NULL);
+    gnome_sound_driver_sample_release (driver, gs, NULL);
 
     trig.type = GTRIG_FUNCTION;
     trig.u.function = sample_trigger_function;
@@ -60,9 +61,9 @@ main (int argc, char **argv)
     gnome_triggers_add_trigger (&trig, "test", "one", NULL);
     gnome_triggers_do ("Test of direct hit", "warning", "test", "one", NULL);
 
-    sleep(5);
+    g_object_unref (G_OBJECT (driver));
 
-    gnome_sound_shutdown (NULL);
+    sleep(5);
 
     return 0;
 }



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