annotate src/sound.c @ 92407:7ba52081e343

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