comparison src/ntplay.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents 5fd7ba8b56e7
children a8d8f419b459
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
1 /* Sound in windows nt XEmacs. 1 /* Sound in windows nt XEmacs.
2 Copyright (C) 1998 Andy Piper. 2 Copyright (C) 1998 Andy Piper.
3 Copyright (C) 2001 Ben Wing.
3 4
4 This file is part of XEmacs. 5 This file is part of XEmacs.
5 6
6 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
20 21
21 /* Synched up with: Not in FSF. */ 22 /* Synched up with: Not in FSF. */
22 23
23 /* This file Mule-ized by Ben Wing, 5-15-01. */ 24 /* This file Mule-ized by Ben Wing, 5-15-01. */
24 25
25 #define DONT_ENCAPSULATE
26
27 #include <config.h> 26 #include <config.h>
28 #include "lisp.h" 27 #include "lisp.h"
29 28
30 #include "sound.h" 29 #include "sound.h"
31 #include "nt.h" 30 #include "syswindows.h"
32 31
33 #include "sysfile.h" 32 #include "sysfile.h"
34 33
35 static int play_sound_data_1 (UChar_Binary *data, int length, 34 static int play_sound_data_1 (UChar_Binary *data, int length,
36 int volume, int convert); 35 int volume, int convert);
37 36
38 void 37 void
39 play_sound_file (Extbyte *sound_file, int volume) 38 play_sound_file (Extbyte *sound_file, int volume)
40 { 39 {
41 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME; 40 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME;
42 OFSTRUCT ofs;
43 Lisp_Object fname = 41 Lisp_Object fname =
44 Ffile_name_nondirectory (build_ext_string (sound_file, Qmswindows_tstr)); 42 Ffile_name_nondirectory (build_tstr_string (sound_file));
45 Extbyte *fnameext; 43 Extbyte *fnameext;
46 44
47 CHECK_STRING (fname); 45 CHECK_STRING (fname);
48 LISP_STRING_TO_EXTERNAL (fname, fnameext, Qmswindows_tstr); 46 LISP_STRING_TO_TSTR (fname, fnameext);
49 47
50 if (OpenFile (fnameext, &ofs, OF_EXIST) < 0) 48 if (qxeSearchPath (NULL, fnameext, NULL, 0, NULL, NULL) == 0)
51 { 49 {
52 /* file isn't in the path so read it as data */ 50 /* file isn't in the path so read it as data */
53 int size; 51 int size;
54 UChar_Binary *data; 52 UChar_Binary *data;
55 int ofd = open (sound_file, O_RDONLY | OPEN_BINARY, 0); 53 int ofd = qxe_open (XSTRING_DATA (fname), O_RDONLY | OPEN_BINARY, 0);
56 54
57 if (ofd <0) 55 if (ofd <0)
58 return; 56 return;
59 57
60 size = lseek (ofd, 0, SEEK_END); 58 size = lseek (ofd, 0, SEEK_END);
61 data = (UChar_Binary *) xmalloc (size); 59 data = (UChar_Binary *) xmalloc (size);
62 lseek (ofd, 0, SEEK_SET); 60 lseek (ofd, 0, SEEK_SET);
63 61
64 if (!data) 62 if (!data)
65 { 63 {
66 close (ofd); 64 retry_close (ofd);
67 return; 65 return;
68 } 66 }
69 67
70 if (read (ofd, data, size) != size) 68 if (retry_read (ofd, data, size) != size)
71 { 69 {
72 close (ofd); 70 retry_close (ofd);
73 xfree (data); 71 xfree (data);
74 return; 72 return;
75 } 73 }
76 close (ofd); 74 retry_close (ofd);
77 75
78 play_sound_data_1 (data, size, 100, FALSE); 76 play_sound_data_1 (data, size, 100, FALSE);
79 } 77 }
80 else 78 else
81 PlaySound (fnameext, NULL, flags); 79 qxePlaySound (fnameext, NULL, flags);
82 } 80 }
83 81
84 /* mswindows can't cope with playing a sound from alloca space so we 82 /* mswindows can't cope with playing a sound from alloca space so we
85 have to convert if necessary */ 83 have to convert if necessary */
86 static int 84 static int
89 { 87 {
90 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; 88 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT;
91 static UChar_Binary *sound_data = 0; 89 static UChar_Binary *sound_data = 0;
92 if (sound_data) 90 if (sound_data)
93 { 91 {
94 PlaySound (NULL, NULL, flags); 92 qxePlaySound (NULL, NULL, flags);
95 xfree (sound_data); 93 xfree (sound_data);
96 sound_data = 0; 94 sound_data = 0;
97 } 95 }
98 96
99 if (convert_to_malloc) 97 if (convert_to_malloc)
102 memcpy (sound_data, data, length); 100 memcpy (sound_data, data, length);
103 } 101 }
104 else 102 else
105 sound_data = data; 103 sound_data = data;
106 104
107 PlaySound ((Extbyte *) sound_data, NULL, flags); 105 qxePlaySound ((Extbyte *) sound_data, NULL, flags);
108 106
109 /* #### Error handling? */ 107 /* #### Error handling? */
110 return 1; 108 return 1;
111 } 109 }
112 110