annotate src/sound.c @ 57683:47bbd69c09b4

(x-set-cut-buffer): Cancel previous change.
author Kenichi Handa <handa@m17n.org>
date Mon, 25 Oct 2004 00:45:38 +0000
parents 695cf19ef79e
children a8fa7c632ee4 375f2633d815
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 /* sound.c -- sound support.
38297
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
2 Copyright (C) 1998, 1999, 2001 Free Software Foundation.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 any later version.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 /* Written by Gerd Moellmann <gerd@gnu.org>. Tested with Luigi's
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 driver on FreeBSD 2.2.7 with a SoundBlaster 16. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
24 /*
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
25 Modified by Ben Key <Bkey1@tampabay.rr.com> to add a partial
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
26 implementation of the play-sound specification for Windows.
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
27
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
28 Notes:
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
29 In the Windows implementation of play-sound-internal only the
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
30 :file and :volume keywords are supported. The :device keyword,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
31 if present, is ignored. The :data keyword, if present, will
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
32 cause an error to be generated.
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
33
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
34 The Windows implementation of play-sound is implemented via the
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
35 Win32 API functions mciSendString, waveOutGetVolume, and
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
36 waveOutSetVolume which are exported by Winmm.dll.
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
37 */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
38
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 #include <config.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 #if defined HAVE_SOUND
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
43 /* BEGIN: Common Includes */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 #include <fcntl.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 #include <unistd.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 #include <sys/types.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 #include <errno.h>
38297
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
48 #include "lisp.h"
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
49 #include "dispextern.h"
17465a81d1dd Include Emacs' header files with #include "...".
Gerd Moellmann <gerd@gnu.org>
parents: 38215
diff changeset
50 #include "atimer.h"
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
51 #include <signal.h>
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
52 #include "syssignal.h"
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
53 /* END: Common Includes */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
54
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
55
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
56 /* BEGIN: Non Windows Includes */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
57 #ifndef WINDOWSNT
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58
39969
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
59 #ifndef MSDOS
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
60 #include <sys/ioctl.h>
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
61 #endif
21d7408e0d86 Include <sys/ioctl.h> also on systems without <soundcard.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
62
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 /* FreeBSD has machine/soundcard.h. Voxware sound driver docs mention
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 sys/soundcard.h. So, let's try whatever's there. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 #ifdef HAVE_MACHINE_SOUNDCARD_H
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 #include <machine/soundcard.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 #ifdef HAVE_SYS_SOUNDCARD_H
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 #include <sys/soundcard.h>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 #endif
30079
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
72 #ifdef HAVE_SOUNDCARD_H
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
73 #include <soundcard.h>
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
74 #endif
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
75 /* END: Non Windows Includes */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
76
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
77 #else /* WINDOWSNT */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
78
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
79 /* BEGIN: Windows Specific Includes */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
80 #include <stdio.h>
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
81 #include <stdlib.h>
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
82 #include <string.h>
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
83 #include <limits.h>
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
84 #include <windows.h>
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
85 #include <mmsystem.h>
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
86 /* END: Windows Specific Includes */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
87
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
88 #endif /* WINDOWSNT */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
89
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
90 /* BEGIN: Common Definitions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
91 #define abs(X) ((X) < 0 ? -(X) : (X))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
92
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
93 /* Symbols. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
94
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
95 extern Lisp_Object QCfile, QCdata;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
96 Lisp_Object QCvolume, QCdevice;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
97 Lisp_Object Qsound;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
98 Lisp_Object Qplay_sound_functions;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
99
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
100 /* Indices of attributes in a sound attributes vector. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
101
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
102 enum sound_attr
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
103 {
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
104 SOUND_FILE,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
105 SOUND_DATA,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
106 SOUND_DEVICE,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
107 SOUND_VOLUME,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
108 SOUND_ATTR_SENTINEL
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
109 };
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
110
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
111 static void sound_perror P_ ((char *));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
112 static void sound_warning P_ ((char *));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
113 static int parse_sound P_ ((Lisp_Object, Lisp_Object *));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
114
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
115 /* END: Common Definitions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
116
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
117 /* BEGIN: Non Windows Definitions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
118 #ifndef WINDOWSNT
30079
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
119
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
120 #ifndef DEFAULT_SOUND_DEVICE
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
121 #define DEFAULT_SOUND_DEVICE "/dev/dsp"
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
122 #endif
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 /* Structure forward declarations. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
127 struct sound;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 struct sound_device;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 /* The file header of RIFF-WAVE files (*.wav). Files are always in
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 little-endian byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 struct wav_header
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 u_int32_t magic;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 u_int32_t length;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 u_int32_t chunk_type;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 u_int32_t chunk_format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 u_int32_t chunk_length;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 u_int16_t format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 u_int16_t channels;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 u_int32_t sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 u_int32_t bytes_per_second;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 u_int16_t sample_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 u_int16_t precision;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 u_int32_t chunk_data;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 u_int32_t data_length;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 /* The file header of Sun adio files (*.au). Files are always in
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 big-endian byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 struct au_header
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 /* ASCII ".snd" */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 u_int32_t magic_number;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
157
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 /* Offset of data part from start of file. Minimum value is 24. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 u_int32_t data_offset;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
160
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 /* Size of data part, 0xffffffff if unknown. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 u_int32_t data_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 /* Data encoding format.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 1 8-bit ISDN u-law
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 2 8-bit linear PCM (REF-PCM)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 3 16-bit linear PCM
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 4 24-bit linear PCM
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 5 32-bit linear PCM
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 6 32-bit IEEE floating-point
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 7 64-bit IEEE floating-point
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 23 8-bit u-law compressed using CCITT 0.721 ADPCM voice data
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 encoding scheme. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 u_int32_t encoding;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 /* Number of samples per second. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 u_int32_t sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 /* Number of interleaved channels. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 u_int32_t channels;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 /* Maximum of all sound file headers sizes. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 #define MAX_SOUND_HEADER_BYTES \
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 max (sizeof (struct wav_header), sizeof (struct au_header))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 /* Interface structure for sound devices. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 struct sound_device
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 /* The name of the device or null meaning use a default device name. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 char *file;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 /* File descriptor of the device. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 int fd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 /* Device-dependent format. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 int format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 /* Volume (0..100). Zero means unspecified. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 int volume;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 /* Sample size. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 int sample_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 /* Sample rate. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 int sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 /* Bytes per second. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 int bps;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 /* 1 = mono, 2 = stereo, 0 = don't set. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 int channels;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
215
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 /* Open device SD. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 void (* open) P_ ((struct sound_device *sd));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 /* Close device SD. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 void (* close) P_ ((struct sound_device *sd));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 /* Configure SD accoring to device-dependent parameters. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 void (* configure) P_ ((struct sound_device *device));
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
224
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
225 /* Choose a device-dependent format for outputting sound S. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 void (* choose_format) P_ ((struct sound_device *sd,
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
227 struct sound *s));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 /* Write NYBTES bytes from BUFFER to device SD. */
46554
fb13fafbd279 (struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents: 46370
diff changeset
230 void (* write) P_ ((struct sound_device *sd, const char *buffer,
fb13fafbd279 (struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents: 46370
diff changeset
231 int nbytes));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 /* A place for devices to store additional data. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 void *data;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 /* An enumerator for each supported sound file type. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 enum sound_type
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 RIFF,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 SUN_AUDIO
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 /* Interface structure for sound files. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
247 struct sound
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 /* The type of the file. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 enum sound_type type;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
252 /* File descriptor of a sound file. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 int fd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
255 /* Pointer to sound file header. This contains header_size bytes
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
256 read from the start of a sound file. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 char *header;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
259 /* Number of bytes raed from sound file. This is always <=
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
260 MAX_SOUND_HEADER_BYTES. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
261 int header_size;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
262
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
263 /* Sound data, if a string. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
264 Lisp_Object data;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
265
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
266 /* Play sound file S on device SD. */
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
267 void (* play) P_ ((struct sound *s, struct sound_device *sd));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269
44399
a399428859ff (Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents: 42754
diff changeset
270 /* These are set during `play-sound-internal' so that sound_cleanup has
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 access to them. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
273 struct sound_device *current_sound_device;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
274 struct sound *current_sound;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 /* Function prototypes. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 static void vox_open P_ ((struct sound_device *));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 static void vox_configure P_ ((struct sound_device *));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 static void vox_close P_ ((struct sound_device *sd));
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
281 static void vox_choose_format P_ ((struct sound_device *, struct sound *));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 static void vox_init P_ ((struct sound_device *));
46554
fb13fafbd279 (struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents: 46370
diff changeset
283 static void vox_write P_ ((struct sound_device *, const char *, int));
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
284 static void find_sound_type P_ ((struct sound *));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 static u_int32_t le2hl P_ ((u_int32_t));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 static u_int16_t le2hs P_ ((u_int16_t));
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 static u_int32_t be2hl P_ ((u_int32_t));
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
288 static int wav_init P_ ((struct sound *));
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
289 static void wav_play P_ ((struct sound *, struct sound_device *));
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
290 static int au_init P_ ((struct sound *));
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
291 static void au_play P_ ((struct sound *, struct sound_device *));
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292
25722
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
293 #if 0 /* Currently not used. */
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
294 static u_int16_t be2hs P_ ((u_int16_t));
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
295 #endif
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
296
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
297 /* END: Non Windows Definitions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
298 #else /* WINDOWSNT */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
299
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
300 /* BEGIN: Windows Specific Definitions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
301 static int do_play_sound P_ ((const char *, unsigned long));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
302 /*
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
303 END: Windows Specific Definitions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
304 #endif /* WINDOWSNT */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 General
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
311 /* BEGIN: Common functions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
312
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 /* Like perror, but signals an error. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 sound_perror (msg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 char *msg;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 {
40745
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
319 int saved_errno = errno;
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
320
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
321 turn_on_atimers (1);
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
322 #ifdef SIGIO
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
323 sigunblock (sigmask (SIGIO));
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
324 #endif
40745
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
325 if (saved_errno != 0)
1622bfdfe454 (sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents: 40364
diff changeset
326 error ("%s: %s", msg, strerror (saved_errno));
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
327 else
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
328 error ("%s", msg);
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
329 }
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
330
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
331
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
332 /* Display a warning message. */
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
333
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
334 static void
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
335 sound_warning (msg)
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
336 char *msg;
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
337 {
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
338 message (msg);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 /* Parse sound specification SOUND, and fill ATTRS with what is
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 found. Value is non-zero if SOUND Is a valid sound specification.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 A valid sound specification is a list starting with the symbol
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 `sound'. The rest of the list is a property list which may
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 contain the following key/value pairs:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 - `:file FILE'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 FILE is the sound file to play. If it isn't an absolute name,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 it's searched under `data-directory'.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
353 - `:data DATA'
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
354
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
355 DATA is a string containing sound data. Either :file or :data
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
356 may be present, but not both.
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
357
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 - `:device DEVICE'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 DEVICE is the name of the device to play on, e.g. "/dev/dsp2".
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 If not specified, a default device is used.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 - `:volume VOL'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
365 VOL must be an integer in the range [0, 100], or a float in the
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
366 range [0, 1]. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 static int
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 parse_sound (sound, attrs)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 Lisp_Object sound;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 Lisp_Object *attrs;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 /* SOUND must be a list starting with the symbol `sound'. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 if (!CONSP (sound) || !EQ (XCAR (sound), Qsound))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 sound = XCDR (sound);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 attrs[SOUND_FILE] = Fplist_get (sound, QCfile);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
379 attrs[SOUND_DATA] = Fplist_get (sound, QCdata);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 attrs[SOUND_DEVICE] = Fplist_get (sound, QCdevice);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 attrs[SOUND_VOLUME] = Fplist_get (sound, QCvolume);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
383 #ifndef WINDOWSNT
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
384 /* File name or data must be specified. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
385 if (!STRINGP (attrs[SOUND_FILE])
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
386 && !STRINGP (attrs[SOUND_DATA]))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 return 0;
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
388 #else /* WINDOWSNT */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
389 /*
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
390 Data is not supported in Windows. Therefore a
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
391 File name MUST be supplied.
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
392 */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
393 if (!STRINGP (attrs[SOUND_FILE]))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
394 {
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
395 return 0;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
396 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
397 #endif /* WINDOWSNT */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 /* Volume must be in the range 0..100 or unspecified. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 if (!NILP (attrs[SOUND_VOLUME]))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 {
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
402 if (INTEGERP (attrs[SOUND_VOLUME]))
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
403 {
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
404 if (XINT (attrs[SOUND_VOLUME]) < 0
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
405 || XINT (attrs[SOUND_VOLUME]) > 100)
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
406 return 0;
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
407 }
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
408 else if (FLOATP (attrs[SOUND_VOLUME]))
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
409 {
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
410 if (XFLOAT_DATA (attrs[SOUND_VOLUME]) < 0
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
411 || XFLOAT_DATA (attrs[SOUND_VOLUME]) > 1)
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
412 return 0;
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
413 }
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
414 else
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
418 #ifndef WINDOWSNT
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 /* Device must be a string or unspecified. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 if (!NILP (attrs[SOUND_DEVICE])
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 && !STRINGP (attrs[SOUND_DEVICE]))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 return 0;
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
423 #endif /* WINDOWSNT */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
424 /*
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
425 Since device is ignored in Windows, it does not matter
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
426 what it is.
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
427 */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 return 1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
431 /* END: Common functions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
432
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
433 /* BEGIN: Non Windows functions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
434 #ifndef WINDOWSNT
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 /* Find out the type of the sound file whose file descriptor is FD.
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
437 S is the sound file structure to fill in. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
440 find_sound_type (s)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
441 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
443 if (!wav_init (s) && !au_init (s))
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
444 error ("Unknown sound format");
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447
44399
a399428859ff (Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents: 42754
diff changeset
448 /* Function installed by play-sound-internal with record_unwind_protect. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 static Lisp_Object
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 sound_cleanup (arg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 Lisp_Object arg;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
454 if (current_sound_device)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 {
27635
8344762c0da2 * sound.c (sound_cleanup): Don't call device close routine if pointer is null.
Ken Raeburn <raeburn@raeburn.org>
parents: 27315
diff changeset
456 if (current_sound_device->close)
8344762c0da2 * sound.c (sound_cleanup): Don't call device close routine if pointer is null.
Ken Raeburn <raeburn@raeburn.org>
parents: 27315
diff changeset
457 current_sound_device->close (current_sound_device);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
458 if (current_sound->fd > 0)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
459 emacs_close (current_sound->fd);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 }
34255
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
461
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
462 return Qnil;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 Byte-order Conversion
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 /* Convert 32-bit value VALUE which is in little-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 static u_int32_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 le2hl (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 u_int32_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 #ifdef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 /* Convert 16-bit value VALUE which is in little-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 static u_int16_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 le2hs (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 u_int16_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 #ifdef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 value = p[0] + (p[1] << 8);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 /* Convert 32-bit value VALUE which is in big-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 static u_int32_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 be2hl (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 u_int32_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 #ifndef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513
25722
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
514 #if 0 /* Currently not used. */
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
515
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 /* Convert 16-bit value VALUE which is in big-endian byte-order
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 to host byte-order. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 static u_int16_t
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 be2hs (value)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 u_int16_t value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 #ifndef WORDS_BIG_ENDIAN
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 unsigned char *p = (unsigned char *) &value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 value = p[1] + (p[0] << 8);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 #endif
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 return value;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529
25722
2be6ced279d3 (Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents: 25548
diff changeset
530 #endif /* 0 */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 RIFF-WAVE (*.wav)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
536 /* Try to initialize sound file S from S->header. S->header
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 sound file. If the file is a WAV-format file, set up interface
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
539 functions in S and convert header fields to host byte-order.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 Value is non-zero if the file is a WAV file. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 static int
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
543 wav_init (s)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
544 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
546 struct wav_header *header = (struct wav_header *) s->header;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
547
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
548 if (s->header_size < sizeof *header
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
549 || bcmp (s->header, "RIFF", 4) != 0)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 return 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 /* WAV files are in little-endian order. Convert the header
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 if on a big-endian machine. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 header->magic = le2hl (header->magic);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 header->length = le2hl (header->length);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 header->chunk_type = le2hl (header->chunk_type);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 header->chunk_format = le2hl (header->chunk_format);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 header->chunk_length = le2hl (header->chunk_length);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 header->format = le2hs (header->format);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 header->channels = le2hs (header->channels);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 header->sample_rate = le2hl (header->sample_rate);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 header->bytes_per_second = le2hl (header->bytes_per_second);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 header->sample_size = le2hs (header->sample_size);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 header->precision = le2hs (header->precision);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 header->chunk_data = le2hl (header->chunk_data);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 header->data_length = le2hl (header->data_length);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 /* Set up the interface functions for WAV. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
569 s->type = RIFF;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
570 s->play = wav_play;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 return 1;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
573 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
576 /* Play RIFF-WAVE audio file S on sound device SD. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
579 wav_play (s, sd)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
580 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
583 struct wav_header *header = (struct wav_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 /* Let the device choose a suitable device-dependent format
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 for the file. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
587 sd->choose_format (sd, s);
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
588
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 /* Configure the device. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 sd->sample_size = header->sample_size;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 sd->sample_rate = header->sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 sd->bps = header->bytes_per_second;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 sd->channels = header->channels;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 sd->configure (sd);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 /* Copy sound data to the device. The WAV file specification is
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 actually more complex. This simple scheme worked with all WAV
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 files I found so far. If someone feels inclined to implement the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 whole RIFF-WAVE spec, please do. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
600 if (STRINGP (s->data))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
601 sd->write (sd, SDATA (s->data) + sizeof *header,
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
602 SBYTES (s->data) - sizeof *header);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
603 else
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
604 {
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
605 char *buffer;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
606 int nbytes;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
607 int blksize = 2048;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
608
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
609 buffer = (char *) alloca (blksize);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
610 lseek (s->fd, sizeof *header, SEEK_SET);
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
611
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
612 while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
613 sd->write (sd, buffer, nbytes);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
615 if (nbytes < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
616 sound_perror ("Error reading sound file");
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
617 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 Sun Audio (*.au)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
625 /* Sun audio file encodings. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 enum au_encoding
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 AU_ENCODING_ULAW_8 = 1,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 AU_ENCODING_8,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 AU_ENCODING_16,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 AU_ENCODING_24,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 AU_ENCODING_32,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 AU_ENCODING_IEEE32,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 AU_ENCODING_IEEE64,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 AU_COMPRESSED = 23
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 };
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
640 /* Try to initialize sound file S from S->header. S->header
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 sound file. If the file is a AU-format file, set up interface
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
643 functions in S and convert header fields to host byte-order.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 Value is non-zero if the file is an AU file. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 static int
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
647 au_init (s)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
648 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
650 struct au_header *header = (struct au_header *) s->header;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
651
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
652 if (s->header_size < sizeof *header
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
653 || bcmp (s->header, ".snd", 4) != 0)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 return 0;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
655
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 header->magic_number = be2hl (header->magic_number);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 header->data_offset = be2hl (header->data_offset);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 header->data_size = be2hl (header->data_size);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 header->encoding = be2hl (header->encoding);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 header->sample_rate = be2hl (header->sample_rate);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 header->channels = be2hl (header->channels);
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
662
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 /* Set up the interface functions for AU. */
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
664 s->type = SUN_AUDIO;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
665 s->play = au_play;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 return 1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
671 /* Play Sun audio file S on sound device SD. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
674 au_play (s, sd)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
675 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
678 struct au_header *header = (struct au_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 sd->sample_size = 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 sd->sample_rate = header->sample_rate;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 sd->bps = 0;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 sd->channels = header->channels;
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
684 sd->choose_format (sd, s);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 sd->configure (sd);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
686
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
687 if (STRINGP (s->data))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
688 sd->write (sd, SDATA (s->data) + header->data_offset,
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
689 SBYTES (s->data) - header->data_offset);
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
690 else
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
691 {
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
692 int blksize = 2048;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
693 char *buffer;
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
694 int nbytes;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
695
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
696 /* Seek */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
697 lseek (s->fd, header->data_offset, SEEK_SET);
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
698
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
699 /* Copy sound data to the device. */
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
700 buffer = (char *) alloca (blksize);
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
701 while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0)
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
702 sd->write (sd, buffer, nbytes);
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
703
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
704 if (nbytes < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
705 sound_perror ("Error reading sound file");
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
706 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 Voxware Driver Interface
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 /* This driver is available on GNU/Linux, and the free BSDs. FreeBSD
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 has a compatible own driver aka Luigi's driver. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 /* Open device SD. If SD->file is non-null, open that device,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 otherwise use a default device name. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 vox_open (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 char *file;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
726
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 /* Open the sound device. Default is /dev/dsp. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 if (sd->file)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 file = sd->file;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 else
30079
1572612184fc Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents: 29717
diff changeset
731 file = DEFAULT_SOUND_DEVICE;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
732
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25722
diff changeset
733 sd->fd = emacs_open (file, O_WRONLY, 0);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 if (sd->fd < 0)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 sound_perror (file);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 /* Configure device SD from parameters in it. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 vox_configure (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 {
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
745 int val;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
746
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747 xassert (sd->fd >= 0);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
749 /* On GNU/Linux, it seems that the device driver doesn't like to be
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
750 interrupted by a signal. Block the ones we know to cause
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
751 troubles. */
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
752 turn_on_atimers (0);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
753 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
754 sigblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
755 #endif
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
756
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
757 val = sd->format;
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
758 if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
759 || val != sd->format)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
760 sound_perror ("Could not set sound format");
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
761
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
762 val = sd->channels != 1;
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
763 if (ioctl (sd->fd, SNDCTL_DSP_STEREO, &val) < 0
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
764 || val != (sd->channels != 1))
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
765 sound_perror ("Could not set stereo/mono");
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
767 /* I think bps and sampling_rate are the same, but who knows.
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
768 Check this. and use SND_DSP_SPEED for both. */
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
769 if (sd->sample_rate > 0)
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
770 {
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
771 val = sd->sample_rate;
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
772 if (ioctl (sd->fd, SNDCTL_DSP_SPEED, &sd->sample_rate) < 0)
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
773 sound_perror ("Could not set sound speed");
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
774 else if (val != sd->sample_rate)
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
775 sound_warning ("Could not set sample rate");
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
776 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777
34255
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
778 if (sd->volume > 0)
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
779 {
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
780 int volume = sd->volume & 0xff;
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
781 volume |= volume << 8;
34354
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
782 /* This may fail if there is no mixer. Ignore the failure. */
db2901e01b72 (vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents: 34255
diff changeset
783 ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume);
34255
cb2b0d1799db (vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents: 31587
diff changeset
784 }
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
785
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
786 turn_on_atimers (1);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
787 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
788 sigunblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
789 #endif
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793 /* Close device SD if it is open. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
795 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
796 vox_close (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
799 if (sd->fd >= 0)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
800 {
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
801 /* On GNU/Linux, it seems that the device driver doesn't like to
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
802 be interrupted by a signal. Block the ones we know to cause
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
803 troubles. */
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
804 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
805 sigblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
806 #endif
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
807 turn_on_atimers (0);
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
808
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
809 /* Flush sound data, and reset the device. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
811
38215
b9fdde642b13 (vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents: 34354
diff changeset
812 turn_on_atimers (1);
38338
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
813 #ifdef SIGIO
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
814 sigunblock (sigmask (SIGIO));
c6ff61f9af43 (toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents: 38297
diff changeset
815 #endif
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
817 /* Close the device. */
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25722
diff changeset
818 emacs_close (sd->fd);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 sd->fd = -1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
820 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
822
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
823
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
824 /* Choose device-dependent format for device SD from sound file S. */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
825
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
826 static void
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
827 vox_choose_format (sd, s)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828 struct sound_device *sd;
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
829 struct sound *s;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
831 if (s->type == RIFF)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
833 struct wav_header *h = (struct wav_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 if (h->precision == 8)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
835 sd->format = AFMT_U8;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836 else if (h->precision == 16)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 sd->format = AFMT_S16_LE;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 else
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839 error ("Unsupported WAV file format");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840 }
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
841 else if (s->type == SUN_AUDIO)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 {
27146
68290f44807a (struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
843 struct au_header *header = (struct au_header *) s->header;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 switch (header->encoding)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
846 case AU_ENCODING_ULAW_8:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847 case AU_ENCODING_IEEE32:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848 case AU_ENCODING_IEEE64:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 sd->format = AFMT_MU_LAW;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 break;
42754
158482d8af9d (Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents: 42534
diff changeset
851
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 case AU_ENCODING_8:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 case AU_ENCODING_16:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 case AU_ENCODING_24:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 case AU_ENCODING_32:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 sd->format = AFMT_S16_LE;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 break;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 default:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 error ("Unsupported AU file format");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 else
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 abort ();
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 /* Initialize device SD. Set up the interface functions in the device
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 structure. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 vox_init (sd)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 struct sound_device *sd;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 sd->fd = -1;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 sd->open = vox_open;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 sd->close = vox_close;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 sd->configure = vox_configure;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 sd->choose_format = vox_choose_format;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 sd->write = vox_write;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 /* Write NBYTES bytes from BUFFER to device SD. */
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 static void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 vox_write (sd, buffer, nbytes)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 struct sound_device *sd;
46554
fb13fafbd279 (struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents: 46370
diff changeset
888 const char *buffer;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 int nbytes;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 {
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25722
diff changeset
891 int nwritten = emacs_write (sd->fd, buffer, nbytes);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 if (nwritten < 0)
40364
f7b039994118 (sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents: 40123
diff changeset
893 sound_perror ("Error writing to sound device");
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
896 /* END: Non Windows functions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
897 #else /* WINDOWSNT */
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
899 /* BEGIN: Windows specific functions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
900
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
901 static int
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
902 do_play_sound (psz_file, ui_volume)
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
903 const char *psz_file;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
904 unsigned long ui_volume;
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
905 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
906 int i_result = 0;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
907 MCIERROR mci_error = 0;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
908 char sz_cmd_buf[520] = {0};
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
909 char sz_ret_buf[520] = {0};
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
910 MMRESULT mm_result = MMSYSERR_NOERROR;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
911 unsigned long ui_volume_org = 0;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
912 BOOL b_reset_volume = FALSE;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
913
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
914 memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
915 memset (sz_ret_buf, 0, sizeof(sz_ret_buf));
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
916 sprintf (sz_cmd_buf,
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
917 "open \"%s\" alias GNUEmacs_PlaySound_Device wait",
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
918 psz_file);
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
919 mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
920 if (mci_error != 0)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
921 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
922 sound_warning ("The open mciSendString command failed to open\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
923 "the specified sound file");
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
924 i_result = (int) mci_error;
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
925 return i_result;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
926 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
927 if ((ui_volume > 0) && (ui_volume != UINT_MAX))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
928 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
929 mm_result = waveOutGetVolume ((HWAVEOUT) WAVE_MAPPER, &ui_volume_org);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
930 if (mm_result == MMSYSERR_NOERROR)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
931 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
932 b_reset_volume = TRUE;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
933 mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
934 if ( mm_result != MMSYSERR_NOERROR)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
935 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
936 sound_warning ("waveOutSetVolume failed to set the volume level\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
937 "of the WAVE_MAPPER device.\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
938 "As a result, the user selected volume level will\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
939 "not be used.");
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
940 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
941 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
942 else
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
943 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
944 sound_warning ("waveOutGetVolume failed to obtain the original\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
945 "volume level of the WAVE_MAPPER device.\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
946 "As a result, the user selected volume level will\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
947 "not be used.");
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
948 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
949 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
950 memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
951 memset (sz_ret_buf, 0, sizeof(sz_ret_buf));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
952 strcpy (sz_cmd_buf, "play GNUEmacs_PlaySound_Device wait");
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
953 mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
954 if (mci_error != 0)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
955 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
956 sound_warning ("The play mciSendString command failed to play the\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
957 "opened sound file.");
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
958 i_result = (int) mci_error;
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
959 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
960 memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
961 memset (sz_ret_buf, 0, sizeof(sz_ret_buf));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
962 strcpy (sz_cmd_buf, "close GNUEmacs_PlaySound_Device wait");
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
963 mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
964 if (b_reset_volume == TRUE)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
965 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
966 mm_result=waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume_org);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
967 if (mm_result != MMSYSERR_NOERROR)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
968 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
969 sound_warning ("waveOutSetVolume failed to reset the original volume\n"
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
970 "level of the WAVE_MAPPER device.");
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
971 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
972 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
973 return i_result;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
974 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
975
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
976 /* END: Windows specific functions */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
977
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
978 #endif /* WINDOWSNT */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
979
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
980 DEFUN ("play-sound-internal", Fplay_sound_internal, Splay_sound_internal, 1, 1, 0,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
981 doc: /* Play sound SOUND.
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
982
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
983 Internal use only, use `play-sound' instead.\n */)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
984 (sound)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
985 Lisp_Object sound;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
986 {
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
987 Lisp_Object attrs[SOUND_ATTR_SENTINEL];
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
988 int count = SPECPDL_INDEX ();
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
989
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
990 #ifndef WINDOWSNT
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
991 Lisp_Object file;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
992 struct gcpro gcpro1, gcpro2;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
993 struct sound_device sd;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
994 struct sound s;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
995 Lisp_Object args[2];
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
996 #else /* WINDOWSNT */
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
997 int len = 0;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
998 Lisp_Object lo_file = {0};
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
999 char * psz_file = NULL;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1000 unsigned long ui_volume_tmp = UINT_MAX;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1001 unsigned long ui_volume = UINT_MAX;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1002 int i_result = 0;
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1003 #endif /* WINDOWSNT */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1004
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1005 /* Parse the sound specification. Give up if it is invalid. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1006 if (!parse_sound (sound, attrs))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1007 error ("Invalid sound specification");
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1008
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1009 #ifndef WINDOWSNT
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1010 file = Qnil;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1011 GCPRO2 (sound, file);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1012 bzero (&sd, sizeof sd);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1013 bzero (&s, sizeof s);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1014 current_sound_device = &sd;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1015 current_sound = &s;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1016 record_unwind_protect (sound_cleanup, Qnil);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1017 s.header = (char *) alloca (MAX_SOUND_HEADER_BYTES);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1018
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1019 if (STRINGP (attrs[SOUND_FILE]))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1020 {
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1021 /* Open the sound file. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1022 s.fd = openp (Fcons (Vdata_directory, Qnil),
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1023 attrs[SOUND_FILE], Qnil, &file, Qnil);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1024 if (s.fd < 0)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1025 sound_perror ("Could not open sound file");
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1026
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1027 /* Read the first bytes from the file. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1028 s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1029 if (s.header_size < 0)
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1030 sound_perror ("Invalid sound file header");
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1031 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1032 else
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1033 {
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1034 s.data = attrs[SOUND_DATA];
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1035 s.header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (s.data));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1036 bcopy (SDATA (s.data), s.header, s.header_size);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1037 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1038
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1039 /* Find out the type of sound. Give up if we can't tell. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1040 find_sound_type (&s);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1041
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1042 /* Set up a device. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1043 if (STRINGP (attrs[SOUND_DEVICE]))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1044 {
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1045 int len = SCHARS (attrs[SOUND_DEVICE]);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1046 sd.file = (char *) alloca (len + 1);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1047 strcpy (sd.file, SDATA (attrs[SOUND_DEVICE]));
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1048 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1049
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1050 if (INTEGERP (attrs[SOUND_VOLUME]))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1051 sd.volume = XFASTINT (attrs[SOUND_VOLUME]);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1052 else if (FLOATP (attrs[SOUND_VOLUME]))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1053 sd.volume = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1054
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1055 args[0] = Qplay_sound_functions;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1056 args[1] = sound;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1057 Frun_hook_with_args (2, args);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1058
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1059 /* There is only one type of device we currently support, the VOX
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1060 sound driver. Set up the device interface functions for that
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1061 device. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1062 vox_init (&sd);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1063
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1064 /* Open the device. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1065 sd.open (&sd);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1066
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1067 /* Play the sound. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1068 s.play (&s, &sd);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1069
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1070 /* Close the input file, if any. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1071 if (!STRINGP (s.data))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1072 {
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1073 emacs_close (s.fd);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1074 s.fd = -1;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1075 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1076
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1077 /* Close the device. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1078 sd.close (&sd);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1079
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1080 /* Clean up. */
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1081 current_sound_device = NULL;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1082 current_sound = NULL;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1083 UNGCPRO;
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1084
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1085 #else /* WINDOWSNT */
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1086
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1087 lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil);
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1088 len = XSTRING (lo_file)->size;
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1089 psz_file = (char *) alloca (len + 1);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1090 strcpy (psz_file, XSTRING (lo_file)->data);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1091 if (INTEGERP (attrs[SOUND_VOLUME]))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1092 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1093 ui_volume_tmp = XFASTINT (attrs[SOUND_VOLUME]);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1094 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1095 else if (FLOATP (attrs[SOUND_VOLUME]))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1096 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1097 ui_volume_tmp = (unsigned long) XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100;
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1098 }
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1099 /*
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1100 Based on some experiments I have conducted, a value of 100 or less
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1101 for the sound volume is much too low. You cannot even hear it.
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1102 A value of UINT_MAX indicates that you wish for the sound to played
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1103 at the maximum possible volume. A value of UINT_MAX/2 plays the
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1104 sound at 50% maximum volume. Therefore the value passed to do_play_sound
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1105 (and thus to waveOutSetVolume) must be some fraction of UINT_MAX.
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1106 The following code adjusts the user specified volume level appropriately.
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1107 */
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1108 if ((ui_volume_tmp > 0) && (ui_volume_tmp <= 100))
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1109 {
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1110 ui_volume = ui_volume_tmp * (UINT_MAX / 100);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1111 }
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1112 i_result = do_play_sound (psz_file, ui_volume);
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1113
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1114 #endif /* WINDOWSNT */
48456
8f7ad3143e4b Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents: 48375
diff changeset
1115
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1116 unbind_to (count, Qnil);
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1117 return Qnil;
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46554
diff changeset
1118 }
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1119
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1120 /***********************************************************************
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1121 Initialization
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1122 ***********************************************************************/
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1123
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1124 void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1125 syms_of_sound ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1126 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1127 QCdevice = intern (":device");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1128 staticpro (&QCdevice);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1129 QCvolume = intern (":volume");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1130 staticpro (&QCvolume);
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1131 Qsound = intern ("sound");
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1132 staticpro (&Qsound);
25548
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
1133 Qplay_sound_functions = intern ("play-sound-functions");
df6548ca33fd (Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
1134 staticpro (&Qplay_sound_functions);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1135
44399
a399428859ff (Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents: 42754
diff changeset
1136 defsubr (&Splay_sound_internal);
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1137 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1138
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1139
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1140 void
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1141 init_sound ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1142 {
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1143 }
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1144
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1145 #endif /* HAVE_SOUND */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48456
diff changeset
1146
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48456
diff changeset
1147 /* arch-tag: dd850ad8-0433-4e2c-9cba-b7aeeccc0dbd
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48456
diff changeset
1148 (do not change this comment) */