Mercurial > emacs
annotate src/sound.c @ 109830:46f382b913d6
Merge from mainline.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Tue, 17 Aug 2010 22:47:11 +0000 |
parents | 470bed744331 |
children | 55c8c3ca3d48 |
rev | line source |
---|---|
25003 | 1 /* sound.c -- sound support. |
64770
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
2 Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, |
106815 | 3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
25003 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92704
diff
changeset
|
7 GNU Emacs is free software: you can redistribute it and/or modify |
25003 | 8 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92704
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92704
diff
changeset
|
10 (at your option) any later version. |
25003 | 11 |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92704
diff
changeset
|
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
25003 | 19 |
20 /* Written by Gerd Moellmann <gerd@gnu.org>. Tested with Luigi's | |
21 driver on FreeBSD 2.2.7 with a SoundBlaster 16. */ | |
22 | |
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
|
23 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
25 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
|
26 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
28 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
|
29 :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
|
30 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
|
31 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
|
32 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
34 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
|
35 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
|
36 */ |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 |
25003 | 38 #include <config.h> |
39 | |
40 #if defined HAVE_SOUND | |
41 | |
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
|
42 /* BEGIN: Common Includes */ |
25003 | 43 #include <fcntl.h> |
44 #include <unistd.h> | |
45 #include <sys/types.h> | |
46 #include <errno.h> | |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102551
diff
changeset
|
47 #include <setjmp.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 | 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 | 63 /* FreeBSD has machine/soundcard.h. Voxware sound driver docs mention |
64 sys/soundcard.h. So, let's try whatever's there. */ | |
65 | |
66 #ifdef HAVE_MACHINE_SOUNDCARD_H | |
67 #include <machine/soundcard.h> | |
68 #endif | |
69 #ifdef HAVE_SYS_SOUNDCARD_H | |
70 #include <sys/soundcard.h> | |
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 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
75 #ifdef HAVE_ALSA |
74775
62968fe3ddad
Include <alsa/asoundlib.h> if ALSA_SUBDIR_INCLUDE is
Jan Djärv <jan.h.d@swipnet.se>
parents:
74315
diff
changeset
|
76 #ifdef ALSA_SUBDIR_INCLUDE |
62968fe3ddad
Include <alsa/asoundlib.h> if ALSA_SUBDIR_INCLUDE is
Jan Djärv <jan.h.d@swipnet.se>
parents:
74315
diff
changeset
|
77 #include <alsa/asoundlib.h> |
62968fe3ddad
Include <alsa/asoundlib.h> if ALSA_SUBDIR_INCLUDE is
Jan Djärv <jan.h.d@swipnet.se>
parents:
74315
diff
changeset
|
78 #else |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
79 #include <asoundlib.h> |
74775
62968fe3ddad
Include <alsa/asoundlib.h> if ALSA_SUBDIR_INCLUDE is
Jan Djärv <jan.h.d@swipnet.se>
parents:
74315
diff
changeset
|
80 #endif /* ALSA_SUBDIR_INCLUDE */ |
62968fe3ddad
Include <alsa/asoundlib.h> if ALSA_SUBDIR_INCLUDE is
Jan Djärv <jan.h.d@swipnet.se>
parents:
74315
diff
changeset
|
81 #endif /* HAVE_ALSA */ |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
82 |
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
|
83 /* 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
|
84 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 #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
|
86 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
88 #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
|
89 #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
|
90 #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
|
91 #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
|
92 #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
|
93 #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
|
94 /* 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
|
95 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 #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
|
97 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
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 /* 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
|
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 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
|
103 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
|
104 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
|
105 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
107 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
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 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 }; |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 |
109516
68ca98ae70fb
Make building under stricter warning flags somewhat cleaner.
Juanma Barranquero <lekktu@gmail.com>
parents:
109480
diff
changeset
|
117 #ifdef HAVE_ALSA |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
118 static void alsa_sound_perror (const char *, int) NO_RETURN; |
109516
68ca98ae70fb
Make building under stricter warning flags somewhat cleaner.
Juanma Barranquero <lekktu@gmail.com>
parents:
109480
diff
changeset
|
119 #endif |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
120 static void sound_perror (const char *) NO_RETURN; |
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
121 static void sound_warning (const char *); |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
122 static int parse_sound (Lisp_Object, Lisp_Object *); |
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
|
123 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
124 /* 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
|
125 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
126 /* 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
|
127 #ifndef WINDOWSNT |
30079
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
128 |
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
129 #ifndef DEFAULT_SOUND_DEVICE |
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
130 #define DEFAULT_SOUND_DEVICE "/dev/dsp" |
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
131 #endif |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
132 #ifndef DEFAULT_ALSA_SOUND_DEVICE |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
133 #define DEFAULT_ALSA_SOUND_DEVICE "default" |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
134 #endif |
25003 | 135 |
136 | |
137 /* Structure forward declarations. */ | |
138 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
139 struct sound; |
25003 | 140 struct sound_device; |
141 | |
142 /* The file header of RIFF-WAVE files (*.wav). Files are always in | |
143 little-endian byte-order. */ | |
144 | |
145 struct wav_header | |
146 { | |
147 u_int32_t magic; | |
148 u_int32_t length; | |
149 u_int32_t chunk_type; | |
150 u_int32_t chunk_format; | |
151 u_int32_t chunk_length; | |
152 u_int16_t format; | |
153 u_int16_t channels; | |
154 u_int32_t sample_rate; | |
155 u_int32_t bytes_per_second; | |
156 u_int16_t sample_size; | |
157 u_int16_t precision; | |
158 u_int32_t chunk_data; | |
159 u_int32_t data_length; | |
160 }; | |
161 | |
162 /* The file header of Sun adio files (*.au). Files are always in | |
163 big-endian byte-order. */ | |
164 | |
165 struct au_header | |
166 { | |
167 /* ASCII ".snd" */ | |
168 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
|
169 |
25003 | 170 /* Offset of data part from start of file. Minimum value is 24. */ |
171 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
|
172 |
25003 | 173 /* Size of data part, 0xffffffff if unknown. */ |
174 u_int32_t data_size; | |
175 | |
176 /* Data encoding format. | |
177 1 8-bit ISDN u-law | |
178 2 8-bit linear PCM (REF-PCM) | |
179 3 16-bit linear PCM | |
180 4 24-bit linear PCM | |
181 5 32-bit linear PCM | |
182 6 32-bit IEEE floating-point | |
183 7 64-bit IEEE floating-point | |
184 23 8-bit u-law compressed using CCITT 0.721 ADPCM voice data | |
185 encoding scheme. */ | |
186 u_int32_t encoding; | |
187 | |
188 /* Number of samples per second. */ | |
189 u_int32_t sample_rate; | |
190 | |
191 /* Number of interleaved channels. */ | |
192 u_int32_t channels; | |
193 }; | |
194 | |
195 /* Maximum of all sound file headers sizes. */ | |
196 | |
197 #define MAX_SOUND_HEADER_BYTES \ | |
198 max (sizeof (struct wav_header), sizeof (struct au_header)) | |
199 | |
200 /* Interface structure for sound devices. */ | |
201 | |
202 struct sound_device | |
203 { | |
204 /* The name of the device or null meaning use a default device name. */ | |
205 char *file; | |
206 | |
207 /* File descriptor of the device. */ | |
208 int fd; | |
209 | |
210 /* Device-dependent format. */ | |
211 int format; | |
212 | |
213 /* Volume (0..100). Zero means unspecified. */ | |
214 int volume; | |
215 | |
216 /* Sample size. */ | |
217 int sample_size; | |
218 | |
219 /* Sample rate. */ | |
220 int sample_rate; | |
221 | |
222 /* Bytes per second. */ | |
223 int bps; | |
224 | |
225 /* 1 = mono, 2 = stereo, 0 = don't set. */ | |
226 int channels; | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
227 |
25003 | 228 /* Open device SD. */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
229 void (* open) (struct sound_device *sd); |
25003 | 230 |
231 /* Close device SD. */ | |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
232 void (* close) (struct sound_device *sd); |
25003 | 233 |
234 /* Configure SD accoring to device-dependent parameters. */ | |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
235 void (* configure) (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
|
236 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
237 /* Choose a device-dependent format for outputting sound S. */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
238 void (* choose_format) (struct sound_device *sd, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
239 struct sound *s); |
25003 | 240 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
241 /* Return a preferred data size in bytes to be sent to write (below) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
242 each time. 2048 is used if this is NULL. */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
243 int (* period_size) (struct sound_device *sd); |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
244 |
25003 | 245 /* Write NYBTES bytes from BUFFER to device SD. */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
246 void (* write) (struct sound_device *sd, const char *buffer, |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
247 int nbytes); |
25003 | 248 |
249 /* A place for devices to store additional data. */ | |
250 void *data; | |
251 }; | |
252 | |
253 /* An enumerator for each supported sound file type. */ | |
254 | |
255 enum sound_type | |
256 { | |
257 RIFF, | |
258 SUN_AUDIO | |
259 }; | |
260 | |
261 /* Interface structure for sound files. */ | |
262 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
263 struct sound |
25003 | 264 { |
265 /* The type of the file. */ | |
266 enum sound_type type; | |
267 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
268 /* File descriptor of a sound file. */ |
25003 | 269 int fd; |
270 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
271 /* 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
|
272 read from the start of a sound file. */ |
25003 | 273 char *header; |
274 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
275 /* 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
|
276 MAX_SOUND_HEADER_BYTES. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
277 int header_size; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
278 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
279 /* Sound data, if a string. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
280 Lisp_Object data; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
281 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
282 /* Play sound file S on device SD. */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
283 void (* play) (struct sound *s, struct sound_device *sd); |
25003 | 284 }; |
285 | |
44399
a399428859ff
(Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents:
42754
diff
changeset
|
286 /* These are set during `play-sound-internal' so that sound_cleanup has |
25003 | 287 access to them. */ |
288 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
289 struct sound_device *current_sound_device; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
290 struct sound *current_sound; |
25003 | 291 |
292 /* Function prototypes. */ | |
293 | |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
294 static void vox_open (struct sound_device *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
295 static void vox_configure (struct sound_device *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
296 static void vox_close (struct sound_device *sd); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
297 static void vox_choose_format (struct sound_device *, struct sound *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
298 static int vox_init (struct sound_device *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
299 static void vox_write (struct sound_device *, const char *, int); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
300 static void find_sound_type (struct sound *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
301 static u_int32_t le2hl (u_int32_t); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
302 static u_int16_t le2hs (u_int16_t); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
303 static u_int32_t be2hl (u_int32_t); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
304 static int wav_init (struct sound *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
305 static void wav_play (struct sound *, struct sound_device *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
306 static int au_init (struct sound *); |
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
307 static void au_play (struct sound *, struct sound_device *); |
25003 | 308 |
25722
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
309 #if 0 /* Currently not used. */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
310 static u_int16_t be2hs (u_int16_t); |
25722
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
311 #endif |
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
312 |
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
|
313 /* 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
|
314 #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
|
315 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
316 /* BEGIN: Windows Specific Definitions */ |
109100
2bc9a0c04c87
Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
317 static int do_play_sound (const char *, unsigned long); |
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
|
318 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
319 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
|
320 #endif /* WINDOWSNT */ |
25003 | 321 |
322 | |
323 /*********************************************************************** | |
324 General | |
325 ***********************************************************************/ | |
326 | |
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
|
327 /* 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
|
328 |
25003 | 329 /* Like perror, but signals an error. */ |
330 | |
331 static void | |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
332 sound_perror (const char *msg) |
25003 | 333 { |
40745
1622bfdfe454
(sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents:
40364
diff
changeset
|
334 int saved_errno = errno; |
1622bfdfe454
(sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents:
40364
diff
changeset
|
335 |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
336 turn_on_atimers (1); |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
337 #ifdef SIGIO |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
338 sigunblock (sigmask (SIGIO)); |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
339 #endif |
40745
1622bfdfe454
(sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents:
40364
diff
changeset
|
340 if (saved_errno != 0) |
1622bfdfe454
(sound_perror): Save errno from being clobbered.
Andreas Schwab <schwab@suse.de>
parents:
40364
diff
changeset
|
341 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
|
342 else |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
343 error ("%s", msg); |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
344 } |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
345 |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
346 |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
347 /* Display a warning message. */ |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
348 |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
349 static void |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
350 sound_warning (const char *msg) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
351 { |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
352 message (msg); |
25003 | 353 } |
354 | |
355 | |
356 /* Parse sound specification SOUND, and fill ATTRS with what is | |
357 found. Value is non-zero if SOUND Is a valid sound specification. | |
358 A valid sound specification is a list starting with the symbol | |
359 `sound'. The rest of the list is a property list which may | |
360 contain the following key/value pairs: | |
361 | |
362 - `:file FILE' | |
363 | |
364 FILE is the sound file to play. If it isn't an absolute name, | |
365 it's searched under `data-directory'. | |
366 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
367 - `:data DATA' |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
368 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
369 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
|
370 may be present, but not both. |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
371 |
25003 | 372 - `:device DEVICE' |
373 | |
374 DEVICE is the name of the device to play on, e.g. "/dev/dsp2". | |
375 If not specified, a default device is used. | |
376 | |
377 - `:volume VOL' | |
378 | |
25548
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
379 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
|
380 range [0, 1]. */ |
25003 | 381 |
382 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
383 parse_sound (Lisp_Object sound, Lisp_Object *attrs) |
25003 | 384 { |
385 /* SOUND must be a list starting with the symbol `sound'. */ | |
386 if (!CONSP (sound) || !EQ (XCAR (sound), Qsound)) | |
387 return 0; | |
388 | |
389 sound = XCDR (sound); | |
390 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
|
391 attrs[SOUND_DATA] = Fplist_get (sound, QCdata); |
25003 | 392 attrs[SOUND_DEVICE] = Fplist_get (sound, QCdevice); |
393 attrs[SOUND_VOLUME] = Fplist_get (sound, QCvolume); | |
394 | |
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
|
395 #ifndef WINDOWSNT |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
396 /* File name or data must be specified. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
397 if (!STRINGP (attrs[SOUND_FILE]) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
398 && !STRINGP (attrs[SOUND_DATA])) |
25003 | 399 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
|
400 #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
|
401 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
402 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
|
403 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
|
404 */ |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
405 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
|
406 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
407 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
|
408 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
409 #endif /* WINDOWSNT */ |
25003 | 410 |
411 /* Volume must be in the range 0..100 or unspecified. */ | |
412 if (!NILP (attrs[SOUND_VOLUME])) | |
413 { | |
25548
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
414 if (INTEGERP (attrs[SOUND_VOLUME])) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
415 { |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
416 if (XINT (attrs[SOUND_VOLUME]) < 0 |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
417 || XINT (attrs[SOUND_VOLUME]) > 100) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
418 return 0; |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
419 } |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
420 else if (FLOATP (attrs[SOUND_VOLUME])) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
421 { |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
422 if (XFLOAT_DATA (attrs[SOUND_VOLUME]) < 0 |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
423 || XFLOAT_DATA (attrs[SOUND_VOLUME]) > 1) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
424 return 0; |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
425 } |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
426 else |
25003 | 427 return 0; |
428 } | |
429 | |
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
|
430 #ifndef WINDOWSNT |
25003 | 431 /* Device must be a string or unspecified. */ |
432 if (!NILP (attrs[SOUND_DEVICE]) | |
433 && !STRINGP (attrs[SOUND_DEVICE])) | |
434 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
|
435 #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
|
436 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
437 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
|
438 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
|
439 */ |
25003 | 440 return 1; |
441 } | |
442 | |
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
|
443 /* 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
|
444 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
445 /* 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
|
446 #ifndef WINDOWSNT |
25003 | 447 |
448 /* 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
|
449 S is the sound file structure to fill in. */ |
25003 | 450 |
451 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
452 find_sound_type (struct sound *s) |
25003 | 453 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
454 if (!wav_init (s) && !au_init (s)) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
455 error ("Unknown sound format"); |
25003 | 456 } |
457 | |
458 | |
44399
a399428859ff
(Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents:
42754
diff
changeset
|
459 /* Function installed by play-sound-internal with record_unwind_protect. */ |
25003 | 460 |
461 static Lisp_Object | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
462 sound_cleanup (Lisp_Object arg) |
25003 | 463 { |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
464 if (current_sound_device->close) |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
465 current_sound_device->close (current_sound_device); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
466 if (current_sound->fd > 0) |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
467 emacs_close (current_sound->fd); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
468 free (current_sound_device); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
469 free (current_sound); |
34255
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
470 |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
471 return Qnil; |
25003 | 472 } |
473 | |
474 /*********************************************************************** | |
475 Byte-order Conversion | |
476 ***********************************************************************/ | |
477 | |
478 /* Convert 32-bit value VALUE which is in little-endian byte-order | |
479 to host byte-order. */ | |
480 | |
481 static u_int32_t | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
482 le2hl (u_int32_t value) |
25003 | 483 { |
109732
470bed744331
Use autoconf determined WORDS_BIGENDIAN instead of hardcoded definition.
Andreas Schwab <schwab@linux-m68k.org>
parents:
109726
diff
changeset
|
484 #ifdef WORDS_BIGENDIAN |
25003 | 485 unsigned char *p = (unsigned char *) &value; |
486 value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24); | |
487 #endif | |
488 return value; | |
489 } | |
490 | |
491 | |
492 /* Convert 16-bit value VALUE which is in little-endian byte-order | |
493 to host byte-order. */ | |
494 | |
495 static u_int16_t | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
496 le2hs (u_int16_t value) |
25003 | 497 { |
109732
470bed744331
Use autoconf determined WORDS_BIGENDIAN instead of hardcoded definition.
Andreas Schwab <schwab@linux-m68k.org>
parents:
109726
diff
changeset
|
498 #ifdef WORDS_BIGENDIAN |
25003 | 499 unsigned char *p = (unsigned char *) &value; |
500 value = p[0] + (p[1] << 8); | |
501 #endif | |
502 return value; | |
503 } | |
504 | |
505 | |
506 /* Convert 32-bit value VALUE which is in big-endian byte-order | |
507 to host byte-order. */ | |
508 | |
509 static u_int32_t | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
510 be2hl (u_int32_t value) |
25003 | 511 { |
109732
470bed744331
Use autoconf determined WORDS_BIGENDIAN instead of hardcoded definition.
Andreas Schwab <schwab@linux-m68k.org>
parents:
109726
diff
changeset
|
512 #ifndef WORDS_BIGENDIAN |
25003 | 513 unsigned char *p = (unsigned char *) &value; |
514 value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24); | |
515 #endif | |
516 return value; | |
517 } | |
518 | |
519 | |
25722
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
520 #if 0 /* Currently not used. */ |
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
521 |
25003 | 522 /* Convert 16-bit value VALUE which is in big-endian byte-order |
523 to host byte-order. */ | |
524 | |
525 static u_int16_t | |
109480
d12162869c07
Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109179
diff
changeset
|
526 be2hs (u_int16_t value) |
25003 | 527 { |
109732
470bed744331
Use autoconf determined WORDS_BIGENDIAN instead of hardcoded definition.
Andreas Schwab <schwab@linux-m68k.org>
parents:
109726
diff
changeset
|
528 #ifndef WORDS_BIGENDIAN |
25003 | 529 unsigned char *p = (unsigned char *) &value; |
530 value = p[1] + (p[0] << 8); | |
531 #endif | |
532 return value; | |
533 } | |
534 | |
25722
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
535 #endif /* 0 */ |
25003 | 536 |
537 /*********************************************************************** | |
538 RIFF-WAVE (*.wav) | |
539 ***********************************************************************/ | |
540 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
541 /* Try to initialize sound file S from S->header. S->header |
25003 | 542 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the |
543 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
|
544 functions in S and convert header fields to host byte-order. |
25003 | 545 Value is non-zero if the file is a WAV file. */ |
546 | |
547 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
548 wav_init (struct sound *s) |
25003 | 549 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
550 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
|
551 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
552 if (s->header_size < sizeof *header |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109126
diff
changeset
|
553 || memcmp (s->header, "RIFF", 4) != 0) |
25003 | 554 return 0; |
555 | |
556 /* WAV files are in little-endian order. Convert the header | |
557 if on a big-endian machine. */ | |
558 header->magic = le2hl (header->magic); | |
559 header->length = le2hl (header->length); | |
560 header->chunk_type = le2hl (header->chunk_type); | |
561 header->chunk_format = le2hl (header->chunk_format); | |
562 header->chunk_length = le2hl (header->chunk_length); | |
563 header->format = le2hs (header->format); | |
564 header->channels = le2hs (header->channels); | |
565 header->sample_rate = le2hl (header->sample_rate); | |
566 header->bytes_per_second = le2hl (header->bytes_per_second); | |
567 header->sample_size = le2hs (header->sample_size); | |
568 header->precision = le2hs (header->precision); | |
569 header->chunk_data = le2hl (header->chunk_data); | |
570 header->data_length = le2hl (header->data_length); | |
571 | |
572 /* 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
|
573 s->type = RIFF; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
574 s->play = wav_play; |
25003 | 575 |
576 return 1; | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
577 } |
25003 | 578 |
579 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
580 /* Play RIFF-WAVE audio file S on sound device SD. */ |
25003 | 581 |
582 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
583 wav_play (struct sound *s, struct sound_device *sd) |
25003 | 584 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
585 struct wav_header *header = (struct wav_header *) s->header; |
25003 | 586 |
587 /* Let the device choose a suitable device-dependent format | |
588 for the file. */ | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
589 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
|
590 |
25003 | 591 /* Configure the device. */ |
592 sd->sample_size = header->sample_size; | |
593 sd->sample_rate = header->sample_rate; | |
594 sd->bps = header->bytes_per_second; | |
595 sd->channels = header->channels; | |
596 sd->configure (sd); | |
597 | |
598 /* Copy sound data to the device. The WAV file specification is | |
599 actually more complex. This simple scheme worked with all WAV | |
600 files I found so far. If someone feels inclined to implement the | |
601 whole RIFF-WAVE spec, please do. */ | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
602 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
|
603 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
|
604 SBYTES (s->data) - sizeof *header); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
605 else |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
606 { |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
607 char *buffer; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
608 int nbytes; |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
609 int blksize = sd->period_size ? sd->period_size (sd) : 2048; |
76364
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
610 int data_left = header->data_length; |
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 buffer = (char *) alloca (blksize); |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
613 lseek (s->fd, sizeof *header, SEEK_SET); |
76364
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
614 while (data_left > 0 |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
615 && (nbytes = emacs_read (s->fd, buffer, blksize)) > 0) |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
616 { |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
617 /* Don't play possible garbage at the end of file */ |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
618 if (data_left < nbytes) nbytes = data_left; |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
619 data_left -= nbytes; |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
620 sd->write (sd, buffer, nbytes); |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
621 } |
25003 | 622 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
623 if (nbytes < 0) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
624 sound_perror ("Error reading sound file"); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
625 } |
25003 | 626 } |
627 | |
628 | |
629 /*********************************************************************** | |
630 Sun Audio (*.au) | |
631 ***********************************************************************/ | |
632 | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
633 /* Sun audio file encodings. */ |
25003 | 634 |
635 enum au_encoding | |
636 { | |
637 AU_ENCODING_ULAW_8 = 1, | |
638 AU_ENCODING_8, | |
639 AU_ENCODING_16, | |
640 AU_ENCODING_24, | |
641 AU_ENCODING_32, | |
642 AU_ENCODING_IEEE32, | |
643 AU_ENCODING_IEEE64, | |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
644 AU_COMPRESSED = 23, |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
645 AU_ENCODING_ALAW_8 = 27 |
25003 | 646 }; |
647 | |
648 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
649 /* Try to initialize sound file S from S->header. S->header |
25003 | 650 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the |
651 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
|
652 functions in S and convert header fields to host byte-order. |
25003 | 653 Value is non-zero if the file is an AU file. */ |
654 | |
655 static int | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
656 au_init (struct sound *s) |
25003 | 657 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
658 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
|
659 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
660 if (s->header_size < sizeof *header |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109126
diff
changeset
|
661 || memcmp (s->header, ".snd", 4) != 0) |
25003 | 662 return 0; |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
663 |
25003 | 664 header->magic_number = be2hl (header->magic_number); |
665 header->data_offset = be2hl (header->data_offset); | |
666 header->data_size = be2hl (header->data_size); | |
667 header->encoding = be2hl (header->encoding); | |
668 header->sample_rate = be2hl (header->sample_rate); | |
669 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
|
670 |
25003 | 671 /* 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
|
672 s->type = SUN_AUDIO; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
673 s->play = au_play; |
25003 | 674 |
675 return 1; | |
676 } | |
677 | |
678 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
679 /* Play Sun audio file S on sound device SD. */ |
25003 | 680 |
681 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
682 au_play (struct sound *s, struct sound_device *sd) |
25003 | 683 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
684 struct au_header *header = (struct au_header *) s->header; |
25003 | 685 |
686 sd->sample_size = 0; | |
687 sd->sample_rate = header->sample_rate; | |
688 sd->bps = 0; | |
689 sd->channels = header->channels; | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
690 sd->choose_format (sd, s); |
25003 | 691 sd->configure (sd); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
692 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
693 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
|
694 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
|
695 SBYTES (s->data) - header->data_offset); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
696 else |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
697 { |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
698 int blksize = sd->period_size ? sd->period_size (sd) : 2048; |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
699 char *buffer; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
700 int nbytes; |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
701 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
702 /* Seek */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
703 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
|
704 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
705 /* Copy sound data to the device. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
706 buffer = (char *) alloca (blksize); |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
707 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
|
708 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
|
709 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
710 if (nbytes < 0) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
711 sound_perror ("Error reading sound file"); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
712 } |
25003 | 713 } |
714 | |
715 | |
716 /*********************************************************************** | |
717 Voxware Driver Interface | |
718 ***********************************************************************/ | |
719 | |
720 /* This driver is available on GNU/Linux, and the free BSDs. FreeBSD | |
721 has a compatible own driver aka Luigi's driver. */ | |
722 | |
723 | |
724 /* Open device SD. If SD->file is non-null, open that device, | |
725 otherwise use a default device name. */ | |
726 | |
727 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
728 vox_open (struct sound_device *sd) |
25003 | 729 { |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
730 const char *file; |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
731 |
25003 | 732 /* Open the sound device. Default is /dev/dsp. */ |
733 if (sd->file) | |
734 file = sd->file; | |
735 else | |
30079
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
736 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
|
737 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25722
diff
changeset
|
738 sd->fd = emacs_open (file, O_WRONLY, 0); |
25003 | 739 if (sd->fd < 0) |
740 sound_perror (file); | |
741 } | |
742 | |
743 | |
744 /* Configure device SD from parameters in it. */ | |
745 | |
746 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
747 vox_configure (struct sound_device *sd) |
25003 | 748 { |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
749 int val; |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
750 |
25003 | 751 xassert (sd->fd >= 0); |
752 | |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
753 /* 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
|
754 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
|
755 troubles. */ |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
756 turn_on_atimers (0); |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
757 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
758 sigblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
759 #endif |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
760 |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
761 val = sd->format; |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
762 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
|
763 || val != sd->format) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
764 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
|
765 |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
766 val = sd->channels != 1; |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
767 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
|
768 || val != (sd->channels != 1)) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
769 sound_perror ("Could not set stereo/mono"); |
25003 | 770 |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
771 /* 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
|
772 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
|
773 if (sd->sample_rate > 0) |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
774 { |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
775 val = sd->sample_rate; |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
776 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
|
777 sound_perror ("Could not set sound speed"); |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
778 else if (val != sd->sample_rate) |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
779 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
|
780 } |
25003 | 781 |
34255
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
782 if (sd->volume > 0) |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
783 { |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
784 int volume = sd->volume & 0xff; |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
785 volume |= volume << 8; |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
786 /* 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
|
787 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
|
788 } |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
789 |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
790 turn_on_atimers (1); |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
791 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
792 sigunblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
793 #endif |
25003 | 794 } |
795 | |
796 | |
797 /* Close device SD if it is open. */ | |
798 | |
799 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
800 vox_close (struct sound_device *sd) |
25003 | 801 { |
802 if (sd->fd >= 0) | |
803 { | |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
804 /* 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
|
805 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
|
806 troubles. */ |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
807 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
808 sigblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
809 #endif |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
810 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
|
811 |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
812 /* Flush sound data, and reset the device. */ |
25003 | 813 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
|
814 |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
815 turn_on_atimers (1); |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
816 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
817 sigunblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
818 #endif |
25003 | 819 |
820 /* 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
|
821 emacs_close (sd->fd); |
25003 | 822 sd->fd = -1; |
823 } | |
824 } | |
825 | |
826 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
827 /* Choose device-dependent format for device SD from sound file S. */ |
25003 | 828 |
829 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
830 vox_choose_format (struct sound_device *sd, struct sound *s) |
25003 | 831 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
832 if (s->type == RIFF) |
25003 | 833 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
834 struct wav_header *h = (struct wav_header *) s->header; |
25003 | 835 if (h->precision == 8) |
836 sd->format = AFMT_U8; | |
837 else if (h->precision == 16) | |
838 sd->format = AFMT_S16_LE; | |
839 else | |
840 error ("Unsupported WAV file format"); | |
841 } | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
842 else if (s->type == SUN_AUDIO) |
25003 | 843 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
844 struct au_header *header = (struct au_header *) s->header; |
25003 | 845 switch (header->encoding) |
846 { | |
847 case AU_ENCODING_ULAW_8: | |
848 case AU_ENCODING_IEEE32: | |
849 case AU_ENCODING_IEEE64: | |
850 sd->format = AFMT_MU_LAW; | |
851 break; | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
852 |
25003 | 853 case AU_ENCODING_8: |
854 case AU_ENCODING_16: | |
855 case AU_ENCODING_24: | |
856 case AU_ENCODING_32: | |
857 sd->format = AFMT_S16_LE; | |
858 break; | |
859 | |
860 default: | |
861 error ("Unsupported AU file format"); | |
862 } | |
863 } | |
864 else | |
865 abort (); | |
866 } | |
867 | |
868 | |
869 /* Initialize device SD. Set up the interface functions in the device | |
870 structure. */ | |
871 | |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
872 static int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
873 vox_init (struct sound_device *sd) |
25003 | 874 { |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
875 const char *file; |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
876 int fd; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
877 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
878 /* Open the sound device. Default is /dev/dsp. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
879 if (sd->file) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
880 file = sd->file; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
881 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
882 file = DEFAULT_SOUND_DEVICE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
883 fd = emacs_open (file, O_WRONLY, 0); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
884 if (fd >= 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
885 emacs_close (fd); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
886 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
887 return 0; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
888 |
25003 | 889 sd->fd = -1; |
890 sd->open = vox_open; | |
891 sd->close = vox_close; | |
892 sd->configure = vox_configure; | |
893 sd->choose_format = vox_choose_format; | |
894 sd->write = vox_write; | |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
895 sd->period_size = NULL; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
896 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
897 return 1; |
25003 | 898 } |
899 | |
900 /* Write NBYTES bytes from BUFFER to device SD. */ | |
901 | |
902 static void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
903 vox_write (struct sound_device *sd, const char *buffer, int nbytes) |
25003 | 904 { |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25722
diff
changeset
|
905 int nwritten = emacs_write (sd->fd, buffer, nbytes); |
25003 | 906 if (nwritten < 0) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
907 sound_perror ("Error writing to sound device"); |
25003 | 908 } |
909 | |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
910 #ifdef HAVE_ALSA |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
911 /*********************************************************************** |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
912 ALSA Driver Interface |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
913 ***********************************************************************/ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
914 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
915 /* This driver is available on GNU/Linux. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
916 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
917 static void |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
918 alsa_sound_perror (const char *msg, int err) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
919 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
920 error ("%s: %s", msg, snd_strerror (err)); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
921 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
922 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
923 struct alsa_params |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
924 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
925 snd_pcm_t *handle; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
926 snd_pcm_hw_params_t *hwparams; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
927 snd_pcm_sw_params_t *swparams; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
928 snd_pcm_uframes_t period_size; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
929 }; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
930 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
931 /* Open device SD. If SD->file is non-null, open that device, |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
932 otherwise use a default device name. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
933 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
934 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
935 alsa_open (struct sound_device *sd) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
936 { |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
937 const char *file; |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
938 struct alsa_params *p; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
939 int err; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
940 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
941 /* Open the sound device. Default is "default". */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
942 if (sd->file) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
943 file = sd->file; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
944 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
945 file = DEFAULT_ALSA_SOUND_DEVICE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
946 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
947 p = xmalloc (sizeof (*p)); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
948 p->handle = NULL; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
949 p->hwparams = NULL; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
950 p->swparams = NULL; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
951 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
952 sd->fd = -1; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
953 sd->data = p; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
954 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
955 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
956 err = snd_pcm_open (&p->handle, file, SND_PCM_STREAM_PLAYBACK, 0); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
957 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
958 alsa_sound_perror (file, err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
959 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
960 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
961 static int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
962 alsa_period_size (struct sound_device *sd) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
963 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
964 struct alsa_params *p = (struct alsa_params *) sd->data; |
76364
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
965 int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
966 return p->period_size * (fact > 0 ? fact : 1); |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
967 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
968 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
969 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
970 alsa_configure (struct sound_device *sd) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
971 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
972 int val, err, dir; |
71892
248ccc534803
* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71063
diff
changeset
|
973 unsigned uval; |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
974 struct alsa_params *p = (struct alsa_params *) sd->data; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
975 snd_pcm_uframes_t buffer_size; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
976 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
977 xassert (p->handle != 0); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
978 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
979 err = snd_pcm_hw_params_malloc (&p->hwparams); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
980 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
981 alsa_sound_perror ("Could not allocate hardware parameter structure", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
982 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
983 err = snd_pcm_sw_params_malloc (&p->swparams); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
984 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
985 alsa_sound_perror ("Could not allocate software parameter structure", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
986 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
987 err = snd_pcm_hw_params_any (p->handle, p->hwparams); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
988 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
989 alsa_sound_perror ("Could not initialize hardware parameter structure", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
990 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
991 err = snd_pcm_hw_params_set_access (p->handle, p->hwparams, |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
992 SND_PCM_ACCESS_RW_INTERLEAVED); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
993 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
994 alsa_sound_perror ("Could not set access type", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
995 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
996 val = sd->format; |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
997 err = snd_pcm_hw_params_set_format (p->handle, p->hwparams, val); |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
998 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
999 alsa_sound_perror ("Could not set sound format", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1000 |
71892
248ccc534803
* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71063
diff
changeset
|
1001 uval = sd->sample_rate; |
248ccc534803
* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71063
diff
changeset
|
1002 err = snd_pcm_hw_params_set_rate_near (p->handle, p->hwparams, &uval, 0); |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1003 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1004 alsa_sound_perror ("Could not set sample rate", err); |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1005 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1006 val = sd->channels; |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1007 err = snd_pcm_hw_params_set_channels (p->handle, p->hwparams, val); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1008 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1009 alsa_sound_perror ("Could not set channel count", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1010 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1011 err = snd_pcm_hw_params (p->handle, p->hwparams); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1012 if (err < 0) |
70955
d42f132da9a8
* sound.c (alsa_configure): Move get period/buffer_size after
Jan Djärv <jan.h.d@swipnet.se>
parents:
70718
diff
changeset
|
1013 alsa_sound_perror ("Could not set parameters", err); |
d42f132da9a8
* sound.c (alsa_configure): Move get period/buffer_size after
Jan Djärv <jan.h.d@swipnet.se>
parents:
70718
diff
changeset
|
1014 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1015 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1016 err = snd_pcm_hw_params_get_period_size (p->hwparams, &p->period_size, &dir); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1017 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1018 alsa_sound_perror ("Unable to get period size for playback", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1019 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1020 err = snd_pcm_hw_params_get_buffer_size (p->hwparams, &buffer_size); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1021 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1022 alsa_sound_perror("Unable to get buffer size for playback", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1023 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1024 err = snd_pcm_sw_params_current (p->handle, p->swparams); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1025 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1026 alsa_sound_perror ("Unable to determine current swparams for playback", |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1027 err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1028 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1029 /* Start the transfer when the buffer is almost full */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1030 err = snd_pcm_sw_params_set_start_threshold (p->handle, p->swparams, |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1031 (buffer_size / p->period_size) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1032 * p->period_size); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1033 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1034 alsa_sound_perror ("Unable to set start threshold mode for playback", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1035 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1036 /* Allow the transfer when at least period_size samples can be processed */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1037 err = snd_pcm_sw_params_set_avail_min (p->handle, p->swparams, p->period_size); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1038 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1039 alsa_sound_perror ("Unable to set avail min for playback", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1040 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1041 err = snd_pcm_sw_params (p->handle, p->swparams); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1042 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1043 alsa_sound_perror ("Unable to set sw params for playback\n", err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1044 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1045 snd_pcm_hw_params_free (p->hwparams); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1046 p->hwparams = NULL; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1047 snd_pcm_sw_params_free (p->swparams); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1048 p->swparams = NULL; |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1049 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1050 err = snd_pcm_prepare (p->handle); |
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1051 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1052 alsa_sound_perror ("Could not prepare audio interface for use", err); |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1053 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1054 if (sd->volume > 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1055 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1056 int chn; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1057 snd_mixer_t *handle; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1058 snd_mixer_elem_t *e; |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
1059 const char *file = sd->file ? sd->file : DEFAULT_ALSA_SOUND_DEVICE; |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1060 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1061 if (snd_mixer_open (&handle, 0) >= 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1062 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1063 if (snd_mixer_attach (handle, file) >= 0 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1064 && snd_mixer_load (handle) >= 0 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1065 && snd_mixer_selem_register (handle, NULL, NULL) >= 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1066 for (e = snd_mixer_first_elem (handle); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1067 e; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1068 e = snd_mixer_elem_next (e)) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1069 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1070 if (snd_mixer_selem_has_playback_volume (e)) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1071 { |
92704
22bce4d93530
(alsa_configure): Declare vol at beginning of block.
Jan Djärv <jan.h.d@swipnet.se>
parents:
87649
diff
changeset
|
1072 long pmin, pmax, vol; |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1073 snd_mixer_selem_get_playback_volume_range (e, &pmin, &pmax); |
92704
22bce4d93530
(alsa_configure): Declare vol at beginning of block.
Jan Djärv <jan.h.d@swipnet.se>
parents:
87649
diff
changeset
|
1074 vol = pmin + (sd->volume * (pmax - pmin)) / 100; |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1075 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1076 for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1077 snd_mixer_selem_set_playback_volume (e, chn, vol); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1078 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1079 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1080 snd_mixer_close(handle); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1081 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1082 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1083 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1084 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1085 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1086 /* Close device SD if it is open. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1087 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1088 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1089 alsa_close (struct sound_device *sd) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1090 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1091 struct alsa_params *p = (struct alsa_params *) sd->data; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1092 if (p) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1093 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1094 if (p->hwparams) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1095 snd_pcm_hw_params_free (p->hwparams); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1096 if (p->swparams) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1097 snd_pcm_sw_params_free (p->swparams); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1098 if (p->handle) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1099 { |
71892
248ccc534803
* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71063
diff
changeset
|
1100 snd_pcm_drain (p->handle); |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1101 snd_pcm_close (p->handle); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1102 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1103 free (p); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1104 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1105 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1106 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1107 /* Choose device-dependent format for device SD from sound file S. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1108 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1109 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1110 alsa_choose_format (struct sound_device *sd, struct sound *s) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1111 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1112 struct alsa_params *p = (struct alsa_params *) sd->data; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1113 if (s->type == RIFF) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1114 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1115 struct wav_header *h = (struct wav_header *) s->header; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1116 if (h->precision == 8) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1117 sd->format = SND_PCM_FORMAT_U8; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1118 else if (h->precision == 16) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1119 sd->format = SND_PCM_FORMAT_S16_LE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1120 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1121 error ("Unsupported WAV file format"); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1122 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1123 else if (s->type == SUN_AUDIO) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1124 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1125 struct au_header *header = (struct au_header *) s->header; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1126 switch (header->encoding) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1127 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1128 case AU_ENCODING_ULAW_8: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1129 sd->format = SND_PCM_FORMAT_MU_LAW; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1130 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1131 case AU_ENCODING_ALAW_8: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1132 sd->format = SND_PCM_FORMAT_A_LAW; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1133 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1134 case AU_ENCODING_IEEE32: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1135 sd->format = SND_PCM_FORMAT_FLOAT_BE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1136 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1137 case AU_ENCODING_IEEE64: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1138 sd->format = SND_PCM_FORMAT_FLOAT64_BE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1139 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1140 case AU_ENCODING_8: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1141 sd->format = SND_PCM_FORMAT_S8; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1142 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1143 case AU_ENCODING_16: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1144 sd->format = SND_PCM_FORMAT_S16_BE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1145 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1146 case AU_ENCODING_24: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1147 sd->format = SND_PCM_FORMAT_S24_BE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1148 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1149 case AU_ENCODING_32: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1150 sd->format = SND_PCM_FORMAT_S32_BE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1151 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1152 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1153 default: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1154 error ("Unsupported AU file format"); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1155 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1156 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1157 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1158 abort (); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1159 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1160 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1161 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1162 /* Write NBYTES bytes from BUFFER to device SD. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1163 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1164 static void |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1165 alsa_write (struct sound_device *sd, const char *buffer, int nbytes) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1166 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1167 struct alsa_params *p = (struct alsa_params *) sd->data; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1168 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1169 /* The the third parameter to snd_pcm_writei is frames, not bytes. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1170 int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1171 int nwritten = 0; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1172 int err; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1173 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1174 while (nwritten < nbytes) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1175 { |
76364
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
1176 snd_pcm_uframes_t frames = (nbytes - nwritten)/fact; |
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
1177 if (frames == 0) break; |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1178 |
76364
ebfc3239385f
* sound.c (wav_play): Check header->data_length to see how much we
Jan Djärv <jan.h.d@swipnet.se>
parents:
75348
diff
changeset
|
1179 err = snd_pcm_writei (p->handle, buffer + nwritten, frames); |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1180 if (err < 0) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1181 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1182 if (err == -EPIPE) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1183 { /* under-run */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1184 err = snd_pcm_prepare (p->handle); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1185 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1186 alsa_sound_perror ("Can't recover from underrun, prepare failed", |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1187 err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1188 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1189 else if (err == -ESTRPIPE) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1190 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1191 while ((err = snd_pcm_resume (p->handle)) == -EAGAIN) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1192 sleep(1); /* wait until the suspend flag is released */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1193 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1194 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1195 err = snd_pcm_prepare (p->handle); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1196 if (err < 0) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1197 alsa_sound_perror ("Can't recover from suspend, " |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1198 "prepare failed", |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1199 err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1200 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1201 } |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1202 else |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1203 alsa_sound_perror ("Error writing to sound device", err); |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1204 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1205 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1206 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1207 nwritten += err * fact; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1208 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1209 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1210 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1211 static void |
109480
d12162869c07
Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109179
diff
changeset
|
1212 snd_error_quiet (const char *file, int line, const char *function, int err, |
d12162869c07
Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109179
diff
changeset
|
1213 const char *fmt) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1214 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1215 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1216 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1217 /* Initialize device SD. Set up the interface functions in the device |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1218 structure. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1219 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1220 static int |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1221 alsa_init (struct sound_device *sd) |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1222 { |
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109637
diff
changeset
|
1223 const char *file; |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1224 snd_pcm_t *handle; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1225 int err; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1226 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1227 /* Open the sound device. Default is "default". */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1228 if (sd->file) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1229 file = sd->file; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1230 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1231 file = DEFAULT_ALSA_SOUND_DEVICE; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1232 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1233 snd_lib_error_set_handler ((snd_lib_error_handler_t) snd_error_quiet); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1234 err = snd_pcm_open (&handle, file, SND_PCM_STREAM_PLAYBACK, 0); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1235 snd_lib_error_set_handler (NULL); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1236 if (err < 0) |
71892
248ccc534803
* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71063
diff
changeset
|
1237 return 0; |
248ccc534803
* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71063
diff
changeset
|
1238 snd_pcm_close (handle); |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1239 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1240 sd->fd = -1; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1241 sd->open = alsa_open; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1242 sd->close = alsa_close; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1243 sd->configure = alsa_configure; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1244 sd->choose_format = alsa_choose_format; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1245 sd->write = alsa_write; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1246 sd->period_size = alsa_period_size; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1247 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1248 return 1; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1249 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1250 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1251 #endif /* HAVE_ALSA */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1252 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1253 |
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
|
1254 /* 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
|
1255 #else /* WINDOWSNT */ |
25003 | 1256 |
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
|
1257 /* 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
|
1258 |
101215
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1259 #define SOUND_WARNING(fun, error, text) \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1260 { \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1261 char buf[1024]; \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1262 char err_string[MAXERRORLENGTH]; \ |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1263 fun (error, err_string, sizeof (err_string)); \ |
101215
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1264 _snprintf (buf, sizeof (buf), "%s\nError: %s", \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1265 text, err_string); \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1266 sound_warning (buf); \ |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1267 } |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1268 |
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
|
1269 static int |
109480
d12162869c07
Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
109179
diff
changeset
|
1270 do_play_sound (const char *psz_file, 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
|
1271 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1272 int i_result = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1273 MCIERROR mci_error = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1274 char sz_cmd_buf[520] = {0}; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1275 char sz_ret_buf[520] = {0}; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1276 MMRESULT mm_result = MMSYSERR_NOERROR; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1277 unsigned long ui_volume_org = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1278 BOOL b_reset_volume = FALSE; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1279 |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1280 memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf)); |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1281 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
|
1282 sprintf (sz_cmd_buf, |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1283 "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
|
1284 psz_file); |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1285 mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), 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
|
1286 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
|
1287 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1288 SOUND_WARNING (mciGetErrorString, mci_error, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1289 "The open mciSendString command failed to open " |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1290 "the specified sound file."); |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1291 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
|
1292 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
|
1293 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1294 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
|
1295 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1296 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
|
1297 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
|
1298 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1299 b_reset_volume = TRUE; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1300 mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume); |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1301 if (mm_result != MMSYSERR_NOERROR) |
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
|
1302 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1303 SOUND_WARNING (waveOutGetErrorText, mm_result, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1304 "waveOutSetVolume failed to set the volume level " |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1305 "of the WAVE_MAPPER device.\n" |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1306 "As a result, the user selected volume level will " |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1307 "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
|
1308 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1309 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1310 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
|
1311 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1312 SOUND_WARNING (waveOutGetErrorText, mm_result, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1313 "waveOutGetVolume failed to obtain the original " |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1314 "volume level of the WAVE_MAPPER device.\n" |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1315 "As a result, the user selected volume level will " |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1316 "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
|
1317 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1318 } |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1319 memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf)); |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1320 memset (sz_ret_buf, 0, sizeof (sz_ret_buf)); |
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
|
1321 strcpy (sz_cmd_buf, "play GNUEmacs_PlaySound_Device wait"); |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1322 mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), 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
|
1323 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
|
1324 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1325 SOUND_WARNING (mciGetErrorString, mci_error, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1326 "The play mciSendString command failed to play the " |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1327 "opened sound file."); |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1328 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
|
1329 } |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1330 memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf)); |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1331 memset (sz_ret_buf, 0, sizeof (sz_ret_buf)); |
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
|
1332 strcpy (sz_cmd_buf, "close GNUEmacs_PlaySound_Device wait"); |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1333 mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), 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
|
1334 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
|
1335 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1336 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
|
1337 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
|
1338 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1339 SOUND_WARNING (waveOutGetErrorText, mm_result, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1340 "waveOutSetVolume failed to reset the original volume " |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1341 "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
|
1342 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1343 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1344 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
|
1345 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1346 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1347 /* 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
|
1348 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1349 #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
|
1350 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1351 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
|
1352 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
|
1353 |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1354 Internal use only, use `play-sound' instead. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
1355 (Lisp_Object sound) |
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
|
1356 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1357 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
|
1358 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
|
1359 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1360 #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
|
1361 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
|
1362 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
|
1363 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
|
1364 #else /* WINDOWSNT */ |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1365 int len = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1366 Lisp_Object lo_file = {0}; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1367 char * psz_file = NULL; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1368 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
|
1369 unsigned long ui_volume = UINT_MAX; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1370 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
|
1371 #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
|
1372 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1373 /* 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
|
1374 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
|
1375 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
|
1376 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1377 #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
|
1378 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
|
1379 GCPRO2 (sound, file); |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1380 current_sound_device = (struct sound_device *) xmalloc (sizeof (struct sound_device)); |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109126
diff
changeset
|
1381 memset (current_sound_device, 0, sizeof (struct sound_device)); |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1382 current_sound = (struct sound *) xmalloc (sizeof (struct sound)); |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109126
diff
changeset
|
1383 memset (current_sound, 0, sizeof (struct sound)); |
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
|
1384 record_unwind_protect (sound_cleanup, Qnil); |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1385 current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES); |
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
|
1386 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1387 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
|
1388 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1389 /* Open the sound file. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1390 current_sound->fd = openp (Fcons (Vdata_directory, Qnil), |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1391 attrs[SOUND_FILE], Qnil, &file, Qnil); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1392 if (current_sound->fd < 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
|
1393 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
|
1394 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1395 /* Read the first bytes from the file. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1396 current_sound->header_size |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1397 = emacs_read (current_sound->fd, current_sound->header, |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1398 MAX_SOUND_HEADER_BYTES); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1399 if (current_sound->header_size < 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
|
1400 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
|
1401 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1402 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
|
1403 { |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1404 current_sound->data = attrs[SOUND_DATA]; |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1405 current_sound->header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (current_sound->data)); |
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109126
diff
changeset
|
1406 memcpy (current_sound->header, SDATA (current_sound->data), |
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109126
diff
changeset
|
1407 current_sound->header_size); |
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
|
1408 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1409 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1410 /* Find out the type of sound. Give up if we can't tell. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1411 find_sound_type (current_sound); |
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
|
1412 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1413 /* 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
|
1414 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
|
1415 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1416 int len = SCHARS (attrs[SOUND_DEVICE]); |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1417 current_sound_device->file = (char *) alloca (len + 1); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1418 strcpy (current_sound_device->file, SDATA (attrs[SOUND_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
|
1419 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1420 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1421 if (INTEGERP (attrs[SOUND_VOLUME])) |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1422 current_sound_device->volume = 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
|
1423 else if (FLOATP (attrs[SOUND_VOLUME])) |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1424 current_sound_device->volume = 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
|
1425 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1426 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
|
1427 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
|
1428 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
|
1429 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1430 #ifdef HAVE_ALSA |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1431 if (!alsa_init (current_sound_device)) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1432 #endif |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1433 if (!vox_init (current_sound_device)) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1434 error ("No usable sound device driver found"); |
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
|
1435 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1436 /* Open the device. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1437 current_sound_device->open (current_sound_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
|
1438 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1439 /* Play the sound. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1440 current_sound->play (current_sound, current_sound_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
|
1441 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1442 /* 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
|
1443 UNGCPRO; |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1444 |
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
|
1445 #else /* WINDOWSNT */ |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1446 |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1447 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
|
1448 len = XSTRING (lo_file)->size; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1449 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
|
1450 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
|
1451 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
|
1452 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1453 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
|
1454 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1455 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
|
1456 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1457 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
|
1458 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1459 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1460 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
|
1461 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
|
1462 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
|
1463 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
|
1464 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
|
1465 (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
|
1466 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
|
1467 */ |
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
|
1468 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
|
1469 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1470 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
|
1471 } |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1472 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
|
1473 |
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
|
1474 #endif /* WINDOWSNT */ |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1475 |
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
|
1476 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
|
1477 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
|
1478 } |
25003 | 1479 |
1480 /*********************************************************************** | |
1481 Initialization | |
1482 ***********************************************************************/ | |
1483 | |
1484 void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1485 syms_of_sound (void) |
25003 | 1486 { |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1487 QCdevice = intern_c_string(":device"); |
25003 | 1488 staticpro (&QCdevice); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1489 QCvolume = intern_c_string (":volume"); |
25003 | 1490 staticpro (&QCvolume); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1491 Qsound = intern_c_string ("sound"); |
25003 | 1492 staticpro (&Qsound); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1493 Qplay_sound_functions = intern_c_string ("play-sound-functions"); |
25548
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
1494 staticpro (&Qplay_sound_functions); |
25003 | 1495 |
44399
a399428859ff
(Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents:
42754
diff
changeset
|
1496 defsubr (&Splay_sound_internal); |
25003 | 1497 } |
1498 | |
1499 | |
1500 void | |
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109100
diff
changeset
|
1501 init_sound (void) |
25003 | 1502 { |
1503 } | |
1504 | |
1505 #endif /* HAVE_SOUND */ | |
52401 | 1506 |
1507 /* arch-tag: dd850ad8-0433-4e2c-9cba-b7aeeccc0dbd | |
1508 (do not change this comment) */ |