comparison src/nas.c @ 1097:26274e0d7794

[xemacs-hg @ 2002-11-11 16:03:12 by stephent] crash message <87of8wyy85.fsf@tleepslib.sk.tsukuba.ac.jp> nas 1.6 <87isz4yy0o.fsf@tleepslib.sk.tsukuba.ac.jp> warning fixes <87el9syvg4.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Mon, 11 Nov 2002 16:03:57 +0000
parents 6728e641994e
children 01c57eb70ae9
comparison
equal deleted inserted replaced
1096:2c2ff019dd33 1097:26274e0d7794
50 * Added back asynchronous play if nas library has 50 * Added back asynchronous play if nas library has
51 * correct error facilities. 51 * correct error facilities.
52 * 4/11/94, rjc Added wait_for_sounds to be called when user wants to 52 * 4/11/94, rjc Added wait_for_sounds to be called when user wants to
53 * be sure all play has finished. 53 * be sure all play has finished.
54 * 1998-10-01 rlt Added support for WAVE files. 54 * 1998-10-01 rlt Added support for WAVE files.
55 * 2002-10-16 Jon Trulson modifed this to work with NAS releases
56 * 1.5f and higher. We were using the private variable
57 * SoundFileInfo that doesn't exist anymore. But preserve
58 * backward compatibility. This will not work for some
59 * versions of NAS around 1.5b to 1.5f or so. Known to
60 * work on 1.2p5 and 1.6.
55 */ 61 */
56 62
57 #include <config.h> 63 #include <config.h>
58 #include "lisp.h" 64 #include "lisp.h"
59 65
958 SoundOpenDataForReading (UChar_Binary *data, 964 SoundOpenDataForReading (UChar_Binary *data,
959 int length) 965 int length)
960 966
961 { 967 {
962 Sound s; 968 Sound s;
969 #if (AudioLibraryVersionMajor >= 2 ) && (AudioLibraryVersionMinor >= 3)
970 SoundFileInfoProc toProc;
971 #endif
963 972
964 if (!(s = (Sound) malloc (sizeof (SoundRec)))) 973 if (!(s = (Sound) malloc (sizeof (SoundRec))))
965 return NULL; 974 return NULL;
966 975
967 if ((s->formatInfo = SndOpenDataForReading ((Char_Binary *) data, length)) != NULL) 976 if ((s->formatInfo = SndOpenDataForReading ((Char_Binary *) data, length)) != NULL)
968 { 977 {
978 #if (AudioLibraryVersionMajor >= 2 ) && (AudioLibraryVersionMinor >= 3)
979 if ((toProc = SoundFileGetProc(SoundFileFormatSnd,
980 SoundFileInfoProcTo)) == NULL)
981 {
982 SndCloseFile ((SndInfo *) (s->formatInfo));
983 free (s);
984
985 return NULL;
986 }
987 if (!((*toProc)(s)))
988 #else
969 if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatSnd].toSound)) (s)) 989 if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatSnd].toSound)) (s))
990 #endif
970 { 991 {
971 SndCloseFile ((SndInfo *) (s->formatInfo)); 992 SndCloseFile ((SndInfo *) (s->formatInfo));
972 free (s); 993 free (s);
973 return NULL; 994 return NULL;
974 } 995 }
975 } 996 }
976 else if ((s->formatInfo = WaveOpenDataForReading ((Char_Binary *) data, length)) != NULL) 997 else if ((s->formatInfo = WaveOpenDataForReading ((Char_Binary *) data, length)) != NULL)
977 { 998 {
999 #if (AudioLibraryVersionMajor >= 2 ) && (AudioLibraryVersionMinor >= 3)
1000 if ((toProc = SoundFileGetProc(SoundFileFormatWave,
1001 SoundFileInfoProcTo)) == NULL)
1002 {
1003 WaveCloseFile ((WaveInfo *) (s->formatInfo));
1004 free (s);
1005
1006 return NULL;
1007 }
1008 if (!((*toProc)(s)))
1009 #else
978 if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatWave].toSound)) (s)) 1010 if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatWave].toSound)) (s))
1011 #endif
979 { 1012 {
980 WaveCloseFile ((WaveInfo *) (s->formatInfo)); 1013 WaveCloseFile ((WaveInfo *) (s->formatInfo));
981 free (s); 1014 free (s);
982 return NULL; 1015 return NULL;
983 } 1016 }