Mercurial > audlegacy-plugins
comparison src/madplug/input.c @ 2276:d25cd7e7eddb
append '\n' to format string for AUDDBG()
| author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
|---|---|
| date | Tue, 01 Jan 2008 23:12:46 +0900 |
| parents | 9a869d4bb0d3 |
| children | 1457b35713d9 |
comparison
equal
deleted
inserted
replaced
| 2275:e09d9633d6aa | 2276:d25cd7e7eddb |
|---|---|
| 69 /** | 69 /** |
| 70 * init the mad_info_t struct. | 70 * init the mad_info_t struct. |
| 71 */ | 71 */ |
| 72 gboolean input_init(struct mad_info_t * info, const char *url, VFSFile *fd) | 72 gboolean input_init(struct mad_info_t * info, const char *url, VFSFile *fd) |
| 73 { | 73 { |
| 74 AUDDBG("f: input_init"); | 74 AUDDBG("f: input_init\n"); |
| 75 | 75 |
| 76 memset(info, 0, sizeof(struct mad_info_t)); // all fields are cleared to 0 --yaz | 76 memset(info, 0, sizeof(struct mad_info_t)); // all fields are cleared to 0 --yaz |
| 77 | 77 |
| 78 info->fmt = FMT_S16_LE; | 78 info->fmt = FMT_S16_LE; |
| 79 info->channels = -1; | 79 info->channels = -1; |
| 110 if(audmad_is_remote((gchar *)url)) | 110 if(audmad_is_remote((gchar *)url)) |
| 111 info->remote = TRUE; | 111 info->remote = TRUE; |
| 112 | 112 |
| 113 info->fileinfo_request = FALSE; | 113 info->fileinfo_request = FALSE; |
| 114 | 114 |
| 115 AUDDBG("i: info->size = %lu", (long unsigned int)info->size); | 115 AUDDBG("i: info->size = %lu\n", (long unsigned int)info->size); |
| 116 AUDDBG("e: input_init"); | 116 AUDDBG("e: input_init\n"); |
| 117 | 117 |
| 118 return TRUE; | 118 return TRUE; |
| 119 } | 119 } |
| 120 | 120 |
| 121 /* return length in letters */ | 121 /* return length in letters */ |
| 343 { | 343 { |
| 344 gchar *string = NULL; | 344 gchar *string = NULL; |
| 345 Tuple *tuple; | 345 Tuple *tuple; |
| 346 glong curpos = 0; | 346 glong curpos = 0; |
| 347 | 347 |
| 348 AUDDBG("f: input_read_tag"); | 348 AUDDBG("f: input_read_tag\n"); |
| 349 | 349 |
| 350 if (info->tuple != NULL) | 350 if (info->tuple != NULL) |
| 351 aud_tuple_free(info->tuple); | 351 aud_tuple_free(info->tuple); |
| 352 | 352 |
| 353 tuple = aud_tuple_new_from_filename(info->filename); | 353 tuple = aud_tuple_new_from_filename(info->filename); |
| 360 else { | 360 else { |
| 361 info->id3file = id3_file_open(info->filename, ID3_FILE_MODE_READONLY); | 361 info->id3file = id3_file_open(info->filename, ID3_FILE_MODE_READONLY); |
| 362 } | 362 } |
| 363 | 363 |
| 364 if (!info->id3file) { | 364 if (!info->id3file) { |
| 365 AUDDBG("read_tag: no id3file"); | 365 AUDDBG("read_tag: no id3file\n"); |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 | 368 |
| 369 info->tag = id3_file_tag(info->id3file); | 369 info->tag = id3_file_tag(info->id3file); |
| 370 if (!info->tag) { | 370 if (!info->tag) { |
| 371 AUDDBG("read_tag: no tag"); | 371 AUDDBG("read_tag: no tag\n"); |
| 372 return; | 372 return; |
| 373 } | 373 } |
| 374 | 374 |
| 375 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ARTIST, FIELD_ARTIST); | 375 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ARTIST, FIELD_ARTIST); |
| 376 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_TITLE, FIELD_TITLE); | 376 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_TITLE, FIELD_TITLE); |
| 399 | 399 |
| 400 // length | 400 // length |
| 401 string = input_id3_get_string(info->tag, "TLEN"); | 401 string = input_id3_get_string(info->tag, "TLEN"); |
| 402 if (string) { | 402 if (string) { |
| 403 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); | 403 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); |
| 404 AUDDBG("input_read_tag: TLEN = %d", atoi(string)); | 404 AUDDBG("input_read_tag: TLEN = %d\n", atoi(string)); |
| 405 g_free(string); | 405 g_free(string); |
| 406 string = NULL; | 406 string = NULL; |
| 407 } else | 407 } else |
| 408 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); | 408 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
| 409 | 409 |
| 417 if (info->infile != NULL) { | 417 if (info->infile != NULL) { |
| 418 aud_vfs_fseek(info->infile, -1, SEEK_SET); // an impossible request | 418 aud_vfs_fseek(info->infile, -1, SEEK_SET); // an impossible request |
| 419 aud_vfs_fseek(info->infile, curpos, SEEK_SET); | 419 aud_vfs_fseek(info->infile, curpos, SEEK_SET); |
| 420 } | 420 } |
| 421 | 421 |
| 422 AUDDBG("e: input_read_tag"); | 422 AUDDBG("e: input_read_tag\n"); |
| 423 } | 423 } |
| 424 | 424 |
| 425 void input_process_remote_metadata(struct mad_info_t *info) | 425 void input_process_remote_metadata(struct mad_info_t *info) |
| 426 { | 426 { |
| 427 gboolean metadata = FALSE; | 427 gboolean metadata = FALSE; |
| 428 | 428 |
| 429 if(info->remote && mad_timer_count(info->duration, MAD_UNITS_SECONDS) <= 0){ | 429 if(info->remote && mad_timer_count(info->duration, MAD_UNITS_SECONDS) <= 0){ |
| 430 gchar *tmp = NULL; | 430 gchar *tmp = NULL; |
| 431 | 431 |
| 432 #ifdef DEBUG_INTENSIVELY | 432 #ifdef DEBUG_INTENSIVELY |
| 433 AUDDBG("process_remote_meta"); | 433 AUDDBG("process_remote_meta\n"); |
| 434 #endif | 434 #endif |
| 435 g_free(info->title); | 435 g_free(info->title); |
| 436 info->title = NULL; | 436 info->title = NULL; |
| 437 aud_tuple_disassociate(info->tuple, FIELD_TITLE, NULL); | 437 aud_tuple_disassociate(info->tuple, FIELD_TITLE, NULL); |
| 438 aud_tuple_disassociate(info->tuple, FIELD_ALBUM, NULL); | 438 aud_tuple_disassociate(info->tuple, FIELD_ALBUM, NULL); |
| 498 */ | 498 */ |
| 499 gboolean input_get_info(struct mad_info_t *info, gboolean fast_scan) | 499 gboolean input_get_info(struct mad_info_t *info, gboolean fast_scan) |
| 500 { | 500 { |
| 501 #ifdef AUD_DEBUG | 501 #ifdef AUD_DEBUG |
| 502 gchar *tmp = g_filename_to_utf8(info->filename, -1, NULL, NULL, NULL); | 502 gchar *tmp = g_filename_to_utf8(info->filename, -1, NULL, NULL, NULL); |
| 503 AUDDBG("f: input_get_info: %s, fast_scan = %s", tmp, fast_scan ? "TRUE" : "FALSE"); | 503 AUDDBG("f: input_get_info: %s, fast_scan = %s\n", tmp, fast_scan ? "TRUE" : "FALSE"); |
| 504 g_free(tmp); | 504 g_free(tmp); |
| 505 #endif /* DEBUG */ | 505 #endif /* DEBUG */ |
| 506 | 506 |
| 507 input_alloc_tag(info); | 507 input_alloc_tag(info); |
| 508 input_read_tag(info); | 508 input_read_tag(info); |
| 511 read_replaygain(info); | 511 read_replaygain(info); |
| 512 } | 512 } |
| 513 | 513 |
| 514 /* scan mp3 file, decoding headers */ | 514 /* scan mp3 file, decoding headers */ |
| 515 if (scan_file(info, fast_scan) == FALSE) { | 515 if (scan_file(info, fast_scan) == FALSE) { |
| 516 AUDDBG("input_get_info: scan_file failed"); | 516 AUDDBG("input_get_info: scan_file failed\n"); |
| 517 return FALSE; | 517 return FALSE; |
| 518 } | 518 } |
| 519 | 519 |
| 520 /* reset the input file to the start */ | 520 /* reset the input file to the start */ |
| 521 aud_vfs_fseek(info->infile, 0, SEEK_SET); | 521 aud_vfs_fseek(info->infile, 0, SEEK_SET); |
| 528 info->title = g_strdup(pos + 1); | 528 info->title = g_strdup(pos + 1); |
| 529 else | 529 else |
| 530 info->title = g_strdup(info->filename); //XXX info->filename is uri. --yaz | 530 info->title = g_strdup(info->filename); //XXX info->filename is uri. --yaz |
| 531 } | 531 } |
| 532 | 532 |
| 533 AUDDBG("e: input_get_info"); | 533 AUDDBG("e: input_get_info\n"); |
| 534 return TRUE; | 534 return TRUE; |
| 535 } | 535 } |
| 536 | 536 |
| 537 | 537 |
| 538 | 538 |
| 547 input_get_data(struct mad_info_t *info, guchar * buffer, | 547 input_get_data(struct mad_info_t *info, guchar * buffer, |
| 548 int buffer_size) | 548 int buffer_size) |
| 549 { | 549 { |
| 550 int len = 0; | 550 int len = 0; |
| 551 #ifdef DEBUG_INTENSIVELY | 551 #ifdef DEBUG_INTENSIVELY |
| 552 AUDDBG ("f: input_get_data: %d", buffer_size); | 552 AUDDBG ("f: input_get_data: %d\n", buffer_size); |
| 553 #endif | 553 #endif |
| 554 /* simply read to data from the file */ | 554 /* simply read to data from the file */ |
| 555 len = aud_vfs_fread(buffer, 1, buffer_size, info->infile); //aud_vfs_fread returns num of elements. | 555 len = aud_vfs_fread(buffer, 1, buffer_size, info->infile); //aud_vfs_fread returns num of elements. |
| 556 | 556 |
| 557 if(len == 0 && info->playback){ | 557 if(len == 0 && info->playback){ |
| 558 info->playback->eof = TRUE; | 558 info->playback->eof = TRUE; |
| 559 } | 559 } |
| 560 | 560 |
| 561 #ifdef DEBUG_INTENSIVELY | 561 #ifdef DEBUG_INTENSIVELY |
| 562 AUDDBG ("e: input_get_data: size=%d offset=%d", len, info->offset); | 562 AUDDBG ("e: input_get_data: size=%d offset=%d\n", len, info->offset); |
| 563 #endif | 563 #endif |
| 564 | 564 |
| 565 info->offset += len; | 565 info->offset += len; |
| 566 return len; | 566 return len; |
| 567 } | 567 } |
| 569 /** | 569 /** |
| 570 * Free up all mad_info_t related resourses. | 570 * Free up all mad_info_t related resourses. |
| 571 */ | 571 */ |
| 572 gboolean input_term(struct mad_info_t * info) | 572 gboolean input_term(struct mad_info_t * info) |
| 573 { | 573 { |
| 574 AUDDBG("f: input_term"); | 574 AUDDBG("f: input_term\n"); |
| 575 | 575 |
| 576 if (info->title) | 576 if (info->title) |
| 577 g_free(info->title); | 577 g_free(info->title); |
| 578 if (info->url) | 578 if (info->url) |
| 579 g_free(info->url); | 579 g_free(info->url); |
| 606 g_free(info->prev_title); | 606 g_free(info->prev_title); |
| 607 | 607 |
| 608 /* set everything to zero in case it gets used again. */ | 608 /* set everything to zero in case it gets used again. */ |
| 609 memset(info, 0, sizeof(struct mad_info_t)); | 609 memset(info, 0, sizeof(struct mad_info_t)); |
| 610 | 610 |
| 611 AUDDBG("e: input_term"); | 611 AUDDBG("e: input_term\n"); |
| 612 | 612 |
| 613 return TRUE; | 613 return TRUE; |
| 614 } | 614 } |
