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