Mercurial > mplayer.hg
annotate Gui/interface.c @ 6975:d2cdfb831265
Sanitize a HTML table, <TR> are at the proper place and get closed.
Largely cosmetic, can be ignored by translators.
author | diego |
---|---|
date | Sun, 11 Aug 2002 18:38:41 +0000 |
parents | 8cc27ab533b2 |
children | 163f78ece9c2 |
rev | line source |
---|---|
6280 | 1 |
4845 | 2 #include <inttypes.h> |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
5 #include <string.h> |
4798 | 6 |
7 #include "ws.h" | |
8 #include "mplayer/play.h" | |
9 #include "interface.h" | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
10 #include "skin/skin.h" |
6627 | 11 #include "mplayer/gtk/eq.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
12 |
4798 | 13 #include "../mplayer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
14 #include "mplayer/widgets.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
15 #include "mplayer/mplayer.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
16 #include "app.h" |
6794 | 17 #include "cfg.h" |
18 #include "../help_mp.h" | |
19 #include "../subreader.h" | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
20 #include "../libvo/x11_common.h" |
5789 | 21 #include "../libvo/video_out.h" |
6794 | 22 #include "../libvo/font_load.h" |
4858 | 23 #include "../input/input.h" |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
24 #include "../libao2/audio_out.h" |
6627 | 25 #include "../mixer.h" |
26 #include "../libao2/audio_plugin.h" | |
27 #include "../libao2/eq.h" | |
5789 | 28 |
6280 | 29 #include <inttypes.h> |
30 #include <sys/types.h> | |
31 | |
5665 | 32 #include "../libmpdemux/stream.h" |
5789 | 33 #include "../libmpdemux/demuxer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
34 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
35 guiInterface_t guiIntfStruct; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
36 |
6627 | 37 char * gstrcat( char ** dest,char * src ) |
38 { | |
39 char * tmp = NULL; | |
40 | |
41 if ( !src ) return NULL; | |
42 | |
43 if ( *dest ) | |
44 { | |
45 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
46 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
47 } | |
48 else | |
49 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
50 *dest=tmp; | |
51 return tmp; | |
52 } | |
53 | |
6794 | 54 int gstrcmp( char * a,char * b ) |
55 { | |
56 if ( !a && !b ) return 0; | |
57 if ( !a || !b ) return -1; | |
58 return strcmp( a,b ); | |
59 } | |
60 | |
61 char * gstrdup( char * str ) | |
62 { | |
63 if ( !str ) return NULL; | |
64 return strdup( str ); | |
65 } | |
66 | |
67 void gfree( void ** p ) | |
68 { | |
69 if ( *p == NULL ) return; | |
70 free( *p ); *p=NULL; | |
71 } | |
72 | |
73 void gset( char ** str,char * what ) | |
74 { | |
75 if ( *str ) { if ( !strstr( *str,what ) ) gstrcat( str,"," ); gstrcat( str,what ); } | |
76 else gstrcat( str,what ); | |
77 } | |
78 | |
6218 | 79 void guiInit( void ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
80 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
81 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); |
6898 | 82 guiIntfStruct.Balance=50.0f; |
83 guiIntfStruct.StreamType=-1; | |
84 | |
6627 | 85 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); |
6794 | 86 gtkAOOSSMixer=strdup( PATH_DEV_MIXER ); |
87 gtkAOOSSDevice=strdup( PATH_DEV_DSP ); | |
6898 | 88 |
89 gtkInit(); | |
6912 | 90 wsXInit( (void *)mDisplay ); |
91 | |
6898 | 92 cfg_read(); |
6218 | 93 appInit( (void*)mDisplay ); |
6898 | 94 |
6857 | 95 if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name ); |
6968 | 96 if ( sub_delay != 0.0f ) gtkSubDelay=sub_delay; |
6973 | 97 if ( sub_name ) guiSetFilename( guiIntfStruct.Subtitlename,sub_name ); |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
98 #if defined( USE_OSD ) || defined( USE_SUB ) |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
99 guiLoadFont(); |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
100 #endif |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
101 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
102 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
103 void guiDone( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
104 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
105 mp_msg( MSGT_GPLAYER,MSGL_V,"[mplayer] exit.\n" ); |
6794 | 106 cfg_write(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
107 gtkDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
108 wsXDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
109 } |
4798 | 110 |
4858 | 111 int guiCMDArray[] = |
112 { | |
113 evLoad, | |
114 evLoadSubtitle, | |
115 evAbout, | |
116 evPlay, | |
117 evStop, | |
118 evPlayList, | |
119 evPreferences, | |
120 evFullScreen, | |
121 evSkinBrowser | |
122 }; | |
123 | |
5789 | 124 typedef struct |
125 { | |
126 demux_stream_t *ds; | |
127 unsigned int format; | |
128 struct codecs_st *codec; | |
129 int inited; | |
130 // output format: | |
131 float timer; | |
132 float fps; | |
133 float frametime; | |
134 int i_bps; | |
135 int disp_w,disp_h; | |
136 } tmp_sh_video_t; | |
137 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
138 extern ao_functions_t * audio_out; |
6755 | 139 extern vo_functions_t * video_out; |
6794 | 140 extern int flip; |
141 extern int frame_dropping; | |
142 extern int sub_pos; | |
143 extern int sub_unicode; | |
144 extern int stream_dump_type; | |
145 extern char ** vo_plugin_args; | |
146 extern int auto_quality; | |
147 | |
148 #if defined( USE_OSD ) || defined( USE_SUB ) | |
149 void guiLoadFont( void ) | |
150 { | |
151 font_factor=gtkSubFFactor; | |
152 if ( vo_font ) | |
153 { | |
154 int i; | |
155 if ( vo_font->name ) free( vo_font->name ); | |
156 if ( vo_font->fpath ) free( vo_font->fpath ); | |
157 for ( i=0;i<16;i++ ) | |
158 if ( vo_font->pic_a[i] ) | |
159 { | |
160 if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp ); | |
161 if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal ); | |
162 } | |
163 for ( i=0;i<16;i++ ) | |
164 if ( vo_font->pic_b[i] ) | |
165 { | |
166 if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp ); | |
167 if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal ); | |
168 } | |
169 free( vo_font ); vo_font=NULL; | |
170 } | |
171 if ( guiIntfStruct.Fontname ) | |
172 { | |
173 vo_font=read_font_desc( guiIntfStruct.Fontname,font_factor,0 ); | |
174 if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name ); | |
175 } | |
176 else | |
177 { | |
178 guiIntfStruct.Fontname=gstrdup( get_path( "font/font.desc" ) ); | |
179 vo_font=read_font_desc( guiIntfStruct.Fontname,font_factor,0 ); | |
180 if ( !vo_font ) | |
181 { | |
182 gfree( (void **)&guiIntfStruct.Fontname ); guiIntfStruct.Fontname=gstrdup( DATADIR"/font/font.desc" ); | |
183 vo_font=read_font_desc( guiIntfStruct.Fontname,font_factor,0 ); | |
184 } | |
185 } | |
186 } | |
187 #endif | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
188 |
4798 | 189 void guiGetEvent( int type,char * arg ) |
190 { | |
6280 | 191 stream_t * stream = (stream_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
192 #ifdef USE_DVDREAD |
5665 | 193 dvd_priv_t * dvdp = (dvd_priv_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
194 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
195 |
4798 | 196 switch ( type ) |
197 { | |
198 case guiXEvent: | |
199 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
200 gtkEventHandling(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
201 break; |
4798 | 202 case guiCEvent: |
4963 | 203 switch ( (int)arg ) |
204 { | |
205 case guiSetPlay: guiIntfStruct.Playing=1; mplState(); break; | |
206 case guiSetStop: guiIntfStruct.Playing=0; mplState(); break; | |
207 case guiSetPause: guiIntfStruct.Playing=2; mplState(); break; | |
208 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
209 break; |
5665 | 210 case guiSetState: |
211 mplState(); | |
212 break; | |
213 case guiSetFileName: | |
214 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
215 break; | |
5789 | 216 case guiSetAudioOnly: |
217 guiIntfStruct.AudioOnly=(int)arg; | |
218 if ( (int)arg ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
219 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
220 break; | |
221 case guiReDrawSubWindow: | |
222 wsPostRedisplay( &appMPlayer.subWindow ); | |
223 break; | |
224 case guiSetShVideo: | |
225 { | |
5986 | 226 if ( !appMPlayer.subWindow.isFullScreen ) |
227 { | |
228 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
229 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
230 } | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
231 guiIntfStruct.MovieWidth=vo_dwidth; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
232 guiIntfStruct.MovieHeight=vo_dheight; |
5789 | 233 } |
234 break; | |
5665 | 235 #ifdef USE_DVDREAD |
236 case guiSetDVD: | |
237 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
238 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
239 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
240 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
241 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
242 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
243 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
244 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
245 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
246 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
247 guiIntfStruct.Track=dvd_title + 1; | |
248 break; | |
249 #endif | |
6280 | 250 case guiSetStream: |
251 guiIntfStruct.StreamType=stream->type; | |
252 switch( stream->type ) | |
253 { | |
254 case STREAMTYPE_DVD: | |
255 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
256 break; | |
257 #ifdef HAVE_VCD | |
258 case STREAMTYPE_VCD: | |
259 { | |
260 int i; | |
261 for ( i=1;i < 100;i++ ) | |
262 if ( vcd_seek_to_track( stream->fd,i ) < 0 ) break; | |
263 vcd_seek_to_track( stream->fd,vcd_track ); | |
264 guiIntfStruct.VCDTracks=--i; | |
265 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[interface] vcd tracks: %d\n",guiIntfStruct.VCDTracks ); | |
266 guiIntfStruct.Track=vcd_track; | |
267 break; | |
268 } | |
269 #endif | |
270 } | |
271 break; | |
5120 | 272 #ifdef HAVE_NEW_INPUT |
4858 | 273 case guiIEvent: |
274 printf( "cmd: %d\n",(int)arg ); | |
275 switch( (int)arg ) | |
276 { | |
277 case MP_CMD_QUIT: | |
278 mplEventHandling( evExit,0 ); | |
279 break; | |
280 case MP_CMD_VO_FULLSCREEN: | |
281 mplEventHandling( evFullScreen,0 ); | |
282 break; | |
283 default: | |
284 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
285 } | |
286 break; | |
5120 | 287 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
288 case guiReDraw: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
289 mplEventHandling( evRedraw,0 ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
290 break; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
291 case guiSetVolume: |
6903 | 292 if ( audio_out ) |
293 { | |
294 float l,r; | |
295 mixer_getvolume( &l,&r ); | |
296 guiIntfStruct.Volume=(r>l?r:l); | |
297 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
298 else guiIntfStruct.Balance=50.0f; | |
299 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
300 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
301 } | |
302 break; | |
303 case guiSetValues: | |
6912 | 304 // -- video |
305 if ( arg ) | |
306 { | |
307 if ( vo_gamma_brightness == 1000 ) | |
308 { vo_gamma_brightness=0; get_video_colors( (void *)arg,"brightness",&vo_gamma_brightness ); } | |
309 if ( vo_gamma_contrast == 1000 ) | |
310 { vo_gamma_contrast=0; get_video_colors( (void *)arg,"contrast",&vo_gamma_contrast ); } | |
311 if ( vo_gamma_hue == 1000 ) | |
312 { vo_gamma_hue=0; get_video_colors( (void *)arg,"hue",&vo_gamma_hue ); } | |
313 if ( vo_gamma_saturation == 1000 ) | |
314 { vo_gamma_saturation=0; get_video_colors( (void *)arg,"saturation",&vo_gamma_saturation ); } | |
315 } | |
6794 | 316 // -- audio |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
317 if ( audio_out ) |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
318 { |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
319 float l,r; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
320 mixer_getvolume( &l,&r ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
321 guiIntfStruct.Volume=(r>l?r:l); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
322 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; |
6627 | 323 else guiIntfStruct.Balance=50.0f; |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
324 btnModify( evSetVolume,guiIntfStruct.Volume ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
325 btnModify( evSetBalance,guiIntfStruct.Balance ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
326 } |
6627 | 327 |
6794 | 328 if ( gtkAONoSound ) { if ( !muted ) mixer_mute(); } |
329 else if ( muted ) mixer_mute(); | |
330 | |
6627 | 331 if ( gtkEnableAudioEqualizer ) |
332 { | |
333 equalizer_t eq; | |
334 int i,j; | |
335 for ( i=0;i<6;i++ ) | |
336 for ( j=0;j<10;j++ ) | |
337 { | |
338 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
339 gtkSet( gtkSetEqualizer,0,&eq ); | |
340 } | |
341 } | |
6794 | 342 // -- subtitle |
343 gtkSubUnicode=sub_unicode; | |
344 gtkSubDelay=sub_delay; | |
345 gtkSubFPS=sub_fps; | |
346 gtkSubPos=sub_pos; | |
347 #ifdef USE_OSD | |
348 gtkSubFFactor=font_factor; | |
349 #endif | |
6627 | 350 break; |
351 case guiSetDefaults: | |
6857 | 352 if ( filename && !guiIntfStruct.Filename ) |
6794 | 353 { |
354 gtkSet( gtkDelPl,0,NULL ); guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
355 guiSetFilename( guiIntfStruct.Filename,filename ); | |
356 } | |
357 | |
358 guiIntfStruct.DiskChanged=0; | |
359 | |
360 // --- video opts | |
361 if ( !gtkVODriver ) | |
362 { | |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
363 int i = 0; |
6903 | 364 if ( video_driver && !gtkVODriver ) |
365 { | |
366 while ( video_out_drivers[i] ) | |
367 if ( video_out_drivers[i++]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
368 { | |
369 const vo_info_t *info = video_out_drivers[i - 1]->get_info(); | |
370 if ( !gstrcmp( video_driver,(char *)info->short_name ) ) gtkVODriver=gstrdup( video_driver ); | |
371 } | |
372 } | |
373 else | |
374 while ( video_out_drivers[i++] ) | |
375 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
376 { | |
377 const vo_info_t *info = video_out_drivers[i - 1]->get_info(); | |
378 gtkVODriver=gstrdup( (char *)info->short_name ); | |
379 break; | |
380 } | |
6794 | 381 } |
382 | |
6903 | 383 if ( gtkVODriver ) { gfree( (void **)&video_driver ); video_driver=gstrdup( gtkVODriver ); } |
6794 | 384 else { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player( "gui init" ); } |
385 | |
386 if ( gtkVPP ) | |
387 { | |
388 if ( vo_plugin_args ) | |
389 { | |
390 int i = 0; | |
391 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],"pp" ) ) { i=-1; break; } | |
392 if ( i != -1 ) | |
393 { vo_plugin_args=realloc( vo_plugin_args,( i + 2 ) * sizeof( char * ) ); vo_plugin_args[i]=strdup( "pp" ); vo_plugin_args[i+1]=NULL; } | |
394 } else { vo_plugin_args=malloc( 2 * sizeof( char * ) ); vo_plugin_args[0]=strdup( "pp" ); vo_plugin_args[1]=NULL; } | |
395 auto_quality=gtkVAutoq; | |
396 } | |
397 else | |
398 if ( vo_plugin_args ) | |
399 { | |
400 int n = 0; | |
401 while ( vo_plugin_args[n++] ); n--; | |
402 if ( n > -1 ) | |
403 { | |
404 int i = 0; | |
405 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],"pp" ) ) break; i--; | |
406 if ( n == i ) | |
407 { | |
408 if ( n == 1 ) { free( vo_plugin_args[0] ); free( vo_plugin_args ); vo_plugin_args=NULL; } | |
409 else memcpy( &vo_plugin_args[i],&vo_plugin_args[i+1],( n - i ) * sizeof( char * ) ); | |
410 } | |
411 } | |
412 auto_quality=0; | |
413 } | |
414 vo_doublebuffering=gtkVODoubleBuffer; | |
415 vo_directrendering=gtkVODirectRendering; | |
416 frame_dropping=gtkVFrameDrop; | |
417 if ( gtkVHardFrameDrop ) frame_dropping=gtkVHardFrameDrop; | |
418 flip=gtkVFlip; | |
419 force_ni=gtkVNIAVI; | |
420 video_family=gtkVVFM; | |
421 | |
422 // --- audio opts | |
423 audio_delay=gtkAODelay; | |
424 if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
6840 | 425 if ( gtkAONorm ) gset( &ao_plugin_cfg.plugin_list,"volnorm" ); |
6794 | 426 if ( gtkEnableAudioEqualizer ) gset( &ao_plugin_cfg.plugin_list,"eq" ); |
427 if ( gtkAOExtraStereo ) | |
428 { | |
429 gset( &ao_plugin_cfg.plugin_list,"extrastereo" ); | |
430 ao_plugin_cfg.pl_extrastereo_mul=gtkAOExtraStereoMul; | |
431 } | |
432 mixer_device=gtkAOOSSMixer; | |
6903 | 433 if ( audio_driver && !gtkAODriver ) gtkAODriver=gstrdup( audio_driver ); |
434 gfree( (void **)&audio_driver ); | |
6794 | 435 if ( !gstrcmp( gtkAODriver,"oss" ) && gtkAOOSSDevice ) |
436 { | |
437 char * tmp = calloc( 1,strlen( gtkAODriver ) + strlen( gtkAOOSSDevice ) + 2 ); | |
438 sprintf( tmp,"%s:%s",gtkAODriver,gtkAOOSSDevice ); | |
439 audio_driver=tmp; | |
440 } else audio_driver=gstrdup( gtkAODriver ); | |
441 | |
442 // -- subtitle | |
443 #ifdef USE_SUB | |
444 sub_auto=0; | |
445 if ( gtkSubAuto && guiIntfStruct.StreamType == STREAMTYPE_FILE && !guiIntfStruct.Subtitlename ) | |
446 guiSetFilename( guiIntfStruct.Subtitlename,( guiIntfStruct.Filename ? sub_filename( get_path("sub/"),guiIntfStruct.Filename ): "default.sub" ) ); | |
447 sub_name=guiIntfStruct.Subtitlename; | |
448 sub_unicode=gtkSubUnicode; | |
449 sub_delay=gtkSubDelay; | |
450 sub_fps=gtkSubFPS; | |
451 sub_pos=gtkSubPos; | |
452 stream_dump_type=0; | |
453 if ( gtkSubDumpMPSub ) stream_dump_type=4; | |
454 if ( gtkSubDumpSrt ) stream_dump_type=6; | |
455 gtkSubDumpMPSub=gtkSubDumpSrt=0; | |
6627 | 456 #endif |
6794 | 457 #if defined( USE_OSD ) || defined( USE_SUB ) |
458 guiLoadFont(); | |
6627 | 459 #endif |
460 | |
6794 | 461 // --- misc |
6627 | 462 if ( guiIntfStruct.AudioFile ) audio_stream=guiIntfStruct.AudioFile; |
463 else if ( guiIntfStruct.FilenameChanged ) audio_stream=NULL; | |
6794 | 464 index_mode=gtkVIndex; |
6627 | 465 |
466 break; | |
4798 | 467 } |
468 } | |
469 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
470 extern unsigned int GetTimerMS( void ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
471 extern int mplTimer; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
472 |
4798 | 473 void guiEventHandling( void ) |
474 { | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
475 if ( !guiIntfStruct.Playing || guiIntfStruct.AudioOnly ) wsHandleEvents(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
476 gtkEventHandling(); |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
477 mplTimer=GetTimerMS() / 20; |
4798 | 478 } |
6627 | 479 |
480 // --- | |
481 | |
482 float gtkEquChannels[6][10]; | |
483 | |
6713 | 484 plItem * plCurrent = NULL; |
485 plItem * plList = NULL; | |
486 plItem * plLastPlayed = NULL; | |
487 | |
488 #if defined( MP_DEBUG ) && 0 | |
489 void list( void ) | |
6627 | 490 { |
6713 | 491 plItem * next = plList; |
492 printf( "--- list ---\n" ); | |
493 while( next || next->next ) | |
494 { | |
495 printf( "item: %s/%s\n",next->path,next->name ); | |
496 if ( next->next ) next=next->next; else break; | |
497 } | |
498 printf( "--- end of list ---\n" ); | |
499 } | |
500 #else | |
501 #define list(); | |
502 #endif | |
503 | |
504 void * gtkSet( int cmd,float fparam, void * vparam ) | |
505 { | |
6794 | 506 mp_cmd_t * mp_cmd; |
6627 | 507 equalizer_t * eq = (equalizer_t *)vparam; |
6713 | 508 plItem * item = (plItem *)vparam; |
6627 | 509 |
510 switch ( cmd ) | |
511 { | |
6713 | 512 // --- handle playlist |
6755 | 513 case gtkAddPlItem: // add item to playlist |
6713 | 514 if ( plList ) |
515 { | |
516 plItem * next = plList; | |
517 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } | |
518 next->next=item; item->prev=next; | |
519 } | |
520 else { item->prev=item->next=NULL; plCurrent=plList=item; } | |
521 list(); | |
522 return NULL; | |
523 case gtkGetNextPlItem: // get current item from playlist | |
524 if ( plCurrent ) | |
525 { | |
526 plCurrent=plCurrent->next; | |
527 if ( !plCurrent && plList ) | |
528 { | |
529 plItem * next = plList; | |
530 while ( next->next ) { if ( !next->next ) break; next=next->next; } | |
531 plCurrent=next; | |
532 } | |
533 return plCurrent; | |
534 } | |
535 return NULL; | |
536 case gtkGetPrevPlItem: | |
537 if ( plCurrent ) | |
538 { | |
539 plCurrent=plCurrent->prev; | |
540 if ( !plCurrent && plList ) plCurrent=plList; | |
541 return plCurrent; | |
542 } | |
6794 | 543 return NULL; |
6713 | 544 case gtkGetCurrPlItem: // get current item |
545 return plCurrent; | |
546 case gtkDelPl: // delete list | |
547 { | |
548 plItem * curr = plList; | |
549 plItem * next; | |
550 if ( !plList ) return NULL; | |
551 if ( !curr->next ) | |
552 { | |
553 if ( curr->path ) free( curr->path ); | |
554 if ( curr->name ) free( curr->name ); | |
555 free( curr ); | |
556 } | |
557 else | |
558 { | |
559 while ( curr->next ) | |
560 { | |
561 next=curr->next; | |
562 if ( curr->path ) free( curr->path ); | |
563 if ( curr->name ) free( curr->name ); | |
564 free( curr ); | |
565 curr=next; | |
566 } | |
567 } | |
568 plList=NULL; plCurrent=NULL; | |
569 } | |
570 return NULL; | |
6794 | 571 // --- subtitle |
572 case gtkSetSubAuto: | |
573 gtkSubAuto=(int)fparam; | |
574 return NULL; | |
575 case gtkSetSubDelay: | |
576 // mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); | |
577 // mp_cmd->id=MP_CMD_SUB_DELAY; mp_cmd->name=strdup( "sub_delay" ); | |
578 // mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
579 // mp_input_queue_cmd( mp_cmd ); | |
580 gtkSubDelay=sub_delay=fparam; | |
581 return NULL; | |
582 case gtkSetSubFPS: | |
583 gtkSubFPS=sub_fps=(int)fparam; | |
584 return NULL; | |
585 case gtkSetSubPos: | |
586 gtkSubPos=sub_pos=(int)fparam; | |
587 return NULL; | |
588 #if defined( USE_OSD ) || defined( USE_SUB ) | |
589 case gtkSetFontFactor: | |
590 gtkSubFFactor=fparam; | |
591 guiLoadFont(); | |
592 return NULL; | |
593 #endif | |
594 // --- misc | |
595 case gtkClearStruct: | |
596 if ( (unsigned int)fparam & guiFilenames ) | |
597 { | |
598 gfree( (void **)&guiIntfStruct.Filename ); | |
599 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
600 gfree( (void **)&guiIntfStruct.AudioFile ); | |
601 } | |
602 #ifdef USE_DVDREAD | |
603 if ( (unsigned int)fparam & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); | |
604 #endif | |
605 #ifdef HAVE_VCD | |
606 if ( (unsigned int)fparam & guiVCD ) guiIntfStruct.VCDTracks=0; | |
607 #endif | |
608 return NULL; | |
609 case gtkSetExtraStereo: | |
610 gtkAOExtraStereoMul=fparam; | |
611 audio_plugin_extrastereo.control( AOCONTROL_PLUGIN_ES_SET,(int)>kAOExtraStereoMul ); | |
612 return NULL; | |
613 case gtkSetAudioDelay: | |
614 audio_delay=gtkAODelay=fparam; | |
615 return NULL; | |
616 case gtkSetPanscan: | |
617 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); | |
618 mp_cmd->id=MP_CMD_PANSCAN; mp_cmd->name=strdup( "panscan" ); | |
619 mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
620 mp_input_queue_cmd( mp_cmd ); | |
621 return NULL; | |
622 case gtkSetAutoq: | |
623 auto_quality=gtkVAutoq=(int)fparam; | |
624 return NULL; | |
6713 | 625 // --- set equalizers |
6627 | 626 case gtkSetContrast: |
6794 | 627 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 628 mp_cmd->id=MP_CMD_CONTRAST; mp_cmd->name=strdup( "contrast" ); |
629 break; | |
630 case gtkSetBrightness: | |
6794 | 631 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 632 mp_cmd->id=MP_CMD_BRIGHTNESS; mp_cmd->name=strdup( "brightness" ); |
633 break; | |
634 case gtkSetHue: | |
6794 | 635 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 636 mp_cmd->id=MP_CMD_HUE; mp_cmd->name=strdup( "hue" ); |
637 break; | |
638 case gtkSetSaturation: | |
6794 | 639 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 640 mp_cmd->id=MP_CMD_SATURATION; mp_cmd->name=strdup( "saturation" ); |
641 break; | |
642 case gtkSetEqualizer: | |
643 if ( eq ) | |
644 { | |
645 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
646 audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)eq ); | |
647 } | |
648 else | |
649 { | |
650 int i,j; equalizer_t tmp; tmp.gain=0.0f; | |
651 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
652 for ( i=0;i<6;i++ ) | |
653 for ( j=0;j<10;j++ ) | |
654 { tmp.channel=i; tmp.band=j; audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)&tmp ); } | |
655 } | |
6713 | 656 return NULL; |
6794 | 657 default: return NULL; |
6627 | 658 } |
659 mp_cmd->args[0].v.i=(int)fparam; | |
660 mp_cmd->args[1].v.i=1; | |
661 mp_input_queue_cmd( mp_cmd ); | |
6713 | 662 return NULL; |
6627 | 663 } |