diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2023-04-04 21:35:51 +0200 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2023-04-13 02:31:32 +0200 |
commit | 6ca57ec389e9dd2141f9c9e73063c7193526dbbd (patch) | |
tree | 2cedbe36f75467fe9fb266c985c477983fa66629 /apps/plugins | |
parent | 78c92c5ca85d275e43bacf0d9948ce9b94605f6e (diff) | |
download | rockbox-6ca57ec389e9dd2141f9c9e73063c7193526dbbd.tar.gz rockbox-6ca57ec389e9dd2141f9c9e73063c7193526dbbd.zip |
Track Info: Display larger file size and length values
When displaying Track Info for multiple tracks,
the value for combined file sizes or length was
capped at 2 GiB / ~596h.
Limit has been raised by a factor of 1000.
Change-Id: I942c64e81864cba3f719c83a24912883fafeb70e
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/lib/mul_id3.c | 44 | ||||
-rw-r--r-- | apps/plugins/lib/mul_id3.h | 3 | ||||
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 6 | ||||
-rw-r--r-- | apps/plugins/properties.c | 10 |
4 files changed, 25 insertions, 38 deletions
diff --git a/apps/plugins/lib/mul_id3.c b/apps/plugins/lib/mul_id3.c index 5c8f4d9d9c..c40a495ecd 100644 --- a/apps/plugins/lib/mul_id3.c +++ b/apps/plugins/lib/mul_id3.c | |||
@@ -22,8 +22,8 @@ | |||
22 | #include "mul_id3.h" | 22 | #include "mul_id3.h" |
23 | 23 | ||
24 | struct multiple_tracks_id3 { | 24 | struct multiple_tracks_id3 { |
25 | unsigned long length; | 25 | unsigned long long filesize; |
26 | unsigned long filesize; | 26 | unsigned long long length; |
27 | unsigned long frequency; | 27 | unsigned long frequency; |
28 | unsigned int artist_hash; | 28 | unsigned int artist_hash; |
29 | unsigned int composer_hash; | 29 | unsigned int composer_hash; |
@@ -35,8 +35,6 @@ struct multiple_tracks_id3 { | |||
35 | unsigned int codectype; | 35 | unsigned int codectype; |
36 | unsigned int bitrate; | 36 | unsigned int bitrate; |
37 | int year; | 37 | int year; |
38 | bool filesize_ovf; | ||
39 | bool length_ovf; | ||
40 | bool vbr; | 38 | bool vbr; |
41 | }; | 39 | }; |
42 | 40 | ||
@@ -64,7 +62,7 @@ static unsigned int mfnv(char *str) | |||
64 | return hash; | 62 | return hash; |
65 | } | 63 | } |
66 | 64 | ||
67 | void init_mul_id3(void) | 65 | static void init_mul_id3(void) |
68 | { | 66 | { |
69 | mul_id3.artist_hash = 0; | 67 | mul_id3.artist_hash = 0; |
70 | mul_id3.album_hash = 0; | 68 | mul_id3.album_hash = 0; |
@@ -80,14 +78,13 @@ void init_mul_id3(void) | |||
80 | mul_id3.length = 0; | 78 | mul_id3.length = 0; |
81 | mul_id3.filesize = 0; | 79 | mul_id3.filesize = 0; |
82 | mul_id3.year = 0; | 80 | mul_id3.year = 0; |
83 | mul_id3.length_ovf = false; | ||
84 | mul_id3.filesize_ovf = false; | ||
85 | } | 81 | } |
86 | 82 | ||
87 | void collect_id3(struct mp3entry *id3, bool is_first_track) | 83 | void collect_id3(struct mp3entry *id3, bool is_first_track) |
88 | { | 84 | { |
89 | if (is_first_track) | 85 | if (is_first_track) |
90 | { | 86 | { |
87 | init_mul_id3(); | ||
91 | mul_id3.artist_hash = mfnv(id3->artist); | 88 | mul_id3.artist_hash = mfnv(id3->artist); |
92 | mul_id3.album_hash = mfnv(id3->album); | 89 | mul_id3.album_hash = mfnv(id3->album); |
93 | mul_id3.genre_hash = mfnv(id3->genre_string); | 90 | mul_id3.genre_hash = mfnv(id3->genre_string); |
@@ -129,25 +126,18 @@ void collect_id3(struct mp3entry *id3, bool is_first_track) | |||
129 | if (mul_id3.year && (id3->year != mul_id3.year)) | 126 | if (mul_id3.year && (id3->year != mul_id3.year)) |
130 | mul_id3.year = 0; | 127 | mul_id3.year = 0; |
131 | } | 128 | } |
132 | 129 | mul_id3.length += id3->length; | |
133 | if (ULONG_MAX - mul_id3.length < id3->length) | 130 | mul_id3.filesize += id3->filesize; |
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 | } | 131 | } |
149 | 132 | ||
150 | void write_id3_mul_tracks(struct mp3entry *id3) | 133 | /* (!) Note scale factor applied to returned metadata: |
134 | * - Unit for filesize will be KiB instead of Bytes | ||
135 | * - Unit for length will be s instead of ms | ||
136 | * | ||
137 | * Use result only as input for browse_id3, | ||
138 | * and set multiple_tracks parameter to true. | ||
139 | */ | ||
140 | void finalize_id3(struct mp3entry *id3) | ||
151 | { | 141 | { |
152 | id3->path[0] = '\0'; | 142 | id3->path[0] = '\0'; |
153 | id3->title = NULL; | 143 | id3->title = NULL; |
@@ -169,8 +159,10 @@ void write_id3_mul_tracks(struct mp3entry *id3) | |||
169 | id3->track_string = NULL; | 159 | id3->track_string = NULL; |
170 | id3->year_string = NULL; | 160 | id3->year_string = NULL; |
171 | id3->year = mul_id3.year; | 161 | id3->year = mul_id3.year; |
172 | id3->length = mul_id3.length; | 162 | mul_id3.length /= 1000; |
173 | id3->filesize = mul_id3.filesize; | 163 | mul_id3.filesize >>= 10; |
164 | id3->length = mul_id3.length > ULONG_MAX ? 0 : mul_id3.length; | ||
165 | id3->filesize = mul_id3.filesize > INT_MAX ? 0 : mul_id3.filesize; | ||
174 | id3->frequency = mul_id3.frequency; | 166 | id3->frequency = mul_id3.frequency; |
175 | id3->bitrate = mul_id3.bitrate; | 167 | id3->bitrate = mul_id3.bitrate; |
176 | id3->codectype = mul_id3.codectype; | 168 | id3->codectype = mul_id3.codectype; |
diff --git a/apps/plugins/lib/mul_id3.h b/apps/plugins/lib/mul_id3.h index 40d7fa7822..d08095de5c 100644 --- a/apps/plugins/lib/mul_id3.h +++ b/apps/plugins/lib/mul_id3.h | |||
@@ -21,8 +21,7 @@ | |||
21 | #ifndef MUL_ID3_H | 21 | #ifndef MUL_ID3_H |
22 | #define MUL_ID3_H | 22 | #define MUL_ID3_H |
23 | 23 | ||
24 | void init_mul_id3(void); | ||
25 | void collect_id3(struct mp3entry *id3, bool is_first_track); | 24 | void collect_id3(struct mp3entry *id3, bool is_first_track); |
26 | void write_id3_mul_tracks(struct mp3entry *id3); | 25 | void finalize_id3(struct mp3entry *id3); |
27 | 26 | ||
28 | #endif /* MUL_ID3_H */ | 27 | #endif /* MUL_ID3_H */ |
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 3b308d1866..52f87355b2 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -4000,8 +4000,6 @@ static int show_id3_info(const char *selected_file) | |||
4000 | const char *file_name; | 4000 | const char *file_name; |
4001 | bool is_multiple_tracks = insert_whole_album && pf_tracks.count > 1; | 4001 | bool is_multiple_tracks = insert_whole_album && pf_tracks.count > 1; |
4002 | 4002 | ||
4003 | init_mul_id3(); | ||
4004 | |||
4005 | last_tick = *(rb->current_tick) + HZ/2; | 4003 | last_tick = *(rb->current_tick) + HZ/2; |
4006 | rb->splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */ | 4004 | rb->splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */ |
4007 | i = 0; | 4005 | i = 0; |
@@ -4027,9 +4025,9 @@ static int show_id3_info(const char *selected_file) | |||
4027 | } while (++i < pf_tracks.count && is_multiple_tracks); | 4025 | } while (++i < pf_tracks.count && is_multiple_tracks); |
4028 | 4026 | ||
4029 | if (is_multiple_tracks) | 4027 | if (is_multiple_tracks) |
4030 | write_id3_mul_tracks(&id3); | 4028 | finalize_id3(&id3); |
4031 | 4029 | ||
4032 | return rb->browse_id3(&id3, 0, 0, NULL) ? PLUGIN_USB_CONNECTED : 0; | 4030 | return rb->browse_id3(&id3, 0, 0, NULL, i > 1) ? PLUGIN_USB_CONNECTED : 0; |
4033 | } | 4031 | } |
4034 | 4032 | ||
4035 | 4033 | ||
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 27bfe9181a..638d7380a5 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c | |||
@@ -406,14 +406,12 @@ enum plugin_status plugin_start(const void* parameter) | |||
406 | if (!rb->strcmp(file, MAKE_ACT_STR(ACTIVITY_DATABASEBROWSER))) /* db table selected */ | 406 | if (!rb->strcmp(file, MAKE_ACT_STR(ACTIVITY_DATABASEBROWSER))) /* db table selected */ |
407 | { | 407 | { |
408 | props_type = PROPS_MUL_ID3; | 408 | props_type = PROPS_MUL_ID3; |
409 | init_mul_id3(); | ||
410 | mul_id3_count = 0; | 409 | mul_id3_count = 0; |
411 | 410 | ||
412 | if (!rb->tagtree_subentries_do_action(&mul_id3_add) || mul_id3_count == 0) | 411 | if (!rb->tagtree_subentries_do_action(&mul_id3_add) || mul_id3_count == 0) |
413 | return PLUGIN_ERROR; | 412 | return PLUGIN_ERROR; |
414 | 413 | else if (mul_id3_count > 1) /* otherwise, the retrieved id3 can be used as-is */ | |
415 | if (mul_id3_count > 1) /* otherwise, the retrieved id3 can be used as-is */ | 414 | finalize_id3(&id3); |
416 | write_id3_mul_tracks(&id3); | ||
417 | } | 415 | } |
418 | else | 416 | else |
419 | #endif | 417 | #endif |
@@ -448,8 +446,8 @@ enum plugin_status plugin_start(const void* parameter) | |||
448 | FOR_NB_SCREENS(i) | 446 | FOR_NB_SCREENS(i) |
449 | rb->viewportmanager_theme_enable(i, true, NULL); | 447 | rb->viewportmanager_theme_enable(i, true, NULL); |
450 | 448 | ||
451 | bool usb = props_type == PROPS_ID3 ? rb->browse_id3(&id3, 0, 0, &tm) : | 449 | bool usb = props_type == PROPS_ID3 ? rb->browse_id3(&id3, 0, 0, &tm, false) : |
452 | (props_type == PROPS_MUL_ID3 ? rb->browse_id3(&id3, 0, 0, NULL) : | 450 | (props_type == PROPS_MUL_ID3 ? rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count > 1) : |
453 | browse_file_or_dir(&stats)); | 451 | browse_file_or_dir(&stats)); |
454 | 452 | ||
455 | FOR_NB_SCREENS(i) | 453 | FOR_NB_SCREENS(i) |