summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpeg_settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c79
1 files changed, 21 insertions, 58 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 3daba2c928..f84a30ddfe 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -315,39 +315,6 @@ static const struct opt_items globaloff[2] = {
315#endif 315#endif
316 316
317static void mpeg_settings(void); 317static void mpeg_settings(void);
318static long mpeg_menu_sysevent_id;
319
320void mpeg_menu_sysevent_clear(void)
321{
322 mpeg_menu_sysevent_id = 0;
323}
324
325int mpeg_menu_sysevent_callback(int btn, const struct menu_item_ex *menu)
326{
327 switch (btn)
328 {
329 case SYS_USB_CONNECTED:
330 case SYS_POWEROFF:
331 mpeg_menu_sysevent_id = btn;
332 return ACTION_STD_CANCEL;
333 }
334
335 return btn;
336 (void)menu;
337}
338
339long mpeg_menu_sysevent(void)
340{
341 return mpeg_menu_sysevent_id;
342}
343
344void mpeg_menu_sysevent_handle(void)
345{
346 long id = mpeg_menu_sysevent();
347 if (id != 0)
348 rb->default_event_handler(id);
349}
350
351static bool mpeg_set_option(const char* string, 318static bool mpeg_set_option(const char* string,
352 void* variable, 319 void* variable,
353 enum optiontype type, 320 enum optiontype type,
@@ -355,14 +322,14 @@ static bool mpeg_set_option(const char* string,
355 int numoptions, 322 int numoptions,
356 void (*function)(int)) 323 void (*function)(int))
357{ 324{
358 mpeg_menu_sysevent_clear(); 325 mpeg_sysevent_clear();
359 326
360 /* This eats SYS_POWEROFF - :\ */ 327 /* This eats SYS_POWEROFF - :\ */
361 bool usb = rb->set_option(string, variable, type, options, numoptions, 328 bool usb = rb->set_option(string, variable, type, options, numoptions,
362 function); 329 function);
363 330
364 if (usb) 331 if (usb)
365 mpeg_menu_sysevent_id = ACTION_STD_CANCEL; 332 mpeg_sysevent_set();
366 333
367 return usb; 334 return usb;
368} 335}
@@ -375,13 +342,13 @@ static bool mpeg_set_int(const char *string, const char *unit,
375 int max, 342 int max,
376 const char* (*formatter)(char*, size_t, int, const char*)) 343 const char* (*formatter)(char*, size_t, int, const char*))
377{ 344{
378 mpeg_menu_sysevent_clear(); 345 mpeg_sysevent_clear();
379 346
380 bool usb = rb->set_int(string, unit, voice_unit, variable, function, 347 bool usb = rb->set_int(string, unit, voice_unit, variable, function,
381 step, min, max, formatter); 348 step, min, max, formatter);
382 349
383 if (usb) 350 if (usb)
384 mpeg_menu_sysevent_id = ACTION_STD_CANCEL; 351 mpeg_sysevent_set();
385 352
386 return usb; 353 return usb;
387} 354}
@@ -778,11 +745,7 @@ static int get_start_time(uint32_t duration)
778 745
779 while (slider_state < STATE9) 746 while (slider_state < STATE9)
780 { 747 {
781 mpeg_menu_sysevent_clear(); 748 button = mpeg_button_get(tmo);
782 button = tmo == TIMEOUT_BLOCK ?
783 rb->button_get(true) : rb->button_get_w_tmo(tmo);
784
785 button = mpeg_menu_sysevent_callback(button, NULL);
786 749
787 switch (button) 750 switch (button)
788 { 751 {
@@ -922,7 +885,7 @@ static int show_start_menu(uint32_t duration)
922 char hms_str[32]; 885 char hms_str[32];
923 struct hms hms; 886 struct hms hms;
924 887
925 MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback, 888 MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_sysevent_callback,
926 "Play from beginning", resume_str, "Set start time", 889 "Play from beginning", resume_str, "Set start time",
927 "Settings", "Quit mpegplayer"); 890 "Settings", "Quit mpegplayer");
928 891
@@ -935,7 +898,7 @@ static int show_start_menu(uint32_t duration)
935 898
936 while (!menu_quit) 899 while (!menu_quit)
937 { 900 {
938 mpeg_menu_sysevent_clear(); 901 mpeg_sysevent_clear();
939 result = rb->do_menu(&menu, &selected, NULL, false); 902 result = rb->do_menu(&menu, &selected, NULL, false);
940 903
941 switch (result) 904 switch (result)
@@ -972,7 +935,7 @@ static int show_start_menu(uint32_t duration)
972 break; 935 break;
973 } 936 }
974 937
975 if (mpeg_menu_sysevent() != 0) 938 if (mpeg_sysevent() != 0)
976 { 939 {
977 result = MPEG_START_QUIT; 940 result = MPEG_START_QUIT;
978 menu_quit = true; 941 menu_quit = true;
@@ -985,7 +948,7 @@ static int show_start_menu(uint32_t duration)
985/* Return the desired resume action */ 948/* Return the desired resume action */
986int mpeg_start_menu(uint32_t duration) 949int mpeg_start_menu(uint32_t duration)
987{ 950{
988 mpeg_menu_sysevent_clear(); 951 mpeg_sysevent_clear();
989 952
990 switch (settings.resume_options) 953 switch (settings.resume_options)
991 { 954 {
@@ -1008,12 +971,12 @@ int mpeg_menu(void)
1008{ 971{
1009 int result; 972 int result;
1010 973
1011 MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback, 974 MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_sysevent_callback,
1012 "Settings", "Resume playback", "Quit mpegplayer"); 975 "Settings", "Resume playback", "Quit mpegplayer");
1013 976
1014 rb->button_clear_queue(); 977 rb->button_clear_queue();
1015 978
1016 mpeg_menu_sysevent_clear(); 979 mpeg_sysevent_clear();
1017 980
1018 result = rb->do_menu(&menu, NULL, NULL, false); 981 result = rb->do_menu(&menu, NULL, NULL, false);
1019 982
@@ -1033,7 +996,7 @@ int mpeg_menu(void)
1033 break; 996 break;
1034 } 997 }
1035 998
1036 if (mpeg_menu_sysevent() != 0) 999 if (mpeg_sysevent() != 0)
1037 result = MPEG_MENU_QUIT; 1000 result = MPEG_MENU_QUIT;
1038 1001
1039 return result; 1002 return result;
@@ -1045,7 +1008,7 @@ static void display_options(void)
1045 int result; 1008 int result;
1046 bool menu_quit = false; 1009 bool menu_quit = false;
1047 1010
1048 MENUITEM_STRINGLIST(menu, "Display Options", mpeg_menu_sysevent_callback, 1011 MENUITEM_STRINGLIST(menu, "Display Options", mpeg_sysevent_callback,
1049#if MPEG_OPTION_DITHERING_ENABLED 1012#if MPEG_OPTION_DITHERING_ENABLED
1050 "Dithering", 1013 "Dithering",
1051#endif 1014#endif
@@ -1059,7 +1022,7 @@ static void display_options(void)
1059 1022
1060 while (!menu_quit) 1023 while (!menu_quit)
1061 { 1024 {
1062 mpeg_menu_sysevent_clear(); 1025 mpeg_sysevent_clear();
1063 result = rb->do_menu(&menu, &selected, NULL, false); 1026 result = rb->do_menu(&menu, &selected, NULL, false);
1064 1027
1065 switch (result) 1028 switch (result)
@@ -1108,7 +1071,7 @@ static void display_options(void)
1108 break; 1071 break;
1109 } 1072 }
1110 1073
1111 if (mpeg_menu_sysevent() != 0) 1074 if (mpeg_sysevent() != 0)
1112 menu_quit = true; 1075 menu_quit = true;
1113 } 1076 }
1114} 1077}
@@ -1119,7 +1082,7 @@ static void audio_options(void)
1119 int result; 1082 int result;
1120 bool menu_quit = false; 1083 bool menu_quit = false;
1121 1084
1122 MENUITEM_STRINGLIST(menu, "Audio Options", mpeg_menu_sysevent_callback, 1085 MENUITEM_STRINGLIST(menu, "Audio Options", mpeg_sysevent_callback,
1123 "Tone Controls", "Channel Modes", "Crossfeed", 1086 "Tone Controls", "Channel Modes", "Crossfeed",
1124 "Equalizer", "Dithering"); 1087 "Equalizer", "Dithering");
1125 1088
@@ -1127,7 +1090,7 @@ static void audio_options(void)
1127 1090
1128 while (!menu_quit) 1091 while (!menu_quit)
1129 { 1092 {
1130 mpeg_menu_sysevent_clear(); 1093 mpeg_sysevent_clear();
1131 result = rb->do_menu(&menu, &selected, NULL, false); 1094 result = rb->do_menu(&menu, &selected, NULL, false);
1132 1095
1133 switch (result) 1096 switch (result)
@@ -1167,7 +1130,7 @@ static void audio_options(void)
1167 break; 1130 break;
1168 } 1131 }
1169 1132
1170 if (mpeg_menu_sysevent() != 0) 1133 if (mpeg_sysevent() != 0)
1171 menu_quit = true; 1134 menu_quit = true;
1172 } 1135 }
1173} 1136}
@@ -1203,7 +1166,7 @@ static void mpeg_settings(void)
1203 bool menu_quit = false; 1166 bool menu_quit = false;
1204 static char clear_str[32]; 1167 static char clear_str[32];
1205 1168
1206 MENUITEM_STRINGLIST(menu, "Settings", mpeg_menu_sysevent_callback, 1169 MENUITEM_STRINGLIST(menu, "Settings", mpeg_sysevent_callback,
1207 "Display Options", "Audio Options", 1170 "Display Options", "Audio Options",
1208 "Resume Options", "Play Mode", clear_str); 1171 "Resume Options", "Play Mode", clear_str);
1209 1172
@@ -1211,7 +1174,7 @@ static void mpeg_settings(void)
1211 1174
1212 while (!menu_quit) 1175 while (!menu_quit)
1213 { 1176 {
1214 mpeg_menu_sysevent_clear(); 1177 mpeg_sysevent_clear();
1215 1178
1216 /* Format and add resume option to the menu display */ 1179 /* Format and add resume option to the menu display */
1217 rb->snprintf(clear_str, sizeof(clear_str), 1180 rb->snprintf(clear_str, sizeof(clear_str),
@@ -1247,7 +1210,7 @@ static void mpeg_settings(void)
1247 break; 1210 break;
1248 } 1211 }
1249 1212
1250 if (mpeg_menu_sysevent() != 0) 1213 if (mpeg_sysevent() != 0)
1251 menu_quit = true; 1214 menu_quit = true;
1252 } 1215 }
1253} 1216}