X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fnas.c;h=a0a5ddb369cda34c990d47985c16916e97523a3b;hb=45d296a62e0a0adaa3a90801f2601bb20e06e993;hp=bc473aa811040eb5b4b9bad8169abd4f815f8546;hpb=59eec5f21669e81977b5b1fe9bf717cab49cf7fb;p=chise%2Fxemacs-chise.git.1 diff --git a/src/nas.c b/src/nas.c index bc473aa..a0a5ddb 100644 --- a/src/nas.c +++ b/src/nas.c @@ -50,6 +50,12 @@ * 4/11/94, rjc Added wait_for_sounds to be called when user wants to * be sure all play has finished. * 1998-10-01 rlt Added support for WAVE files. + * 2002-10-16 Jon Trulson modifed this to work with NAS releases + * 1.5f and higher. We were using the private variable + * SoundFileInfo that doesn't exist anymore. But preserve + * backward compatibility. This will not work for some + * versions of NAS around 1.5b to 1.5f or so. Known to + * work on 1.2p5 and 1.6. */ #ifdef emacs @@ -745,7 +751,7 @@ SndOpenDataForReading (const char *data, /* Stuff taken from wave.c from NAS. Just like snd files, NAS can't read wave data from memory, so these functions do that for us. */ -#define Err() { return NULL; } +#define Err() { free (wi); return NULL; } #define readFourcc(_f) dread(_f, sizeof(RIFF_FOURCC), 1) #define cmpID(_x, _y) \ strncmp((char *) (_x), (char *) (_y), sizeof(RIFF_FOURCC)) @@ -884,7 +890,7 @@ WaveOpenDataForReading (const char *data, fileSize = PAD2(ck.ckSize) - sizeof(RIFF_FOURCC); - while (fileSize >= sizeof(RiffChunk)) + while (fileSize >= (AuInt32) sizeof(RiffChunk)) { if (!readChunk(&ck)) Err(); @@ -998,13 +1004,28 @@ SoundOpenDataForReading (unsigned char *data, { Sound s; +#if (AudioLibraryVersionMajor >= 2 ) && (AudioLibraryVersionMinor >= 3) + SoundFileInfoProc toProc; +#endif if (!(s = (Sound) malloc (sizeof (SoundRec)))) return NULL; if ((s->formatInfo = SndOpenDataForReading ((char *) data, length)) != NULL) { +#if (AudioLibraryVersionMajor >= 2 ) && (AudioLibraryVersionMinor >= 3) + if ((toProc = SoundFileGetProc(SoundFileFormatSnd, + SoundFileInfoProcTo)) == NULL) + { + SndCloseFile ((SndInfo *) (s->formatInfo)); + free (s); + + return NULL; + } + if (!((*toProc)(s))) +#else if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatSnd].toSound)) (s)) +#endif { SndCloseFile ((SndInfo *) (s->formatInfo)); free (s); @@ -1013,7 +1034,19 @@ SoundOpenDataForReading (unsigned char *data, } else if ((s->formatInfo = WaveOpenDataForReading ((char *) data, length)) != NULL) { +#if (AudioLibraryVersionMajor >= 2 ) && (AudioLibraryVersionMinor >= 3) + if ((toProc = SoundFileGetProc(SoundFileFormatWave, + SoundFileInfoProcTo)) == NULL) + { + WaveCloseFile ((WaveInfo *) (s->formatInfo)); + free (s); + + return NULL; + } + if (!((*toProc)(s))) +#else if (!((int(*)(Sound))(SoundFileInfo[SoundFileFormatWave].toSound)) (s)) +#endif { WaveCloseFile ((WaveInfo *) (s->formatInfo)); free (s);