Mercurial > hg > xemacs-beta
comparison src/ntplay.c @ 292:6cb5e14cd98e r21-0b44
Import from CVS: tag r21-0b44
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:37:15 +0200 |
parents | e11d67e05968 |
children | 4711e16a8e49 |
comparison
equal
deleted
inserted
replaced
291:7aa74ac42bd2 | 292:6cb5e14cd98e |
---|---|
25 #include "sysfile.h" | 25 #include "sysfile.h" |
26 #include "lisp.h" | 26 #include "lisp.h" |
27 | 27 |
28 #ifdef __CYGWIN32__ | 28 #ifdef __CYGWIN32__ |
29 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD); | 29 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD); |
30 #else | |
31 #include <mmsystem.h> | |
30 #endif | 32 #endif |
31 static void play_sound_data_1 (unsigned char *data, int length, | 33 static void play_sound_data_1 (unsigned char *data, int length, |
32 int volume, int convert); | 34 int volume, int convert); |
33 | 35 |
34 void play_sound_file (char *sound_file, int volume) | 36 void play_sound_file (char *sound_file, int volume) |
62 { | 64 { |
63 close (ofd); | 65 close (ofd); |
64 xfree (data); | 66 xfree (data); |
65 return; | 67 return; |
66 } | 68 } |
69 close (ofd); | |
67 | 70 |
68 play_sound_data_1 (data, size, 100, FALSE); | 71 play_sound_data_1 (data, size, 100, FALSE); |
69 | |
70 xfree (data); | |
71 close (ofd); | |
72 } | 72 } |
73 else | 73 else |
74 PlaySound (XSTRING_DATA (fname), NULL, flags); | 74 PlaySound (XSTRING_DATA (fname), NULL, flags); |
75 } | 75 } |
76 | 76 |
78 have to convert if necessary */ | 78 have to convert if necessary */ |
79 static void 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, |
80 int convert_to_malloc) | 80 int convert_to_malloc) |
81 { | 81 { |
82 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; | 82 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; |
83 unsigned char* sound_data; | 83 static unsigned char* sound_data=0; |
84 if (sound_data) | |
85 { | |
86 PlaySound (NULL, NULL, flags); | |
87 xfree (sound_data); | |
88 sound_data=0; | |
89 } | |
90 | |
84 if (convert_to_malloc) | 91 if (convert_to_malloc) |
85 { | 92 { |
86 sound_data = xmalloc (length); | 93 sound_data = xmalloc (length); |
87 memcpy (sound_data, data, length); | 94 memcpy (sound_data, data, length); |
88 } | 95 } |
89 else | 96 else |
90 sound_data = data; | 97 sound_data = data; |
91 | 98 |
92 PlaySound(sound_data, NULL, flags); | 99 PlaySound(sound_data, NULL, flags); |
93 if (convert_to_malloc) | 100 |
94 xfree (sound_data); | |
95 return; | 101 return; |
96 } | 102 } |
97 | 103 |
98 void play_sound_data (unsigned char *data, int length, int volume) | 104 void play_sound_data (unsigned char *data, int length, int volume) |
99 { | 105 { |