Mercurial > audlegacy-plugins
comparison src/madplug/input.c @ 2519:2da1343a024d
Automated merge with ssh://hg.atheme.org//hg/audacious-plugins
| author | William Pitcock <nenolod@atheme.org> |
|---|---|
| date | Tue, 08 Apr 2008 15:11:35 -0500 |
| parents | a4629703edc3 |
| children | bd3a24b39058 |
comparison
equal
deleted
inserted
replaced
| 2518:eef3a506a2b8 | 2519:2da1343a024d |
|---|---|
| 136 | 136 |
| 137 /* duplicate id3_ucs4_t string. new string will be terminated with 0. */ | 137 /* duplicate id3_ucs4_t string. new string will be terminated with 0. */ |
| 138 id3_ucs4_t * | 138 id3_ucs4_t * |
| 139 mad_ucs4dup(id3_ucs4_t *org) | 139 mad_ucs4dup(id3_ucs4_t *org) |
| 140 { | 140 { |
| 141 id3_ucs4_t *res = NULL; | 141 id3_ucs4_t *res; |
| 142 size_t len = mad_ucs4len(org); | 142 size_t len = mad_ucs4len(org); |
| 143 | 143 |
| 144 res = g_malloc0((len + 1) * sizeof(id3_ucs4_t)); | 144 res = g_malloc0((len + 1) * sizeof(id3_ucs4_t)); |
| 145 memcpy(res, org, len * sizeof(id3_ucs4_t)); | 145 memcpy(res, org, len * sizeof(id3_ucs4_t)); |
| 146 *(res + len) = 0; //terminate | 146 *(res + len) = 0; //terminate |
| 350 * read the ID3 tag | 350 * read the ID3 tag |
| 351 */ | 351 */ |
| 352 static void | 352 static void |
| 353 input_read_tag(struct mad_info_t *info) | 353 input_read_tag(struct mad_info_t *info) |
| 354 { | 354 { |
| 355 gchar *string = NULL; | 355 gchar *string; |
| 356 Tuple *tuple; | 356 Tuple *tuple; |
| 357 glong curpos = 0; | 357 glong curpos = 0; |
| 358 | 358 |
| 359 AUDDBG("f: input_read_tag\n"); | 359 AUDDBG("f: input_read_tag\n"); |
| 360 | 360 |
| 361 if (info->tuple != NULL) | 361 if (info->tuple != NULL) |
| 362 aud_tuple_free(info->tuple); | 362 aud_tuple_free(info->tuple); |
| 363 | 363 |
| 364 tuple = aud_tuple_new_from_filename(info->filename); | 364 tuple = aud_tuple_new_from_filename(info->filename); |
| 365 info->tuple = tuple; | 365 info->tuple = tuple; |
| 366 | 366 |
| 367 if(info->infile) { | 367 if(info->infile) { |
| 368 curpos = aud_vfs_ftell(info->infile); | 368 curpos = aud_vfs_ftell(info->infile); |
| 391 | 391 |
| 392 string = input_id3_get_string(info->tag, ID3_FRAME_TRACK); | 392 string = input_id3_get_string(info->tag, ID3_FRAME_TRACK); |
| 393 if (string) { | 393 if (string) { |
| 394 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string)); | 394 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string)); |
| 395 g_free(string); | 395 g_free(string); |
| 396 string = NULL; | |
| 397 } | 396 } |
| 398 | 397 |
| 399 // year | 398 // year |
| 400 string = NULL; | |
| 401 string = input_id3_get_string(info->tag, ID3_FRAME_YEAR); //TDRC | 399 string = input_id3_get_string(info->tag, ID3_FRAME_YEAR); //TDRC |
| 402 if (!string) | 400 if (!string) |
| 403 string = input_id3_get_string(info->tag, "TYER"); | 401 string = input_id3_get_string(info->tag, "TYER"); |
| 404 | 402 |
| 405 if (string) { | 403 if (string) { |
| 406 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string)); | 404 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string)); |
| 407 g_free(string); | 405 g_free(string); |
| 408 string = NULL; | |
| 409 } | 406 } |
| 410 | 407 |
| 411 // length | 408 // length |
| 412 string = input_id3_get_string(info->tag, "TLEN"); | 409 string = input_id3_get_string(info->tag, "TLEN"); |
| 413 if (string && atoi(string)) { | 410 if (string && atoi(string)) { |
| 414 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); | 411 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); |
| 415 AUDDBG("input_read_tag: TLEN = %d\n", atoi(string)); | 412 AUDDBG("input_read_tag: TLEN = %d\n", atoi(string)); |
| 416 g_free(string); | 413 g_free(string); |
| 417 string = NULL; | |
| 418 } else | 414 } else |
| 419 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); | 415 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
| 420 | 416 |
| 421 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)"); | 417 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)"); |
| 422 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); | 418 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); |
| 437 input_process_remote_metadata(struct mad_info_t *info) | 433 input_process_remote_metadata(struct mad_info_t *info) |
| 438 { | 434 { |
| 439 gboolean metadata = FALSE; | 435 gboolean metadata = FALSE; |
| 440 | 436 |
| 441 if(info->remote && mad_timer_count(info->duration, MAD_UNITS_SECONDS) <= 0){ | 437 if(info->remote && mad_timer_count(info->duration, MAD_UNITS_SECONDS) <= 0){ |
| 442 gchar *tmp = NULL; | 438 gchar *tmp; |
| 443 | 439 |
| 444 #ifdef DEBUG_INTENSIVELY | 440 #ifdef DEBUG_INTENSIVELY |
| 445 AUDDBG("process_remote_meta\n"); | 441 AUDDBG("process_remote_meta\n"); |
| 446 #endif | 442 #endif |
| 447 g_free(info->title); | 443 g_free(info->title); |
| 450 aud_tuple_disassociate(info->tuple, FIELD_ALBUM, NULL); | 446 aud_tuple_disassociate(info->tuple, FIELD_ALBUM, NULL); |
| 451 | 447 |
| 452 tmp = aud_vfs_get_metadata(info->infile, "track-name"); | 448 tmp = aud_vfs_get_metadata(info->infile, "track-name"); |
| 453 if(tmp){ | 449 if(tmp){ |
| 454 metadata = TRUE; | 450 metadata = TRUE; |
| 455 gchar *scratch; | 451 gchar *scratch = aud_str_to_utf8(tmp); |
| 456 | |
| 457 scratch = aud_str_to_utf8(tmp); | |
| 458 aud_tuple_associate_string(info->tuple, FIELD_TITLE, NULL, scratch); | 452 aud_tuple_associate_string(info->tuple, FIELD_TITLE, NULL, scratch); |
| 459 g_free(scratch); | 453 g_free(scratch); |
| 460 | |
| 461 g_free(tmp); | 454 g_free(tmp); |
| 462 tmp = NULL; | |
| 463 } | 455 } |
| 464 | 456 |
| 465 tmp = aud_vfs_get_metadata(info->infile, "stream-name"); | 457 tmp = aud_vfs_get_metadata(info->infile, "stream-name"); |
| 466 if(tmp){ | 458 if(tmp){ |
| 467 metadata = TRUE; | 459 metadata = TRUE; |
| 468 gchar *scratch; | 460 gchar *scratch = aud_str_to_utf8(tmp); |
| 469 | |
| 470 scratch = aud_str_to_utf8(tmp); | |
| 471 aud_tuple_associate_string(info->tuple, FIELD_ALBUM, NULL, scratch); | 461 aud_tuple_associate_string(info->tuple, FIELD_ALBUM, NULL, scratch); |
| 472 aud_tuple_associate_string(info->tuple, -1, "stream", scratch); | 462 aud_tuple_associate_string(info->tuple, -1, "stream", scratch); |
| 473 g_free(scratch); | 463 g_free(scratch); |
| 474 | |
| 475 g_free(tmp); | 464 g_free(tmp); |
| 476 tmp = NULL; | |
| 477 } | 465 } |
| 478 | 466 |
| 479 if (metadata) | 467 if (metadata) |
| 480 tmp = aud_tuple_formatter_process_string(info->tuple, "${?title:${title}}${?stream: (${stream})}"); | 468 tmp = aud_tuple_formatter_process_string(info->tuple, "${?title:${title}}${?stream: (${stream})}"); |
| 481 else { | 469 else { |
| 482 gchar *realfn = g_filename_from_uri(info->filename, NULL, NULL); | 470 gchar *realfn = g_filename_from_uri(info->filename, NULL, NULL); |
| 483 gchar *tmp2 = g_path_get_basename(realfn ? realfn : info->filename); // info->filename is uri. --yaz | 471 gchar *tmp2 = g_path_get_basename(realfn ? realfn : info->filename); // info->filename is uri. --yaz |
| 484 tmp = aud_str_to_utf8(tmp2); | 472 tmp = aud_str_to_utf8(tmp2); |
| 485 g_free(tmp2); tmp2 = NULL; | 473 g_free(tmp2); |
| 486 g_free(realfn); realfn = NULL; | 474 g_free(realfn); |
| 487 // tmp = g_strdup(g_basename(info->filename)); //XXX maybe ok. --yaz | 475 // tmp = g_strdup(g_basename(info->filename)); //XXX maybe ok. --yaz |
| 488 } | 476 } |
| 489 | 477 |
| 490 /* call set_info only if tmp is different from prev_tmp */ | 478 /* call set_info only if tmp is different from prev_tmp */ |
| 491 if ( ( ( info->prev_title != NULL ) && ( strcmp(info->prev_title,tmp) ) ) || | 479 if ( ( ( info->prev_title != NULL ) && ( strcmp(info->prev_title,tmp) ) ) || |
| 585 gboolean | 573 gboolean |
| 586 input_term(struct mad_info_t * info) | 574 input_term(struct mad_info_t * info) |
| 587 { | 575 { |
| 588 AUDDBG("f: input_term\n"); | 576 AUDDBG("f: input_term\n"); |
| 589 | 577 |
| 590 if (info->title) | 578 g_free(info->title); |
| 591 g_free(info->title); | 579 g_free(info->url); |
| 592 if (info->url) | 580 g_free(info->filename); |
| 593 g_free(info->url); | |
| 594 if (info->filename) | |
| 595 g_free(info->filename); | |
| 596 if (info->infile) | 581 if (info->infile) |
| 597 aud_vfs_fclose(info->infile); | 582 aud_vfs_fclose(info->infile); |
| 598 if (info->id3file) | 583 if (info->id3file) |
| 599 id3_file_close(info->id3file); | 584 id3_file_close(info->id3file); |
| 600 | 585 |
| 601 if (info->replaygain_album_str) | 586 g_free(info->replaygain_album_str); |
| 602 g_free(info->replaygain_album_str); | 587 g_free(info->replaygain_track_str); |
| 603 if (info->replaygain_track_str) | 588 g_free(info->replaygain_album_peak_str); |
| 604 g_free(info->replaygain_track_str); | 589 g_free(info->replaygain_track_peak_str); |
| 605 if (info->replaygain_album_peak_str) | 590 g_free(info->mp3gain_undo_str); |
| 606 g_free(info->replaygain_album_peak_str); | 591 g_free(info->mp3gain_minmax_str); |
| 607 if (info->replaygain_track_peak_str) | |
| 608 g_free(info->replaygain_track_peak_str); | |
| 609 if (info->mp3gain_undo_str) | |
| 610 g_free(info->mp3gain_undo_str); | |
| 611 if (info->mp3gain_minmax_str) | |
| 612 g_free(info->mp3gain_minmax_str); | |
| 613 | 592 |
| 614 if (info->tuple) { | 593 if (info->tuple) { |
| 615 aud_tuple_free(info->tuple); | 594 aud_tuple_free(info->tuple); |
| 616 info->tuple = NULL; | 595 info->tuple = NULL; |
| 617 } | 596 } |
| 618 | 597 |
| 619 if (info->prev_title) | 598 g_free(info->prev_title); |
| 620 g_free(info->prev_title); | |
| 621 | 599 |
| 622 /* set everything to zero in case it gets used again. */ | 600 /* set everything to zero in case it gets used again. */ |
| 623 memset(info, 0, sizeof(struct mad_info_t)); | 601 memset(info, 0, sizeof(struct mad_info_t)); |
| 624 | 602 |
| 625 AUDDBG("e: input_term\n"); | 603 AUDDBG("e: input_term\n"); |
