Mercurial > mplayer.hg
annotate Gui/interface.c @ 8043:e5dda05f9aab
cleanup
author | pontscho |
---|---|
date | Sat, 02 Nov 2002 16:09:05 +0000 |
parents | 0e5544951425 |
children | 9246adcf95f0 |
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" |
7169 | 23 #include "../libvo/sub.h" |
4858 | 24 #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
|
25 #include "../libao2/audio_out.h" |
6627 | 26 #include "../mixer.h" |
27 #include "../libao2/audio_plugin.h" | |
28 #include "../libao2/eq.h" | |
5789 | 29 |
6280 | 30 #include <inttypes.h> |
31 #include <sys/types.h> | |
32 | |
6996 | 33 #ifdef USE_ICONV |
7128 | 34 #include <iconv.h> |
6996 | 35 #endif |
36 | |
5665 | 37 #include "../libmpdemux/stream.h" |
5789 | 38 #include "../libmpdemux/demuxer.h" |
7217 | 39 #include "../libmpdemux/stheader.h" |
40 #include "../libmpcodecs/dec_video.h" | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
41 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
42 guiInterface_t guiIntfStruct; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
43 |
6627 | 44 char * gstrcat( char ** dest,char * src ) |
45 { | |
46 char * tmp = NULL; | |
47 | |
48 if ( !src ) return NULL; | |
49 | |
50 if ( *dest ) | |
51 { | |
52 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
53 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
54 } | |
55 else | |
56 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
57 *dest=tmp; | |
58 return tmp; | |
59 } | |
60 | |
6794 | 61 int gstrcmp( char * a,char * b ) |
62 { | |
63 if ( !a && !b ) return 0; | |
64 if ( !a || !b ) return -1; | |
65 return strcmp( a,b ); | |
66 } | |
67 | |
7019 | 68 int gstrncmp( char * a,char * b,int size ) |
69 { | |
70 if ( !a && !b ) return 0; | |
71 if ( !a || !b ) return -1; | |
72 return strncmp( a,b,size ); | |
73 } | |
74 | |
6794 | 75 char * gstrdup( char * str ) |
76 { | |
77 if ( !str ) return NULL; | |
78 return strdup( str ); | |
79 } | |
80 | |
81 void gfree( void ** p ) | |
82 { | |
83 if ( *p == NULL ) return; | |
84 free( *p ); *p=NULL; | |
85 } | |
86 | |
87 void gset( char ** str,char * what ) | |
88 { | |
7887
0e5544951425
A small patch to Gui/interface.c; the first fix is a plain bug, the second is
arpi
parents:
7707
diff
changeset
|
89 if ( *str ) { if ( !strstr( *str,what ) ) { gstrcat( str,"," ); gstrcat( str,what ); }} |
6794 | 90 else gstrcat( str,what ); |
91 } | |
92 | |
7582 | 93 void gaddlist( char *** list,char * entry ) |
94 { | |
95 int i; | |
96 | |
97 if ( (*list) ) | |
98 { | |
99 for ( i=0;(*list)[i];i++ ) free( (*list)[i] ); | |
100 free( (*list) ); | |
101 } | |
102 | |
103 (*list)=malloc( 8 ); | |
104 (*list)[0]=gstrdup( entry ); | |
105 (*list)[1]=NULL; | |
106 } | |
107 | |
6996 | 108 #ifdef USE_ICONV |
109 char * gconvert_uri_to_filename( char * str ) | |
110 { | |
111 iconv_t d; | |
112 char * out = strdup( str ); | |
113 char * tmp = NULL; | |
114 char * ize; | |
115 size_t inb,outb; | |
116 char * charset = "ISO8859-1"; | |
117 char * cs; | |
118 | |
119 if ( !strchr( str,'%' ) ) return str; | |
120 | |
121 { | |
122 char * t = calloc( 1,strlen( out ) ); | |
123 int i,c = 0; | |
124 for ( i=0;i < (int)strlen( out );i++ ) | |
125 if ( out[i] != '%' ) t[c++]=out[i]; | |
126 else | |
127 { | |
128 char tmp[4] = "0xXX"; | |
129 // if ( out[++i] == '%' ) { t[c++]='%'; continue; }; | |
130 tmp[2]=out[++i]; tmp[3]=out[++i]; | |
131 t[c++]=(char)strtol( tmp,(char **)NULL,0 ); | |
132 } | |
133 free( out ); | |
134 out=t; | |
135 } | |
136 | |
137 if ( (cs=getenv( "CHARSET" )) && *cs ) charset=cs; | |
138 | |
139 inb=outb=strlen( out ); | |
140 tmp=calloc( 1,outb + 1 ); | |
141 ize=tmp; | |
142 d=iconv_open( charset,"UTF-8" ); | |
143 if ( (iconv_t)(-1) == d ) return str; | |
144 iconv( d,&out,&inb,&tmp,&outb ); | |
145 iconv_close( d ); | |
146 free( out ); | |
147 return ize; | |
148 } | |
149 #endif | |
150 | |
6218 | 151 void guiInit( void ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
152 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
153 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); |
6898 | 154 guiIntfStruct.Balance=50.0f; |
155 guiIntfStruct.StreamType=-1; | |
156 | |
6627 | 157 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); |
7706 | 158 if ( !gtkAOOSSMixer ) gtkAOOSSMixer=strdup( PATH_DEV_MIXER ); |
159 if ( !gtkAOOSSDevice ) gtkAOOSSDevice=strdup( PATH_DEV_DSP ); | |
7707 | 160 #ifdef HAVE_DXR3 |
7706 | 161 if ( !gtkDXR3Device ) gtkDXR3Device=strdup( "/dev/em8300-0" ); |
7707 | 162 #endif |
7538 | 163 fullscreen=gtkLoadFullscreen; |
6898 | 164 |
165 gtkInit(); | |
8043 | 166 // --- initialize X |
6912 | 167 wsXInit( (void *)mDisplay ); |
8043 | 168 // --- |
169 skinDirInHome=get_path("Skin"); | |
170 skinMPlayerDir=DATADIR "/Skin"; | |
171 printf("SKIN dir 1: '%s'\n",skinDirInHome); | |
172 printf("SKIN dir 2: '%s'\n",skinMPlayerDir); | |
173 if ( !skinName ) skinName=strdup( "default" ); | |
174 switch ( skinRead( skinName ) ) | |
175 { | |
176 case -1: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinNotFound,skinName ); exit( 0 ); | |
177 case -2: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinCfgReadError,skinName ); exit( 0 ); | |
178 } | |
179 mplInit( (void *)mDisplay ); | |
180 // --- | |
7538 | 181 |
7009 | 182 if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name,STREAMTYPE_FILE ); |
6973 | 183 if ( sub_name ) guiSetFilename( guiIntfStruct.Subtitlename,sub_name ); |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
184 #if defined( USE_OSD ) || defined( USE_SUB ) |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
185 guiLoadFont(); |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
186 #endif |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
187 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
188 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
189 void guiDone( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
190 { |
8043 | 191 mp_msg( MSGT_GPLAYER,MSGL_V,"[gui] done.\n" ); |
6794 | 192 cfg_write(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
193 wsXDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
194 } |
4798 | 195 |
4858 | 196 int guiCMDArray[] = |
197 { | |
198 evLoad, | |
199 evLoadSubtitle, | |
200 evAbout, | |
201 evPlay, | |
202 evStop, | |
203 evPlayList, | |
204 evPreferences, | |
205 evFullScreen, | |
206 evSkinBrowser | |
207 }; | |
208 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
209 extern ao_functions_t * audio_out; |
6755 | 210 extern vo_functions_t * video_out; |
6794 | 211 extern int frame_dropping; |
212 extern int stream_dump_type; | |
213 extern char ** vo_plugin_args; | |
214 | |
215 #if defined( USE_OSD ) || defined( USE_SUB ) | |
216 void guiLoadFont( void ) | |
217 { | |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
218 #ifdef HAVE_FREETYPE |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
219 load_font(vo_image_width, vo_image_height); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
220 #else |
6794 | 221 if ( vo_font ) |
222 { | |
223 int i; | |
224 if ( vo_font->name ) free( vo_font->name ); | |
225 if ( vo_font->fpath ) free( vo_font->fpath ); | |
226 for ( i=0;i<16;i++ ) | |
227 if ( vo_font->pic_a[i] ) | |
228 { | |
229 if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp ); | |
230 if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal ); | |
231 } | |
232 for ( i=0;i<16;i++ ) | |
233 if ( vo_font->pic_b[i] ) | |
234 { | |
235 if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp ); | |
236 if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal ); | |
237 } | |
238 free( vo_font ); vo_font=NULL; | |
239 } | |
7019 | 240 if ( font_name ) |
6794 | 241 { |
7019 | 242 vo_font=read_font_desc( font_name,font_factor,0 ); |
6794 | 243 if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name ); |
244 } | |
245 else | |
246 { | |
7019 | 247 font_name=gstrdup( get_path( "font/font.desc" ) ); |
248 vo_font=read_font_desc( font_name,font_factor,0 ); | |
6794 | 249 if ( !vo_font ) |
250 { | |
7019 | 251 gfree( (void **)&font_name ); font_name=gstrdup( DATADIR"/font/font.desc" ); |
252 vo_font=read_font_desc( font_name,font_factor,0 ); | |
6794 | 253 } |
254 } | |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
255 #endif |
6794 | 256 } |
257 #endif | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
258 |
7150 | 259 #ifdef USE_SUB |
7169 | 260 extern mp_osd_obj_t* vo_osd_list; |
261 | |
7150 | 262 void guiLoadSubtitle( char * name ) |
263 { | |
264 if ( guiIntfStruct.Playing == 0 ) | |
265 { | |
266 guiIntfStruct.SubtitleChanged=1; | |
267 return; | |
268 } | |
269 if ( subtitles ) | |
270 { | |
7169 | 271 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[gui] Delete subtitles.\n" ); |
7150 | 272 sub_free( subtitles ); |
7169 | 273 subtitles=NULL; |
7170 | 274 gfree( (void **)&sub_name ); |
7150 | 275 vo_sub=NULL; |
7169 | 276 if ( vo_osd_list ) |
277 { | |
278 int len; | |
279 mp_osd_obj_t * osd = vo_osd_list; | |
280 while ( osd ) | |
281 { | |
282 if ( osd->type == OSDTYPE_SUBTITLE ) break; | |
283 osd=osd->next; | |
284 } | |
285 if ( osd && osd->flags&OSDFLAG_VISIBLE ) | |
286 { | |
287 len=osd->stride * ( osd->bbox.y2 - osd->bbox.y1 ); | |
288 memset( osd->bitmap_buffer,0,len ); | |
289 memset( osd->alpha_buffer,0,len ); | |
290 } | |
291 } | |
7150 | 292 } |
7169 | 293 if ( name ) |
294 { | |
295 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[gui] Delete Load subtitle: %s\n",name ); | |
296 sub_name=gstrdup( name ); | |
297 subtitles=sub_read_file( sub_name,guiIntfStruct.FPS ); | |
298 } | |
7150 | 299 } |
300 #endif | |
301 | |
7009 | 302 static void add_vop( char * str ) |
303 { | |
304 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[gui] add video filter: %s\n",str ); | |
305 if ( vo_plugin_args ) | |
306 { | |
307 int i = 0; | |
308 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],str ) ) { i=-1; break; } | |
309 if ( i != -1 ) | |
310 { vo_plugin_args=realloc( vo_plugin_args,( i + 2 ) * sizeof( char * ) ); vo_plugin_args[i]=strdup( str ); vo_plugin_args[i+1]=NULL; } | |
311 } else { vo_plugin_args=malloc( 2 * sizeof( char * ) ); vo_plugin_args[0]=strdup( str ); vo_plugin_args[1]=NULL; } | |
312 } | |
313 | |
314 static void remove_vop( char * str ) | |
315 { | |
316 int n = 0; | |
317 | |
318 if ( !vo_plugin_args ) return; | |
319 | |
320 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[gui] remove video filter: %s\n",str ); | |
321 | |
322 while ( vo_plugin_args[n++] ); n--; | |
323 if ( n > -1 ) | |
324 { | |
325 int i = 0,m = -1; | |
326 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],str ) ) { m=i - 1; break; } | |
327 i--; | |
328 if ( m > -1 ) | |
329 { | |
330 if ( n == 1 ) { free( vo_plugin_args[0] ); free( vo_plugin_args ); vo_plugin_args=NULL; } | |
331 else memcpy( &vo_plugin_args[i],&vo_plugin_args[i + 1],( n - i ) * sizeof( char * ) ); | |
332 } | |
333 } | |
334 } | |
335 | |
336 int guiGetEvent( int type,char * arg ) | |
4798 | 337 { |
6280 | 338 stream_t * stream = (stream_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
339 #ifdef USE_DVDREAD |
5665 | 340 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
|
341 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
342 |
4798 | 343 switch ( type ) |
344 { | |
345 case guiXEvent: | |
346 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
347 gtkEventHandling(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
348 break; |
4798 | 349 case guiCEvent: |
4963 | 350 switch ( (int)arg ) |
351 { | |
352 case guiSetPlay: guiIntfStruct.Playing=1; mplState(); break; | |
353 case guiSetStop: guiIntfStruct.Playing=0; mplState(); break; | |
354 case guiSetPause: guiIntfStruct.Playing=2; mplState(); break; | |
355 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
356 break; |
5665 | 357 case guiSetState: |
358 mplState(); | |
359 break; | |
360 case guiSetFileName: | |
361 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
362 break; | |
5789 | 363 case guiSetAudioOnly: |
364 guiIntfStruct.AudioOnly=(int)arg; | |
7009 | 365 if ( (int)arg ) { guiIntfStruct.NoWindow=True; wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); } |
5789 | 366 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); |
367 break; | |
368 case guiReDrawSubWindow: | |
369 wsPostRedisplay( &appMPlayer.subWindow ); | |
370 break; | |
371 case guiSetShVideo: | |
372 { | |
5986 | 373 if ( !appMPlayer.subWindow.isFullScreen ) |
374 { | |
375 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
376 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
377 } | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
378 guiIntfStruct.MovieWidth=vo_dwidth; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
379 guiIntfStruct.MovieHeight=vo_dheight; |
5789 | 380 } |
381 break; | |
5665 | 382 #ifdef USE_DVDREAD |
383 case guiSetDVD: | |
384 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
385 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
386 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
387 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
388 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
389 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
390 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
391 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
392 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
393 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
394 guiIntfStruct.Track=dvd_title + 1; | |
395 break; | |
396 #endif | |
6280 | 397 case guiSetStream: |
398 guiIntfStruct.StreamType=stream->type; | |
399 switch( stream->type ) | |
400 { | |
7150 | 401 #ifdef USE_DVDREAD |
6280 | 402 case STREAMTYPE_DVD: |
403 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
404 break; | |
7150 | 405 #endif |
6280 | 406 #ifdef HAVE_VCD |
407 case STREAMTYPE_VCD: | |
408 { | |
409 int i; | |
410 for ( i=1;i < 100;i++ ) | |
411 if ( vcd_seek_to_track( stream->fd,i ) < 0 ) break; | |
412 vcd_seek_to_track( stream->fd,vcd_track ); | |
413 guiIntfStruct.VCDTracks=--i; | |
8043 | 414 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[gui] vcd tracks: %d\n",guiIntfStruct.VCDTracks ); |
6280 | 415 guiIntfStruct.Track=vcd_track; |
416 break; | |
417 } | |
418 #endif | |
7150 | 419 default: break; |
6280 | 420 } |
421 break; | |
4858 | 422 case guiIEvent: |
423 printf( "cmd: %d\n",(int)arg ); | |
424 switch( (int)arg ) | |
425 { | |
426 case MP_CMD_QUIT: | |
427 mplEventHandling( evExit,0 ); | |
428 break; | |
429 case MP_CMD_VO_FULLSCREEN: | |
430 mplEventHandling( evFullScreen,0 ); | |
431 break; | |
432 default: | |
433 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
434 } | |
435 break; | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
436 case guiReDraw: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
437 mplEventHandling( evRedraw,0 ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
438 break; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
439 case guiSetVolume: |
6903 | 440 if ( audio_out ) |
441 { | |
442 float l,r; | |
443 mixer_getvolume( &l,&r ); | |
444 guiIntfStruct.Volume=(r>l?r:l); | |
445 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
446 else guiIntfStruct.Balance=50.0f; | |
447 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
448 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
449 } | |
450 break; | |
7009 | 451 case guiSetFileFormat: |
452 guiIntfStruct.FileFormat=(int)arg; | |
453 break; | |
6903 | 454 case guiSetValues: |
6912 | 455 // -- video |
7217 | 456 guiIntfStruct.sh_video=arg; |
6912 | 457 if ( arg ) |
458 { | |
7217 | 459 sh_video_t * sh = (sh_video_t *)arg; |
7150 | 460 guiIntfStruct.FPS=sh->fps; |
6912 | 461 } |
7009 | 462 |
463 if ( guiIntfStruct.NoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
464 | |
6794 | 465 // -- audio |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
466 if ( audio_out ) |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
467 { |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
468 float l,r; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
469 mixer_getvolume( &l,&r ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
470 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
|
471 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; |
6627 | 472 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
|
473 btnModify( evSetVolume,guiIntfStruct.Volume ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
474 btnModify( evSetBalance,guiIntfStruct.Balance ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
475 } |
6627 | 476 |
6794 | 477 if ( gtkAONoSound ) { if ( !muted ) mixer_mute(); } |
478 else if ( muted ) mixer_mute(); | |
479 | |
6627 | 480 if ( gtkEnableAudioEqualizer ) |
481 { | |
482 equalizer_t eq; | |
483 int i,j; | |
484 for ( i=0;i<6;i++ ) | |
485 for ( j=0;j<10;j++ ) | |
486 { | |
487 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
488 gtkSet( gtkSetEqualizer,0,&eq ); | |
489 } | |
490 } | |
6794 | 491 // -- subtitle |
7009 | 492 #ifdef HAVE_DXR3 |
8043 | 493 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) && guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS |
494 #ifdef USE_LIBAVCODEC | |
495 && !gtkVopLAVC | |
496 #endif | |
497 #ifdef USE_LIBFAME | |
498 && !gtkVopFAME | |
499 #endif | |
500 ) | |
7009 | 501 { |
502 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEEDLAVCFAME ); | |
503 guiIntfStruct.Playing=0; | |
504 return True; | |
505 } | |
506 #endif | |
6627 | 507 break; |
508 case guiSetDefaults: | |
6857 | 509 if ( filename && !guiIntfStruct.Filename ) |
6794 | 510 { |
511 gtkSet( gtkDelPl,0,NULL ); guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
512 guiSetFilename( guiIntfStruct.Filename,filename ); | |
513 } | |
514 | |
515 guiIntfStruct.DiskChanged=0; | |
516 | |
7009 | 517 // --- video opts |
7019 | 518 |
7582 | 519 if ( !video_driver_list ) |
6794 | 520 { |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
521 int i = 0; |
6903 | 522 while ( video_out_drivers[i++] ) |
523 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
524 { | |
525 const vo_info_t *info = video_out_drivers[i - 1]->get_info(); | |
7582 | 526 gaddlist( &video_driver_list,(char *)info->short_name ); |
6903 | 527 break; |
528 } | |
6794 | 529 } |
530 | |
7582 | 531 if ( !video_driver_list && !video_driver_list[0] ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player( "gui init" ); } |
7009 | 532 |
533 { | |
534 int i = 0; | |
535 guiIntfStruct.NoWindow=False; | |
536 while ( video_out_drivers[i++] ) | |
537 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
6794 | 538 { |
7009 | 539 const vo_info_t *info = video_out_drivers[i - 1]->get_info(); |
7582 | 540 if ( ( video_driver_list && !gstrcmp( video_driver_list[0],(char *)info->short_name ) )&&( video_out_drivers[i - 1]->control( VOCTRL_GUI_NOWINDOW,NULL ) == VO_TRUE ) ) |
7009 | 541 { guiIntfStruct.NoWindow=True; break; } |
6794 | 542 } |
7009 | 543 } |
544 | |
545 #ifdef HAVE_DXR3 | |
8043 | 546 #ifdef USE_LIBAVCODEC |
7009 | 547 remove_vop( "lavc" ); |
8043 | 548 #endif |
549 #ifdef USE_LIBFAME | |
7009 | 550 remove_vop( "fame" ); |
8043 | 551 #endif |
7582 | 552 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) ) |
7009 | 553 { |
554 if ( ( guiIntfStruct.StreamType != STREAMTYPE_DVD)&&( guiIntfStruct.StreamType != STREAMTYPE_VCD ) ) | |
555 { | |
8043 | 556 #ifdef USE_LIBAVCODEC |
7009 | 557 if ( gtkVopLAVC ) add_vop( "lavc" ); |
8043 | 558 #endif |
559 #ifdef USE_LIBFAME | |
7009 | 560 if ( gtkVopFAME ) add_vop( "fame" ); |
8043 | 561 #endif |
7009 | 562 } |
563 } | |
564 #endif | |
565 // --- | |
7019 | 566 if ( gtkVopPP ) add_vop( "pp" ); |
567 else remove_vop( "pp" ); | |
6794 | 568 |
569 // --- audio opts | |
7887
0e5544951425
A small patch to Gui/interface.c; the first fix is a plain bug, the second is
arpi
parents:
7707
diff
changeset
|
570 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } |
6840 | 571 if ( gtkAONorm ) gset( &ao_plugin_cfg.plugin_list,"volnorm" ); |
6794 | 572 if ( gtkEnableAudioEqualizer ) gset( &ao_plugin_cfg.plugin_list,"eq" ); |
573 if ( gtkAOExtraStereo ) | |
574 { | |
575 gset( &ao_plugin_cfg.plugin_list,"extrastereo" ); | |
576 ao_plugin_cfg.pl_extrastereo_mul=gtkAOExtraStereoMul; | |
577 } | |
578 mixer_device=gtkAOOSSMixer; | |
7582 | 579 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"oss",3 ) && gtkAOOSSDevice ) |
6794 | 580 { |
7019 | 581 char * tmp = calloc( 1,strlen( gtkAOOSSDevice ) + 5 ); |
582 sprintf( tmp,"oss:%s",gtkAOOSSDevice ); | |
7582 | 583 gaddlist( &audio_driver_list,tmp ); |
7019 | 584 } |
6794 | 585 |
586 // -- subtitle | |
587 #ifdef USE_SUB | |
7170 | 588 sub_name=gstrdup( guiIntfStruct.Subtitlename ); |
6794 | 589 stream_dump_type=0; |
590 if ( gtkSubDumpMPSub ) stream_dump_type=4; | |
591 if ( gtkSubDumpSrt ) stream_dump_type=6; | |
592 gtkSubDumpMPSub=gtkSubDumpSrt=0; | |
6627 | 593 #endif |
6794 | 594 #if defined( USE_OSD ) || defined( USE_SUB ) |
595 guiLoadFont(); | |
6627 | 596 #endif |
597 | |
6794 | 598 // --- misc |
6627 | 599 if ( guiIntfStruct.AudioFile ) audio_stream=guiIntfStruct.AudioFile; |
600 else if ( guiIntfStruct.FilenameChanged ) audio_stream=NULL; | |
601 | |
602 break; | |
4798 | 603 } |
7009 | 604 return False; |
4798 | 605 } |
606 | |
607 void guiEventHandling( void ) | |
608 { | |
7009 | 609 if ( !guiIntfStruct.Playing || guiIntfStruct.NoWindow ) wsHandleEvents(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
610 gtkEventHandling(); |
4798 | 611 } |
6627 | 612 |
613 // --- | |
614 | |
615 float gtkEquChannels[6][10]; | |
616 | |
6713 | 617 plItem * plCurrent = NULL; |
618 plItem * plList = NULL; | |
619 plItem * plLastPlayed = NULL; | |
620 | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
621 URLItem *URLList = NULL; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
622 |
6713 | 623 #if defined( MP_DEBUG ) && 0 |
624 void list( void ) | |
6627 | 625 { |
6713 | 626 plItem * next = plList; |
627 printf( "--- list ---\n" ); | |
628 while( next || next->next ) | |
629 { | |
630 printf( "item: %s/%s\n",next->path,next->name ); | |
631 if ( next->next ) next=next->next; else break; | |
632 } | |
633 printf( "--- end of list ---\n" ); | |
634 } | |
635 #else | |
636 #define list(); | |
637 #endif | |
638 | |
639 void * gtkSet( int cmd,float fparam, void * vparam ) | |
640 { | |
6627 | 641 equalizer_t * eq = (equalizer_t *)vparam; |
6713 | 642 plItem * item = (plItem *)vparam; |
6627 | 643 |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
644 URLItem * url_item = (URLItem *)vparam; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
645 int is_added = True; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
646 |
6627 | 647 switch ( cmd ) |
648 { | |
6713 | 649 // --- handle playlist |
6755 | 650 case gtkAddPlItem: // add item to playlist |
6713 | 651 if ( plList ) |
652 { | |
653 plItem * next = plList; | |
654 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } | |
655 next->next=item; item->prev=next; | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
656 } else { item->prev=item->next=NULL; plCurrent=plList=item; } |
6713 | 657 list(); |
658 return NULL; | |
659 case gtkGetNextPlItem: // get current item from playlist | |
660 if ( plCurrent ) | |
661 { | |
662 plCurrent=plCurrent->next; | |
663 if ( !plCurrent && plList ) | |
664 { | |
665 plItem * next = plList; | |
666 while ( next->next ) { if ( !next->next ) break; next=next->next; } | |
667 plCurrent=next; | |
668 } | |
669 return plCurrent; | |
670 } | |
671 return NULL; | |
672 case gtkGetPrevPlItem: | |
673 if ( plCurrent ) | |
674 { | |
675 plCurrent=plCurrent->prev; | |
676 if ( !plCurrent && plList ) plCurrent=plList; | |
677 return plCurrent; | |
678 } | |
6794 | 679 return NULL; |
6713 | 680 case gtkGetCurrPlItem: // get current item |
681 return plCurrent; | |
682 case gtkDelPl: // delete list | |
683 { | |
684 plItem * curr = plList; | |
685 plItem * next; | |
686 if ( !plList ) return NULL; | |
687 if ( !curr->next ) | |
688 { | |
689 if ( curr->path ) free( curr->path ); | |
690 if ( curr->name ) free( curr->name ); | |
691 free( curr ); | |
692 } | |
693 else | |
694 { | |
695 while ( curr->next ) | |
696 { | |
697 next=curr->next; | |
698 if ( curr->path ) free( curr->path ); | |
699 if ( curr->name ) free( curr->name ); | |
700 free( curr ); | |
701 curr=next; | |
702 } | |
703 } | |
704 plList=NULL; plCurrent=NULL; | |
705 } | |
706 return NULL; | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
707 // ----- Handle url |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
708 case gtkAddURLItem: |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
709 if ( URLList ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
710 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
711 URLItem * next_url = URLList; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
712 is_added = False; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
713 while ( next_url->next ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
714 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
715 if ( !gstrcmp( next_url->url,url_item->url ) ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
716 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
717 is_added=True; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
718 break; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
719 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
720 next_url=next_url->next; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
721 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
722 if ( ( !is_added )&&( gstrcmp( next_url->url,url_item->url ) ) ) next_url->next=url_item; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
723 } else { url_item->next=NULL; URLList=url_item; } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
724 return NULL; |
6794 | 725 // --- subtitle |
726 #if defined( USE_OSD ) || defined( USE_SUB ) | |
7139 | 727 #ifndef HAVE_FREETYPE |
6794 | 728 case gtkSetFontFactor: |
7019 | 729 font_factor=fparam; |
6794 | 730 guiLoadFont(); |
731 return NULL; | |
7139 | 732 #else |
733 case gtkSetFontOutLine: | |
734 subtitle_font_thickness=( 8.0f / 100.0f ) * fparam; | |
735 guiLoadFont(); | |
736 return NULL; | |
737 case gtkSetFontBlur: | |
738 subtitle_font_radius=( 8.0f / 100.0f ) * fparam; | |
739 guiLoadFont(); | |
740 return NULL; | |
741 case gtkSetFontTextScale: | |
742 text_font_scale_factor=fparam; | |
743 guiLoadFont(); | |
744 return NULL; | |
745 case gtkSetFontOSDScale: | |
746 osd_font_scale_factor=fparam; | |
747 guiLoadFont(); | |
748 return NULL; | |
749 case gtkSetFontEncoding: | |
750 if ( subtitle_font_encoding ) free( subtitle_font_encoding ); | |
751 subtitle_font_encoding=gstrdup( (char *)vparam ); | |
752 guiLoadFont(); | |
753 return NULL; | |
754 case gtkSetFontAutoScale: | |
755 subtitle_autoscale=(int)fparam; | |
756 guiLoadFont(); | |
757 return NULL; | |
758 #endif | |
6794 | 759 #endif |
760 // --- misc | |
761 case gtkClearStruct: | |
7009 | 762 if ( (unsigned int)vparam & guiFilenames ) |
6794 | 763 { |
764 gfree( (void **)&guiIntfStruct.Filename ); | |
765 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
766 gfree( (void **)&guiIntfStruct.AudioFile ); | |
7009 | 767 gtkSet( gtkDelPl,0,NULL ); |
6794 | 768 } |
769 #ifdef USE_DVDREAD | |
7009 | 770 if ( (unsigned int)vparam & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); |
6794 | 771 #endif |
772 #ifdef HAVE_VCD | |
7009 | 773 if ( (unsigned int)vparam & guiVCD ) guiIntfStruct.VCDTracks=0; |
6794 | 774 #endif |
775 return NULL; | |
776 case gtkSetExtraStereo: | |
777 gtkAOExtraStereoMul=fparam; | |
778 audio_plugin_extrastereo.control( AOCONTROL_PLUGIN_ES_SET,(int)>kAOExtraStereoMul ); | |
779 return NULL; | |
780 case gtkSetPanscan: | |
7217 | 781 { |
782 mp_cmd_t * mp_cmd; | |
783 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); | |
784 mp_cmd->id=MP_CMD_PANSCAN; mp_cmd->name=strdup( "panscan" ); | |
785 mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
786 mp_input_queue_cmd( mp_cmd ); | |
787 } | |
6794 | 788 return NULL; |
789 case gtkSetAutoq: | |
7019 | 790 auto_quality=(int)fparam; |
6794 | 791 return NULL; |
6713 | 792 // --- set equalizers |
6627 | 793 case gtkSetContrast: |
7217 | 794 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"contrast",(int)fparam ); |
795 return NULL; | |
6627 | 796 case gtkSetBrightness: |
7217 | 797 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"brightness",(int)fparam ); |
798 return NULL; | |
6627 | 799 case gtkSetHue: |
7217 | 800 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"hue",(int)fparam ); |
801 return NULL; | |
6627 | 802 case gtkSetSaturation: |
7217 | 803 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"saturation",(int)fparam ); |
804 return NULL; | |
6627 | 805 case gtkSetEqualizer: |
806 if ( eq ) | |
807 { | |
808 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
809 audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)eq ); | |
810 } | |
811 else | |
812 { | |
813 int i,j; equalizer_t tmp; tmp.gain=0.0f; | |
814 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
815 for ( i=0;i<6;i++ ) | |
816 for ( j=0;j<10;j++ ) | |
817 { tmp.channel=i; tmp.band=j; audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)&tmp ); } | |
818 } | |
6713 | 819 return NULL; |
6627 | 820 } |
6713 | 821 return NULL; |
6627 | 822 } |