diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/lib/SOURCES | 6 | ||||
-rw-r--r-- | apps/plugins/lib/id3.c | 46 | ||||
-rw-r--r-- | apps/plugins/lib/id3.h | 26 | ||||
-rw-r--r-- | apps/plugins/lib/mul_id3.c | 182 | ||||
-rw-r--r-- | apps/plugins/lib/mul_id3.h | 28 | ||||
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 223 |
6 files changed, 308 insertions, 203 deletions
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index bff9017404..09a8b1c5ed 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES | |||
@@ -69,3 +69,9 @@ kbd_helper.c | |||
69 | #ifdef HAVE_TOUCHSCREEN | 69 | #ifdef HAVE_TOUCHSCREEN |
70 | pluginlib_touchscreen.c | 70 | pluginlib_touchscreen.c |
71 | #endif | 71 | #endif |
72 | |||
73 | id3.c | ||
74 | |||
75 | #ifdef HAVE_TAGCACHE | ||
76 | mul_id3.c | ||
77 | #endif | ||
diff --git a/apps/plugins/lib/id3.c b/apps/plugins/lib/id3.c new file mode 100644 index 0000000000..0ce1736ffe --- /dev/null +++ b/apps/plugins/lib/id3.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2023 Christian Soffke | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "plugin.h" | ||
22 | |||
23 | bool retrieve_id3(struct mp3entry *id3, const char* file, bool try_tagcache) | ||
24 | { | ||
25 | bool ret = false; | ||
26 | int fd; | ||
27 | |||
28 | #if defined (HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | ||
29 | if (try_tagcache && rb->tagcache_fill_tags(id3, file)) | ||
30 | { | ||
31 | rb->strlcpy(id3->path, file, sizeof(id3->path)); | ||
32 | return true; | ||
33 | } | ||
34 | #else | ||
35 | (void) try_tagcache; | ||
36 | #endif | ||
37 | |||
38 | fd = rb->open(file, O_RDONLY); | ||
39 | if (fd >= 0) | ||
40 | { | ||
41 | if (rb->get_metadata(id3, fd, file)) | ||
42 | ret = true; | ||
43 | rb->close(fd); | ||
44 | } | ||
45 | return ret; | ||
46 | } | ||
diff --git a/apps/plugins/lib/id3.h b/apps/plugins/lib/id3.h new file mode 100644 index 0000000000..292556d0c4 --- /dev/null +++ b/apps/plugins/lib/id3.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2023 Christian Soffke | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef ID3_H | ||
22 | #define ID3_H | ||
23 | |||
24 | bool retrieve_id3(struct mp3entry *id3, const char* file, bool try_tagcache); | ||
25 | |||
26 | #endif /* ID3_H */ \ No newline at end of file | ||
diff --git a/apps/plugins/lib/mul_id3.c b/apps/plugins/lib/mul_id3.c new file mode 100644 index 0000000000..5c8f4d9d9c --- /dev/null +++ b/apps/plugins/lib/mul_id3.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2023 Christian Soffke | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "plugin.h" | ||
22 | #include "mul_id3.h" | ||
23 | |||
24 | struct multiple_tracks_id3 { | ||
25 | unsigned long length; | ||
26 | unsigned long filesize; | ||
27 | unsigned long frequency; | ||
28 | unsigned int artist_hash; | ||
29 | unsigned int composer_hash; | ||
30 | unsigned int albumartist_hash; | ||
31 | unsigned int grouping_hash; | ||
32 | unsigned int comment_hash; | ||
33 | unsigned int album_hash; | ||
34 | unsigned int genre_hash; | ||
35 | unsigned int codectype; | ||
36 | unsigned int bitrate; | ||
37 | int year; | ||
38 | bool filesize_ovf; | ||
39 | bool length_ovf; | ||
40 | bool vbr; | ||
41 | }; | ||
42 | |||
43 | static struct multiple_tracks_id3 mul_id3; | ||
44 | |||
45 | |||
46 | /* Calculate modified FNV hash of string | ||
47 | * has good avalanche behaviour and uniform distribution | ||
48 | * see http://home.comcast.net/~bretm/hash/ */ | ||
49 | static unsigned int mfnv(char *str) | ||
50 | { | ||
51 | const unsigned int p = 16777619; | ||
52 | unsigned int hash = 0x811C9DC5; // 2166136261; | ||
53 | |||
54 | if (!str) | ||
55 | return 0; | ||
56 | |||
57 | while(*str) | ||
58 | hash = (hash ^ *str++) * p; | ||
59 | hash += hash << 13; | ||
60 | hash ^= hash >> 7; | ||
61 | hash += hash << 3; | ||
62 | hash ^= hash >> 17; | ||
63 | hash += hash << 5; | ||
64 | return hash; | ||
65 | } | ||
66 | |||
67 | void init_mul_id3(void) | ||
68 | { | ||
69 | mul_id3.artist_hash = 0; | ||
70 | mul_id3.album_hash = 0; | ||
71 | mul_id3.genre_hash = 0; | ||
72 | mul_id3.composer_hash = 0; | ||
73 | mul_id3.albumartist_hash = 0; | ||
74 | mul_id3.grouping_hash = 0; | ||
75 | mul_id3.comment_hash = 0; | ||
76 | mul_id3.codectype = 0; | ||
77 | mul_id3.vbr = false; | ||
78 | mul_id3.bitrate = 0; | ||
79 | mul_id3.frequency = 0; | ||
80 | mul_id3.length = 0; | ||
81 | mul_id3.filesize = 0; | ||
82 | mul_id3.year = 0; | ||
83 | mul_id3.length_ovf = false; | ||
84 | mul_id3.filesize_ovf = false; | ||
85 | } | ||
86 | |||
87 | void collect_id3(struct mp3entry *id3, bool is_first_track) | ||
88 | { | ||
89 | if (is_first_track) | ||
90 | { | ||
91 | mul_id3.artist_hash = mfnv(id3->artist); | ||
92 | mul_id3.album_hash = mfnv(id3->album); | ||
93 | mul_id3.genre_hash = mfnv(id3->genre_string); | ||
94 | mul_id3.composer_hash = mfnv(id3->composer); | ||
95 | mul_id3.albumartist_hash = mfnv(id3->albumartist); | ||
96 | mul_id3.grouping_hash = mfnv(id3->grouping); | ||
97 | mul_id3.comment_hash = mfnv(id3->comment); | ||
98 | mul_id3.codectype = id3->codectype; | ||
99 | mul_id3.vbr = id3->vbr; | ||
100 | mul_id3.bitrate = id3->bitrate; | ||
101 | mul_id3.frequency = id3->frequency; | ||
102 | mul_id3.year = id3->year; | ||
103 | } | ||
104 | else | ||
105 | { | ||
106 | if (mul_id3.artist_hash && (mfnv(id3->artist) != mul_id3.artist_hash)) | ||
107 | mul_id3.artist_hash = 0; | ||
108 | if (mul_id3.album_hash && (mfnv(id3->album) != mul_id3.album_hash)) | ||
109 | mul_id3.album_hash = 0; | ||
110 | if (mul_id3.genre_hash && (mfnv(id3->genre_string) != mul_id3.genre_hash)) | ||
111 | mul_id3.genre_hash = 0; | ||
112 | if (mul_id3.composer_hash && (mfnv(id3->composer) != mul_id3.composer_hash)) | ||
113 | mul_id3.composer_hash = 0; | ||
114 | if (mul_id3.albumartist_hash && (mfnv(id3->albumartist) != | ||
115 | mul_id3.albumartist_hash)) | ||
116 | mul_id3.albumartist_hash = 0; | ||
117 | if (mul_id3.grouping_hash && (mfnv(id3->grouping) != mul_id3.grouping_hash)) | ||
118 | mul_id3.grouping_hash = 0; | ||
119 | if (mul_id3.comment_hash && (mfnv(id3->comment) != mul_id3.comment_hash)) | ||
120 | mul_id3.comment_hash = 0; | ||
121 | |||
122 | if (mul_id3.codectype && (id3->codectype != mul_id3.codectype)) | ||
123 | mul_id3.codectype = AFMT_UNKNOWN; | ||
124 | if (mul_id3.bitrate && (id3->bitrate != mul_id3.bitrate || | ||
125 | id3->vbr != mul_id3.vbr)) | ||
126 | mul_id3.bitrate = 0; | ||
127 | if (mul_id3.frequency && (id3->frequency != mul_id3.frequency)) | ||
128 | mul_id3.frequency = 0; | ||
129 | if (mul_id3.year && (id3->year != mul_id3.year)) | ||
130 | mul_id3.year = 0; | ||
131 | } | ||
132 | |||
133 | if (ULONG_MAX - mul_id3.length < id3->length) | ||
134 | { | ||
135 | mul_id3.length_ovf = true; | ||
136 | mul_id3.length = 0; | ||
137 | } | ||
138 | else if (!mul_id3.length_ovf) | ||
139 | mul_id3.length += id3->length; | ||
140 | |||
141 | if (INT_MAX - mul_id3.filesize < id3->filesize) /* output_dyn_value expects int */ | ||
142 | { | ||
143 | mul_id3.filesize_ovf = true; | ||
144 | mul_id3.filesize = 0; | ||
145 | } | ||
146 | else if (!mul_id3.filesize_ovf) | ||
147 | mul_id3.filesize += id3->filesize; | ||
148 | } | ||
149 | |||
150 | void write_id3_mul_tracks(struct mp3entry *id3) | ||
151 | { | ||
152 | id3->path[0] = '\0'; | ||
153 | id3->title = NULL; | ||
154 | if (!mul_id3.artist_hash) | ||
155 | id3->artist = NULL; | ||
156 | if (!mul_id3.album_hash) | ||
157 | id3->album = NULL; | ||
158 | if (!mul_id3.genre_hash) | ||
159 | id3->genre_string = NULL; | ||
160 | if (!mul_id3.composer_hash) | ||
161 | id3->composer = NULL; | ||
162 | if (!mul_id3.albumartist_hash) | ||
163 | id3->albumartist = NULL; | ||
164 | if (!mul_id3.grouping_hash) | ||
165 | id3->grouping = NULL; | ||
166 | if (!mul_id3.comment_hash) | ||
167 | id3->comment = NULL; | ||
168 | id3->disc_string = NULL; | ||
169 | id3->track_string = NULL; | ||
170 | id3->year_string = NULL; | ||
171 | id3->year = mul_id3.year; | ||
172 | id3->length = mul_id3.length; | ||
173 | id3->filesize = mul_id3.filesize; | ||
174 | id3->frequency = mul_id3.frequency; | ||
175 | id3->bitrate = mul_id3.bitrate; | ||
176 | id3->codectype = mul_id3.codectype; | ||
177 | id3->vbr = mul_id3.vbr; | ||
178 | id3->discnum = 0; | ||
179 | id3->tracknum = 0; | ||
180 | id3->track_level = 0; | ||
181 | id3->album_level = 0; | ||
182 | } | ||
diff --git a/apps/plugins/lib/mul_id3.h b/apps/plugins/lib/mul_id3.h new file mode 100644 index 0000000000..71da10e87e --- /dev/null +++ b/apps/plugins/lib/mul_id3.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2023 Christian Soffke | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef MUL_ID3_H | ||
22 | #define MUL_ID3_H | ||
23 | |||
24 | void init_mul_id3(void); | ||
25 | void collect_id3(struct mp3entry *id3, bool is_first_track); | ||
26 | void write_id3_mul_tracks(struct mp3entry *id3); | ||
27 | |||
28 | #endif /* MUL_ID3_H */ \ No newline at end of file | ||
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index b231390420..999ed2563f 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "lib/grey.h" | 33 | #include "lib/grey.h" |
34 | #include "lib/mylcd.h" | 34 | #include "lib/mylcd.h" |
35 | #include "lib/feature_wrappers.h" | 35 | #include "lib/feature_wrappers.h" |
36 | #include "lib/id3.h" | ||
36 | 37 | ||
37 | /******************************* Globals ***********************************/ | 38 | /******************************* Globals ***********************************/ |
38 | static fb_data *lcd_fb; | 39 | static fb_data *lcd_fb; |
@@ -44,6 +45,7 @@ static fb_data *lcd_fb; | |||
44 | 45 | ||
45 | #if PF_PLAYBACK_CAPABLE | 46 | #if PF_PLAYBACK_CAPABLE |
46 | #include "lib/playback_control.h" | 47 | #include "lib/playback_control.h" |
48 | #include "lib/mul_id3.h" | ||
47 | #endif | 49 | #endif |
48 | 50 | ||
49 | #define PF_PREV ACTION_STD_PREV | 51 | #define PF_PREV ACTION_STD_PREV |
@@ -397,26 +399,6 @@ struct track_data { | |||
397 | #endif | 399 | #endif |
398 | }; | 400 | }; |
399 | 401 | ||
400 | #if PF_PLAYBACK_CAPABLE | ||
401 | struct multiple_tracks_id3 { | ||
402 | unsigned long length; | ||
403 | unsigned long filesize; | ||
404 | unsigned long frequency; | ||
405 | unsigned int artist_hash; | ||
406 | unsigned int composer_hash; | ||
407 | unsigned int albumartist_hash; | ||
408 | unsigned int grouping_hash; | ||
409 | unsigned int comment_hash; | ||
410 | unsigned int album_hash; | ||
411 | unsigned int genre_hash; | ||
412 | unsigned int codectype; | ||
413 | unsigned int bitrate; | ||
414 | bool filesize_ovf; | ||
415 | bool length_ovf; | ||
416 | bool vbr; | ||
417 | }; | ||
418 | #endif | ||
419 | |||
420 | struct rect { | 402 | struct rect { |
421 | int left; | 403 | int left; |
422 | int right; | 404 | int right; |
@@ -2096,15 +2078,13 @@ static inline void free_borrowed_tracks(void) | |||
2096 | static bool get_albumart_for_index_from_db(const int slide_index, char *buf, | 2078 | static bool get_albumart_for_index_from_db(const int slide_index, char *buf, |
2097 | int buflen) | 2079 | int buflen) |
2098 | { | 2080 | { |
2099 | if ( slide_index == -1 ) | 2081 | bool ret; |
2100 | { | 2082 | if (slide_index == -1) |
2101 | rb->strlcpy( buf, EMPTY_SLIDE, buflen ); | 2083 | rb->strlcpy(buf, EMPTY_SLIDE, buflen); |
2102 | } | ||
2103 | 2084 | ||
2104 | if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename)) | 2085 | if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename)) |
2105 | return false; | 2086 | return false; |
2106 | 2087 | ||
2107 | bool result; | ||
2108 | /* find the first track of the album */ | 2088 | /* find the first track of the album */ |
2109 | rb->tagcache_search_add_filter(&tcs, tag_album, | 2089 | rb->tagcache_search_add_filter(&tcs, tag_album, |
2110 | pf_idx.album_index[slide_index].seek); | 2090 | pf_idx.album_index[slide_index].seek); |
@@ -2112,35 +2092,12 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf, | |||
2112 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, | 2092 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, |
2113 | pf_idx.album_index[slide_index].artist_seek); | 2093 | pf_idx.album_index[slide_index].artist_seek); |
2114 | 2094 | ||
2115 | if ( rb->tagcache_get_next(&tcs) ) { | 2095 | ret = rb->tagcache_get_next(&tcs) && |
2116 | int fd; | 2096 | retrieve_id3(&id3, tcs.result, true) && |
2117 | 2097 | search_albumart_files(&id3, ":", buf, buflen); | |
2118 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | ||
2119 | if (rb->tagcache_fill_tags(&id3, tcs.result)) | ||
2120 | { | ||
2121 | rb->strlcpy(id3.path, tcs.result, sizeof(id3.path)); | ||
2122 | } | ||
2123 | else | ||
2124 | #endif | ||
2125 | { | ||
2126 | fd = rb->open(tcs.result, O_RDONLY); | ||
2127 | if (fd) { | ||
2128 | rb->get_metadata(&id3, fd, tcs.result); | ||
2129 | rb->close(fd); | ||
2130 | } | ||
2131 | } | ||
2132 | 2098 | ||
2133 | if ( search_albumart_files(&id3, ":", buf, buflen) ) | ||
2134 | result = true; | ||
2135 | else | ||
2136 | result = false; | ||
2137 | } | ||
2138 | else { | ||
2139 | /* did not find a matching track */ | ||
2140 | result = false; | ||
2141 | } | ||
2142 | rb->tagcache_search_finish(&tcs); | 2099 | rb->tagcache_search_finish(&tcs); |
2143 | return result; | 2100 | return ret; |
2144 | } | 2101 | } |
2145 | 2102 | ||
2146 | /** | 2103 | /** |
@@ -4032,145 +3989,21 @@ static void select_prev_album(void) | |||
4032 | } | 3989 | } |
4033 | 3990 | ||
4034 | #if PF_PLAYBACK_CAPABLE | 3991 | #if PF_PLAYBACK_CAPABLE |
4035 | static void collect_id3(struct multiple_tracks_id3 *mul_id3, bool is_first_track) | ||
4036 | { | ||
4037 | if (is_first_track) | ||
4038 | { | ||
4039 | mul_id3->artist_hash = mfnv(id3.artist); | ||
4040 | mul_id3->album_hash = mfnv(id3.album); | ||
4041 | mul_id3->genre_hash = mfnv(id3.genre_string); | ||
4042 | mul_id3->composer_hash = mfnv(id3.composer); | ||
4043 | mul_id3->albumartist_hash = mfnv(id3.albumartist); | ||
4044 | mul_id3->grouping_hash = mfnv(id3.grouping); | ||
4045 | mul_id3->comment_hash = mfnv(id3.comment); | ||
4046 | mul_id3->codectype = id3.codectype; | ||
4047 | mul_id3->vbr = id3.vbr; | ||
4048 | mul_id3->bitrate = id3.bitrate; | ||
4049 | mul_id3->frequency = id3.frequency; | ||
4050 | } | ||
4051 | else | ||
4052 | { | ||
4053 | if (mul_id3->artist_hash && (mfnv(id3.artist) != mul_id3->artist_hash)) | ||
4054 | mul_id3->artist_hash = 0; | ||
4055 | if (mul_id3->album_hash && (mfnv(id3.album) != mul_id3->album_hash)) | ||
4056 | mul_id3->album_hash = 0; | ||
4057 | if (mul_id3->genre_hash && (mfnv(id3.genre_string) != mul_id3->genre_hash)) | ||
4058 | mul_id3->genre_hash = 0; | ||
4059 | if (mul_id3->composer_hash && (mfnv(id3.composer) != mul_id3->composer_hash)) | ||
4060 | mul_id3->composer_hash = 0; | ||
4061 | if (mul_id3->albumartist_hash && (mfnv(id3.albumartist) != | ||
4062 | mul_id3->albumartist_hash)) | ||
4063 | mul_id3->albumartist_hash = 0; | ||
4064 | if (mul_id3->grouping_hash && (mfnv(id3.grouping) != mul_id3->grouping_hash)) | ||
4065 | mul_id3->grouping_hash = 0; | ||
4066 | if (mul_id3->comment_hash && (mfnv(id3.comment) != mul_id3->comment_hash)) | ||
4067 | mul_id3->comment_hash = 0; | ||
4068 | |||
4069 | if (mul_id3->codectype && (id3.codectype != mul_id3->codectype)) | ||
4070 | mul_id3->codectype = AFMT_UNKNOWN; | ||
4071 | if (mul_id3->bitrate && (id3.bitrate != mul_id3->bitrate || | ||
4072 | id3.vbr != mul_id3->vbr)) | ||
4073 | mul_id3->bitrate = 0; | ||
4074 | if (mul_id3->frequency && (id3.frequency != mul_id3->frequency)) | ||
4075 | mul_id3->frequency = 0; | ||
4076 | } | ||
4077 | |||
4078 | if (ULONG_MAX - mul_id3->length < id3.length) | ||
4079 | { | ||
4080 | mul_id3->length_ovf = true; | ||
4081 | mul_id3->length = 0; | ||
4082 | } | ||
4083 | else if (!mul_id3->length_ovf) | ||
4084 | mul_id3->length += id3.length; | ||
4085 | |||
4086 | if (INT_MAX - mul_id3->filesize < id3.filesize) /* output_dyn_value expects int */ | ||
4087 | { | ||
4088 | mul_id3->filesize_ovf = true; | ||
4089 | mul_id3->filesize = 0; | ||
4090 | } | ||
4091 | else if (!mul_id3->filesize_ovf) | ||
4092 | mul_id3->filesize += id3.filesize; | ||
4093 | } | ||
4094 | |||
4095 | |||
4096 | static void write_id3_mul_tracks(struct multiple_tracks_id3 *mul_id3) | ||
4097 | { | ||
4098 | id3.path[0] = '\0'; | ||
4099 | id3.title = NULL; | ||
4100 | if (!mul_id3->artist_hash) | ||
4101 | id3.artist = NULL; | ||
4102 | if (!mul_id3->album_hash) | ||
4103 | id3.album = NULL; | ||
4104 | if (!mul_id3->genre_hash) | ||
4105 | id3.genre_string = NULL; | ||
4106 | if (!mul_id3->composer_hash) | ||
4107 | id3.composer = NULL; | ||
4108 | if (!mul_id3->albumartist_hash) | ||
4109 | id3.albumartist = NULL; | ||
4110 | if (!mul_id3->grouping_hash) | ||
4111 | id3.grouping = NULL; | ||
4112 | if (!mul_id3->comment_hash) | ||
4113 | id3.comment = NULL; | ||
4114 | id3.disc_string = NULL; | ||
4115 | id3.track_string = NULL; | ||
4116 | id3.year_string = NULL; | ||
4117 | id3.year = pf_idx.album_index[center_index].year; | ||
4118 | id3.length = mul_id3->length; | ||
4119 | id3.filesize = mul_id3->filesize; | ||
4120 | id3.frequency = mul_id3->frequency; | ||
4121 | id3.bitrate = mul_id3->bitrate; | ||
4122 | id3.codectype = mul_id3->codectype; | ||
4123 | id3.vbr = mul_id3->vbr; | ||
4124 | id3.discnum = 0; | ||
4125 | id3.tracknum = 0; | ||
4126 | id3.track_level = 0; | ||
4127 | id3.album_level = 0; | ||
4128 | } | ||
4129 | |||
4130 | static void init_mul_id3(struct multiple_tracks_id3 *mul_id3) | ||
4131 | { | ||
4132 | mul_id3->artist_hash = 0; | ||
4133 | mul_id3->album_hash = 0; | ||
4134 | mul_id3->genre_hash = 0; | ||
4135 | mul_id3->composer_hash = 0; | ||
4136 | mul_id3->albumartist_hash = 0; | ||
4137 | mul_id3->grouping_hash = 0; | ||
4138 | mul_id3->comment_hash = 0; | ||
4139 | mul_id3->codectype = 0; | ||
4140 | mul_id3->vbr = false; | ||
4141 | mul_id3->bitrate = 0; | ||
4142 | mul_id3->frequency = 0; | ||
4143 | mul_id3->length = 0; | ||
4144 | mul_id3->filesize = 0; | ||
4145 | mul_id3->length_ovf = false; | ||
4146 | mul_id3->filesize_ovf = false; | ||
4147 | } | ||
4148 | |||
4149 | static int show_id3_info(const char *selected_file) | 3992 | static int show_id3_info(const char *selected_file) |
4150 | { | 3993 | { |
4151 | int fd, i; | 3994 | int i; |
4152 | unsigned long last_tick; | 3995 | unsigned long last_tick; |
4153 | const char *file_name; | 3996 | const char *file_name; |
4154 | bool id3_retrieval_successful; | ||
4155 | bool is_multiple_tracks = insert_whole_album && pf_tracks.count > 1; | 3997 | bool is_multiple_tracks = insert_whole_album && pf_tracks.count > 1; |
4156 | struct multiple_tracks_id3 mul_id3; | ||
4157 | 3998 | ||
4158 | init_mul_id3(&mul_id3); | 3999 | init_mul_id3(); |
4159 | 4000 | ||
4160 | last_tick = *(rb->current_tick) + HZ/2; | 4001 | last_tick = *(rb->current_tick) + HZ/2; |
4161 | rb->splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */ | 4002 | rb->splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */ |
4162 | i = 0; | 4003 | i = 0; |
4163 | do { | 4004 | do { |
4164 | id3_retrieval_successful = false; | ||
4165 | file_name = i == 0 ? selected_file : get_track_filename(i); | 4005 | file_name = i == 0 ? selected_file : get_track_filename(i); |
4166 | fd = rb->open(file_name, O_RDONLY); | 4006 | if (!retrieve_id3(&id3, file_name, false)) |
4167 | if (fd >= 0) | ||
4168 | { | ||
4169 | if (rb->get_metadata(&id3, fd, file_name)) | ||
4170 | id3_retrieval_successful = true; | ||
4171 | rb->close(fd); | ||
4172 | } | ||
4173 | if (!id3_retrieval_successful) | ||
4174 | return 0; | 4007 | return 0; |
4175 | 4008 | ||
4176 | if (is_multiple_tracks) | 4009 | if (is_multiple_tracks) |
@@ -4184,13 +4017,13 @@ static int show_id3_info(const char *selected_file) | |||
4184 | last_tick = *(rb->current_tick); | 4017 | last_tick = *(rb->current_tick); |
4185 | } | 4018 | } |
4186 | 4019 | ||
4187 | collect_id3(&mul_id3, i == 0); | 4020 | collect_id3(&id3, i == 0); |
4188 | rb->yield(); | 4021 | rb->yield(); |
4189 | } | 4022 | } |
4190 | } while (++i < pf_tracks.count && is_multiple_tracks); | 4023 | } while (++i < pf_tracks.count && is_multiple_tracks); |
4191 | 4024 | ||
4192 | if (is_multiple_tracks) | 4025 | if (is_multiple_tracks) |
4193 | write_id3_mul_tracks(&mul_id3); | 4026 | write_id3_mul_tracks(&id3); |
4194 | 4027 | ||
4195 | return rb->browse_id3(&id3, 0, 0, NULL) ? PLUGIN_USB_CONNECTED : 0; | 4028 | return rb->browse_id3(&id3, 0, 0, NULL) ? PLUGIN_USB_CONNECTED : 0; |
4196 | } | 4029 | } |
@@ -4520,31 +4353,15 @@ static void draw_album_text(void) | |||
4520 | 4353 | ||
4521 | static void set_initial_slide(const char* selected_file) | 4354 | static void set_initial_slide(const char* selected_file) |
4522 | { | 4355 | { |
4523 | if (selected_file == NULL) | 4356 | if (selected_file) |
4357 | set_current_slide(retrieve_id3(&id3, selected_file, true) ? | ||
4358 | id3_get_index(&id3) : | ||
4359 | pf_cfg.last_album); | ||
4360 | else | ||
4524 | set_current_slide(rb->audio_status() ? | 4361 | set_current_slide(rb->audio_status() ? |
4525 | id3_get_index(rb->audio_current_track()) : | 4362 | id3_get_index(rb->audio_current_track()) : |
4526 | pf_cfg.last_album); | 4363 | pf_cfg.last_album); |
4527 | else | 4364 | |
4528 | { | ||
4529 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | ||
4530 | if (rb->tagcache_fill_tags(&id3, selected_file)) | ||
4531 | set_current_slide(id3_get_index(&id3)); | ||
4532 | else | ||
4533 | #endif | ||
4534 | { | ||
4535 | int fd = rb->open(selected_file, O_RDONLY); | ||
4536 | if (fd >= 0) | ||
4537 | { | ||
4538 | if (rb->get_metadata(&id3, fd, selected_file)) | ||
4539 | set_current_slide(id3_get_index(&id3)); | ||
4540 | else | ||
4541 | set_current_slide(pf_cfg.last_album); | ||
4542 | rb->close(fd); | ||
4543 | } | ||
4544 | else | ||
4545 | set_current_slide(pf_cfg.last_album); | ||
4546 | } | ||
4547 | } | ||
4548 | } | 4365 | } |
4549 | 4366 | ||
4550 | /** | 4367 | /** |