comparison decoders/voc.c @ 477:3e705c9180e5

Fixed binary compatibility, added Sound_GetDuration().
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 12 May 2004 02:15:00 +0000
parents c66080364dff
children 00b61987b555
comparison
equal deleted inserted replaced
475:f0b8865577db 477:3e705c9180e5
243 v->rest = sblen - 2; 243 v->rest = sblen - 2;
244 v->size = ST_SIZE_BYTE; 244 v->size = ST_SIZE_BYTE;
245 245
246 bytes_per_second = sample->actual.rate 246 bytes_per_second = sample->actual.rate
247 * sample->actual.channels; 247 * sample->actual.channels;
248 sample->total_time += ( v->rest ) / bytes_per_second * 1000; 248 internal->total_time += ( v->rest ) / bytes_per_second * 1000;
249 sample->total_time += (v->rest % bytes_per_second) * 1000 249 internal->total_time += (v->rest % bytes_per_second) * 1000
250 / bytes_per_second; 250 / bytes_per_second;
251 return 1; 251 return 1;
252 252
253 case VOC_DATA_16: 253 case VOC_DATA_16:
254 if (!voc_readbytes(src, v, &new_rate_long, sizeof (Uint32))) 254 if (!voc_readbytes(src, v, &new_rate_long, sizeof (Uint32)))
255 return 0; 255 return 0;
279 279
280 if (!voc_readbytes(src, v, trash, sizeof (Uint8) * 6)) 280 if (!voc_readbytes(src, v, trash, sizeof (Uint8) * 6))
281 return 0; 281 return 0;
282 v->rest = sblen - 12; 282 v->rest = sblen - 12;
283 283
284 bytes_per_second = ((v->size == ST_SIZE_WORD) ? (2) : (1)) * 284 bytes_per_second = ((v->size == ST_SIZE_WORD) ? (2) : (1)) *
285 sample->actual.rate * v->channels; 285 sample->actual.rate * v->channels;
286 sample->total_time += v->rest / bytes_per_second * 1000; 286 internal->total_time += v->rest / bytes_per_second * 1000;
287 sample->total_time += ( v->rest % bytes_per_second ) * 1000 287 internal->total_time += ( v->rest % bytes_per_second ) * 1000
288 / bytes_per_second; 288 / bytes_per_second;
289 return 1; 289 return 1;
290 290
291 case VOC_CONT: 291 case VOC_CONT:
292 v->rest = sblen; 292 v->rest = sblen;
293 return 1; 293 return 1;
313 else 313 else
314 v->rate = uc; 314 v->rate = uc;
315 v->rest = period; 315 v->rest = period;
316 v->silent = 1; 316 v->silent = 1;
317 317
318 sample->total_time += (period) / (v->rate) * 1000; 318 internal->total_time += (period) / (v->rate) * 1000;
319 sample->total_time += (period % v->rate) * 1000 / v->rate; 319 internal->total_time += (period % v->rate) * 1000 / v->rate;
320 return 1; 320 return 1;
321 321
322 case VOC_LOOP: 322 case VOC_LOOP:
323 case VOC_LOOPEND: 323 case VOC_LOOPEND:
324 for(i = 0; i < sblen; i++) /* skip repeat loops. */ 324 for(i = 0; i < sblen; i++) /* skip repeat loops. */