[monkey-bubble: 597/753] Added `const gchar *name' argument.
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 597/753] Added `const gchar *name' argument.
- Date: Wed, 14 Jul 2010 22:45:51 +0000 (UTC)
commit d3e044e1b09844e2b9d37bd8b316592991671ca8
Author: Martin Baulig <baulig suse de>
Date: Sat Aug 4 00:25:49 2001 +0000
Added `const gchar *name' argument.
2001-08-04 Martin Baulig <baulig suse de>
* gnome-sound.h (gnome_sound_sample_new_from_file):
Added `const gchar *name' argument.
libgnome/ChangeLog | 5 +++++
libgnome/gnome-sound-csl.c | 41 +++++++++++++++++++++++++++++++++++------
libgnome/gnome-sound.c | 5 +++--
libgnome/gnome-sound.h | 6 ++++--
libgnome/test-sound.c | 35 ++++++-----------------------------
5 files changed, 53 insertions(+), 39 deletions(-)
---
diff --git a/libgnome/ChangeLog b/libgnome/ChangeLog
index 4932e9f..5d75a82 100644
--- a/libgnome/ChangeLog
+++ b/libgnome/ChangeLog
@@ -1,5 +1,10 @@
2001-08-04 Martin Baulig <baulig suse de>
+ * gnome-sound.h (gnome_sound_sample_new_from_file):
+ Added `const gchar *name' argument.
+
+2001-08-04 Martin Baulig <baulig suse de>
+
* *.[ch]: Fixed #includes, only include necessary
header files, use <...> instead of "..." where
appropriate.
diff --git a/libgnome/gnome-sound-csl.c b/libgnome/gnome-sound-csl.c
index e94ba14..e9f49ec 100644
--- a/libgnome/gnome-sound-csl.c
+++ b/libgnome/gnome-sound-csl.c
@@ -24,6 +24,10 @@
*/
#include "config.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
#include <glib.h>
#include <libgnome/gnome-sound.h>
@@ -61,21 +65,46 @@ gnome_sound_csl_play_file (const char *filename, GError **error)
}
static GnomeSoundSample *
-gnome_sound_csl_sample_new_from_file (const char *filename, GError **error)
+gnome_sound_csl_sample_new_from_file (const char *name, const char *filename,
+ GError **error)
{
CslErrorType err;
CslSample *sample;
GnomeSoundSample *retval;
+ int fd;
if (!gnome_sound_csl_driver)
return NULL;
- err = csl_sample_new_from_file (gnome_sound_csl_driver, filename,
- "gnome_sound_csl_sample_new", NULL,
- &sample);
+ err = csl_sample_new (gnome_sound_csl_driver, name,
+ "gnome_sound_csl_sample_new", NULL,
+ &sample);
if (err) {
- csl_warning ("unable to create sample from file '%s': %s",
- filename, csl_strerror (err));
+ csl_warning ("unable to create sample '%s': %s",
+ name, csl_strerror (err));
+ return NULL;
+ }
+
+ fd = open (filename, O_RDONLY);
+
+ if (fd >= 0) {
+ char buffer[4096];
+ int len;
+
+ do {
+ do
+ len = read (fd, buffer, sizeof(buffer));
+ while (len < 0 && errno == EINTR);
+
+ if (len > 0)
+ csl_sample_write (sample, len, buffer);
+ }
+ while (len > 0);
+ close (fd);
+
+ csl_sample_write_done (sample);
+ } else {
+ csl_sample_release (sample);
return NULL;
}
diff --git a/libgnome/gnome-sound.c b/libgnome/gnome-sound.c
index d4ed0de..847920f 100644
--- a/libgnome/gnome-sound.c
+++ b/libgnome/gnome-sound.c
@@ -74,10 +74,11 @@ gnome_sound_cache_remove_sample (GnomeSoundSample *gs, GError **error)
}
GnomeSoundSample *
-gnome_sound_sample_new_from_file (const char *filename, GError **error)
+gnome_sound_sample_new_from_file (const gchar *name, const char *filename,
+ GError **error)
{
if (sound_plugin)
- return sound_plugin->sample_new_from_file (filename, error);
+ return sound_plugin->sample_new_from_file (name, filename, error);
else {
_gnome_sound_error_nodriver (error);
return NULL;
diff --git a/libgnome/gnome-sound.h b/libgnome/gnome-sound.h
index 46428fa..ca00bac 100644
--- a/libgnome/gnome-sound.h
+++ b/libgnome/gnome-sound.h
@@ -58,7 +58,8 @@ struct _GnomeSoundPlugin {
void (*cache_remove_sample) (GnomeSoundSample *sample,
GError **error);
- GnomeSoundSample * (*sample_new_from_file) (const gchar *filename,
+ GnomeSoundSample * (*sample_new_from_file) (const gchar *name,
+ const gchar *filename,
GError **error);
GnomeSoundSample * (*sample_new_from_cache) (const gchar *name,
GError **error);
@@ -113,7 +114,8 @@ void
gnome_sound_cache_remove_sample (GnomeSoundSample *sample, GError **error);
GnomeSoundSample *
-gnome_sound_sample_new_from_file (const char *filename,
+gnome_sound_sample_new_from_file (const char *name,
+ const char *filename,
GError **error);
GnomeSoundSample *
diff --git a/libgnome/test-sound.c b/libgnome/test-sound.c
index 37da938..87d011d 100644
--- a/libgnome/test-sound.c
+++ b/libgnome/test-sound.c
@@ -27,31 +27,6 @@ sample_trigger_function(char *msg, char *level, char *supinfo[])
global_cntr++;
}
-static void
-sample_read_from_file (GnomeSoundSample *gs, const gchar *name)
-{
- int fd = open (name, O_RDONLY);
-
- if (fd >= 0) {
- char buffer[4096];
- int len;
-
- do {
- do
- len = read (fd, buffer, sizeof (buffer));
- while (len < 0 && errno == EINTR);
-
- if (len > 0)
- gnome_sound_sample_write (gs, len, buffer, NULL);
- }
-
- while (len > 0);
- close (fd);
- }
-
- gnome_sound_sample_write_done (gs, NULL);
-}
-
int
main (int argc, char **argv)
{
@@ -65,13 +40,15 @@ main (int argc, char **argv)
gnome_sound_init ("csl", NULL, NULL, NULL);
- gs = gnome_sound_sample_new ("gnome/warning", NULL);
- sample_read_from_file (gs, "/usr/share/sounds/phone.wav");
+ 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_sample_new ("test/one", NULL);
- sample_read_from_file (gs, "/usr/share/sounds/panel/slide.wav");
+ 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]