summaryrefslogtreecommitdiff
path: root/apps/tagtree.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c71
1 files changed, 45 insertions, 26 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 6b0c6aa3dd..417b6f28f0 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -794,10 +794,13 @@ static int compare(const void *p1, const void *p2)
794static void tagtree_buffer_event(void *data) 794static void tagtree_buffer_event(void *data)
795{ 795{
796 struct tagcache_search tcs; 796 struct tagcache_search tcs;
797 struct mp3entry *id3 = (struct mp3entry*)data; 797 struct mp3entry *id3 = ((struct track_event *)data)->id3;
798
799 bool runtimedb = global_settings.runtimedb;
800 bool autoresume = global_settings.autoresume_enable;
798 801
799 /* Do not gather data unless proper setting has been enabled. */ 802 /* Do not gather data unless proper setting has been enabled. */
800 if (!global_settings.runtimedb && !global_settings.autoresume_enable) 803 if (!runtimedb && !autoresume)
801 return; 804 return;
802 805
803 logf("be:%s", id3->path); 806 logf("be:%s", id3->path);
@@ -811,7 +814,7 @@ static void tagtree_buffer_event(void *data)
811 return; 814 return;
812 } 815 }
813 816
814 if (global_settings.runtimedb) 817 if (runtimedb)
815 { 818 {
816 id3->playcount = tagcache_get_numeric(&tcs, tag_playcount); 819 id3->playcount = tagcache_get_numeric(&tcs, tag_playcount);
817 if (!id3->rating) 820 if (!id3->rating)
@@ -824,7 +827,7 @@ static void tagtree_buffer_event(void *data)
824 } 827 }
825 828
826 #if CONFIG_CODEC == SWCODEC 829 #if CONFIG_CODEC == SWCODEC
827 if (global_settings.autoresume_enable) 830 if (autoresume)
828 { 831 {
829 /* Load current file resume offset if not already defined (by 832 /* Load current file resume offset if not already defined (by
830 another resume mechanism) */ 833 another resume mechanism) */
@@ -846,18 +849,10 @@ static void tagtree_buffer_event(void *data)
846 849
847static void tagtree_track_finish_event(void *data) 850static void tagtree_track_finish_event(void *data)
848{ 851{
849 long lastplayed; 852 struct track_event *te = (struct track_event *)data;
850 long tagcache_idx; 853 struct mp3entry *id3 = te->id3;
851 struct mp3entry *id3 = (struct mp3entry*)data;
852
853 /* Do not gather data unless proper setting has been enabled. */
854 if (!global_settings.runtimedb && !global_settings.autoresume_enable)
855 {
856 logf("runtimedb gathering and autoresume not enabled");
857 return;
858 }
859 854
860 tagcache_idx=id3->tagcache_idx; 855 long tagcache_idx = id3->tagcache_idx;
861 if (!tagcache_idx) 856 if (!tagcache_idx)
862 { 857 {
863 logf("No tagcache index pointer found"); 858 logf("No tagcache index pointer found");
@@ -865,26 +860,51 @@ static void tagtree_track_finish_event(void *data)
865 } 860 }
866 tagcache_idx--; 861 tagcache_idx--;
867 862
868 /* Don't process unplayed tracks, or tracks interrupted within the
869 first 15 seconds. */
870 if (id3->elapsed == 0
871#if CONFIG_CODEC == SWCODEC /* HWCODEC doesn't have automatic_skip */ 863#if CONFIG_CODEC == SWCODEC /* HWCODEC doesn't have automatic_skip */
872 || (id3->elapsed < 15 * 1000 && !audio_automatic_skip()) 864 bool auto_skip = te->flags & TEF_AUTO_SKIP;
873#endif 865#endif
874 ) 866 bool runtimedb = global_settings.runtimedb;
867 bool autoresume = global_settings.autoresume_enable;
868
869 /* Don't process unplayed tracks, or tracks interrupted within the
870 first 15 seconds but always process autoresume point */
871 if (runtimedb && (id3->elapsed == 0
872#if CONFIG_CODEC == SWCODEC
873 || (id3->elapsed < 15 * 1000 && !auto_skip)
874#endif
875 ))
876 {
877 logf("not db logging unplayed or skipped track");
878 runtimedb = false;
879 }
880
881#if CONFIG_CODEC == SWCODEC
882 /* 3s because that is the threshold the WPS uses to rewind instead
883 of skip backwards */
884 if (autoresume && (id3->elapsed == 0
885 || (id3->elapsed < 3 * 1000 && !auto_skip)))
886 {
887 logf("not logging autoresume");
888 autoresume = false;
889 }
890#endif
891
892 /* Do not gather data unless proper setting has been enabled and at least
893 one is still slated to be recorded */
894 if (!(runtimedb || autoresume))
875 { 895 {
876 logf("not logging unplayed or skipped track"); 896 logf("runtimedb gathering and autoresume not enabled/ignored");
877 return; 897 return;
878 } 898 }
879 899
880 lastplayed = tagcache_increase_serial(); 900 long lastplayed = tagcache_increase_serial();
881 if (lastplayed < 0) 901 if (lastplayed < 0)
882 { 902 {
883 logf("incorrect tc serial:%ld", lastplayed); 903 logf("incorrect tc serial:%ld", lastplayed);
884 return; 904 return;
885 } 905 }
886 906
887 if (global_settings.runtimedb) 907 if (runtimedb)
888 { 908 {
889 long playcount; 909 long playcount;
890 long playtime; 910 long playtime;
@@ -906,10 +926,9 @@ static void tagtree_track_finish_event(void *data)
906 } 926 }
907 927
908#if CONFIG_CODEC == SWCODEC 928#if CONFIG_CODEC == SWCODEC
909 if (global_settings.autoresume_enable) 929 if (autoresume)
910 { 930 {
911 unsigned long offset 931 unsigned long offset = auto_skip ? 0 : id3->offset;
912 = audio_automatic_skip() ? 0 : id3->offset;
913 932
914 tagcache_update_numeric(tagcache_idx, tag_lastoffset, offset); 933 tagcache_update_numeric(tagcache_idx, tag_lastoffset, offset);
915 934