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