projects
/
chise
/
xemacs-chise.git-
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update.
[chise/xemacs-chise.git-]
/
src
/
sunplay.c
diff --git
a/src/sunplay.c
b/src/sunplay.c
index
631d044
..
db4574a
100644
(file)
--- a/
src/sunplay.c
+++ b/
src/sunplay.c
@@
-33,20
+33,15
@@
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/fcntl.h>
#include <sys/file.h>
-/* libaudio.h includes a header which defines CONST. We temporarily
- undefine it in order to eliminate a compiler warning. Yes, this is
- a gross hack. */
-#undef CONST
#include <multimedia/libaudio.h>
#include <multimedia/audio_device.h>
#include <multimedia/libaudio.h>
#include <multimedia/audio_device.h>
-#undef CONST
-#define CONST const
#ifdef emacs
# include <config.h>
# include "lisp.h"
# include "sysdep.h"
# include <errno.h>
#ifdef emacs
# include <config.h>
# include "lisp.h"
# include "sysdep.h"
# include <errno.h>
+# include "nativesound.h"
#include "syssignal.h"
# define perror(string) \
message("audio: %s, %s ", string, strerror (errno))
#include "syssignal.h"
# define perror(string) \
message("audio: %s, %s ", string, strerror (errno))
@@
-61,15
+56,13
@@
static SIGTYPE sighandler (int sig);
static int audio_fd;
static int audio_fd;
-#define audio_open() open ("/dev/audio", (O_WRONLY | O_NDELAY), 0)
+#define audio_open() open ("/dev/audio", (O_WRONLY | O_NONBLOCK), 0)
+static int initialized_device_p;
static int reset_volume_p, reset_device_p;
static double old_volume;
static Audio_hdr dev_hdr;
static int reset_volume_p, reset_device_p;
static double old_volume;
static Audio_hdr dev_hdr;
-void play_sound_file (char *name, int volume);
-void play_sound_data (unsigned char *data, int length, int volume);
-
static int
init_device (int volume, unsigned char *data, int fd,
unsigned int *header_length)
static int
init_device (int volume, unsigned char *data, int fd,
unsigned int *header_length)
@@
-83,7
+76,7
@@
init_device (int volume, unsigned char *data, int fd,
reset_volume_p = 0;
reset_device_p = 0;
reset_volume_p = 0;
reset_device_p = 0;
- if (data && fd) abort (); /* one or the other */
+ if (data && fd) ABORT (); /* one or the other */
if (AUDIO_SUCCESS != audio_get_play_config (audio_fd, &dev_hdr))
{
if (AUDIO_SUCCESS != audio_get_play_config (audio_fd, &dev_hdr))
{
@@
-104,11
+97,12
@@
init_device (int volume, unsigned char *data, int fd,
audio_flush_play (audio_fd);
audio_flush_play (audio_fd);
- if (0 != audio_cmp_hdr (&dev_hdr, &file_hdr))
+ if (!initialized_device_p || (0 != audio_cmp_hdr (&dev_hdr, &file_hdr)))
{
Audio_hdr new_hdr;
new_hdr = file_hdr;
reset_device_p = 1;
{
Audio_hdr new_hdr;
new_hdr = file_hdr;
reset_device_p = 1;
+ initialized_device_p = 1;
if (AUDIO_SUCCESS != audio_set_play_config (audio_fd, &new_hdr))
{
char buf1 [100], buf2 [100], buf3 [250];
if (AUDIO_SUCCESS != audio_set_play_config (audio_fd, &new_hdr))
{
char buf1 [100], buf2 [100], buf3 [250];
@@
-233,15
+227,16
@@
play_sound_file (char *sound_file, int volume)
}
}
-void
+int
play_sound_data (unsigned char *data, int length, int volume)
{
int wrtn, start = 0;
unsigned int ilen;
play_sound_data (unsigned char *data, int length, int volume)
{
int wrtn, start = 0;
unsigned int ilen;
+ int result = 0;
audio_fd = -1;
audio_fd = -1;
- if (length == 0) return;
+ if (length == 0) return 0;
/* this is just to get a better error message */
if (strncmp (".snd\0", (char *) data, 4))
/* this is just to get a better error message */
if (strncmp (".snd\0", (char *) data, 4))
@@
-257,10
+252,7
@@
play_sound_data (unsigned char *data, int length, int volume)
audio_fd = audio_open ();
if (audio_fd < 0)
audio_fd = audio_open ();
if (audio_fd < 0)
- {
- perror ("open /dev/audio");
- return;
- }
+ return 0;
/* where to find the proto for signal()... */
sighup_handler = (SIGTYPE (*) (int)) signal (SIGHUP, sighandler);
/* where to find the proto for signal()... */
sighup_handler = (SIGTYPE (*) (int)) signal (SIGHUP, sighandler);
@@
-298,6
+290,8
@@
play_sound_data (unsigned char *data, int length, int volume)
goto END_OF_PLAY;
}
goto END_OF_PLAY;
}
+ result = 1;
+
END_OF_PLAY:
if (audio_fd > 0)
END_OF_PLAY:
if (audio_fd > 0)
@@
-308,11
+302,13
@@
play_sound_data (unsigned char *data, int length, int volume)
signal (SIGHUP, sighup_handler);
signal (SIGINT, sigint_handler);
signal (SIGHUP, sighup_handler);
signal (SIGINT, sigint_handler);
+
+ return result;
}
/* #### sigcontext doesn't exist in Solaris. This should be updated
to be correct for Solaris. */
}
/* #### sigcontext doesn't exist in Solaris. This should be updated
to be correct for Solaris. */
-static void
+static SIGTYPE
sighandler (int sig)
{
if (audio_fd > 0)
sighandler (int sig)
{
if (audio_fd > 0)