Mercurial > mplayer.hg
annotate Gui/cfg.c @ 6887:66427e850216
Add the control VFCTRL_CHANGE_RECTANGLE
print the rectangle boundaries.
vf_rectangle accepts stride. Is this correct?
author | kmkaplan |
---|---|
date | Sun, 04 Aug 2002 02:21:50 +0000 |
parents | ed02bae611d5 |
children | 138a7ff52a26 |
rev | line source |
---|---|
6770 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 #include <string.h> | |
5 | |
6 #include "../config.h" | |
7 #include "../mp_msg.h" | |
8 #include "../mplayer.h" | |
9 #include "../cfgparser.h" | |
10 | |
6840 | 11 #ifdef USE_I18N |
12 #include <locale.h> | |
13 #endif | |
14 | |
6770 | 15 #include "../../libvo/video_out.h" |
16 | |
17 #include "cfg.h" | |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
18 #include "app.h" |
6770 | 19 #include "interface.h" |
20 #include "mplayer/play.h" | |
21 | |
22 // --- params | |
23 | |
24 int gtkEnableAudioEqualizer = 0; | |
25 int gtkEnableVideoEqualizer = 0; | |
26 | |
27 char * gtkVODriver = NULL; | |
28 int gtkVODoubleBuffer = 1; | |
29 int gtkVODirectRendering = 0; | |
30 int gtkVFrameDrop = 1; | |
31 int gtkVHardFrameDrop = 0; | |
32 int gtkVNIAVI = 0; | |
33 int gtkVFlip = 0; | |
34 int gtkVIndex = 1; | |
35 int gtkVVFM = -1; | |
36 int gtkVPP = 0; | |
37 int gtkVAutoq = 0; | |
38 | |
39 char * gtkAODriver = NULL; | |
40 int gtkAONoSound = 0; | |
41 float gtkAODelay = 0.0f; | |
42 int gtkAONorm = 0; | |
43 int gtkAOSurround = 0; | |
44 int gtkAOExtraStereo = 0; | |
45 float gtkAOExtraStereoMul = 1.0; | |
46 char * gtkAOOSSMixer; | |
47 char * gtkAOOSSDevice; | |
48 | |
49 int gtkSubAuto = 1; // | |
50 int gtkSubUnicode = 0; // | |
51 int gtkSubDumpMPSub = 0; | |
52 int gtkSubDumpSrt = 0; | |
53 float gtkSubDelay = 0.0f; | |
6794 | 54 float gtkSubFPS = 0.0f; |
6770 | 55 int gtkSubPos = 100; // |
56 float gtkSubFFactor = 0.75; | |
57 | |
58 // --- | |
59 | |
60 extern char * get_path( char * filename ); | |
61 extern int flip; | |
62 extern int frame_dropping; | |
63 | |
64 static m_config_t * gui_conf; | |
65 static config_t gui_opts[] = | |
66 { | |
67 { "enable_audio_equ",>kEnableAudioEqualizer,CONF_TYPE_FLAG,0,0,1,NULL }, | |
68 { "enable_video_equ",>kEnableVideoEqualizer,CONF_TYPE_FLAG,0,0,1,NULL }, | |
69 | |
70 { "vo_driver",>kVODriver,CONF_TYPE_STRING,0,0,0,NULL }, | |
71 { "vo_panscan",&vo_panscan,CONF_TYPE_FLOAT,CONF_RANGE,0.0,1.0,NULL }, | |
72 { "vo_doublebuffering",&vo_doublebuffering,CONF_TYPE_FLAG,0,0,1,NULL }, | |
73 { "vo_direct_render",>kVODirectRendering,CONF_TYPE_FLAG,0,0,1,NULL }, | |
74 | |
75 { "v_framedrop",>kVFrameDrop,CONF_TYPE_FLAG,0,0,1,NULL }, | |
76 { "v_hard_framedrop",>kVHardFrameDrop,CONF_TYPE_FLAG,0,0,1,NULL }, | |
77 { "v_flip",>kVFlip,CONF_TYPE_FLAG,0,0,1,NULL }, | |
78 { "v_ni",>kVNIAVI,CONF_TYPE_FLAG,0,0,1,NULL }, | |
79 { "v_idx",>kVIndex,CONF_TYPE_FLAG,0,0,1,NULL }, | |
6794 | 80 { "v_vfm",>kVVFM,CONF_TYPE_INT,CONF_RANGE,-1,10,NULL }, |
6770 | 81 { "vf_pp",>kVPP,CONF_TYPE_FLAG,0,0,1,NULL }, |
82 { "vf_autoq",>kVAutoq,CONF_TYPE_INT,CONF_RANGE,0,100,NULL }, | |
83 | |
84 { "ao_driver",>kAODriver,CONF_TYPE_STRING,0,0,0,NULL }, | |
85 { "ao_nosound",>kAONoSound,CONF_TYPE_FLAG,0,0,1,NULL }, | |
86 { "ao_volnorm",>kAONorm,CONF_TYPE_FLAG,0,0,1,NULL }, | |
87 { "ao_surround",>kAOSurround,CONF_TYPE_FLAG,0,0,1,NULL }, | |
88 { "ao_extra_stereo",>kAOExtraStereo,CONF_TYPE_FLAG,0,0,1,NULL }, | |
89 { "ao_extra_stereo_coefficient",>kAOExtraStereoMul,CONF_TYPE_FLOAT,CONF_RANGE,-10,10,NULL }, | |
90 { "ao_delay",>kAODelay,CONF_TYPE_FLOAT,CONF_RANGE,-100,100,NULL }, | |
91 { "ao_oss_mixer",>kAOOSSMixer,CONF_TYPE_STRING,0,0,0,NULL }, | |
92 { "ao_oss_device",>kAOOSSDevice,CONF_TYPE_STRING,0,0,0,NULL }, | |
93 | |
94 { "osd_level",&osd_level,CONF_TYPE_INT,CONF_RANGE,0,2,NULL }, | |
95 { "sub_auto_load",>kSubAuto,CONF_TYPE_FLAG,0,0,1,NULL }, | |
96 { "sub_unicode",>kSubUnicode,CONF_TYPE_FLAG,0,0,1,NULL }, | |
97 { "sub_pos",>kSubPos,CONF_TYPE_INT,CONF_RANGE,0,200,NULL }, | |
98 { "font_factor",>kSubFFactor,CONF_TYPE_FLOAT,CONF_RANGE,0.0,10.0,NULL }, | |
99 { "font_name",&guiIntfStruct.Fontname,CONF_TYPE_STRING,0,0,0,NULL }, | |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
100 |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
101 { "gui_skin",&skinName,CONF_TYPE_STRING,0,0,0,NULL }, |
6770 | 102 |
103 { "equ_channel_1",>kEquChannel1,CONF_TYPE_STRING,0,0,0,NULL }, | |
104 { "equ_channel_2",>kEquChannel2,CONF_TYPE_STRING,0,0,0,NULL }, | |
105 { "equ_channel_3",>kEquChannel3,CONF_TYPE_STRING,0,0,0,NULL }, | |
106 { "equ_channel_4",>kEquChannel4,CONF_TYPE_STRING,0,0,0,NULL }, | |
107 { "equ_channel_5",>kEquChannel5,CONF_TYPE_STRING,0,0,0,NULL }, | |
108 { "equ_channel_6",>kEquChannel6,CONF_TYPE_STRING,0,0,0,NULL }, | |
109 | |
110 #if 1 | |
6840 | 111 #define audio_equ_row( i,j ) { "equ_band_"#i#j,>kEquChannels[i][j],CONF_TYPE_FLOAT,CONF_RANGE,-15.0,15.0,NULL }, |
6770 | 112 audio_equ_row( 0,0 ) audio_equ_row( 0,1 ) audio_equ_row( 0,2 ) audio_equ_row( 0,3 ) audio_equ_row( 0,4 ) audio_equ_row( 0,5 ) audio_equ_row( 0,6 ) audio_equ_row( 0,7 ) audio_equ_row( 0,8 ) audio_equ_row( 0,9 ) |
113 audio_equ_row( 1,0 ) audio_equ_row( 1,1 ) audio_equ_row( 1,2 ) audio_equ_row( 1,3 ) audio_equ_row( 1,4 ) audio_equ_row( 1,5 ) audio_equ_row( 1,6 ) audio_equ_row( 1,7 ) audio_equ_row( 1,8 ) audio_equ_row( 1,9 ) | |
114 audio_equ_row( 2,0 ) audio_equ_row( 2,1 ) audio_equ_row( 2,2 ) audio_equ_row( 2,3 ) audio_equ_row( 2,4 ) audio_equ_row( 2,5 ) audio_equ_row( 2,6 ) audio_equ_row( 2,7 ) audio_equ_row( 2,8 ) audio_equ_row( 2,9 ) | |
115 audio_equ_row( 3,0 ) audio_equ_row( 3,1 ) audio_equ_row( 3,2 ) audio_equ_row( 3,3 ) audio_equ_row( 3,4 ) audio_equ_row( 3,5 ) audio_equ_row( 3,6 ) audio_equ_row( 3,7 ) audio_equ_row( 3,8 ) audio_equ_row( 3,9 ) | |
116 audio_equ_row( 4,0 ) audio_equ_row( 4,1 ) audio_equ_row( 4,2 ) audio_equ_row( 4,3 ) audio_equ_row( 4,4 ) audio_equ_row( 4,5 ) audio_equ_row( 4,6 ) audio_equ_row( 4,7 ) audio_equ_row( 4,8 ) audio_equ_row( 4,9 ) | |
117 audio_equ_row( 5,0 ) audio_equ_row( 5,1 ) audio_equ_row( 5,2 ) audio_equ_row( 5,3 ) audio_equ_row( 5,4 ) audio_equ_row( 5,5 ) audio_equ_row( 5,6 ) audio_equ_row( 5,7 ) audio_equ_row( 5,8 ) audio_equ_row( 5,9 ) | |
118 #undef audio_equ_row | |
119 #endif | |
120 | |
121 { NULL, NULL, 0, 0, 0, 0, NULL } | |
122 }; | |
123 | |
124 int cfg_read( void ) | |
125 { | |
126 char * cfg = get_path( "gui.conf" ); | |
127 | |
128 // -- read configuration | |
129 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg ); | |
130 gui_conf=m_config_new( play_tree_new() ); | |
131 m_config_register_options( gui_conf,gui_opts ); | |
132 if ( m_config_parse_config_file( gui_conf,cfg ) < 0 ) | |
133 { | |
134 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[cfg] config file read error ...\n" ); | |
135 exit( 1 ); | |
136 } | |
137 free( cfg ); | |
138 | |
139 // -- read pl | |
140 { | |
141 FILE * f; | |
142 cfg=get_path( "gui.pl" ); | |
143 if ( (f=fopen( cfg,"rt" )) == NULL ) return 1; | |
144 while ( !feof( f ) ) | |
145 { | |
146 char tmp[512]; plItem * item = calloc( 1,sizeof( plItem ) ); char c; | |
147 if ( fgets( tmp,512,f ) == NULL ) continue; | |
148 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
149 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
150 item->path=strdup( tmp ); | |
151 fgets( tmp,512,f ); | |
152 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
153 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
154 item->name=strdup( tmp ); | |
155 gtkSet( gtkAddPlItem,0,(void*)item ); | |
156 } | |
157 fclose( f ); | |
158 free( cfg ); | |
159 } | |
160 return 0; | |
161 } | |
162 | |
163 int cfg_write( void ) | |
164 { | |
165 char * cfg = get_path( "gui.conf" ); | |
166 FILE * f; | |
167 int i; | |
168 | |
6840 | 169 #ifdef USE_I18N |
170 setlocale( LC_ALL,"" ); | |
171 #endif | |
172 | |
6770 | 173 // -- save configuration |
174 if ( (f=fopen( cfg,"wt+" )) ) | |
175 { | |
176 for ( i=0;gui_opts[i].name;i++ ) | |
177 { | |
178 switch ( gui_opts[i].type ) | |
179 { | |
180 case CONF_TYPE_INT: | |
181 case CONF_TYPE_FLAG: fprintf( f,"%s = %d\n",gui_opts[i].name,*( (int *)gui_opts[i].p ) ); break; | |
182 case CONF_TYPE_FLOAT: fprintf( f,"%s = %f\n",gui_opts[i].name,*( (float *)gui_opts[i].p ) ); break; | |
6794 | 183 case CONF_TYPE_STRING: |
184 { | |
185 char * tmp = *( (char **)gui_opts[i].p ); | |
186 if ( tmp && tmp[0] ) fprintf( f,"%s = \"%s\"\n",gui_opts[i].name,tmp ); | |
187 break; | |
188 } | |
6770 | 189 } |
190 } | |
191 fclose( f ); | |
192 } | |
193 free( cfg ); | |
194 | |
195 // -- save playlist | |
196 cfg=get_path( "gui.pl" ); | |
197 if ( (f=fopen( cfg,"wt+" )) ) | |
198 { | |
199 plCurrent=plList; | |
200 while ( plCurrent ) | |
201 { | |
202 if ( plCurrent->path && plCurrent->name ) | |
203 { | |
204 fprintf( f,"%s\n",plCurrent->path ); | |
205 fprintf( f,"%s\n",plCurrent->name ); | |
206 } | |
207 plCurrent=plCurrent->next; | |
208 } | |
209 fclose( f ); | |
210 } | |
211 free( cfg ); | |
212 | |
213 return 0; | |
214 } | |
215 |