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