Mercurial > SDL_sound_CoreAudio
comparison decoders/flac.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 | 46d5f399cb35 |
comparison
equal
deleted
inserted
replaced
475:f0b8865577db | 477:3e705c9180e5 |
---|---|
231 const decoder_t *decoder, | 231 const decoder_t *decoder, |
232 const d_metadata_t *metadata, | 232 const d_metadata_t *metadata, |
233 void *client_data) | 233 void *client_data) |
234 { | 234 { |
235 flac_t *f = (flac_t *) client_data; | 235 flac_t *f = (flac_t *) client_data; |
236 Sound_Sample *sample = f->sample; | |
237 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | |
236 | 238 |
237 SNDDBG(("FLAC: Metadata callback.\n")); | 239 SNDDBG(("FLAC: Metadata callback.\n")); |
238 | 240 |
239 /* There are several kinds of metadata, but STREAMINFO is the only | 241 /* There are several kinds of metadata, but STREAMINFO is the only |
240 * one that always has to be there. | 242 * one that always has to be there. |
242 if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) | 244 if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) |
243 { | 245 { |
244 SNDDBG(("FLAC: Metadata is streaminfo.\n")); | 246 SNDDBG(("FLAC: Metadata is streaminfo.\n")); |
245 | 247 |
246 f->is_flac = 1; | 248 f->is_flac = 1; |
247 f->sample->actual.channels = metadata->data.stream_info.channels; | 249 sample->actual.channels = metadata->data.stream_info.channels; |
248 f->sample->actual.rate = metadata->data.stream_info.sample_rate; | 250 sample->actual.rate = metadata->data.stream_info.sample_rate; |
249 | 251 |
250 if (metadata->data.stream_info.sample_rate == 0 || | 252 if (metadata->data.stream_info.sample_rate == 0 || |
251 metadata->data.stream_info.total_samples == 0) | 253 metadata->data.stream_info.total_samples == 0) |
252 f->sample->total_time = -1; | 254 { |
253 else { | 255 internal->total_time = -1; |
254 f->sample->total_time = (metadata->data.stream_info.total_samples) | 256 } /* if */ |
257 else | |
258 { | |
259 internal->total_time = (metadata->data.stream_info.total_samples) | |
255 / metadata->data.stream_info.sample_rate * 1000; | 260 / metadata->data.stream_info.sample_rate * 1000; |
256 f->sample->total_time += (metadata->data.stream_info.total_samples | 261 internal->total_time += (metadata->data.stream_info.total_samples |
257 % metadata->data.stream_info.sample_rate) * 1000 | 262 % metadata->data.stream_info.sample_rate) * 1000 |
258 / metadata->data.stream_info.sample_rate; | 263 / metadata->data.stream_info.sample_rate; |
259 } | 264 } /* else */ |
260 | 265 |
261 if (metadata->data.stream_info.bits_per_sample > 8) | 266 if (metadata->data.stream_info.bits_per_sample > 8) |
262 f->sample->actual.format = AUDIO_S16MSB; | 267 sample->actual.format = AUDIO_S16MSB; |
263 else | 268 else |
264 f->sample->actual.format = AUDIO_S8; | 269 sample->actual.format = AUDIO_S8; |
265 } /* if */ | 270 } /* if */ |
266 } /* metadata_callback */ | 271 } /* metadata_callback */ |
267 | 272 |
268 | 273 |
269 static void error_callback( | 274 static void error_callback( |