summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpeg_settings.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-08-20 23:12:56 +0000
committerDave Chapman <dave@dchapman.com>2006-08-20 23:12:56 +0000
commitc8e69dfb71d936b4bc5e18f6246ac126c629f772 (patch)
treed43563a0c30011d3ec7af1e13e1892bdfff60a46 /apps/plugins/mpegplayer/mpeg_settings.c
parent18cfe431d7556f8cd7047018febe191073c26a1f (diff)
downloadrockbox-c8e69dfb71d936b4bc5e18f6246ac126c629f772.tar.gz
rockbox-c8e69dfb71d936b4bc5e18f6246ac126c629f772.zip
Move FPS display out of video_out_rockbox.c and into mpegplayer.c. Also add frame-rate limiting and frame-skipping (skipping display only, not decoding) to try and achieve real-time playback. Frame-rate limiting and frame skipping (and FPS display) are enabled via options in a new menu and are currently all off by default.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10669 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
new file mode 100644
index 0000000000..dc63626c10
--- /dev/null
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -0,0 +1,118 @@
1#include "plugin.h"
2#include "lib/configfile.h"
3
4#include "mpeg_settings.h"
5
6extern struct plugin_api* rb;
7
8struct mpeg_settings settings;
9static struct mpeg_settings old_settings;
10
11#define SETTINGS_VERSION 1
12#define SETTINGS_MIN_VERSION 1
13#define SETTINGS_FILENAME "mpegplayer.cfg"
14
15static char* showfps_options[] = {"No", "Yes"};
16static char* limitfps_options[] = {"No", "Yes"};
17static char* skipframes_options[] = {"No", "Yes"};
18
19static struct configdata config[] =
20{
21 {TYPE_ENUM, 0, 2, &settings.showfps, "Show FPS", showfps_options, NULL},
22 {TYPE_ENUM, 0, 2, &settings.limitfps, "Limit FPS", limitfps_options, NULL},
23 {TYPE_ENUM, 0, 2, &settings.skipframes, "Skip frames", skipframes_options, NULL},
24};
25
26bool mpeg_menu(void)
27{
28 int m;
29 int result;
30 int menu_quit=0;
31
32 static const struct opt_items noyes[2] = {
33 { "No", -1 },
34 { "Yes", -1 },
35 };
36
37 static const struct menu_item items[] = {
38 { "Display FPS", NULL },
39 { "Limit FPS", NULL },
40 { "Skip frames", NULL },
41 { "Quit mpegplayer", NULL },
42 };
43
44 m = rb->menu_init(items, sizeof(items) / sizeof(*items),
45 NULL, NULL, NULL, NULL);
46
47 rb->button_clear_queue();
48
49 while (!menu_quit) {
50 result=rb->menu_show(m);
51
52 switch(result)
53 {
54 case 0: /* Show FPS */
55 rb->set_option("Display FPS",&settings.showfps,INT,
56 noyes, 2, NULL);
57 break;
58 case 1: /* Limit FPS */
59 rb->set_option("Limit FPS",&settings.limitfps,INT,
60 noyes, 2, NULL);
61 break;
62 case 2: /* Skip frames */
63 rb->set_option("Skip frames",&settings.skipframes,INT,
64 noyes, 2, NULL);
65 break;
66 default:
67 menu_quit=1;
68 break;
69 }
70 }
71
72 rb->menu_exit(m);
73
74 rb->lcd_clear_display();
75 rb->lcd_update();
76
77 return (result==3);
78}
79
80
81void init_settings(void)
82{
83 /* Set the default settings */
84 settings.showfps = 0; /* Do not show FPS */
85 settings.limitfps = 0; /* Do not limit FPS */
86 settings.skipframes = 0; /* Do not skip frames */
87
88 configfile_init(rb);
89
90 if (configfile_load(SETTINGS_FILENAME, config,
91 sizeof(config)/sizeof(*config),
92 SETTINGS_MIN_VERSION
93 ) < 0)
94 {
95 /* If the loading failed, save a new config file (as the disk is
96 already spinning) */
97 configfile_save(SETTINGS_FILENAME, config,
98 sizeof(config)/sizeof(*config),
99 SETTINGS_VERSION);
100 }
101
102 /* Keep a copy of the saved version of the settings - so we can check if
103 the settings have changed when we quit */
104 old_settings = settings;
105}
106
107void save_settings(void)
108{
109 /* Save the user settings if they have changed */
110 if (rb->memcmp(&settings,&old_settings,sizeof(settings))!=0) {
111 configfile_save(SETTINGS_FILENAME, config,
112 sizeof(config)/sizeof(*config),
113 SETTINGS_VERSION);
114
115 /* Store the settings in old_settings - to check for future changes */
116 old_settings = settings;
117 }
118}