summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2023-04-04 21:35:51 +0200
committerChristian Soffke <christian.soffke@gmail.com>2023-04-13 02:31:32 +0200
commit6ca57ec389e9dd2141f9c9e73063c7193526dbbd (patch)
tree2cedbe36f75467fe9fb266c985c477983fa66629
parent78c92c5ca85d275e43bacf0d9948ce9b94605f6e (diff)
downloadrockbox-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
-rw-r--r--apps/gui/wps.c2
-rw-r--r--apps/onplay.c2
-rw-r--r--apps/playlist_viewer.c2
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/plugins/lib/mul_id3.c44
-rw-r--r--apps/plugins/lib/mul_id3.h3
-rw-r--r--apps/plugins/pictureflow/pictureflow.c6
-rw-r--r--apps/plugins/properties.c10
-rw-r--r--apps/screens.c31
-rw-r--r--apps/screens.h2
10 files changed, 57 insertions, 49 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index d35a5ac6d2..d87f78de2d 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -1035,7 +1035,7 @@ long gui_wps_show(void)
1035 gwps_leave_wps(true); 1035 gwps_leave_wps(true);
1036 if (browse_id3(audio_current_track(), 1036 if (browse_id3(audio_current_track(),
1037 playlist_get_display_index(), 1037 playlist_get_display_index(),
1038 playlist_amount(), NULL)) 1038 playlist_amount(), NULL, false))
1039 return GO_TO_ROOT; 1039 return GO_TO_ROOT;
1040 restore = true; 1040 restore = true;
1041 } 1041 }
diff --git a/apps/onplay.c b/apps/onplay.c
index 9dd780fd6e..4b6171746c 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -1569,7 +1569,7 @@ static int browse_id3_wrapper(void)
1569 1569
1570 if (browse_id3(audio_current_track(), 1570 if (browse_id3(audio_current_track(),
1571 playlist_get_display_index(), 1571 playlist_get_display_index(),
1572 playlist_amount(), NULL)) 1572 playlist_amount(), NULL, false))
1573 return GO_TO_ROOT; 1573 return GO_TO_ROOT;
1574 return GO_TO_PREVIOUS; 1574 return GO_TO_PREVIOUS;
1575} 1575}
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 8761f0dbc9..d9bfee343f 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -526,7 +526,7 @@ static enum pv_onplay_result show_track_info(const struct playlist_entry *curren
526 526
527 return id3_retrieval_successful && 527 return id3_retrieval_successful &&
528 browse_id3(&id3, current_track->index + 1, 528 browse_id3(&id3, current_track->index + 1,
529 viewer.num_tracks, NULL) ? PV_ONPLAY_USB : PV_ONPLAY_UNCHANGED; 529 viewer.num_tracks, NULL, false) ? PV_ONPLAY_USB : PV_ONPLAY_UNCHANGED;
530} 530}
531 531
532 532
diff --git a/apps/plugin.h b/apps/plugin.h
index 3eb4101cbe..835063e25f 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -162,7 +162,7 @@ int plugin_open(const char *plugin, const char *parameter);
162 * when this happens please take the opportunity to sort in 162 * when this happens please take the opportunity to sort in
163 * any new functions "waiting" at the end of the list. 163 * any new functions "waiting" at the end of the list.
164 */ 164 */
165#define PLUGIN_API_VERSION 267 165#define PLUGIN_API_VERSION 268
166 166
167/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ 167/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
168 168
@@ -500,7 +500,7 @@ struct plugin_api {
500 void (*add_to_pl_cb)); 500 void (*add_to_pl_cb));
501 bool (*browse_id3)(struct mp3entry *id3, 501 bool (*browse_id3)(struct mp3entry *id3,
502 int playlist_display_index, int playlist_amount, 502 int playlist_display_index, int playlist_amount,
503 struct tm *modified); 503 struct tm *modified, bool multiple_tracks);
504 504
505 /* talking */ 505 /* talking */
506 int (*talk_id)(int32_t id, bool enqueue); 506 int (*talk_id)(int32_t id, bool enqueue);
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
24struct multiple_tracks_id3 { 24struct 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
67void init_mul_id3(void) 65static 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
87void collect_id3(struct mp3entry *id3, bool is_first_track) 83void 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
150void 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 */
140void 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
24void init_mul_id3(void);
25void collect_id3(struct mp3entry *id3, bool is_first_track); 24void collect_id3(struct mp3entry *id3, bool is_first_track);
26void write_id3_mul_tracks(struct mp3entry *id3); 25void 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)
diff --git a/apps/screens.c b/apps/screens.c
index 869d081498..c519da9353 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -394,6 +394,7 @@ static const int id3_headers[]=
394struct id3view_info { 394struct id3view_info {
395 struct mp3entry* id3; 395 struct mp3entry* id3;
396 struct tm *modified; 396 struct tm *modified;
397 bool multiple_tracks;
397 int count; 398 int count;
398 int playlist_display_index; 399 int playlist_display_index;
399 int playlist_amount; 400 int playlist_amount;
@@ -491,6 +492,9 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
491{ 492{
492 struct id3view_info *info = (struct id3view_info*)data; 493 struct id3view_info *info = (struct id3view_info*)data;
493 struct mp3entry* id3 =info->id3; 494 struct mp3entry* id3 =info->id3;
495 const unsigned char * const *unit;
496 unsigned int unit_ct;
497 unsigned long length;
494 struct tm *tm = info->modified; 498 struct tm *tm = info->modified;
495 int info_no=selected_item/2; 499 int info_no=selected_item/2;
496 if(!(selected_item%2)) 500 if(!(selected_item%2))
@@ -593,10 +597,13 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
593 } 597 }
594 break; 598 break;
595 case LANG_ID3_LENGTH: 599 case LANG_ID3_LENGTH:
596 format_time(buffer, buffer_len, id3->length); 600 length = info->multiple_tracks ? id3->length : id3->length / 1000;
601
602 format_time_auto(buffer, buffer_len,
603 length, UNIT_SEC | UNIT_TRIM_ZERO, true);
597 val=buffer; 604 val=buffer;
598 if(say_it) 605 if(say_it)
599 talk_value(id3->length /1000, UNIT_TIME, true); 606 talk_value(length, UNIT_TIME, true);
600 break; 607 break;
601 case LANG_ID3_PLAYLIST: 608 case LANG_ID3_PLAYLIST:
602 if (info->playlist_display_index == 0 || info->playlist_amount == 0 ) 609 if (info->playlist_display_index == 0 || info->playlist_amount == 0 )
@@ -667,10 +674,20 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
667 case LANG_FILESIZE: /* not LANG_ID3_FILESIZE because the string is shared */ 674 case LANG_FILESIZE: /* not LANG_ID3_FILESIZE because the string is shared */
668 if (!id3->filesize) 675 if (!id3->filesize)
669 return NULL; 676 return NULL;
670 output_dyn_value(buffer, buffer_len, id3->filesize, byte_units, 4, true); 677 if (info->multiple_tracks)
678 {
679 unit = kibyte_units;
680 unit_ct = 3;
681 }
682 else
683 {
684 unit = byte_units;
685 unit_ct = 4;
686 }
687 output_dyn_value(buffer, buffer_len, id3->filesize, unit, unit_ct, true);
671 val=buffer; 688 val=buffer;
672 if(say_it && val) 689 if(say_it && val)
673 output_dyn_value(NULL, 0, id3->filesize, byte_units, 4, true); 690 output_dyn_value(NULL, 0, id3->filesize, unit, unit_ct, true);
674 break; 691 break;
675 case LANG_DATE: 692 case LANG_DATE:
676 if (!tm) 693 if (!tm)
@@ -720,8 +737,11 @@ static int id3_speak_item(int selected_item, void* data)
720 return 0; 737 return 0;
721} 738}
722 739
740/* Note: Setting multiple_tracks parameter to true causes filesize value
741 * to be treated as KiB (instead of Bytes), and length as s instead of ms.
742 */
723bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, 743bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount,
724 struct tm *modified) 744 struct tm *modified, bool multiple_tracks)
725{ 745{
726 struct gui_synclist id3_lists; 746 struct gui_synclist id3_lists;
727 int key; 747 int key;
@@ -730,6 +750,7 @@ bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_a
730 info.count = 0; 750 info.count = 0;
731 info.id3 = id3; 751 info.id3 = id3;
732 info.modified = modified; 752 info.modified = modified;
753 info.multiple_tracks = multiple_tracks;
733 info.playlist_display_index = playlist_display_index; 754 info.playlist_display_index = playlist_display_index;
734 info.playlist_amount = playlist_amount; 755 info.playlist_amount = playlist_amount;
735 bool ret = false; 756 bool ret = false;
diff --git a/apps/screens.h b/apps/screens.h
index 47dc1375ca..2dc0530f3a 100644
--- a/apps/screens.h
+++ b/apps/screens.h
@@ -40,7 +40,7 @@ bool set_time_screen(const char* title, struct tm *tm, bool set_date);
40#endif 40#endif
41 41
42bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, 42bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount,
43 struct tm *modified); 43 struct tm *modified, bool multiple_tracks);
44int view_runtime(void); 44int view_runtime(void);
45 45
46#ifdef HAVE_TOUCHSCREEN 46#ifdef HAVE_TOUCHSCREEN