# HG changeset patch # User Ryan C. Gordon # Date 1021887659 0 # Node ID e683cb99f88fd71791a85776a430a2484c673bd3 # Parent a81976ed5df7f7f69e35ab64976971e494c9e8de Fixed seek implementation. diff -r a81976ed5df7 -r e683cb99f88f decoders/au.c --- a/decoders/au.c Mon May 20 09:22:42 2002 +0000 +++ b/decoders/au.c Mon May 20 09:40:59 2002 +0000 @@ -364,42 +364,17 @@ { Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; struct audec *dec = (struct audec *) internal->decoder_private; - int offset = dec->start_offset; - int frames = (int) (((float) sample->actual.rate / 1000.0) * ((float) ms)); - int points = (int) (frames * sample->actual.channels); + int offset = __Sound_convertMsToBytePos(&sample->actual, ms); int rc; - -SNDDBG(("WARNING: AU_seek() may be buggy.\n")); /* !!! FIXME : remove this. */ - - switch (dec->encoding) - { - case AU_ENC_ULAW_8: /* halve the byte offset for compression. */ -SNDDBG(("uLaw8 encoding\n")); /* !!! FIXME : remove this. */ - offset += ((sizeof (Uint8) * points) >> 1); - break; + int pos; - case AU_ENC_LINEAR_8: -SNDDBG(("linear8 encoding\n")); /* !!! FIXME : remove this. */ - offset += (sizeof (Uint8) * points); - break; - - case AU_ENC_LINEAR_16: -SNDDBG(("linear16 encoding\n")); /* !!! FIXME : remove this. */ - offset += (sizeof (Uint16) * points); - break; + if (dec->encoding == AU_ENC_ULAW_8) + offset >>= 1; /* halve the byte offset for compression. */ - default: - BAIL_MACRO("Unexpected format. Something is very wrong.", 0); - break; - } /* switch */ - -SNDDBG(("Seek to %d (edge is %d).\n", (int) offset, (int) dec->total)); - - BAIL_IF_MACRO(offset >= dec->total, ERR_IO_ERROR, 0); /* seek past end? */ - - rc = SDL_RWseek(internal->rw, offset, SEEK_SET); - BAIL_IF_MACRO(rc != offset, ERR_IO_ERROR, 0); - dec->remaining = dec->total - (offset - 2); + pos = (int) (dec->start_offset + offset); + rc = SDL_RWseek(internal->rw, pos, SEEK_SET); + BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0); + dec->remaining = dec->total - offset; return(1); } /* AU_seek */