comparison src/ntplay.c @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents a86b2b5e0111
children 501cfd01ee6d
comparison
equal deleted inserted replaced
405:0e08f63c74d2 406:b8cc9ab3f761
21 #include <windows.h> 21 #include <windows.h>
22 #include <config.h> 22 #include <config.h>
23 #include <stdio.h> 23 #include <stdio.h>
24 #include "sysfile.h" 24 #include "sysfile.h"
25 #include "lisp.h" 25 #include "lisp.h"
26 #include "nativesound.h"
26 27
27 #if (defined (__CYGWIN32__) || defined(__MINGW32__)) && \ 28 #if (defined (__CYGWIN32__) || defined(__MINGW32__)) && \
28 CYGWIN_VERSION_DLL_MAJOR < 21 29 CYGWIN_VERSION_DLL_MAJOR < 21
29 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD); 30 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD);
30 #else 31 #else
31 #include <mmsystem.h> 32 #include <mmsystem.h>
32 #endif 33 #endif
33 static void play_sound_data_1 (unsigned char *data, int length, 34 static int play_sound_data_1 (unsigned char *data, int length,
34 int volume, int convert); 35 int volume, int convert);
35 36
36 void play_sound_file (char *sound_file, int volume) 37 void play_sound_file (char *sound_file, int volume)
37 { 38 {
38 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME; 39 DWORD flags = SND_ASYNC | SND_NODEFAULT | SND_FILENAME;
74 PlaySound (XSTRING_DATA (fname), NULL, flags); 75 PlaySound (XSTRING_DATA (fname), NULL, flags);
75 } 76 }
76 77
77 /* mswindows can't cope with playing a sound from alloca space so we 78 /* mswindows can't cope with playing a sound from alloca space so we
78 have to convert if necessary */ 79 have to convert if necessary */
79 static void play_sound_data_1 (unsigned char *data, int length, int volume, 80 static int play_sound_data_1 (unsigned char *data, int length, int volume,
80 int convert_to_malloc) 81 int convert_to_malloc)
81 { 82 {
82 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT; 83 DWORD flags = SND_ASYNC | SND_MEMORY | SND_NODEFAULT;
83 static unsigned char* sound_data=0; 84 static unsigned char* sound_data=0;
84 if (sound_data) 85 if (sound_data)
96 else 97 else
97 sound_data = data; 98 sound_data = data;
98 99
99 PlaySound(sound_data, NULL, flags); 100 PlaySound(sound_data, NULL, flags);
100 101
101 return; 102 /* #### Error handling? */
103 return 1;
102 } 104 }
103 105
104 void play_sound_data (unsigned char *data, int length, int volume) 106 int play_sound_data (unsigned char *data, int length, int volume)
105 { 107 {
106 play_sound_data_1 (data, length, volume, TRUE); 108 return play_sound_data_1 (data, length, volume, TRUE);
107 } 109 }