diff options
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r-- | apps/tagtree.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c index 03673fc653..271f30ffa8 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -624,9 +624,14 @@ static void tagtree_buffer_event(struct mp3entry *id3, bool last_track) | |||
624 | } | 624 | } |
625 | 625 | ||
626 | id3->playcount = tagcache_get_numeric(&tcs, tag_playcount); | 626 | id3->playcount = tagcache_get_numeric(&tcs, tag_playcount); |
627 | if(!id3->rating) id3->rating = tagcache_get_numeric(&tcs, tag_rating); | 627 | if (!id3->rating) |
628 | id3->rating = tagcache_get_numeric(&tcs, tag_rating); | ||
628 | id3->lastplayed = tagcache_get_numeric(&tcs, tag_lastplayed); | 629 | id3->lastplayed = tagcache_get_numeric(&tcs, tag_lastplayed); |
629 | id3->score = tagcache_get_numeric(&tcs, tag_virt_autoscore) / 10; | 630 | id3->score = tagcache_get_numeric(&tcs, tag_virt_autoscore) / 10; |
631 | id3->playtime = tagcache_get_numeric(&tcs, tag_playtime); | ||
632 | |||
633 | /* Store our tagcache index pointer. */ | ||
634 | id3->tagcache_idx = tcs.idx_id; | ||
630 | 635 | ||
631 | tagcache_search_finish(&tcs); | 636 | tagcache_search_finish(&tcs); |
632 | } | 637 | } |
@@ -635,7 +640,6 @@ static void tagtree_unbuffer_event(struct mp3entry *id3, bool last_track) | |||
635 | { | 640 | { |
636 | (void)last_track; | 641 | (void)last_track; |
637 | long playcount; | 642 | long playcount; |
638 | long rating; | ||
639 | long playtime; | 643 | long playtime; |
640 | long lastplayed; | 644 | long lastplayed; |
641 | 645 | ||
@@ -646,55 +650,38 @@ static void tagtree_unbuffer_event(struct mp3entry *id3, bool last_track) | |||
646 | return; | 650 | return; |
647 | } | 651 | } |
648 | 652 | ||
649 | /* Don't process unplayed tracks. */ | 653 | if (!id3->tagcache_idx) |
650 | if (id3->elapsed == 0) | ||
651 | { | 654 | { |
652 | logf("not logging unplayed track"); | 655 | logf("No tagcache index pointer found"); |
653 | return; | 656 | return; |
654 | } | 657 | } |
655 | 658 | ||
656 | if (!tagcache_find_index(&tcs, id3->path)) | 659 | /* Don't process unplayed tracks. */ |
660 | if (id3->elapsed == 0) | ||
657 | { | 661 | { |
658 | logf("tc stat: not found: %s", id3->path); | 662 | logf("not logging unplayed track"); |
659 | return; | 663 | return; |
660 | } | 664 | } |
661 | 665 | ||
662 | playcount = tagcache_get_numeric(&tcs, tag_playcount); | 666 | playcount = id3->playcount + 1; |
663 | playtime = tagcache_get_numeric(&tcs, tag_playtime); | ||
664 | lastplayed = tagcache_get_numeric(&tcs, tag_lastplayed); | ||
665 | |||
666 | playcount++; | ||
667 | |||
668 | rating = (long) id3->rating; | ||
669 | |||
670 | lastplayed = tagcache_increase_serial(); | 667 | lastplayed = tagcache_increase_serial(); |
671 | if (lastplayed < 0) | 668 | if (lastplayed < 0) |
672 | { | 669 | { |
673 | logf("incorrect tc serial:%ld", lastplayed); | 670 | logf("incorrect tc serial:%ld", lastplayed); |
674 | tagcache_search_finish(&tcs); | ||
675 | return; | 671 | return; |
676 | } | 672 | } |
677 | 673 | ||
678 | /* Ignore the last 15s (crossfade etc.) */ | 674 | /* Ignore the last 15s (crossfade etc.) */ |
679 | playtime += MIN(id3->length, id3->elapsed + 15 * 1000); | 675 | playtime = id3->playtime + MIN(id3->length, id3->elapsed + 15 * 1000); |
680 | 676 | ||
681 | logf("ube:%s", id3->path); | 677 | logf("ube:%s", id3->path); |
682 | logf("-> %d/%ld/%ld/%ld", last_track, playcount, rating, playtime); | 678 | logf("-> %d/%ld/%ld", last_track, playcount, playtime); |
683 | logf("-> %ld/%ld/%ld", id3->elapsed, id3->length, MIN(id3->length, id3->elapsed + 15 * 1000)); | 679 | logf("-> %ld/%ld/%ld", id3->elapsed, id3->length, MIN(id3->length, id3->elapsed + 15 * 1000)); |
684 | 680 | ||
685 | /* lastplayed not yet supported. */ | 681 | /* Queue the updates to the tagcache system. */ |
686 | 682 | tagcache_update_numeric(id3->tagcache_idx, tag_playcount, playcount); | |
687 | if (!tagcache_modify_numeric_entry(&tcs, tag_playcount, playcount) | 683 | tagcache_update_numeric(id3->tagcache_idx, tag_playtime, playtime); |
688 | || !tagcache_modify_numeric_entry(&tcs, tag_rating, rating) | 684 | tagcache_update_numeric(id3->tagcache_idx, tag_lastplayed, lastplayed); |
689 | || !tagcache_modify_numeric_entry(&tcs, tag_playtime, playtime) | ||
690 | || !tagcache_modify_numeric_entry(&tcs, tag_lastplayed, lastplayed)) | ||
691 | { | ||
692 | logf("tc stat: modify failed!"); | ||
693 | tagcache_search_finish(&tcs); | ||
694 | return; | ||
695 | } | ||
696 | |||
697 | tagcache_search_finish(&tcs); | ||
698 | } | 685 | } |
699 | 686 | ||
700 | bool tagtree_export(void) | 687 | bool tagtree_export(void) |