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