Mercurial > hg > xemacs-beta
comparison src/ntplay.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with XEmacs; see the file COPYING. If not, write to the Free | 17 along with XEmacs; see the file COPYING. If not, write to the Free |
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
19 02111-1307, USA.*/ | 19 02111-1307, USA.*/ |
20 | 20 |
21 #include <windows.h> | |
22 #undef CONST | |
21 #include <config.h> | 23 #include <config.h> |
24 #include <stdio.h> | |
25 #include "sysfile.h" | |
22 #include "lisp.h" | 26 #include "lisp.h" |
23 | 27 |
24 #include "sysfile.h" | 28 #if defined (__CYGWIN32__) || defined(__MINGW32__) |
25 #include "nt.h" | 29 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD); |
26 #include "nativesound.h" | 30 #else |
27 | 31 #include <mmsystem.h> |
28 static int play_sound_data_1 (unsigned char *data, int length, | 32 #endif |
33 static void play_sound_data_1 (unsigned char *data, int length, | |
29 int volume, int convert); | 34 int volume, int convert); |
30 | 35 |
31 void play_sound_file (char *sound_file, int volume) | 36 void play_sound_file (char *sound_file, int volume) |
32 { | 37 { |
33 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME; | 38 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME; |
44 | 49 |
45 if (ofd <0) | 50 if (ofd <0) |
46 return; | 51 return; |
47 | 52 |
48 size = lseek (ofd, 0, SEEK_END); | 53 size = lseek (ofd, 0, SEEK_END); |
49 data = (unsigned char *)xmalloc (size); | 54 data = xmalloc (size); |
50 lseek (ofd, 0, SEEK_SET); | 55 lseek (ofd, 0, SEEK_SET); |
51 | 56 |
52 if (!data) | 57 if (!data) |
53 { | 58 { |
54 close (ofd); | 59 close (ofd); |
69 PlaySound (XSTRING_DATA (fname), NULL, flags); | 74 PlaySound (XSTRING_DATA (fname), NULL, flags); |
70 } | 75 } |
71 | 76 |
72 /* mswindows can't cope with playing a sound from alloca space so we | 77 /* mswindows can't cope with playing a sound from alloca space so we |
73 have to convert if necessary */ | 78 have to convert if necessary */ |
74 static int play_sound_data_1 (unsigned char *data, int length, int volume, | 79 static void play_sound_data_1 (unsigned char *data, int length, int volume, |
75 int convert_to_malloc) | 80 int convert_to_malloc) |
76 { | 81 { |
77 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; | 82 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; |
78 static unsigned char* sound_data=0; | 83 static unsigned char* sound_data=0; |
79 if (sound_data) | 84 if (sound_data) |
83 sound_data=0; | 88 sound_data=0; |
84 } | 89 } |
85 | 90 |
86 if (convert_to_malloc) | 91 if (convert_to_malloc) |
87 { | 92 { |
88 sound_data = (unsigned char *)xmalloc (length); | 93 sound_data = xmalloc (length); |
89 memcpy (sound_data, data, length); | 94 memcpy (sound_data, data, length); |
90 } | 95 } |
91 else | 96 else |
92 sound_data = data; | 97 sound_data = data; |
93 | 98 |
94 PlaySound(sound_data, NULL, flags); | 99 PlaySound(sound_data, NULL, flags); |
95 | 100 |
96 /* #### Error handling? */ | 101 return; |
97 return 1; | |
98 } | 102 } |
99 | 103 |
100 int play_sound_data (unsigned char *data, int length, int volume) | 104 void play_sound_data (unsigned char *data, int length, int volume) |
101 { | 105 { |
102 return play_sound_data_1 (data, length, volume, TRUE); | 106 play_sound_data_1 (data, length, volume, TRUE); |
103 } | 107 } |