Do not set VFCAP_EOSD_UNSCALED if we use scaled-osd
[mplayer/glamo.git] / gui / win32 / wincfg.c
blob901bcdfbb1e606d1485fc65e4a8906ec1ba6d24c
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>
7 * This file is part of MPlayer.
9 * MPlayer is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * MPlayer is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with MPlayer; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <stdlib.h>
25 #include <string.h>
27 #include "mplayer.h"
28 #include "mp_msg.h"
29 #include "help_mp.h"
30 #include "m_config.h"
31 #include "m_option.h"
32 #include "libvo/video_out.h"
33 #include "mixer.h"
34 #include "wincfg.h"
35 #include "interface.h"
37 /* params */
38 int gtkAONorm = 0;
39 int gtkAOExtraStereo = 0;
40 float gtkAOExtraStereoMul = 1.0;
41 int gtkCacheOn = 0;
42 int gtkCacheSize = 2048;
43 int gtkAutoSyncOn = 0;
44 int gtkAutoSync = 0;
46 int sub_window = 0;
47 int console = 0;
49 int gui_save_pos = 1;
50 int gui_main_pos_x = -2;
51 int gui_main_pos_y = -2;
52 int gui_sub_pos_x = -1;
53 int gui_sub_pos_y = -1;
55 /* External functions */
56 extern int frame_dropping;
57 extern char *proc_priority;
58 extern int m_config_parse_config_file(m_config_t *config, char *conffile);
60 static m_config_t *gui_conf;
61 static m_option_t gui_opts[] =
63 { "priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
64 { "vo_driver", &video_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
65 { "v_framedrop", &frame_dropping, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL },
66 { "vo_doublebuffering", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
67 { "vo_direct_render", &vo_directrendering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
68 { "ao_driver", &audio_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
69 { "ao_volnorm", &gtkAONorm, CONF_TYPE_FLAG, 0, 0, 1, NULL },
70 { "softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL },
71 { "ao_extra_stereo", &gtkAOExtraStereo, CONF_TYPE_FLAG, 0, 0, 1, NULL },
72 { "ao_extra_stereo_coefficient", &gtkAOExtraStereoMul, CONF_TYPE_FLOAT, CONF_RANGE, -10, 10, NULL },
73 { "delay", &audio_delay, CONF_TYPE_FLOAT, CONF_RANGE, -100.0, 100.0, NULL},
74 { "dvd_device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL },
75 { "cdrom_device", &cdrom_device, CONF_TYPE_STRING, 0, 0, 0, NULL },
76 { "osd_level", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL },
77 { "cache", &gtkCacheOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
78 { "cache_size", &gtkCacheSize, CONF_TYPE_INT, CONF_RANGE, -1, 65535, NULL },
79 { "autosync", &gtkAutoSyncOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
80 { "autosync_size", &gtkAutoSync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL },
81 { "gui_skin", &skinName, CONF_TYPE_STRING, 0, 0, 0, NULL },
82 { "gui_main_pos_x", &gui_main_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
83 { "gui_main_pos_y", &gui_main_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
84 { "gui_sub_pos_x", &gui_sub_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
85 { "gui_sub_pos_y", &gui_sub_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
86 { "sub_window", &sub_window, CONF_TYPE_FLAG, 0, 0, 1, NULL},
87 { "console", &console, CONF_TYPE_FLAG, 0, 0, 1, NULL},
88 { NULL, NULL, 0, 0, 0, 0, NULL }
91 char *gfgets(char *str, int size, FILE *f)
93 char *s = fgets(str, size, f);
94 char c;
95 if(s)
97 c = s[strlen(s) - 1];
98 if ((c == '\n') || (c == '\r'))
99 s[strlen(s) - 1]=0;
100 c = s[strlen(s) - 1];
101 if ((c == '\n') || (c == '\r'))
102 s[strlen(s) - 1]=0;
104 return s;
107 int cfg_read(void)
109 char *cfg = get_path("gui.conf");
111 /* read configuration */
112 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] [cfg] reading config file: %s\n", cfg);
113 gui_conf = m_config_new();
114 m_config_register_options(gui_conf, gui_opts);
115 if (m_config_parse_config_file(gui_conf, cfg) < 0)
116 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_ConfigFileError);
117 free(cfg);
118 return 0;
121 int cfg_write(void)
123 char *cfg = get_path("gui.conf");
124 FILE *f;
125 int i;
127 /* save configuration */
128 if ((f = fopen(cfg, "wt+")))
130 for (i=0; gui_opts[i].name; i++)
132 char *v = m_option_print(&gui_opts[i], gui_opts[i].p);
133 if(v)
135 fprintf(f, "%s = \"%s\"\n", gui_opts[i].name, v);
136 free(v);
138 else if((int) v == -1)
139 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, gui_opts[i].name);
141 fclose(f);
143 free(cfg);
144 return 0;