Mercurial > hg > xemacs-beta
comparison src/ntplay.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | a5df635868b2 |
children | 183866b06e0b |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
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 | |
23 #include <config.h> | 21 #include <config.h> |
24 #include <stdio.h> | |
25 #include "sysfile.h" | |
26 #include "lisp.h" | 22 #include "lisp.h" |
27 | 23 |
28 #if (defined (__CYGWIN32__) || defined(__MINGW32__)) && \ | 24 #include "sysfile.h" |
29 CYGWIN_VERSION_DLL_MAJOR < 21 | 25 #include "nt.h" |
30 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD); | 26 #include "nativesound.h" |
31 #else | 27 |
32 #include <mmsystem.h> | 28 static int play_sound_data_1 (unsigned char *data, int length, |
33 #endif | |
34 static void play_sound_data_1 (unsigned char *data, int length, | |
35 int volume, int convert); | 29 int volume, int convert); |
36 | 30 |
37 void play_sound_file (char *sound_file, int volume) | 31 void play_sound_file (char *sound_file, int volume) |
38 { | 32 { |
39 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME; | 33 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME; |
50 | 44 |
51 if (ofd <0) | 45 if (ofd <0) |
52 return; | 46 return; |
53 | 47 |
54 size = lseek (ofd, 0, SEEK_END); | 48 size = lseek (ofd, 0, SEEK_END); |
55 data = xmalloc (size); | 49 data = (unsigned char *)xmalloc (size); |
56 lseek (ofd, 0, SEEK_SET); | 50 lseek (ofd, 0, SEEK_SET); |
57 | 51 |
58 if (!data) | 52 if (!data) |
59 { | 53 { |
60 close (ofd); | 54 close (ofd); |
75 PlaySound (XSTRING_DATA (fname), NULL, flags); | 69 PlaySound (XSTRING_DATA (fname), NULL, flags); |
76 } | 70 } |
77 | 71 |
78 /* mswindows can't cope with playing a sound from alloca space so we | 72 /* mswindows can't cope with playing a sound from alloca space so we |
79 have to convert if necessary */ | 73 have to convert if necessary */ |
80 static void play_sound_data_1 (unsigned char *data, int length, int volume, | 74 static int play_sound_data_1 (unsigned char *data, int length, int volume, |
81 int convert_to_malloc) | 75 int convert_to_malloc) |
82 { | 76 { |
83 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; | 77 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; |
84 static unsigned char* sound_data=0; | 78 static unsigned char* sound_data=0; |
85 if (sound_data) | 79 if (sound_data) |
89 sound_data=0; | 83 sound_data=0; |
90 } | 84 } |
91 | 85 |
92 if (convert_to_malloc) | 86 if (convert_to_malloc) |
93 { | 87 { |
94 sound_data = xmalloc (length); | 88 sound_data = (unsigned char *)xmalloc (length); |
95 memcpy (sound_data, data, length); | 89 memcpy (sound_data, data, length); |
96 } | 90 } |
97 else | 91 else |
98 sound_data = data; | 92 sound_data = data; |
99 | 93 |
100 PlaySound(sound_data, NULL, flags); | 94 PlaySound(sound_data, NULL, flags); |
101 | 95 |
102 return; | 96 /* #### Error handling? */ |
97 return 1; | |
103 } | 98 } |
104 | 99 |
105 void play_sound_data (unsigned char *data, int length, int volume) | 100 int play_sound_data (unsigned char *data, int length, int volume) |
106 { | 101 { |
107 play_sound_data_1 (data, length, volume, TRUE); | 102 return play_sound_data_1 (data, length, volume, TRUE); |
108 } | 103 } |