~ubuntu-branches/ubuntu/trusty/idjc/trusty

« back to all changes in this revision

Viewing changes to c/oggdec.c

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2011-12-03 16:33:59 UTC
  • mfrom: (0.2.6)
  • Revision ID: package-import@ubuntu.com-20111203163359-dq5fy9i756jpoy29
Tags: 0.8.6-1
* New upstream release.
* debian/control:
  - Wrap and sort.
  - Build-depend on autopoint.
  - Drop autotools-dev, unnecessary.
* Drop the whole patch set, none of them is still needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
   return 1;
77
77
   }
78
78
 
79
 
static int vorbis_get_samplerate(struct oggdec_vars *self)  /* attempt to get ARTIST=, TITLE= also */
 
79
static unsigned vorbis_get_samplerate(struct oggdec_vars *self)  /* attempt to get ARTIST=, TITLE= also */
80
80
   {
81
81
   vorbis_info vi;
82
82
   vorbis_comment vc;
83
 
   int samplerate;
 
83
   unsigned samplerate;
84
84
 
85
85
   vorbis_info_init(&vi);
86
86
   vorbis_comment_init(&vc);
173
173
   
174
174
#ifdef HAVE_OGGFLAC
175
175
 
176
 
#ifdef FLAC_POST1_1_3
177
176
FLAC__StreamDecoderReadStatus oggflac_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
178
177
   {
179
178
   struct oggdec_vars *self = client_data;
187
186
   if (bytes_remaining < 0 || *bytes <= 0)
188
187
      return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
189
188
 
190
 
   if (*bytes > bytes_remaining)
 
189
   if (*bytes > (size_t)bytes_remaining)
191
190
      *bytes = bytes_remaining;
192
191
 
193
192
   *bytes = fread(buffer, sizeof (FLAC__byte), *bytes, self->fp);
213
212
   else
214
213
      end_bound = self->bos_offset[self->ix + 1] - start_bound;
215
214
 
216
 
   if (absolute_byte_offset > end_bound - start_bound)
 
215
   if (absolute_byte_offset > (FLAC__uint64)(end_bound - start_bound))
217
216
      {
218
217
      fprintf(stderr, "oggflac_seek_callback: seek error1\n");
219
218
      return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
282
281
   struct oggdec_vars *self = client_data;
283
282
   const FLAC__StreamMetadata_StreamInfo *si;
284
283
   const FLAC__StreamMetadata_VorbisComment *vc;
285
 
   int i, use_alt_tags;
 
284
   int use_alt_tags;
286
285
   
287
286
   int match(char *t, char *comment)
288
287
      {
299
298
 
300
299
   void copy_tag(char *t, char **target, int multiple)
301
300
      {
302
 
      int j;
303
301
      char *old, *new;
304
302
      
305
 
      for (j = 0; j < vc->num_comments; j++)
 
303
      for (unsigned j = 0; j < vc->num_comments; j++)
306
304
         {
307
305
         if (match(t, (char *)vc->comments[j].entry))
308
306
            {
336
334
         vc = &metadata->data.vorbis_comment;
337
335
         fprintf(stderr, "There are %u comment tags\n", (unsigned)vc->num_comments);
338
336
         use_alt_tags = FALSE;
339
 
         for (i = 0; i < vc->num_comments; i++)
 
337
         for (unsigned i = 0; i < vc->num_comments; i++)
340
338
            {
341
339
            if (match("trk-title", (char *)vc->comments[i].entry))
342
340
               use_alt_tags = TRUE;
384
382
         fprintf(stderr, "oggflac_error_callback: flac decoder error, unknown error\n");
385
383
      }
386
384
   }
387
 
#endif /* FLAC_POST1_1_3 */
388
385
 
389
386
static int flac_get_samplerate(struct oggdec_vars *self)
390
387
   {
391
 
#ifndef FLAC_POST1_1_3
392
 
   fprintf(stderr, "flac_get_samplerate: obsolete FLAC API not supported on new features\n"); 
393
 
   return 0;
394
 
#else
395
388
   FLAC__StreamDecoder *decoder;
396
389
 
397
390
   if (!(decoder = FLAC__stream_decoder_new()))
407
400
      oggflac_tell_callback, oggflac_length_callback,
408
401
      oggflac_eof_callback,  oggflac_write_callback,
409
402
      oggflac_metadata_callback, oggflac_error_callback,
410
 
      self) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
 
403
      self) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
411
404
      {
412
405
      fprintf(stderr, "flac_get_samplerate: call to FLAC__stream_decoder_init_stream failed\n");
413
406
      FLAC__stream_decoder_delete(decoder);
418
411
   FLAC__stream_decoder_delete(decoder);
419
412
 
420
413
   return self->samplerate[self->ix];
421
 
#endif /* FLAC_POST1_1_3 */
422
414
   }
423
415
#endif /* HAVE_OGGFLAC */
424
416
 
691
683
         /* make space for data about this logical stream */
692
684
         self->n_streams++;
693
685
         self->bos_offset = realloc(self->bos_offset, self->n_streams * sizeof (off_t));
694
 
         self->granule_count = realloc(self->granule_count, self->n_streams * sizeof (int));
 
686
         self->granule_count = realloc(self->granule_count, self->n_streams * sizeof (unsigned));
695
687
         self->samplerate = realloc(self->samplerate, self->n_streams * sizeof (int));
696
688
         self->channels = realloc(self->channels, self->n_streams * sizeof (int));
697
689
         self->serial = realloc(self->serial, self->n_streams * sizeof (int));
774
766
   off_t  offset = 0, offset_end, offset_new;
775
767
   size_t bytes;
776
768
   char  *buffer;
777
 
   int i, samplerate = 0;
 
769
   int i;
 
770
   unsigned samplerate = 0;
778
771
   double start_time = 0.0;
779
772
   
780
773
   /* allocate storage space */