comparison src/madplug/decoder.c @ 1428:4993976d7ed0

madplug: tuple API changes
author William Pitcock <nenolod@atheme-project.org>
date Fri, 10 Aug 2007 07:45:29 -0500
parents d3fb6dfcd2f8
children db616ccdd40c
comparison
equal deleted inserted replaced
1424:230661b01dc7 1428:4993976d7ed0
190 info->bitrate = 0; 190 info->bitrate = 0;
191 info->pos = mad_timer_zero; 191 info->pos = mad_timer_zero;
192 info->duration = mad_timer_zero; // should be cleared before loop, if we use it as break condition. 192 info->duration = mad_timer_zero; // should be cleared before loop, if we use it as break condition.
193 193
194 if(info->fileinfo_request == TRUE) { 194 if(info->fileinfo_request == TRUE) {
195 info->tuple->length = -1; 195 tuple_associate_int(info->tuple, "length", -1);
196 info->fileinfo_request = FALSE; 196 info->fileinfo_request = FALSE;
197 } 197 }
198 198
199 #ifdef DEBUG 199 #ifdef DEBUG
200 g_message("f: scan_file"); 200 g_message("f: scan_file");
268 mad_timer_count(header.duration, 268 mad_timer_count(header.duration,
269 MAD_UNITS_MILLISECONDS)); 269 MAD_UNITS_MILLISECONDS));
270 g_message("size = %d", stream.next_frame - stream.this_frame); 270 g_message("size = %d", stream.next_frame - stream.this_frame);
271 #endif 271 #endif
272 #endif 272 #endif
273 if(info->tuple->length == -1) 273 if(tuple_get_int(info->tuple, "length") == -1)
274 mad_timer_add(&info->duration, header.duration); 274 mad_timer_add(&info->duration, header.duration);
275 else { 275 else {
276 info->duration.seconds = info->tuple->length / 1000; 276 gint length = tuple_get_int(info->tuple, "length");
277 info->duration.fraction = info->tuple->length % 1000; 277
278 info->duration.seconds = length / 1000;
279 info->duration.fraction = length % 1000;
278 } 280 }
279 data_used += stream.next_frame - stream.this_frame; 281 data_used += stream.next_frame - stream.this_frame;
280 if (info->frames == 1) { 282 if (info->frames == 1) {
281 /* most of these *should* remain constant */ 283 /* most of these *should* remain constant */
282 info->bitrate = header.bitrate; 284 info->bitrate = header.bitrate;
353 if(info->size != 0) 355 if(info->size != 0)
354 info->frames = (info->size - tagsize) / frame_size; 356 info->frames = (info->size - tagsize) / frame_size;
355 #ifdef DEBUG 357 #ifdef DEBUG
356 g_message("info->frames = %d", info->frames); 358 g_message("info->frames = %d", info->frames);
357 #endif 359 #endif
358 if(info->tuple->length == -1) { 360 if(tuple_get_int(info->tuple, "length") == -1) {
359 if(xing_bitrate > 0.0) { 361 if(xing_bitrate > 0.0) {
360 /* calc duration with xing info */ 362 /* calc duration with xing info */
361 double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate; 363 double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate;
362 info->duration.seconds = (guint)(tmp / 1000); 364 info->duration.seconds = (guint)(tmp / 1000);
363 info->duration.fraction = (guint)(tmp - info->duration.seconds * 1000); 365 info->duration.fraction = (guint)(tmp - info->duration.seconds * 1000);
367 info->duration.fraction /= N_AVERAGE_FRAMES; 369 info->duration.fraction /= N_AVERAGE_FRAMES;
368 mad_timer_multiply(&info->duration, info->frames); 370 mad_timer_multiply(&info->duration, info->frames);
369 } 371 }
370 } 372 }
371 else { 373 else {
372 info->duration.seconds = info->tuple->length / 1000; 374 gint length = tuple_get_int(info->tuple, "length");
373 info->duration.fraction = info->tuple->length % 1000; 375
376 info->duration.seconds = length / 1000;
377 info->duration.fraction = length % 1000;
374 } 378 }
375 #ifdef DEBUG 379 #ifdef DEBUG
376 g_message("using fast playtime calculation"); 380 g_message("using fast playtime calculation");
377 g_message("data used = %d [tagsize=%d framesize=%f]", 381 g_message("data used = %d [tagsize=%d framesize=%f]",
378 data_used, tagsize, frame_size); 382 data_used, tagsize, frame_size);
476 } 480 }
477 481
478 /* set mainwin title */ 482 /* set mainwin title */
479 if (info->title) 483 if (info->title)
480 g_free(info->title); 484 g_free(info->title);
481 info->title = xmms_get_titlestring(audmad_config.title_override == TRUE ? 485 info->title = tuple_formatter_process_string(info->tuple, audmad_config.title_override == TRUE ?
482 audmad_config.id3_format : xmms_get_gentitle_format(), info->tuple); 486 audmad_config.id3_format : cfg.gentitle_format);
483 487
484 tlen = (gint) mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS), 488 tlen = (gint) mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS),
485 mad_plugin->set_info(info->title, 489 mad_plugin->set_info(info->title,
486 (tlen == 0 || info->size <= 0) ? -1 : tlen, 490 (tlen == 0 || info->size <= 0) ? -1 : tlen,
487 info->bitrate, info->freq, info->channels); 491 info->bitrate, info->freq, info->channels);
488 #ifdef DEBUG 492 #ifdef DEBUG
702 } 706 }
703 #ifdef DEBUG 707 #ifdef DEBUG
704 g_message("e: decode"); 708 g_message("e: decode");
705 #endif /* DEBUG */ 709 #endif /* DEBUG */
706 710
707 bmp_title_input_free(info->tuple); 711 mowgli_object_unref(info->tuple);
708 info->tuple = NULL; 712 info->tuple = NULL;
709 713
710 info->playback->output->close_audio(); 714 info->playback->output->close_audio();
711 g_mutex_lock(mad_mutex); 715 g_mutex_lock(mad_mutex);
712 info->playback->playing = 0; 716 info->playback->playing = 0;