Mercurial > SDL_sound_CoreAudio
diff decoders/au.c @ 217:9bab949e2318
Fixed memory leak I introduced, mangled coding style some more. :)
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 13 Jan 2002 21:34:46 +0000 |
parents | 948b62500a54 |
children | c9772a9f5271 |
line wrap: on
line diff
--- a/decoders/au.c Sun Jan 13 19:51:14 2002 +0000 +++ b/decoders/au.c Sun Jan 13 21:34:46 2002 +0000 @@ -75,12 +75,12 @@ static int AU_init(void) { return(1); -} +} /* AU_init */ static void AU_quit(void) { /* no-op. */ -} +} /* AU_quit */ struct au_file_hdr { @@ -138,8 +138,8 @@ { Sound_SetError("No .au file (bad header)"); free(dec); - return 0; - } + return(0); + } /* if */ if (SDL_SwapLE32(hdr.magic) == AU_MAGIC) { @@ -166,7 +166,7 @@ Sound_SetError("Unsupported .au encoding"); free(dec); return 0; - } + } /* switch */ sample->actual.rate = SDL_SwapBE32(hdr.sample_rate); sample->actual.channels = SDL_SwapBE32(hdr.channels); @@ -176,7 +176,7 @@ /* skip remaining part of header (input may be unseekable) */ for (i = HDR_SIZE; i < hsize; i++) SDL_RWread(rw, &c, 1, 1); - } + } /* if */ else if (__Sound_strcasecmp(ext, "au") == 0) { @@ -194,20 +194,28 @@ sample->actual.format = AUDIO_S16SYS; sample->actual.rate = 8000; sample->actual.channels = 1; - } + } /* else if */ + + else + { + SNDDBG(("AU: Not an .AU stream.\n")); + free(dec); + return(0); + } /* else */ sample->flags = SOUND_SAMPLEFLAG_NONE; SNDDBG(("AU: Accepting data stream.\n")); - return 1; -} + return(1); +} /* AU_open */ static void AU_close(Sound_Sample *sample) { Sound_SampleInternal *internal = sample->opaque; free(internal->decoder_private); -} +} /* AU_close */ + /* table to convert from µ-law encoding to signed 16-bit samples, generated by a throwaway perl script */ @@ -246,6 +254,7 @@ 56, 48, 40, 32, 24, 16, 8, 0 }; + static Uint32 AU_read(Sound_Sample *sample) { int ret; @@ -262,7 +271,7 @@ we can expand them to 16-bit samples afterwards */ maxlen >>= 1; buf += maxlen; - } + } /* if */ if(maxlen > dec->remaining) maxlen = dec->remaining; @@ -284,11 +293,11 @@ for (i = 0; i < ret; i++) dst[i] = ulaw_to_linear[buf[i]]; ret <<= 1; /* return twice as much as read */ - } - } + } /* if */ + } /* else */ - return ret; -} + return(ret); +} /* AU_read */ #endif /* SOUND_SUPPORTS_AU */