summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/fft/fft.c5
-rw-r--r--apps/plugins/lua/rockaux.c2
-rw-r--r--apps/plugins/mikmod/mikmod.c2
-rw-r--r--apps/plugins/mikmod/mikmod.make2
-rw-r--r--apps/plugins/playing_time.c104
-rw-r--r--apps/plugins/plugins.make12
6 files changed, 96 insertions, 31 deletions
diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index 4d36302ddf..99d9e033fc 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -33,8 +33,13 @@
33#include "lib/osd.h" 33#include "lib/osd.h"
34 34
35#ifndef HAVE_LCD_COLOR 35#ifndef HAVE_LCD_COLOR
36#if defined(SIMULATOR)
37// Use the one in pluginlib/osd
38extern GREY_INFO_STRUCT
39#else
36GREY_INFO_STRUCT 40GREY_INFO_STRUCT
37#endif 41#endif
42#endif
38 43
39#include "lib/pluginlib_actions.h" 44#include "lib/pluginlib_actions.h"
40 45
diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c
index c4af2b3e96..c9066e5610 100644
--- a/apps/plugins/lua/rockaux.c
+++ b/apps/plugins/lua/rockaux.c
@@ -202,11 +202,13 @@ int strcoll(const char * str1, const char * str2)
202 return rb->strcmp(str1, str2); 202 return rb->strcmp(str1, str2);
203} 203}
204 204
205#ifndef _WIN32
205struct tm * gmtime(const time_t *timep) 206struct tm * gmtime(const time_t *timep)
206{ 207{
207 static struct tm time; 208 static struct tm time;
208 return rb->gmtime_r(timep, &time); 209 return rb->gmtime_r(timep, &time);
209} 210}
211#endif
210 212
211int get_current_path(lua_State *L, int level) 213int get_current_path(lua_State *L, int level)
212{ 214{
diff --git a/apps/plugins/mikmod/mikmod.c b/apps/plugins/mikmod/mikmod.c
index 30f8c2f079..6b08fa258b 100644
--- a/apps/plugins/mikmod/mikmod.c
+++ b/apps/plugins/mikmod/mikmod.c
@@ -378,7 +378,7 @@ static void showinstruments(void)
378 rb->lcd_clear_display(); 378 rb->lcd_clear_display();
379 for( i=0; i<MAX_LINES && i+vscroll<module->numins; i++ ) 379 for( i=0; i<MAX_LINES && i+vscroll<module->numins; i++ )
380 { 380 {
381 sprintf(statustext, "%02d %s", i+vscroll+1, module->instruments[i+vscroll].insname); 381 sprintf(statustext, "%02d %s", i+vscroll+1, module->instruments[i+vscroll].insname ? module->instruments[i+vscroll].insname : "[n/a]");
382 rb->lcd_putsxy(1, 1+(8*i), statustext); 382 rb->lcd_putsxy(1, 1+(8*i), statustext);
383 } 383 }
384 rb->lcd_update(); 384 rb->lcd_update();
diff --git a/apps/plugins/mikmod/mikmod.make b/apps/plugins/mikmod/mikmod.make
index f93a10ca27..bff7b82099 100644
--- a/apps/plugins/mikmod/mikmod.make
+++ b/apps/plugins/mikmod/mikmod.make
@@ -18,7 +18,7 @@ MIKMOD_OBJ := $(call c2obj, $(MIKMOD_SRC))
18# add source files to OTHER_SRC to get automatic dependencies 18# add source files to OTHER_SRC to get automatic dependencies
19OTHER_SRC += $(MIKMOD_SRC) 19OTHER_SRC += $(MIKMOD_SRC)
20 20
21MIKMODCFLAGS = $(PLUGINFLAGS) -I$(MIKMODSRCDIR) -O2 21MIKMODCFLAGS = $(PLUGINFLAGS) -I$(MIKMODSRCDIR) -O2 -DMIKMOD_STATIC
22 22
23# Disable stringop-truncation warnings on GCC 8 or greater 23# Disable stringop-truncation warnings on GCC 8 or greater
24ifeq ($(shell expr $(GCCNUM) \> 800),1) 24ifeq ($(shell expr $(GCCNUM) \> 800),1)
diff --git a/apps/plugins/playing_time.c b/apps/plugins/playing_time.c
index 354c5a3e06..e465c35a18 100644
--- a/apps/plugins/playing_time.c
+++ b/apps/plugins/playing_time.c
@@ -31,6 +31,17 @@ const unsigned char * const byte_units[] =
31 ID2P(LANG_GIBIBYTE) 31 ID2P(LANG_GIBIBYTE)
32}; 32};
33 33
34const int menu_items[] = {
35 LANG_PLAYTIME_ELAPSED,
36 LANG_PLAYTIME_REMAINING,
37 LANG_PLAYTIME_TRK_ELAPSED,
38 LANG_PLAYTIME_TRK_REMAINING,
39 LANG_PLAYTIME_TRACK,
40 LANG_PLAYTIME_STORAGE,
41 LANG_PLAYTIME_AVG_TRACK_SIZE,
42 LANG_PLAYTIME_AVG_BITRATE,
43};
44
34const unsigned char * const * const kibyte_units = &byte_units[1]; 45const unsigned char * const * const kibyte_units = &byte_units[1];
35 46
36enum ePT_SECS { 47enum ePT_SECS {
@@ -53,7 +64,7 @@ struct playing_time_info {
53 int curr_index; /* index of currently playing track in playlist */ 64 int curr_index; /* index of currently playing track in playlist */
54 int curr_display_index; /* display index of currently playing track in playlist */ 65 int curr_display_index; /* display index of currently playing track in playlist */
55 int nb_tracks; /* how many tracks in playlist */ 66 int nb_tracks; /* how many tracks in playlist */
56 67
57 /* seconds total, before, and after current position. Datatype 68 /* seconds total, before, and after current position. Datatype
58 allows for values up to 68years. If I had kept it in ms 69 allows for values up to 68years. If I had kept it in ms
59 though, it would have overflowed at 24days, which takes 70 though, it would have overflowed at 24days, which takes
@@ -68,6 +79,27 @@ struct playing_time_info {
68 long kbs[ePT_KBS_COUNT]; 79 long kbs[ePT_KBS_COUNT];
69}; 80};
70 81
82static char* get_percent_str(long percents)
83{
84 static char val[10];
85 rb->snprintf(val, 10, rb->str(LANG_PERCENT_FORMAT), percents);
86 return val;
87}
88
89static inline void prepare_time_string(char *buf, size_t buffer_len, long elapsed_pct, const char *timestr1, const char *timestr2)
90{
91 if (rb->lang_is_rtl())
92 {
93 rb->snprintf(buf, buffer_len, "%s %s / %s",
94 get_percent_str(elapsed_pct), timestr2, timestr1);
95 }
96 else
97 {
98 rb->snprintf(buf, buffer_len, "%s / %s %s",
99 timestr1, timestr2, get_percent_str(elapsed_pct));
100 }
101}
102
71/* list callback for playing_time screen */ 103/* list callback for playing_time screen */
72static const char * playing_time_get_or_speak_info(int selected_item, void * data, 104static const char * playing_time_get_or_speak_info(int selected_item, void * data,
73 char *buf, size_t buffer_len, 105 char *buf, size_t buffer_len,
@@ -75,14 +107,22 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
75{ 107{
76 long elapsed_pct; /* percentage of duration elapsed */ 108 long elapsed_pct; /* percentage of duration elapsed */
77 struct playing_time_info *pti = (struct playing_time_info *)data; 109 struct playing_time_info *pti = (struct playing_time_info *)data;
78 switch(selected_item) { 110 int info_no = selected_item/2;
111 const int menu_name_id = menu_items[info_no];
112
113 if (!(selected_item%2))
114 {/* header */
115 return rb->str(menu_name_id);
116 }
117
118 switch(info_no) {
79 case 0: { /* elapsed and total time */ 119 case 0: { /* elapsed and total time */
80 char timestr1[25], timestr2[25]; 120 char timestr1[25], timestr2[25];
81 rb->format_time_auto(timestr1, sizeof(timestr1), 121 rb->format_time_auto(timestr1, sizeof(timestr1),
82 pti->secs[ePT_SECS_BEF], UNIT_SEC, false); 122 pti->secs[ePT_SECS_BEF], UNIT_SEC, true);
83 123
84 rb->format_time_auto(timestr2, sizeof(timestr2), 124 rb->format_time_auto(timestr2, sizeof(timestr2),
85 pti->secs[ePT_SECS_TTL], UNIT_SEC, false); 125 pti->secs[ePT_SECS_TTL], UNIT_SEC, true);
86 126
87 if (pti->secs[ePT_SECS_TTL] == 0) 127 if (pti->secs[ePT_SECS_TTL] == 0)
88 elapsed_pct = 0; 128 elapsed_pct = 0;
@@ -96,11 +136,10 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
96 elapsed_pct = (pti->secs[ePT_SECS_BEF] >> 7) * 100 136 elapsed_pct = (pti->secs[ePT_SECS_BEF] >> 7) * 100
97 / (pti->secs[ePT_SECS_TTL] >> 7); 137 / (pti->secs[ePT_SECS_TTL] >> 7);
98 } 138 }
99 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_ELAPSED), 139 prepare_time_string(buf, buffer_len, elapsed_pct, timestr1, timestr2);
100 timestr1, timestr2, elapsed_pct);
101 140
102 if (say_it) 141 if (say_it)
103 rb_talk_ids(false, LANG_PLAYTIME_ELAPSED, 142 rb_talk_ids(false, menu_name_id,
104 TALK_ID(pti->secs[ePT_SECS_BEF], UNIT_TIME), 143 TALK_ID(pti->secs[ePT_SECS_BEF], UNIT_TIME),
105 VOICE_OF, 144 VOICE_OF,
106 TALK_ID(pti->secs[ePT_SECS_TTL], UNIT_TIME), 145 TALK_ID(pti->secs[ePT_SECS_TTL], UNIT_TIME),
@@ -112,10 +151,10 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
112 char timestr[25]; 151 char timestr[25];
113 rb->format_time_auto(timestr, sizeof(timestr), pti->secs[ePT_SECS_AFT], 152 rb->format_time_auto(timestr, sizeof(timestr), pti->secs[ePT_SECS_AFT],
114 UNIT_SEC, false); 153 UNIT_SEC, false);
115 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_REMAINING), timestr); 154 rb->snprintf(buf, buffer_len, "%s", timestr);
116 155
117 if (say_it) 156 if (say_it)
118 rb_talk_ids(false, LANG_PLAYTIME_REMAINING, 157 rb_talk_ids(false, menu_name_id,
119 TALK_ID(pti->secs[ePT_SECS_AFT], UNIT_TIME)); 158 TALK_ID(pti->secs[ePT_SECS_AFT], UNIT_TIME));
120 break; 159 break;
121 } 160 }
@@ -123,9 +162,9 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
123 char timestr1[25], timestr2[25]; 162 char timestr1[25], timestr2[25];
124 163
125 rb->format_time_auto(timestr1, sizeof(timestr1), pti->trk_secs[ePT_SECS_BEF], 164 rb->format_time_auto(timestr1, sizeof(timestr1), pti->trk_secs[ePT_SECS_BEF],
126 UNIT_SEC, false); 165 UNIT_SEC, true);
127 rb->format_time_auto(timestr2, sizeof(timestr2), pti->trk_secs[ePT_SECS_TTL], 166 rb->format_time_auto(timestr2, sizeof(timestr2), pti->trk_secs[ePT_SECS_TTL],
128 UNIT_SEC, false); 167 UNIT_SEC, true);
129 168
130 if (pti->trk_secs[ePT_SECS_TTL] == 0) 169 if (pti->trk_secs[ePT_SECS_TTL] == 0)
131 elapsed_pct = 0; 170 elapsed_pct = 0;
@@ -139,11 +178,10 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
139 elapsed_pct = (pti->trk_secs[ePT_SECS_BEF] >> 7) * 100 178 elapsed_pct = (pti->trk_secs[ePT_SECS_BEF] >> 7) * 100
140 / (pti->trk_secs[ePT_SECS_TTL] >> 7); 179 / (pti->trk_secs[ePT_SECS_TTL] >> 7);
141 } 180 }
142 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_TRK_ELAPSED), 181 prepare_time_string(buf, buffer_len, elapsed_pct, timestr1, timestr2);
143 timestr1, timestr2, elapsed_pct);
144 182
145 if (say_it) 183 if (say_it)
146 rb_talk_ids(false, LANG_PLAYTIME_TRK_ELAPSED, 184 rb_talk_ids(false, menu_name_id,
147 TALK_ID(pti->trk_secs[ePT_SECS_BEF], UNIT_TIME), 185 TALK_ID(pti->trk_secs[ePT_SECS_BEF], UNIT_TIME),
148 VOICE_OF, 186 VOICE_OF,
149 TALK_ID(pti->trk_secs[ePT_SECS_TTL], UNIT_TIME), 187 TALK_ID(pti->trk_secs[ePT_SECS_TTL], UNIT_TIME),
@@ -155,21 +193,29 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
155 char timestr[25]; 193 char timestr[25];
156 rb->format_time_auto(timestr, sizeof(timestr), pti->trk_secs[ePT_SECS_AFT], 194 rb->format_time_auto(timestr, sizeof(timestr), pti->trk_secs[ePT_SECS_AFT],
157 UNIT_SEC, false); 195 UNIT_SEC, false);
158 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_TRK_REMAINING), timestr); 196 rb->snprintf(buf, buffer_len, "%s", timestr);
159 197
160 if (say_it) 198 if (say_it)
161 rb_talk_ids(false, LANG_PLAYTIME_TRK_REMAINING, 199 rb_talk_ids(false, menu_name_id,
162 TALK_ID(pti->trk_secs[ePT_SECS_AFT], UNIT_TIME)); 200 TALK_ID(pti->trk_secs[ePT_SECS_AFT], UNIT_TIME));
163 break; 201 break;
164 } 202 }
165 case 4: { /* track index */ 203 case 4: { /* track index */
166 int track_pct = pti->curr_display_index * 100 / pti->nb_tracks; 204 int track_pct = pti->curr_display_index * 100 / pti->nb_tracks;
167 205
168 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_TRACK), 206 if (rb->lang_is_rtl())
169 pti->curr_display_index, pti->nb_tracks, track_pct); 207 {
208 rb->snprintf(buf, buffer_len, "%s %d / %d",
209 get_percent_str(track_pct), pti->nb_tracks, pti->curr_display_index);
210 }
211 else
212 {
213 rb->snprintf(buf, buffer_len, "%d / %d %s",
214 pti->curr_display_index, pti->nb_tracks, get_percent_str(track_pct));
215 }
170 216
171 if (say_it) 217 if (say_it)
172 rb_talk_ids(false, LANG_PLAYTIME_TRACK, 218 rb_talk_ids(false, menu_name_id,
173 TALK_ID(pti->curr_display_index, UNIT_INT), 219 TALK_ID(pti->curr_display_index, UNIT_INT),
174 VOICE_OF, 220 VOICE_OF,
175 TALK_ID(pti->nb_tracks, UNIT_INT), 221 TALK_ID(pti->nb_tracks, UNIT_INT),
@@ -179,18 +225,18 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
179 } 225 }
180 case 5: { /* storage size */ 226 case 5: { /* storage size */
181 int i; 227 int i;
182 char kbstr[ePT_KBS_COUNT][10]; 228 char kbstr[ePT_KBS_COUNT][20];
183 229
184 for (i = 0; i < ePT_KBS_COUNT; i++) { 230 for (i = 0; i < ePT_KBS_COUNT; i++) {
185 rb->output_dyn_value(kbstr[i], sizeof(kbstr[i]), 231 rb->output_dyn_value(kbstr[i], sizeof(kbstr[i]),
186 pti->kbs[i], kibyte_units, 3, true); 232 pti->kbs[i], kibyte_units, 3, true);
187 } 233 }
188 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_STORAGE), 234 rb->snprintf(buf, buffer_len, "%s (%s / %s)",
189 kbstr[ePT_KBS_TTL], kbstr[ePT_KBS_BEF],kbstr[ePT_KBS_AFT]); 235 kbstr[ePT_KBS_TTL], kbstr[ePT_KBS_BEF],kbstr[ePT_KBS_AFT]);
190 236
191 if (say_it) { 237 if (say_it) {
192 int32_t voice_ids[ePT_KBS_COUNT]; 238 int32_t voice_ids[ePT_KBS_COUNT];
193 voice_ids[ePT_KBS_TTL] = LANG_PLAYTIME_STORAGE; 239 voice_ids[ePT_KBS_TTL] = menu_name_id;
194 voice_ids[ePT_KBS_BEF] = VOICE_PLAYTIME_DONE; 240 voice_ids[ePT_KBS_BEF] = VOICE_PLAYTIME_DONE;
195 voice_ids[ePT_KBS_AFT] = LANG_PLAYTIME_REMAINING; 241 voice_ids[ePT_KBS_AFT] = LANG_PLAYTIME_REMAINING;
196 242
@@ -202,13 +248,13 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
202 break; 248 break;
203 } 249 }
204 case 6: { /* Average track file size */ 250 case 6: { /* Average track file size */
205 char str[10]; 251 char str[20];
206 long avg_track_size = pti->kbs[ePT_KBS_TTL] / pti->nb_tracks; 252 long avg_track_size = pti->kbs[ePT_KBS_TTL] / pti->nb_tracks;
207 rb->output_dyn_value(str, sizeof(str), avg_track_size, kibyte_units, 3, true); 253 rb->output_dyn_value(str, sizeof(str), avg_track_size, kibyte_units, 3, true);
208 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_AVG_TRACK_SIZE), str); 254 rb->snprintf(buf, buffer_len, "%s", str);
209 255
210 if (say_it) { 256 if (say_it) {
211 rb->talk_id(LANG_PLAYTIME_AVG_TRACK_SIZE, false); 257 rb->talk_id(menu_name_id, false);
212 rb->output_dyn_value(NULL, 0, avg_track_size, kibyte_units, 3, true); 258 rb->output_dyn_value(NULL, 0, avg_track_size, kibyte_units, 3, true);
213 } 259 }
214 break; 260 break;
@@ -217,10 +263,10 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat
217 /* Convert power of 2 kilobytes to power of 10 kilobits */ 263 /* Convert power of 2 kilobytes to power of 10 kilobits */
218 long avg_bitrate = (pti->kbs[ePT_KBS_TTL] / pti->secs[ePT_SECS_TTL] 264 long avg_bitrate = (pti->kbs[ePT_KBS_TTL] / pti->secs[ePT_SECS_TTL]
219 * 1024 * 8 / 1000); 265 * 1024 * 8 / 1000);
220 rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_AVG_BITRATE), avg_bitrate); 266 rb->snprintf(buf, buffer_len, "%ld kbps", avg_bitrate);
221 267
222 if (say_it) 268 if (say_it)
223 rb_talk_ids(false, LANG_PLAYTIME_AVG_BITRATE, 269 rb_talk_ids(false, menu_name_id,
224 TALK_ID(avg_bitrate, UNIT_KBIT)); 270 TALK_ID(avg_bitrate, UNIT_KBIT));
225 break; 271 break;
226 } 272 }
@@ -340,10 +386,10 @@ static bool playing_time(void)
340 struct gui_synclist pt_lists; 386 struct gui_synclist pt_lists;
341 int key; 387 int key;
342 388
343 rb->gui_synclist_init(&pt_lists, &playing_time_get_info, &pti, true, 1, NULL); 389 rb->gui_synclist_init(&pt_lists, &playing_time_get_info, &pti, true, 2, NULL);
344 if (rb->global_settings->talk_menu) 390 if (rb->global_settings->talk_menu)
345 rb->gui_synclist_set_voice_callback(&pt_lists, playing_time_speak_info); 391 rb->gui_synclist_set_voice_callback(&pt_lists, playing_time_speak_info);
346 rb->gui_synclist_set_nb_items(&pt_lists, 8); 392 rb->gui_synclist_set_nb_items(&pt_lists, 16);
347 rb->gui_synclist_set_title(&pt_lists, rb->str(LANG_PLAYING_TIME), NOICON); 393 rb->gui_synclist_set_title(&pt_lists, rb->str(LANG_PLAYING_TIME), NOICON);
348 rb->gui_synclist_draw(&pt_lists); 394 rb->gui_synclist_draw(&pt_lists);
349 rb->gui_synclist_speak_item(&pt_lists); 395 rb->gui_synclist_speak_item(&pt_lists);
diff --git a/apps/plugins/plugins.make b/apps/plugins/plugins.make
index b430bd2792..4a126f812c 100644
--- a/apps/plugins/plugins.make
+++ b/apps/plugins/plugins.make
@@ -37,6 +37,12 @@ PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
37PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o) 37PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
38PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ)) 38PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ))
39 39
40ifdef USE_LTO
41# We do NOT want LTO on the GCC support file.
42$(BUILDDIR)/apps/plugins/lib/gcc-support.o: PLUGINFLAGS += -fno-lto
43$(BUILDDIR)/apps/plugins/plugin_crt0.o: PLUGINFLAGS += -fno-lto
44endif
45
40### build data / rules 46### build data / rules
41ifndef APP_TYPE 47ifndef APP_TYPE
42CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h 48CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
@@ -147,6 +153,12 @@ else
147endif 153endif
148PLUGINLDFLAGS += $(GLOBAL_LDOPTS) 154PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
149 155
156ifdef USE_LTO
157 PLUGINFLAGS += -flto -fno-builtin -ffreestanding
158 PLUGINLDFLAGS += -flto -fno-builtin -ffreestanding
159 PLUGINLDFLAGS += -e plugin_start
160endif
161
150$(BUILDDIR)/%.rock: 162$(BUILDDIR)/%.rock:
151 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \ 163 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
152 $(filter %.o, $^) \ 164 $(filter %.o, $^) \