diff options
Diffstat (limited to 'apps/plugins/test_codec.c')
-rw-r--r-- | apps/plugins/test_codec.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index a1f1b29037..9cbfa70614 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -514,7 +514,7 @@ static enum plugin_status test_track(char* filename) | |||
514 | { | 514 | { |
515 | size_t n; | 515 | size_t n; |
516 | int fd; | 516 | int fd; |
517 | enum plugin_status res = PLUGIN_OK; | 517 | enum plugin_status res = PLUGIN_ERROR; |
518 | unsigned long starttick; | 518 | unsigned long starttick; |
519 | unsigned long ticks; | 519 | unsigned long ticks; |
520 | unsigned long speed; | 520 | unsigned long speed; |
@@ -538,7 +538,7 @@ static enum plugin_status test_track(char* filename) | |||
538 | if (fd < 0) | 538 | if (fd < 0) |
539 | { | 539 | { |
540 | log_text("Cannot open file",true); | 540 | log_text("Cannot open file",true); |
541 | return PLUGIN_ERROR; | 541 | goto exit; |
542 | } | 542 | } |
543 | 543 | ||
544 | track.filesize = rb->filesize(fd); | 544 | track.filesize = rb->filesize(fd); |
@@ -549,13 +549,13 @@ static enum plugin_status test_track(char* filename) | |||
549 | if (!rb->get_metadata(&(track.id3), fd, filename)) | 549 | if (!rb->get_metadata(&(track.id3), fd, filename)) |
550 | { | 550 | { |
551 | log_text("Cannot read metadata",true); | 551 | log_text("Cannot read metadata",true); |
552 | return PLUGIN_ERROR; | 552 | goto exit; |
553 | } | 553 | } |
554 | 554 | ||
555 | if (track.filesize > audiosize) | 555 | if (track.filesize > audiosize) |
556 | { | 556 | { |
557 | log_text("File too large",true); | 557 | log_text("File too large",true); |
558 | return PLUGIN_ERROR; | 558 | goto exit; |
559 | } | 559 | } |
560 | 560 | ||
561 | n = rb->read(fd, audiobuf, track.filesize); | 561 | n = rb->read(fd, audiobuf, track.filesize); |
@@ -563,7 +563,6 @@ static enum plugin_status test_track(char* filename) | |||
563 | if (n != track.filesize) | 563 | if (n != track.filesize) |
564 | { | 564 | { |
565 | log_text("Read failed.",true); | 565 | log_text("Read failed.",true); |
566 | res = PLUGIN_ERROR; | ||
567 | goto exit; | 566 | goto exit; |
568 | } | 567 | } |
569 | 568 | ||
@@ -606,11 +605,8 @@ static enum plugin_status test_track(char* filename) | |||
606 | 605 | ||
607 | log_text(str,true); | 606 | log_text(str,true); |
608 | 607 | ||
609 | /* Close WAV file (if there was one) */ | 608 | if (wavinfo.fd < 0) |
610 | if (wavinfo.fd >= 0) { | 609 | { |
611 | close_wav(); | ||
612 | log_text("Wrote /test.wav",true); | ||
613 | } else { | ||
614 | /* Display benchmark information */ | 610 | /* Display benchmark information */ |
615 | rb->snprintf(str,sizeof(str),"Decode time - %d.%02ds",(int)ticks/100,(int)ticks%100); | 611 | rb->snprintf(str,sizeof(str),"Decode time - %d.%02ds",(int)ticks/100,(int)ticks%100); |
616 | log_text(str,true); | 612 | log_text(str,true); |
@@ -628,11 +624,16 @@ static enum plugin_status test_track(char* filename) | |||
628 | log_text(str,true); | 624 | log_text(str,true); |
629 | } | 625 | } |
630 | 626 | ||
631 | /* Write an empty line to the log */ | 627 | res = PLUGIN_OK; |
632 | log_text("",true); | ||
633 | rb->backlight_on(); | ||
634 | 628 | ||
635 | exit: | 629 | exit: |
630 | rb->backlight_on(); | ||
631 | |||
632 | if (fd >= 0) | ||
633 | { | ||
634 | rb->close(fd); | ||
635 | } | ||
636 | |||
636 | return res; | 637 | return res; |
637 | } | 638 | } |
638 | 639 | ||
@@ -761,16 +762,25 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
761 | if (!(entry->attribute & ATTR_DIRECTORY)) { | 762 | if (!(entry->attribute & ATTR_DIRECTORY)) { |
762 | rb->snprintf(filename,sizeof(filename),"%s%s",dirpath,entry->d_name); | 763 | rb->snprintf(filename,sizeof(filename),"%s%s",dirpath,entry->d_name); |
763 | test_track(filename); | 764 | test_track(filename); |
765 | log_text("", true); | ||
764 | } | 766 | } |
765 | 767 | ||
766 | /* Read next entry */ | 768 | /* Read next entry */ |
767 | entry = rb->readdir(dir); | 769 | entry = rb->readdir(dir); |
768 | } | 770 | } |
771 | |||
772 | rb->closedir(dir); | ||
769 | } | 773 | } |
770 | } else { | 774 | } else { |
771 | /* Just test the file */ | 775 | /* Just test the file */ |
772 | res = test_track(parameter); | 776 | res = test_track(parameter); |
773 | 777 | ||
778 | /* Close WAV file (if there was one) */ | ||
779 | if (wavinfo.fd >= 0) { | ||
780 | close_wav(); | ||
781 | log_text("Wrote /test.wav",true); | ||
782 | } | ||
783 | |||
774 | while (rb->button_get(true) != TESTCODEC_EXITBUTTON); | 784 | while (rb->button_get(true) != TESTCODEC_EXITBUTTON); |
775 | } | 785 | } |
776 | 786 | ||