~ubuntu-branches/debian/wheezy/idjc/wheezy

« back to all changes in this revision

Viewing changes to c/flacdecode.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:
34
34
 
35
35
void make_flac_audio_to_float(struct xlplayer *self, float *flbuf, const FLAC__int32 * const inputbuffer[], unsigned int numsamples, unsigned int bits_per_sample, unsigned int numchannels)
36
36
   {
37
 
   int sample, channel, shiftvalue = 32 - bits_per_sample;
 
37
   int shiftvalue = 32 - bits_per_sample;
 
38
   unsigned sample, channel;
38
39
   const float half_randmax = (float)(RAND_MAX >> 1);
39
40
   float dither;
40
41
   float dscale;
58
59
      }
59
60
   }
60
61
 
61
 
#ifdef FLAC_PRE1_1_2
62
 
static FLAC__StreamDecoderWriteStatus flac_writer_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const inputbuffer[], void *client_data)
63
 
#endif
64
 
#ifdef FLAC_POST1_1_3
65
62
static FLAC__StreamDecoderWriteStatus flac_writer_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const inputbuffer[], void *client_data)
66
 
#endif
67
63
   {
68
64
   struct xlplayer *xlplayer = client_data;
69
65
   struct flacdecode_vars *self = xlplayer->dec_data;
112
108
   return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
113
109
   }
114
110
 
115
 
#ifdef FLAC_PRE1_1_2
116
 
static void flac_metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *md, void *client_data)
117
 
   {
118
 
   /* do nothing with the metadata */
119
 
   }
120
 
#endif
121
 
 
122
 
#ifdef FLAC_PRE1_1_2
123
 
static void flac_error_callback(const FLAC__FileDecoder *decoder,FLAC__StreamDecoderErrorStatus se, void *client_data)
124
 
#endif
125
 
#ifdef FLAC_POST1_1_3
126
111
static void flac_error_callback(const FLAC__StreamDecoder *decoder,FLAC__StreamDecoderErrorStatus se, void *client_data)
127
 
#endif
128
112
   {
129
113
   struct xlplayer *xlplayer = client_data;
130
114
         
149
133
   struct flacdecode_vars *self = xlplayer->dec_data;
150
134
   int src_error;
151
135
   
152
 
#ifdef FLAC_PRE1_1_2
153
 
   if (!(self->decoder = FLAC__file_decoder_new()))
154
 
      {
155
 
      fprintf(stderr, "flacdecode_init: %s could not initialise flac decoder\n", xlplayer->playername);
156
 
      goto cleanup;
157
 
      }
158
 
   FLAC__file_decoder_set_client_data(self->decoder, xlplayer);
159
 
   FLAC__file_decoder_set_write_callback(self->decoder, flac_writer_callback);
160
 
   FLAC__file_decoder_set_error_callback(self->decoder, flac_error_callback);
161
 
   FLAC__file_decoder_set_metadata_callback(self->decoder, flac_metadata_callback);
162
 
   FLAC__file_decoder_set_filename(self->decoder, xlplayer->pathname);
163
 
   if ((self->decoderstate = FLAC__file_decoder_init(self->decoder)) != FLAC__FILE_DECODER_OK)
164
 
      {
165
 
      fprintf(stderr, "flacdecode_init: %s error during flac player initialisation\n", xlplayer->playername);
166
 
      FLAC__file_decoder_delete(self->decoder);
167
 
      goto cleanup;
168
 
      }
169
 
   if (xlplayer->seek_s)
170
 
      {
171
 
      self->suppress_audio_output = TRUE;               /* prevent seek noise */
172
 
      FLAC__file_decoder_seek_absolute(self->decoder, ((FLAC__uint64)xlplayer->seek_s) * ((FLAC__uint64)self->metainfo.data.stream_info.sample_rate));
173
 
      self->suppress_audio_output = FALSE;
174
 
      }
175
 
#endif
176
 
#ifdef FLAC_POST1_1_3
177
136
   if (!(self->decoder = FLAC__stream_decoder_new()))
178
137
      {
179
138
      fprintf(stderr, "flacdecode_init: %s could not initialise flac decoder\n", xlplayer->playername);
191
150
      FLAC__stream_decoder_seek_absolute(self->decoder, ((FLAC__uint64)xlplayer->seek_s) * ((FLAC__uint64)self->metainfo.data.stream_info.sample_rate));
192
151
      self->suppress_audio_output = FALSE;
193
152
      }
194
 
#endif
195
153
   if ((self->resample_f = (self->metainfo.data.stream_info.sample_rate != xlplayer->samplerate)))
196
154
      {
197
155
      fprintf(stderr, "flacdecode_init: %s configuring resampler\n", xlplayer->playername);
199
157
      if (src_error)
200
158
         {
201
159
         fprintf(stderr, "flacdecode_init: %s src_new reports - %s\n", xlplayer->playername, src_strerror(src_error));
202
 
#ifdef FLAC_PRE1_1_2
203
 
         FLAC__file_decoder_delete(self->decoder);
204
 
#endif
205
 
#ifdef FLAC_POST1_1_3
206
160
         FLAC__stream_decoder_delete(self->decoder);
207
 
#endif
208
161
         goto cleanup;
209
162
         }
210
163
      xlplayer->src_data.output_frames = 0;
228
181
   {
229
182
   struct flacdecode_vars *self = xlplayer->dec_data;
230
183
 
231
 
#ifdef FLAC_PRE1_1_2
232
 
   FLAC__file_decoder_process_single(self->decoder);
233
 
   if (FLAC__file_decoder_get_state(self->decoder) != FLAC__FILE_DECODER_OK) 
234
 
      xlplayer->playmode = PM_EJECTING;
235
 
#endif
236
 
#ifdef FLAC_POST1_1_3
237
184
   FLAC__stream_decoder_process_single(self->decoder);
238
185
   if (FLAC__stream_decoder_get_state(self->decoder) == FLAC__STREAM_DECODER_END_OF_STREAM)
239
186
      xlplayer->playmode = PM_EJECTING;
240
 
#endif
241
187
   }
242
188
 
243
189
static void flacdecode_eject(struct xlplayer *xlplayer)
244
190
   {
245
191
   struct flacdecode_vars *self = xlplayer->dec_data;
246
192
 
247
 
#ifdef FLAC_PRE1_1_2
248
 
   FLAC__file_decoder_finish(self->decoder);
249
 
   FLAC__file_decoder_delete(self->decoder);
250
 
#endif
251
 
#ifdef FLAC_POST1_1_3
252
193
   FLAC__stream_decoder_finish(self->decoder);
253
194
   FLAC__stream_decoder_delete(self->decoder);
254
 
#endif
255
195
   if (self->flbuf)
256
196
      free(self->flbuf);
257
197
   if (self->resample_f)