18914
|
1 /*
|
|
2 MPlayer Gui for win32
|
|
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de>
|
|
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com>
|
|
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
|
|
6
|
|
7 This program is free software; you can redistribute it and/or modify
|
|
8 it under the terms of the GNU General Public License as published by
|
|
9 the Free Software Foundation; either version 2 of the License, or
|
|
10 (at your option) any later version.
|
|
11
|
|
12 This program is distributed in the hope that it will be useful,
|
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 GNU General Public License for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with this program; if not, write to the Free Software
|
|
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
|
|
20 */
|
|
21
|
|
22 #include <stdlib.h>
|
|
23 #include <string.h>
|
|
24
|
|
25 #include <mp_msg.h>
|
|
26 #include <help_mp.h>
|
|
27
|
|
28 #include <m_config.h>
|
|
29 #include <m_option.h>
|
|
30 #include <libvo/video_out.h>
|
|
31 #include <mixer.h>
|
|
32 #include "wincfg.h"
|
|
33 #include "interface.h"
|
|
34
|
|
35 /* params */
|
|
36 int gtkAONorm = 0;
|
|
37 int gtkAOExtraStereo = 0;
|
|
38 float gtkAOExtraStereoMul = 1.0;
|
|
39 int gtkCacheOn = 0;
|
|
40 int gtkCacheSize = 2048;
|
|
41 int gtkAutoSyncOn = 0;
|
|
42 int gtkAutoSync = 0;
|
|
43
|
|
44 int sub_window = 0;
|
|
45 int console = 0;
|
|
46
|
|
47 int gui_save_pos = 1;
|
|
48 int gui_main_pos_x = -2;
|
|
49 int gui_main_pos_y = -2;
|
|
50 int gui_sub_pos_x = -1;
|
|
51 int gui_sub_pos_y = -1;
|
|
52
|
|
53 /* External functions */
|
|
54 extern int frame_dropping;
|
|
55 extern char *proc_priority;
|
|
56 extern int m_config_parse_config_file(m_config_t *config, char *conffile);
|
|
57
|
|
58 static m_config_t *gui_conf;
|
|
59 static m_option_t gui_opts[] =
|
|
60 {
|
|
61 { "priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
|
62 { "vo_driver", &video_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
|
|
63 { "v_framedrop", &frame_dropping, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL },
|
|
64 { "vo_doublebuffering", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
|
65 { "vo_direct_render", &vo_directrendering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
|
66 { "ao_driver", &audio_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
|
|
67 { "ao_volnorm", >kAONorm, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
|
68 { "softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
|
69 { "ao_extra_stereo", >kAOExtraStereo, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
|
70 { "ao_extra_stereo_coefficient", >kAOExtraStereoMul, CONF_TYPE_FLOAT, CONF_RANGE, -10, 10, NULL },
|
|
71 { "delay", &audio_delay, CONF_TYPE_FLOAT, CONF_RANGE, -100.0, 100.0, NULL},
|
|
72 { "dvd_device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL },
|
|
73 { "cdrom_device", &cdrom_device, CONF_TYPE_STRING, 0, 0, 0, NULL },
|
|
74 { "osd_level", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL },
|
|
75 { "cache", >kCacheOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
|
76 { "cache_size", >kCacheSize, CONF_TYPE_INT, CONF_RANGE, -1, 65535, NULL },
|
|
77 { "autosync", >kAutoSyncOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
|
78 { "autosync_size", >kAutoSync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL },
|
|
79 { "gui_skin", &skinName, CONF_TYPE_STRING, 0, 0, 0, NULL },
|
|
80 { "gui_main_pos_x", &gui_main_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
|
|
81 { "gui_main_pos_y", &gui_main_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
|
|
82 { "gui_sub_pos_x", &gui_sub_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
|
|
83 { "gui_sub_pos_y", &gui_sub_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
|
|
84 { "sub_window", &sub_window, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
|
85 { "console", &console, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
|
86 { NULL, NULL, 0, 0, 0, 0, NULL }
|
|
87 };
|
|
88
|
|
89 char *gfgets(char *str, int size, FILE *f)
|
|
90 {
|
|
91 char *s = fgets(str, size, f);
|
|
92 char c;
|
|
93 if(s)
|
|
94 {
|
|
95 c = s[strlen(s) - 1];
|
|
96 if ((c == '\n') || (c == '\r'))
|
|
97 s[strlen(s) - 1]=0;
|
|
98 c = s[strlen(s) - 1];
|
|
99 if ((c == '\n') || (c == '\r'))
|
|
100 s[strlen(s) - 1]=0;
|
|
101 }
|
|
102 return s;
|
|
103 }
|
|
104
|
|
105 int cfg_read(void)
|
|
106 {
|
|
107 char *cfg = get_path("gui.conf");
|
|
108
|
|
109 /* read configuration */
|
|
110 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] [cfg] reading config file: %s\n", cfg);
|
|
111 gui_conf = m_config_new();
|
|
112 m_config_register_options(gui_conf, gui_opts);
|
|
113 if (m_config_parse_config_file(gui_conf, cfg) < 0)
|
|
114 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_ConfigFileError);
|
|
115 free(cfg);
|
|
116 return 0;
|
|
117 }
|
|
118
|
|
119 int cfg_write(void)
|
|
120 {
|
|
121 char *cfg = get_path("gui.conf");
|
|
122 FILE *f;
|
|
123 int i;
|
|
124
|
|
125 /* save configuration */
|
|
126 if ((f = fopen(cfg, "wt+")))
|
|
127 {
|
|
128 for (i=0; gui_opts[i].name; i++)
|
|
129 {
|
|
130 char *v = m_option_print(&gui_opts[i], gui_opts[i].p);
|
|
131 if(v)
|
|
132 {
|
|
133 fprintf(f, "%s = \"%s\"\n", gui_opts[i].name, v);
|
|
134 free(v);
|
|
135 }
|
|
136 else if((int) v == -1)
|
|
137 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, gui_opts[i].name);
|
|
138 }
|
|
139 fclose(f);
|
|
140 }
|
|
141 free(cfg);
|
|
142 return 0;
|
|
143 }
|