comparison decoders/mikmod.c @ 397:077cdba5d5f6

FIXME cleanup.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 11 Jul 2002 05:02:14 +0000
parents 6095d0a52a20
children c09cf7c046cd
comparison
equal deleted inserted replaced
396:8cff79634bc5 397:077cdba5d5f6
164 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 164 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
165 165
166 MRWOPSREADER *reader = (MRWOPSREADER *) malloc(sizeof (MRWOPSREADER)); 166 MRWOPSREADER *reader = (MRWOPSREADER *) malloc(sizeof (MRWOPSREADER));
167 if (reader != NULL) 167 if (reader != NULL)
168 { 168 {
169 int failed_seek = 1;
169 int here; 170 int here;
170 reader->core.Eof = _mm_RWopsReader_eof; 171 reader->core.Eof = _mm_RWopsReader_eof;
171 reader->core.Read = _mm_RWopsReader_read; 172 reader->core.Read = _mm_RWopsReader_read;
172 reader->core.Get = _mm_RWopsReader_get; 173 reader->core.Get = _mm_RWopsReader_get;
173 reader->core.Seek = _mm_RWopsReader_seek; 174 reader->core.Seek = _mm_RWopsReader_seek;
175 reader->sample = sample; 176 reader->sample = sample;
176 177
177 /* RWops does not explicitly support an eof check, so we shall find 178 /* RWops does not explicitly support an eof check, so we shall find
178 the end manually - this requires seek support for the RWop */ 179 the end manually - this requires seek support for the RWop */
179 here = SDL_RWtell(internal->rw); 180 here = SDL_RWtell(internal->rw);
180 reader->end = SDL_RWseek(internal->rw, 0, SEEK_END); 181 if (here != -1)
181 SDL_RWseek(internal->rw, here, SEEK_SET); /* Move back */ 182 {
182 /* !!! FIXME: What happens if the seek fails? */ 183 reader->end = SDL_RWseek(internal->rw, 0, SEEK_END);
184 if (reader->end != -1)
185 {
186 /* Move back */
187 if (SDL_RWseek(internal->rw, here, SEEK_SET) != -1)
188 failed_seek = 0;
189 } /* if */
190 } /* if */
191
192 if (failed_seek)
193 {
194 free(reader);
195 reader = NULL;
196 } /* if */
183 } /* if */ 197 } /* if */
184 198
185 return((MREADER *) reader); 199 return((MREADER *) reader);
186 } /* _mm_new_rwops_reader */ 200 } /* _mm_new_rwops_reader */
187 201