Mercurial > emacs
annotate src/sound.c @ 107874:b97c55098dcc
Check both `isearch-scroll' and `scroll-command' properties.
* isearch.el (isearch-lookup-scroll-key): Check both
`isearch-scroll' and `scroll-command' properties.
(scroll-up, scroll-down): Remove `isearch-scroll' property.
* mwheel.el (mwheel-scroll): Remove `isearch-scroll' property.
* simple.el (scroll-up-command, scroll-down-command)
(scroll-up-line, scroll-down-line): Remove `isearch-scroll' property.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Fri, 16 Apr 2010 04:24:00 +0300 |
parents | 1d1d5d9bd884 |
children | 2bc9a0c04c87 376148b31b5e |
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 extern Lisp_Object QCfile, QCdata; |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
103 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
|
104 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
|
105 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
|
106 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
108 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
110 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 }; |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
117 |
71063
7510757f449b
* search.c (matcher_overflow): Mark as NO_RETURN.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
71062
diff
changeset
|
118 static void alsa_sound_perror P_ ((char *, int)) NO_RETURN; |
7510757f449b
* search.c (matcher_overflow): Mark as NO_RETURN.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
71062
diff
changeset
|
119 static void sound_perror P_ ((char *)) NO_RETURN; |
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
|
120 static void sound_warning P_ ((char *)); |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
121 static int parse_sound P_ ((Lisp_Object, Lisp_Object *)); |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
122 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
124 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
126 #ifndef WINDOWSNT |
30079
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
127 |
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
128 #ifndef DEFAULT_SOUND_DEVICE |
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
129 #define DEFAULT_SOUND_DEVICE "/dev/dsp" |
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
130 #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
|
131 #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
|
132 #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
|
133 #endif |
25003 | 134 |
135 | |
136 /* Structure forward declarations. */ | |
137 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
138 struct sound; |
25003 | 139 struct sound_device; |
140 | |
141 /* The file header of RIFF-WAVE files (*.wav). Files are always in | |
142 little-endian byte-order. */ | |
143 | |
144 struct wav_header | |
145 { | |
146 u_int32_t magic; | |
147 u_int32_t length; | |
148 u_int32_t chunk_type; | |
149 u_int32_t chunk_format; | |
150 u_int32_t chunk_length; | |
151 u_int16_t format; | |
152 u_int16_t channels; | |
153 u_int32_t sample_rate; | |
154 u_int32_t bytes_per_second; | |
155 u_int16_t sample_size; | |
156 u_int16_t precision; | |
157 u_int32_t chunk_data; | |
158 u_int32_t data_length; | |
159 }; | |
160 | |
161 /* The file header of Sun adio files (*.au). Files are always in | |
162 big-endian byte-order. */ | |
163 | |
164 struct au_header | |
165 { | |
166 /* ASCII ".snd" */ | |
167 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
|
168 |
25003 | 169 /* Offset of data part from start of file. Minimum value is 24. */ |
170 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
|
171 |
25003 | 172 /* Size of data part, 0xffffffff if unknown. */ |
173 u_int32_t data_size; | |
174 | |
175 /* Data encoding format. | |
176 1 8-bit ISDN u-law | |
177 2 8-bit linear PCM (REF-PCM) | |
178 3 16-bit linear PCM | |
179 4 24-bit linear PCM | |
180 5 32-bit linear PCM | |
181 6 32-bit IEEE floating-point | |
182 7 64-bit IEEE floating-point | |
183 23 8-bit u-law compressed using CCITT 0.721 ADPCM voice data | |
184 encoding scheme. */ | |
185 u_int32_t encoding; | |
186 | |
187 /* Number of samples per second. */ | |
188 u_int32_t sample_rate; | |
189 | |
190 /* Number of interleaved channels. */ | |
191 u_int32_t channels; | |
192 }; | |
193 | |
194 /* Maximum of all sound file headers sizes. */ | |
195 | |
196 #define MAX_SOUND_HEADER_BYTES \ | |
197 max (sizeof (struct wav_header), sizeof (struct au_header)) | |
198 | |
199 /* Interface structure for sound devices. */ | |
200 | |
201 struct sound_device | |
202 { | |
203 /* The name of the device or null meaning use a default device name. */ | |
204 char *file; | |
205 | |
206 /* File descriptor of the device. */ | |
207 int fd; | |
208 | |
209 /* Device-dependent format. */ | |
210 int format; | |
211 | |
212 /* Volume (0..100). Zero means unspecified. */ | |
213 int volume; | |
214 | |
215 /* Sample size. */ | |
216 int sample_size; | |
217 | |
218 /* Sample rate. */ | |
219 int sample_rate; | |
220 | |
221 /* Bytes per second. */ | |
222 int bps; | |
223 | |
224 /* 1 = mono, 2 = stereo, 0 = don't set. */ | |
225 int channels; | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
226 |
25003 | 227 /* Open device SD. */ |
228 void (* open) P_ ((struct sound_device *sd)); | |
229 | |
230 /* Close device SD. */ | |
231 void (* close) P_ ((struct sound_device *sd)); | |
232 | |
233 /* Configure SD accoring to device-dependent parameters. */ | |
234 void (* configure) P_ ((struct sound_device *device)); | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
235 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
236 /* Choose a device-dependent format for outputting sound S. */ |
25003 | 237 void (* choose_format) P_ ((struct sound_device *sd, |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
238 struct sound *s)); |
25003 | 239 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
240 /* 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
|
241 each time. 2048 is used if this is NULL. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
242 int (* period_size) P_ ((struct sound_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
|
243 |
25003 | 244 /* Write NYBTES bytes from BUFFER to device SD. */ |
46554
fb13fafbd279
(struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
245 void (* write) P_ ((struct sound_device *sd, const char *buffer, |
fb13fafbd279
(struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
246 int nbytes)); |
25003 | 247 |
248 /* A place for devices to store additional data. */ | |
249 void *data; | |
250 }; | |
251 | |
252 /* An enumerator for each supported sound file type. */ | |
253 | |
254 enum sound_type | |
255 { | |
256 RIFF, | |
257 SUN_AUDIO | |
258 }; | |
259 | |
260 /* Interface structure for sound files. */ | |
261 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
262 struct sound |
25003 | 263 { |
264 /* The type of the file. */ | |
265 enum sound_type type; | |
266 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
267 /* File descriptor of a sound file. */ |
25003 | 268 int fd; |
269 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
270 /* 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
|
271 read from the start of a sound file. */ |
25003 | 272 char *header; |
273 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
274 /* 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
|
275 MAX_SOUND_HEADER_BYTES. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
276 int header_size; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
277 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
278 /* Sound data, if a string. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
279 Lisp_Object data; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
280 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
281 /* Play sound file S on device SD. */ |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
282 void (* play) P_ ((struct sound *s, struct sound_device *sd)); |
25003 | 283 }; |
284 | |
44399
a399428859ff
(Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents:
42754
diff
changeset
|
285 /* These are set during `play-sound-internal' so that sound_cleanup has |
25003 | 286 access to them. */ |
287 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
288 struct sound_device *current_sound_device; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
289 struct sound *current_sound; |
25003 | 290 |
291 /* Function prototypes. */ | |
292 | |
293 static void vox_open P_ ((struct sound_device *)); | |
294 static void vox_configure P_ ((struct sound_device *)); | |
295 static void vox_close P_ ((struct sound_device *sd)); | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
296 static void vox_choose_format P_ ((struct sound_device *, struct sound *)); |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
297 static int vox_init P_ ((struct sound_device *)); |
46554
fb13fafbd279
(struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
298 static void vox_write P_ ((struct sound_device *, const char *, int)); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
299 static void find_sound_type P_ ((struct sound *)); |
25003 | 300 static u_int32_t le2hl P_ ((u_int32_t)); |
301 static u_int16_t le2hs P_ ((u_int16_t)); | |
302 static u_int32_t be2hl P_ ((u_int32_t)); | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
303 static int wav_init P_ ((struct sound *)); |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
304 static void wav_play P_ ((struct sound *, struct sound_device *)); |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
305 static int au_init P_ ((struct sound *)); |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
306 static void au_play P_ ((struct sound *, struct sound_device *)); |
25003 | 307 |
25722
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
308 #if 0 /* Currently not used. */ |
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
309 static u_int16_t be2hs P_ ((u_int16_t)); |
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
310 #endif |
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
311 |
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
|
312 /* 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
|
313 #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
|
314 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* BEGIN: Windows Specific Definitions */ |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
316 static int do_play_sound P_ ((const char *, unsigned long)); |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
317 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
319 #endif /* WINDOWSNT */ |
25003 | 320 |
321 | |
322 /*********************************************************************** | |
323 General | |
324 ***********************************************************************/ | |
325 | |
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
|
326 /* 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
|
327 |
25003 | 328 /* Like perror, but signals an error. */ |
329 | |
330 static void | |
331 sound_perror (msg) | |
332 char *msg; | |
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 |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
350 sound_warning (msg) |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
351 char *msg; |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
352 { |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
353 message (msg); |
25003 | 354 } |
355 | |
356 | |
357 /* Parse sound specification SOUND, and fill ATTRS with what is | |
358 found. Value is non-zero if SOUND Is a valid sound specification. | |
359 A valid sound specification is a list starting with the symbol | |
360 `sound'. The rest of the list is a property list which may | |
361 contain the following key/value pairs: | |
362 | |
363 - `:file FILE' | |
364 | |
365 FILE is the sound file to play. If it isn't an absolute name, | |
366 it's searched under `data-directory'. | |
367 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
368 - `:data DATA' |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
369 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
370 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
|
371 may be present, but not both. |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
372 |
25003 | 373 - `:device DEVICE' |
374 | |
375 DEVICE is the name of the device to play on, e.g. "/dev/dsp2". | |
376 If not specified, a default device is used. | |
377 | |
378 - `:volume VOL' | |
379 | |
25548
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
380 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
|
381 range [0, 1]. */ |
25003 | 382 |
383 static int | |
384 parse_sound (sound, attrs) | |
385 Lisp_Object sound; | |
386 Lisp_Object *attrs; | |
387 { | |
388 /* SOUND must be a list starting with the symbol `sound'. */ | |
389 if (!CONSP (sound) || !EQ (XCAR (sound), Qsound)) | |
390 return 0; | |
391 | |
392 sound = XCDR (sound); | |
393 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
|
394 attrs[SOUND_DATA] = Fplist_get (sound, QCdata); |
25003 | 395 attrs[SOUND_DEVICE] = Fplist_get (sound, QCdevice); |
396 attrs[SOUND_VOLUME] = Fplist_get (sound, QCvolume); | |
397 | |
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
|
398 #ifndef WINDOWSNT |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
399 /* File name or data must be specified. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
400 if (!STRINGP (attrs[SOUND_FILE]) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
401 && !STRINGP (attrs[SOUND_DATA])) |
25003 | 402 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
|
403 #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
|
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 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
|
406 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
|
407 */ |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
409 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
410 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
|
411 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
412 #endif /* WINDOWSNT */ |
25003 | 413 |
414 /* Volume must be in the range 0..100 or unspecified. */ | |
415 if (!NILP (attrs[SOUND_VOLUME])) | |
416 { | |
25548
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
417 if (INTEGERP (attrs[SOUND_VOLUME])) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
418 { |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
419 if (XINT (attrs[SOUND_VOLUME]) < 0 |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
420 || XINT (attrs[SOUND_VOLUME]) > 100) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
421 return 0; |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
422 } |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
423 else if (FLOATP (attrs[SOUND_VOLUME])) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
424 { |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
425 if (XFLOAT_DATA (attrs[SOUND_VOLUME]) < 0 |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
426 || XFLOAT_DATA (attrs[SOUND_VOLUME]) > 1) |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
427 return 0; |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
428 } |
df6548ca33fd
(Qplay_sound_functions): Replaces Qplay_sound_hook.
Gerd Moellmann <gerd@gnu.org>
parents:
25003
diff
changeset
|
429 else |
25003 | 430 return 0; |
431 } | |
432 | |
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
|
433 #ifndef WINDOWSNT |
25003 | 434 /* Device must be a string or unspecified. */ |
435 if (!NILP (attrs[SOUND_DEVICE]) | |
436 && !STRINGP (attrs[SOUND_DEVICE])) | |
437 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
|
438 #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
|
439 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
440 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
|
441 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
|
442 */ |
25003 | 443 return 1; |
444 } | |
445 | |
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
|
446 /* 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
|
447 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
448 /* 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
|
449 #ifndef WINDOWSNT |
25003 | 450 |
451 /* 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
|
452 S is the sound file structure to fill in. */ |
25003 | 453 |
454 static void | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
455 find_sound_type (s) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
456 struct sound *s; |
25003 | 457 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
458 if (!wav_init (s) && !au_init (s)) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
459 error ("Unknown sound format"); |
25003 | 460 } |
461 | |
462 | |
44399
a399428859ff
(Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents:
42754
diff
changeset
|
463 /* Function installed by play-sound-internal with record_unwind_protect. */ |
25003 | 464 |
465 static Lisp_Object | |
466 sound_cleanup (arg) | |
467 Lisp_Object arg; | |
468 { | |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
469 if (current_sound_device->close) |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
470 current_sound_device->close (current_sound_device); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
471 if (current_sound->fd > 0) |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
472 emacs_close (current_sound->fd); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
473 free (current_sound_device); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
474 free (current_sound); |
34255
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
475 |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
476 return Qnil; |
25003 | 477 } |
478 | |
479 /*********************************************************************** | |
480 Byte-order Conversion | |
481 ***********************************************************************/ | |
482 | |
483 /* Convert 32-bit value VALUE which is in little-endian byte-order | |
484 to host byte-order. */ | |
485 | |
486 static u_int32_t | |
487 le2hl (value) | |
488 u_int32_t value; | |
489 { | |
490 #ifdef WORDS_BIG_ENDIAN | |
491 unsigned char *p = (unsigned char *) &value; | |
492 value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24); | |
493 #endif | |
494 return value; | |
495 } | |
496 | |
497 | |
498 /* Convert 16-bit value VALUE which is in little-endian byte-order | |
499 to host byte-order. */ | |
500 | |
501 static u_int16_t | |
502 le2hs (value) | |
503 u_int16_t value; | |
504 { | |
505 #ifdef WORDS_BIG_ENDIAN | |
506 unsigned char *p = (unsigned char *) &value; | |
507 value = p[0] + (p[1] << 8); | |
508 #endif | |
509 return value; | |
510 } | |
511 | |
512 | |
513 /* Convert 32-bit value VALUE which is in big-endian byte-order | |
514 to host byte-order. */ | |
515 | |
516 static u_int32_t | |
517 be2hl (value) | |
518 u_int32_t value; | |
519 { | |
520 #ifndef WORDS_BIG_ENDIAN | |
521 unsigned char *p = (unsigned char *) &value; | |
522 value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24); | |
523 #endif | |
524 return value; | |
525 } | |
526 | |
527 | |
25722
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
528 #if 0 /* Currently not used. */ |
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
529 |
25003 | 530 /* Convert 16-bit value VALUE which is in big-endian byte-order |
531 to host byte-order. */ | |
532 | |
533 static u_int16_t | |
534 be2hs (value) | |
535 u_int16_t value; | |
536 { | |
537 #ifndef WORDS_BIG_ENDIAN | |
538 unsigned char *p = (unsigned char *) &value; | |
539 value = p[1] + (p[0] << 8); | |
540 #endif | |
541 return value; | |
542 } | |
543 | |
25722
2be6ced279d3
(Fplay_sound): Remove usused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25548
diff
changeset
|
544 #endif /* 0 */ |
25003 | 545 |
546 /*********************************************************************** | |
547 RIFF-WAVE (*.wav) | |
548 ***********************************************************************/ | |
549 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
550 /* Try to initialize sound file S from S->header. S->header |
25003 | 551 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the |
552 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
|
553 functions in S and convert header fields to host byte-order. |
25003 | 554 Value is non-zero if the file is a WAV file. */ |
555 | |
556 static int | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
557 wav_init (s) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
558 struct sound *s; |
25003 | 559 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
560 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
|
561 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
562 if (s->header_size < sizeof *header |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
563 || bcmp (s->header, "RIFF", 4) != 0) |
25003 | 564 return 0; |
565 | |
566 /* WAV files are in little-endian order. Convert the header | |
567 if on a big-endian machine. */ | |
568 header->magic = le2hl (header->magic); | |
569 header->length = le2hl (header->length); | |
570 header->chunk_type = le2hl (header->chunk_type); | |
571 header->chunk_format = le2hl (header->chunk_format); | |
572 header->chunk_length = le2hl (header->chunk_length); | |
573 header->format = le2hs (header->format); | |
574 header->channels = le2hs (header->channels); | |
575 header->sample_rate = le2hl (header->sample_rate); | |
576 header->bytes_per_second = le2hl (header->bytes_per_second); | |
577 header->sample_size = le2hs (header->sample_size); | |
578 header->precision = le2hs (header->precision); | |
579 header->chunk_data = le2hl (header->chunk_data); | |
580 header->data_length = le2hl (header->data_length); | |
581 | |
582 /* 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
|
583 s->type = RIFF; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
584 s->play = wav_play; |
25003 | 585 |
586 return 1; | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
587 } |
25003 | 588 |
589 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
590 /* Play RIFF-WAVE audio file S on sound device SD. */ |
25003 | 591 |
592 static void | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
593 wav_play (s, sd) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
594 struct sound *s; |
25003 | 595 struct sound_device *sd; |
596 { | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
597 struct wav_header *header = (struct wav_header *) s->header; |
25003 | 598 |
599 /* Let the device choose a suitable device-dependent format | |
600 for the file. */ | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
601 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
|
602 |
25003 | 603 /* Configure the device. */ |
604 sd->sample_size = header->sample_size; | |
605 sd->sample_rate = header->sample_rate; | |
606 sd->bps = header->bytes_per_second; | |
607 sd->channels = header->channels; | |
608 sd->configure (sd); | |
609 | |
610 /* Copy sound data to the device. The WAV file specification is | |
611 actually more complex. This simple scheme worked with all WAV | |
612 files I found so far. If someone feels inclined to implement the | |
613 whole RIFF-WAVE spec, please do. */ | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
614 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
|
615 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
|
616 SBYTES (s->data) - sizeof *header); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
617 else |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
618 { |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
619 char *buffer; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
620 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
|
621 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
|
622 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
|
623 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
624 buffer = (char *) alloca (blksize); |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
625 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
|
626 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
|
627 && (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
|
628 { |
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
|
629 /* 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
|
630 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
|
631 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
|
632 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
|
633 } |
25003 | 634 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
635 if (nbytes < 0) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
636 sound_perror ("Error reading sound file"); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
637 } |
25003 | 638 } |
639 | |
640 | |
641 /*********************************************************************** | |
642 Sun Audio (*.au) | |
643 ***********************************************************************/ | |
644 | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
645 /* Sun audio file encodings. */ |
25003 | 646 |
647 enum au_encoding | |
648 { | |
649 AU_ENCODING_ULAW_8 = 1, | |
650 AU_ENCODING_8, | |
651 AU_ENCODING_16, | |
652 AU_ENCODING_24, | |
653 AU_ENCODING_32, | |
654 AU_ENCODING_IEEE32, | |
655 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
|
656 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
|
657 AU_ENCODING_ALAW_8 = 27 |
25003 | 658 }; |
659 | |
660 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
661 /* Try to initialize sound file S from S->header. S->header |
25003 | 662 contains the first MAX_SOUND_HEADER_BYTES number of bytes from the |
663 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
|
664 functions in S and convert header fields to host byte-order. |
25003 | 665 Value is non-zero if the file is an AU file. */ |
666 | |
667 static int | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
668 au_init (s) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
669 struct sound *s; |
25003 | 670 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
671 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
|
672 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
673 if (s->header_size < sizeof *header |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
674 || bcmp (s->header, ".snd", 4) != 0) |
25003 | 675 return 0; |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
676 |
25003 | 677 header->magic_number = be2hl (header->magic_number); |
678 header->data_offset = be2hl (header->data_offset); | |
679 header->data_size = be2hl (header->data_size); | |
680 header->encoding = be2hl (header->encoding); | |
681 header->sample_rate = be2hl (header->sample_rate); | |
682 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
|
683 |
25003 | 684 /* 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
|
685 s->type = SUN_AUDIO; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
686 s->play = au_play; |
25003 | 687 |
688 return 1; | |
689 } | |
690 | |
691 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
692 /* Play Sun audio file S on sound device SD. */ |
25003 | 693 |
694 static void | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
695 au_play (s, sd) |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
696 struct sound *s; |
25003 | 697 struct sound_device *sd; |
698 { | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
699 struct au_header *header = (struct au_header *) s->header; |
25003 | 700 |
701 sd->sample_size = 0; | |
702 sd->sample_rate = header->sample_rate; | |
703 sd->bps = 0; | |
704 sd->channels = header->channels; | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
705 sd->choose_format (sd, s); |
25003 | 706 sd->configure (sd); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
707 |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
708 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
|
709 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
|
710 SBYTES (s->data) - header->data_offset); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
711 else |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
712 { |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
713 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
|
714 char *buffer; |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
715 int nbytes; |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
716 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
717 /* Seek */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
718 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
|
719 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
720 /* Copy sound data to the device. */ |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
721 buffer = (char *) alloca (blksize); |
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
722 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
|
723 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
|
724 |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
725 if (nbytes < 0) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
726 sound_perror ("Error reading sound file"); |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
727 } |
25003 | 728 } |
729 | |
730 | |
731 /*********************************************************************** | |
732 Voxware Driver Interface | |
733 ***********************************************************************/ | |
734 | |
735 /* This driver is available on GNU/Linux, and the free BSDs. FreeBSD | |
736 has a compatible own driver aka Luigi's driver. */ | |
737 | |
738 | |
739 /* Open device SD. If SD->file is non-null, open that device, | |
740 otherwise use a default device name. */ | |
741 | |
742 static void | |
743 vox_open (sd) | |
744 struct sound_device *sd; | |
745 { | |
746 char *file; | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
747 |
25003 | 748 /* Open the sound device. Default is /dev/dsp. */ |
749 if (sd->file) | |
750 file = sd->file; | |
751 else | |
30079
1572612184fc
Sound support for NetBSD through "Linux emulation" support:
Ken Raeburn <raeburn@raeburn.org>
parents:
29717
diff
changeset
|
752 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
|
753 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25722
diff
changeset
|
754 sd->fd = emacs_open (file, O_WRONLY, 0); |
25003 | 755 if (sd->fd < 0) |
756 sound_perror (file); | |
757 } | |
758 | |
759 | |
760 /* Configure device SD from parameters in it. */ | |
761 | |
762 static void | |
763 vox_configure (sd) | |
764 struct sound_device *sd; | |
765 { | |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
766 int val; |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
767 |
25003 | 768 xassert (sd->fd >= 0); |
769 | |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
770 /* 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
|
771 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
|
772 troubles. */ |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
773 turn_on_atimers (0); |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
774 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
775 sigblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
776 #endif |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
777 |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
778 val = sd->format; |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
779 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
|
780 || val != sd->format) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
781 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
|
782 |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
783 val = sd->channels != 1; |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
784 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
|
785 || val != (sd->channels != 1)) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
786 sound_perror ("Could not set stereo/mono"); |
25003 | 787 |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
788 /* 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
|
789 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
|
790 if (sd->sample_rate > 0) |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
791 { |
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
792 val = sd->sample_rate; |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
793 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
|
794 sound_perror ("Could not set sound speed"); |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
795 else if (val != sd->sample_rate) |
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
796 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
|
797 } |
25003 | 798 |
34255
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
799 if (sd->volume > 0) |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
800 { |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
801 int volume = sd->volume & 0xff; |
cb2b0d1799db
(vox_configure): Set volume for left and right channel.
Gerd Moellmann <gerd@gnu.org>
parents:
31587
diff
changeset
|
802 volume |= volume << 8; |
34354
db2901e01b72
(vox_configure): Change order of ioctls. Don't
Gerd Moellmann <gerd@gnu.org>
parents:
34255
diff
changeset
|
803 /* 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
|
804 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
|
805 } |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
806 |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
807 turn_on_atimers (1); |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
808 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
809 sigunblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
810 #endif |
25003 | 811 } |
812 | |
813 | |
814 /* Close device SD if it is open. */ | |
815 | |
816 static void | |
817 vox_close (sd) | |
818 struct sound_device *sd; | |
819 { | |
820 if (sd->fd >= 0) | |
821 { | |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
822 /* 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
|
823 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
|
824 troubles. */ |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
825 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
826 sigblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
827 #endif |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
828 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
|
829 |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
830 /* Flush sound data, and reset the device. */ |
25003 | 831 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
|
832 |
38215
b9fdde642b13
(vox_configure, vox_close): Turn off atimers
Gerd Moellmann <gerd@gnu.org>
parents:
34354
diff
changeset
|
833 turn_on_atimers (1); |
38338
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
834 #ifdef SIGIO |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
835 sigunblock (sigmask (SIGIO)); |
c6ff61f9af43
(toplevel): Include <signal.h> and "syssignal.h".
Gerd Moellmann <gerd@gnu.org>
parents:
38297
diff
changeset
|
836 #endif |
25003 | 837 |
838 /* 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
|
839 emacs_close (sd->fd); |
25003 | 840 sd->fd = -1; |
841 } | |
842 } | |
843 | |
844 | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
845 /* Choose device-dependent format for device SD from sound file S. */ |
25003 | 846 |
847 static void | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
848 vox_choose_format (sd, s) |
25003 | 849 struct sound_device *sd; |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
850 struct sound *s; |
25003 | 851 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
852 if (s->type == RIFF) |
25003 | 853 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
854 struct wav_header *h = (struct wav_header *) s->header; |
25003 | 855 if (h->precision == 8) |
856 sd->format = AFMT_U8; | |
857 else if (h->precision == 16) | |
858 sd->format = AFMT_S16_LE; | |
859 else | |
860 error ("Unsupported WAV file format"); | |
861 } | |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
862 else if (s->type == SUN_AUDIO) |
25003 | 863 { |
27146
68290f44807a
(struct sound): Renamed from struct sound_file.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
864 struct au_header *header = (struct au_header *) s->header; |
25003 | 865 switch (header->encoding) |
866 { | |
867 case AU_ENCODING_ULAW_8: | |
868 case AU_ENCODING_IEEE32: | |
869 case AU_ENCODING_IEEE64: | |
870 sd->format = AFMT_MU_LAW; | |
871 break; | |
42754
158482d8af9d
(Fplay_sound): Initialize header_size also for :data case.
Pavel Janík <Pavel@Janik.cz>
parents:
42534
diff
changeset
|
872 |
25003 | 873 case AU_ENCODING_8: |
874 case AU_ENCODING_16: | |
875 case AU_ENCODING_24: | |
876 case AU_ENCODING_32: | |
877 sd->format = AFMT_S16_LE; | |
878 break; | |
879 | |
880 default: | |
881 error ("Unsupported AU file format"); | |
882 } | |
883 } | |
884 else | |
885 abort (); | |
886 } | |
887 | |
888 | |
889 /* Initialize device SD. Set up the interface functions in the device | |
890 structure. */ | |
891 | |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
892 static int |
25003 | 893 vox_init (sd) |
894 struct sound_device *sd; | |
895 { | |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
896 char *file; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
897 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
|
898 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
899 /* 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
|
900 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
|
901 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
|
902 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
903 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
|
904 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
|
905 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
|
906 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
|
907 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
908 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
|
909 |
25003 | 910 sd->fd = -1; |
911 sd->open = vox_open; | |
912 sd->close = vox_close; | |
913 sd->configure = vox_configure; | |
914 sd->choose_format = vox_choose_format; | |
915 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
|
916 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
|
917 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
918 return 1; |
25003 | 919 } |
920 | |
921 /* Write NBYTES bytes from BUFFER to device SD. */ | |
922 | |
923 static void | |
924 vox_write (sd, buffer, nbytes) | |
925 struct sound_device *sd; | |
46554
fb13fafbd279
(struct sound_device): Function pointer field "write"
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
926 const char *buffer; |
25003 | 927 int nbytes; |
928 { | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25722
diff
changeset
|
929 int nwritten = emacs_write (sd->fd, buffer, nbytes); |
25003 | 930 if (nwritten < 0) |
40364
f7b039994118
(sound_perror): Unblock SIGIO, turn on atimers.
Gerd Moellmann <gerd@gnu.org>
parents:
40123
diff
changeset
|
931 sound_perror ("Error writing to sound device"); |
25003 | 932 } |
933 | |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
934 #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
|
935 /*********************************************************************** |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
936 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
|
937 ***********************************************************************/ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
938 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
939 /* 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
|
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 static void |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
942 alsa_sound_perror (msg, err) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
943 char *msg; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
944 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
|
945 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
946 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
|
947 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
948 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
949 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
|
950 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
951 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
|
952 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
|
953 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
|
954 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
|
955 }; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
956 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
957 /* 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
|
958 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
|
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 static void |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
961 alsa_open (sd) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
962 struct sound_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
|
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 char *file; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
965 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
|
966 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
|
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 /* 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
|
969 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
|
970 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
|
971 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
972 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
|
973 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
974 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
|
975 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
|
976 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
|
977 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
|
978 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
979 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
|
980 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
|
981 |
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_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
|
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 (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
|
986 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
987 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
988 static int |
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_period_size (sd) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
990 struct sound_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
|
991 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
992 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
|
993 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
|
994 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
|
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 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
997 static void |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
998 alsa_configure (sd) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
999 struct sound_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
|
1000 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1001 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
|
1002 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
|
1003 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
|
1004 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
|
1005 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1006 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
|
1007 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1008 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
|
1009 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
|
1010 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
|
1011 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1012 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
|
1013 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
|
1014 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
|
1015 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1016 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
|
1017 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
|
1018 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
|
1019 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 |
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
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1040 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
|
1041 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
|
1042 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
|
1043 |
70718
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 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
|
1046 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
|
1047 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
|
1048 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1049 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
|
1050 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
|
1051 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
|
1052 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1053 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
|
1054 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
|
1055 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
|
1056 err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1057 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1058 /* 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
|
1059 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
|
1060 (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
|
1061 * 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
|
1062 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
|
1063 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
|
1064 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1065 /* 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
|
1066 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
|
1067 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
|
1068 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
|
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 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
|
1071 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
|
1072 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
|
1073 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1074 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
|
1075 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
|
1076 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
|
1077 p->swparams = NULL; |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1078 |
71062
47e6374861d1
* sound.c (alsa_open, alsa_configure, alsa_write): Move
Jan Djärv <jan.h.d@swipnet.se>
parents:
70955
diff
changeset
|
1079 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
|
1080 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
|
1081 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
|
1082 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1083 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
|
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 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
|
1086 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
|
1087 snd_mixer_elem_t *e; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1088 char *file = sd->file ? sd->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
|
1089 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1090 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
|
1091 { |
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 (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
|
1093 && 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
|
1094 && 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
|
1095 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
|
1096 e; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1097 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
|
1098 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1099 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
|
1100 { |
92704
22bce4d93530
(alsa_configure): Declare vol at beginning of block.
Jan Djärv <jan.h.d@swipnet.se>
parents:
87649
diff
changeset
|
1101 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
|
1102 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
|
1103 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
|
1104 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1105 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
|
1106 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
|
1107 } |
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 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
|
1110 } |
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 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1113 |
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 /* 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
|
1116 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1117 static void |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1118 alsa_close (sd) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1119 struct sound_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
|
1120 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1121 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
|
1122 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
|
1123 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1124 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
|
1125 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
|
1126 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
|
1127 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
|
1128 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
|
1129 { |
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
|
1130 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
|
1131 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
|
1132 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1133 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
|
1134 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1135 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1136 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1137 /* 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
|
1138 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1139 static void |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1140 alsa_choose_format (sd, s) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1141 struct sound_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
|
1142 struct sound *s; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1143 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1144 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
|
1145 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
|
1146 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1147 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
|
1148 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
|
1149 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
|
1150 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
|
1151 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
|
1152 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1153 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
|
1154 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1155 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
|
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 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
|
1158 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
|
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 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
|
1161 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
|
1162 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1163 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
|
1164 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
|
1165 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1166 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
|
1167 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
|
1168 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1169 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
|
1170 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
|
1171 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1172 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
|
1173 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
|
1174 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1175 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
|
1176 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
|
1177 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1178 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
|
1179 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
|
1180 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1181 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
|
1182 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
|
1183 break; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1184 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1185 default: |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1186 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
|
1187 } |
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 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1190 abort (); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1191 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1192 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1193 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1194 /* 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
|
1195 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1196 static void |
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_write (sd, buffer, nbytes) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1198 struct sound_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
|
1199 const char *buffer; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1200 int nbytes; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1201 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1202 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
|
1203 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1204 /* 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
|
1205 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
|
1206 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
|
1207 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
|
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 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
|
1210 { |
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
|
1211 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
|
1212 if (frames == 0) break; |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1213 |
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
|
1214 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
|
1215 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
|
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 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
|
1218 { /* 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
|
1219 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
|
1220 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
|
1221 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
|
1222 err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1223 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1224 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
|
1225 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1226 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
|
1227 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
|
1228 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
|
1229 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1230 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
|
1231 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
|
1232 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
|
1233 "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
|
1234 err); |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1235 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1236 } |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1237 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
|
1238 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
|
1239 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1240 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1241 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1242 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
|
1243 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1244 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1245 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1246 static void |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1247 snd_error_quiet (file, line, function, err, fmt) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1248 const char *file; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1249 int line; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1250 const char *function; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1251 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
|
1252 const char *fmt; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1253 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1254 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1255 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1256 /* 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
|
1257 structure. */ |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1258 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1259 static int |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1260 alsa_init (sd) |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1261 struct sound_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
|
1262 { |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1263 char *file; |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1264 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
|
1265 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
|
1266 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1267 /* 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
|
1268 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
|
1269 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
|
1270 else |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1271 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
|
1272 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1273 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
|
1274 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
|
1275 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
|
1276 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
|
1277 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
|
1278 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
|
1279 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1280 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
|
1281 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
|
1282 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
|
1283 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
|
1284 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
|
1285 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
|
1286 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
|
1287 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1288 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
|
1289 } |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1290 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1291 #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
|
1292 |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1293 |
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
|
1294 /* 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
|
1295 #else /* WINDOWSNT */ |
25003 | 1296 |
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 /* 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
|
1298 |
101215
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1299 #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
|
1300 { \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1301 char buf[1024]; \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1302 char err_string[MAXERRORLENGTH]; \ |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1303 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
|
1304 _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
|
1305 text, err_string); \ |
877adea17756
* sound.c (SOUND_WARNING): Use _snprintf, for MSVC compatibility.
Juanma Barranquero <lekktu@gmail.com>
parents:
101141
diff
changeset
|
1306 sound_warning (buf); \ |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1307 } |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1308 |
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
|
1309 static int |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1310 do_play_sound (psz_file, ui_volume) |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1311 const char *psz_file; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1312 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
|
1313 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1314 int i_result = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1315 MCIERROR mci_error = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1316 char sz_cmd_buf[520] = {0}; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1317 char sz_ret_buf[520] = {0}; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1318 MMRESULT mm_result = MMSYSERR_NOERROR; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1319 unsigned long ui_volume_org = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1320 BOOL b_reset_volume = FALSE; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1321 |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1322 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
|
1323 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
|
1324 sprintf (sz_cmd_buf, |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1325 "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
|
1326 psz_file); |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1327 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
|
1328 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
|
1329 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1330 SOUND_WARNING (mciGetErrorString, mci_error, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1331 "The open mciSendString command failed to open " |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1332 "the specified sound file."); |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1333 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
|
1334 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
|
1335 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1336 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
|
1337 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1338 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
|
1339 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
|
1340 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1341 b_reset_volume = TRUE; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1342 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
|
1343 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
|
1344 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1345 SOUND_WARNING (waveOutGetErrorText, mm_result, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1346 "waveOutSetVolume failed to set the volume level " |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1347 "of the WAVE_MAPPER device.\n" |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1348 "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
|
1349 "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
|
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 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
1353 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1354 SOUND_WARNING (waveOutGetErrorText, mm_result, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1355 "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
|
1356 "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
|
1357 "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
|
1358 "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
|
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 } |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1361 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
|
1362 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
|
1363 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
|
1364 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
|
1365 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
|
1366 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1367 SOUND_WARNING (mciGetErrorString, mci_error, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1368 "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
|
1369 "opened sound file."); |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1370 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
|
1371 } |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1372 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
|
1373 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
|
1374 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
|
1375 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
|
1376 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
|
1377 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1378 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
|
1379 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
|
1380 { |
101141
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1381 SOUND_WARNING (waveOutGetErrorText, mm_result, |
706175eda1de
* sound.c [WINDOWSNT] (SOUND_WARNING): New macro.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
1382 "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
|
1383 "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
|
1384 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1385 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
1387 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
1390 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1391 #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
|
1392 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
1394 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
|
1395 |
74315
a7c077b29617
(Fplay_sound_internal): Remove spurious newline in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
71892
diff
changeset
|
1396 Internal use only, use `play-sound' instead. */) |
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
|
1397 (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
|
1398 Lisp_Object sound; |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1399 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
1401 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
|
1402 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 #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
|
1404 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
|
1405 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
|
1406 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
|
1407 #else /* WINDOWSNT */ |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1408 int len = 0; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1409 Lisp_Object lo_file = {0}; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1410 char * psz_file = NULL; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1411 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
|
1412 unsigned long ui_volume = UINT_MAX; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1413 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
|
1414 #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
|
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 /* 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
|
1417 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
|
1418 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
|
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 #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
|
1421 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
|
1422 GCPRO2 (sound, file); |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1423 current_sound_device = (struct sound_device *) xmalloc (sizeof (struct sound_device)); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1424 bzero (current_sound_device, sizeof (struct sound_device)); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1425 current_sound = (struct sound *) xmalloc (sizeof (struct sound)); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1426 bzero (current_sound, 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
|
1427 record_unwind_protect (sound_cleanup, Qnil); |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1428 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
|
1429 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1430 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
|
1431 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1432 /* Open the sound file. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1433 current_sound->fd = openp (Fcons (Vdata_directory, Qnil), |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1434 attrs[SOUND_FILE], Qnil, &file, Qnil); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1435 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
|
1436 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
|
1437 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* Read the first bytes from the file. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1439 current_sound->header_size |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1440 = emacs_read (current_sound->fd, current_sound->header, |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1441 MAX_SOUND_HEADER_BYTES); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1442 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
|
1443 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
|
1444 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1446 { |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1447 current_sound->data = attrs[SOUND_DATA]; |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1448 current_sound->header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (current_sound->data)); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1449 bcopy (SDATA (current_sound->data), current_sound->header, 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
|
1450 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* 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
|
1453 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
|
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 /* 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
|
1456 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
|
1457 { |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 int len = SCHARS (attrs[SOUND_DEVICE]); |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1459 current_sound_device->file = (char *) alloca (len + 1); |
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1460 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
|
1461 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 if (INTEGERP (attrs[SOUND_VOLUME])) |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1464 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
|
1465 else if (FLOATP (attrs[SOUND_VOLUME])) |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1466 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
|
1467 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 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
|
1469 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
|
1470 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
|
1471 |
70718
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1472 #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
|
1473 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
|
1474 #endif |
f8a3f870d0c4
* sound.c (alsa_sound_perror, alsa_open, alsa_period_size)
Jan Djärv <jan.h.d@swipnet.se>
parents:
70363
diff
changeset
|
1475 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
|
1476 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
|
1477 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on 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 /* Open the device. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1479 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
|
1480 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1481 /* Play the sound. */ |
70363
54e4c6ece57f
(Fplay_sound_internal): Dynamically allocate
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
1482 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
|
1483 |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1484 /* 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
|
1485 UNGCPRO; |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1486 |
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
|
1487 #else /* WINDOWSNT */ |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1488 |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1489 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
|
1490 len = XSTRING (lo_file)->size; |
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1491 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
|
1492 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
|
1493 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
|
1494 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1495 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
|
1496 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1497 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
|
1498 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1499 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
|
1500 } |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1501 /* |
4d7b83cc03aa
Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents:
46554
diff
changeset
|
1502 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
|
1503 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
|
1504 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
|
1505 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
|
1506 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
|
1507 (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
|
1508 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
|
1509 */ |
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
|
1510 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
|
1511 { |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1512 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
|
1513 } |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1514 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
|
1515 |
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
|
1516 #endif /* WINDOWSNT */ |
48456
8f7ad3143e4b
Fix spacing and adapt to GNU coding conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
48375
diff
changeset
|
1517 |
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
|
1518 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
|
1519 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
|
1520 } |
25003 | 1521 |
1522 /*********************************************************************** | |
1523 Initialization | |
1524 ***********************************************************************/ | |
1525 | |
1526 void | |
1527 syms_of_sound () | |
1528 { | |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1529 QCdevice = intern_c_string(":device"); |
25003 | 1530 staticpro (&QCdevice); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1531 QCvolume = intern_c_string (":volume"); |
25003 | 1532 staticpro (&QCvolume); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1533 Qsound = intern_c_string ("sound"); |
25003 | 1534 staticpro (&Qsound); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
1535 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
|
1536 staticpro (&Qplay_sound_functions); |
25003 | 1537 |
44399
a399428859ff
(Fplay_sound_internal): Renamed from Fplay_sound.
Pavel Janík <Pavel@Janik.cz>
parents:
42754
diff
changeset
|
1538 defsubr (&Splay_sound_internal); |
25003 | 1539 } |
1540 | |
1541 | |
1542 void | |
1543 init_sound () | |
1544 { | |
1545 } | |
1546 | |
1547 #endif /* HAVE_SOUND */ | |
52401 | 1548 |
1549 /* arch-tag: dd850ad8-0433-4e2c-9cba-b7aeeccc0dbd | |
1550 (do not change this comment) */ |