Mercurial > mplayer.hg
annotate gui/interface.c @ 24205:4cf8dfb567d6
warning fix:
fastmemcpybench.c: At top level:
fastmemcpybench.c:29: warning: 'mga_next_frame' defined but not used
author | diego |
---|---|
date | Mon, 27 Aug 2007 09:59:23 +0000 |
parents | 0bbfebce0583 |
children | 76f5d8892c04 |
rev | line source |
---|---|
23077 | 1 |
2 #include <inttypes.h> | |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
5 #include <string.h> | |
6 #include <sys/types.h> | |
7 | |
8 #include "wm/ws.h" | |
9 #include "wm/wsxdnd.h" | |
10 #include "interface.h" | |
11 #include "skin/skin.h" | |
12 | |
13 #include "mplayer/gtk/eq.h" | |
14 #include "mplayer/widgets.h" | |
15 #include "mplayer/gmplayer.h" | |
16 #include "mplayer/play.h" | |
17 | |
18 #include "access_mpcontext.h" | |
19 #include "app.h" | |
20 #include "cfg.h" | |
21 #include "help_mp.h" | |
22 #include "libvo/x11_common.h" | |
23 #include "libvo/video_out.h" | |
24 #include "libvo/font_load.h" | |
25 #include "libvo/sub.h" | |
26 #include "input/input.h" | |
27 #include "libao2/audio_out.h" | |
28 #include "mixer.h" | |
29 #include "libaf/af.h" | |
30 #include "libaf/equalizer.h" | |
24153
0bbfebce0583
Remove redundant extern declarations, #include the right headers instead.
diego
parents:
24149
diff
changeset
|
31 #include "libass/ass.h" |
0bbfebce0583
Remove redundant extern declarations, #include the right headers instead.
diego
parents:
24149
diff
changeset
|
32 #include "libass/ass_mp.h" |
23077 | 33 |
34 extern af_cfg_t af_cfg; | |
35 | |
36 #ifdef USE_ICONV | |
37 #include <iconv.h> | |
38 #endif | |
39 | |
40 #include "stream/stream.h" | |
41 #include "libmpdemux/demuxer.h" | |
42 #include "libmpdemux/stheader.h" | |
43 #include "libmpcodecs/dec_video.h" | |
44 | |
45 #ifdef USE_DVDREAD | |
46 #include "stream/stream_dvd.h" | |
47 #endif | |
48 | |
23603
c1221a031ab7
Add a (almost correct) prototype for vcd_seek_to_track
reimar
parents:
23341
diff
changeset
|
49 int vcd_seek_to_track(void *vcd, int track); |
23077 | 50 |
51 #include "m_config.h" | |
52 #include "m_option.h" | |
53 | |
54 | |
55 guiInterface_t guiIntfStruct; | |
56 int guiWinID=-1; | |
57 | |
58 char * gstrcat( char ** dest,const char * src ) | |
59 { | |
60 char * tmp = NULL; | |
61 | |
62 if ( !src ) return NULL; | |
63 | |
64 if ( *dest ) | |
65 { | |
66 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
67 | |
68 if ( tmp ) /* TODO: advanced error handling */ | |
69 { | |
70 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
71 } | |
72 } | |
73 else | |
74 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
75 *dest=tmp; | |
76 return tmp; | |
77 } | |
78 | |
79 int gstrcmp( const char * a,const char * b ) | |
80 { | |
81 if ( !a && !b ) return 0; | |
82 if ( !a || !b ) return -1; | |
83 return strcmp( a,b ); | |
84 } | |
85 | |
86 int gstrncmp( const char * a,const char * b,int size ) | |
87 { | |
88 if ( !a && !b ) return 0; | |
89 if ( !a || !b ) return -1; | |
90 return strncmp( a,b,size ); | |
91 } | |
92 | |
93 char * gstrdup( const char * str ) | |
94 { | |
95 if ( !str ) return NULL; | |
96 return strdup( str ); | |
97 } | |
98 | |
99 char * gstrchr( char * str,int c ) | |
100 { | |
101 if ( !str ) return NULL; | |
102 return strchr( str,c ); | |
103 } | |
104 | |
105 void gfree( void ** p ) | |
106 { | |
107 if ( *p == NULL ) return; | |
108 free( *p ); *p=NULL; | |
109 } | |
110 | |
111 void gset( char ** str, const char * what ) | |
112 { | |
113 if ( *str ) { if ( !strstr( *str,what ) ) { gstrcat( str,"," ); gstrcat( str,what ); }} | |
114 else gstrcat( str,what ); | |
115 } | |
116 | |
117 /** | |
118 * \brief this actually creates a new list containing only one element... | |
119 */ | |
120 void gaddlist( char *** list,const char * entry ) | |
121 { | |
122 int i; | |
123 | |
124 if ( (*list) ) | |
125 { | |
126 for ( i=0;(*list)[i];i++ ) free( (*list)[i] ); | |
127 free( (*list) ); | |
128 } | |
129 | |
130 (*list)=malloc( 2 * sizeof(char **) ); | |
131 (*list)[0]=gstrdup( entry ); | |
132 (*list)[1]=NULL; | |
133 } | |
134 | |
135 /** | |
136 * \brief this replaces a string starting with search by replace. | |
137 * If not found, replace is appended. | |
138 */ | |
139 void greplace(char ***list, const char *search, const char *replace) | |
140 { | |
141 int i = 0; | |
142 int len = (search) ? strlen(search) : 0; | |
143 | |
144 if (*list) { | |
145 for (i = 0; (*list)[i]; i++) { | |
146 if (search && (strncmp((*list)[i], search, len) == 0)) { | |
147 free((*list)[i]); | |
148 (*list)[i] = gstrdup(replace); | |
149 return; | |
150 } | |
151 } | |
152 *list = realloc(*list, (i + 2) * sizeof(char *)); | |
153 } | |
154 else | |
155 *list = malloc(2 * sizeof(char *)); | |
156 | |
157 (*list)[i] = gstrdup(replace); | |
158 (*list)[i + 1] = NULL; | |
159 } | |
160 | |
161 void guiInit( void ) | |
162 { | |
163 int i; | |
164 | |
165 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); | |
166 guiIntfStruct.Balance=50.0f; | |
167 guiIntfStruct.StreamType=-1; | |
168 | |
169 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); | |
170 #ifdef HAVE_DXR3 | |
171 if ( !gtkDXR3Device ) gtkDXR3Device=strdup( "/dev/em8300-0" ); | |
172 #endif | |
173 if ( stream_cache_size > 0 ) { gtkCacheOn=1; gtkCacheSize=stream_cache_size; } | |
174 else if ( stream_cache_size == 0 ) gtkCacheOn = 0; | |
175 if ( autosync && autosync != gtkAutoSync ) { gtkAutoSyncOn=1; gtkAutoSync=autosync; } | |
176 | |
177 #ifdef USE_ASS | |
178 gtkASS.enabled = ass_enabled; | |
179 gtkASS.use_margins = ass_use_margins; | |
180 gtkASS.top_margin = ass_top_margin; | |
181 gtkASS.bottom_margin = ass_bottom_margin; | |
182 #endif | |
183 | |
184 gtkInit(); | |
185 // --- initialize X | |
186 wsXInit( (void *)mDisplay ); | |
187 // --- load skin | |
188 skinDirInHome=get_path("skins"); | |
189 skinDirInHome_obsolete=get_path("Skin"); | |
190 skinMPlayerDir=MPLAYER_DATADIR "/skins"; | |
191 skinMPlayerDir_obsolete=MPLAYER_DATADIR "/Skin"; | |
192 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1: '%s'\n",skinDirInHome); | |
193 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1 (obsolete): '%s'\n",skinDirInHome_obsolete); | |
194 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2: '%s'\n",skinMPlayerDir); | |
195 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2 (obsolete): '%s'\n",skinMPlayerDir_obsolete); | |
196 if ( !skinName ) skinName=strdup( "default" ); | |
197 i = skinRead( skinName ); | |
198 if ((i == -1) && strcmp(skinName,"default")) | |
199 { | |
200 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_SKIN_SKINCFG_SelectedSkinNotFound, skinName); | |
201 skinName=strdup( "default" ); | |
202 i = skinRead( skinName ); | |
203 } | |
204 switch (i) { | |
205 case -1: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinNotFound,skinName ); exit( 0 ); | |
206 case -2: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinCfgReadError,skinName ); exit( 0 ); | |
207 } | |
208 // --- initialize windows | |
209 if ( ( mplDrawBuffer = malloc( appMPlayer.main.Bitmap.ImageSize ) ) == NULL ) | |
210 { | |
211 fprintf( stderr,MSGTR_NEMDB ); | |
212 exit( 0 ); | |
213 } | |
214 | |
215 if ( gui_save_pos ) | |
216 { | |
217 appMPlayer.main.x = gui_main_pos_x; | |
218 appMPlayer.main.y = gui_main_pos_y; | |
219 appMPlayer.sub.x = gui_sub_pos_x; | |
220 appMPlayer.sub.y = gui_sub_pos_y; | |
221 } | |
222 | |
223 if (WinID>0) | |
224 { | |
225 appMPlayer.subWindow.Parent=WinID; | |
226 appMPlayer.sub.x=0; | |
227 appMPlayer.sub.y=0; | |
228 } | |
229 if (guiWinID>=0) appMPlayer.mainWindow.Parent=guiWinID; | |
230 | |
231 wsCreateWindow( &appMPlayer.subWindow, | |
232 appMPlayer.sub.x,appMPlayer.sub.y,appMPlayer.sub.width,appMPlayer.sub.height, | |
233 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsShowFrame|wsHideWindow,"MPlayer - Video" ); | |
234 | |
235 wsDestroyImage( &appMPlayer.subWindow ); | |
236 wsCreateImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height ); | |
237 wsXDNDMakeAwareness(&appMPlayer.subWindow); | |
238 | |
239 mplMenuInit(); | |
240 mplPBInit(); | |
241 | |
242 vo_setwindow( appMPlayer.subWindow.WindowID, appMPlayer.subWindow.wGC ); | |
243 | |
244 // i=wsHideFrame|wsMaxSize|wsHideWindow; | |
245 // if ( appMPlayer.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow; | |
246 i=wsShowFrame|wsMaxSize|wsHideWindow; | |
247 wsCreateWindow( &appMPlayer.mainWindow, | |
248 appMPlayer.main.x,appMPlayer.main.y,appMPlayer.main.width,appMPlayer.main.height, | |
249 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,i,"MPlayer" ); | |
250 | |
251 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image ); | |
252 wsXDNDMakeAwareness(&appMPlayer.mainWindow); | |
253 | |
254 #ifdef DEBUG | |
255 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] depth on screen: %d\n",wsDepthOnScreen ); | |
256 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] parent: 0x%x\n",(int)appMPlayer.mainWindow.WindowID ); | |
257 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] sub: 0x%x\n",(int)appMPlayer.subWindow.WindowID ); | |
258 #endif | |
259 | |
260 appMPlayer.mainWindow.ReDraw=(void *)mplMainDraw; | |
261 appMPlayer.mainWindow.MouseHandler=mplMainMouseHandle; | |
262 appMPlayer.mainWindow.KeyHandler=mplMainKeyHandle; | |
263 appMPlayer.mainWindow.DandDHandler=mplDandDHandler; | |
264 | |
265 appMPlayer.subWindow.ReDraw=(void *)mplSubDraw; | |
266 appMPlayer.subWindow.MouseHandler=mplSubMouseHandle; | |
267 appMPlayer.subWindow.KeyHandler=mplMainKeyHandle; | |
268 appMPlayer.subWindow.DandDHandler=mplDandDHandler; | |
269 | |
270 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B ); | |
271 wsClearWindow( appMPlayer.subWindow ); | |
272 if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize ); | |
273 | |
274 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
275 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
276 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
277 | |
278 wsSetIcon( wsDisplay,appMPlayer.mainWindow.WindowID,guiIcon,guiIconMask ); | |
279 wsSetIcon( wsDisplay,appMPlayer.subWindow.WindowID,guiIcon,guiIconMask ); | |
280 | |
281 guiIntfStruct.Playing=0; | |
282 | |
283 if ( !appMPlayer.mainDecoration ) wsWindowDecoration( &appMPlayer.mainWindow,0 ); | |
284 | |
285 wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow ); | |
286 #if 0 | |
287 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
288 | |
289 { | |
290 XEvent xev; | |
291 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
292 appMPlayer.subWindow.Mapped=wsMapped; | |
293 } | |
294 | |
295 if ( !fullscreen ) fullscreen=gtkLoadFullscreen; | |
296 if ( fullscreen ) | |
297 { | |
298 mplFullScreen(); | |
299 btnModify( evFullScreen,btnPressed ); | |
300 } | |
301 #else | |
302 if ( !fullscreen ) fullscreen=gtkLoadFullscreen; | |
303 if ( gtkShowVideoWindow ) | |
304 { | |
305 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
306 { | |
307 XEvent xev; | |
308 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
309 appMPlayer.subWindow.Mapped=wsMapped; | |
310 } | |
311 | |
312 if ( fullscreen ) | |
313 { | |
314 mplFullScreen(); | |
315 btnModify( evFullScreen,btnPressed ); | |
316 } | |
317 } | |
318 else | |
319 { | |
320 if ( fullscreen ) | |
321 { | |
322 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
323 { | |
324 XEvent xev; | |
325 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
326 appMPlayer.subWindow.Mapped=wsMapped; | |
327 } | |
328 wsVisibleWindow( &appMPlayer.subWindow, wsShowWindow ); | |
329 | |
330 mplFullScreen(); | |
331 btnModify( evFullScreen,btnPressed ); | |
332 } | |
333 } | |
334 #endif | |
335 mplSubRender=1; | |
336 // --- | |
337 | |
338 if ( filename ) mplSetFileName( NULL,filename,STREAMTYPE_FILE ); | |
339 if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name,STREAMTYPE_FILE ); | |
340 if ( subdata ) guiSetFilename( guiIntfStruct.Subtitlename, subdata->filename ); | |
341 guiLoadFont(); | |
342 } | |
343 | |
344 void guiDone( void ) | |
345 { | |
346 mplMainRender=0; | |
347 mp_msg( MSGT_GPLAYER,MSGL_V,"[GUI] done.\n" ); | |
348 | |
349 if ( gui_save_pos ) | |
350 { | |
351 gui_main_pos_x=appMPlayer.mainWindow.X; gui_main_pos_y=appMPlayer.mainWindow.Y; | |
352 gui_sub_pos_x=appMPlayer.subWindow.X; gui_sub_pos_y=appMPlayer.subWindow.Y; | |
353 } | |
354 | |
355 #ifdef USE_ASS | |
356 ass_enabled = gtkASS.enabled; | |
357 ass_use_margins = gtkASS.use_margins; | |
358 ass_top_margin = gtkASS.top_margin; | |
359 ass_bottom_margin = gtkASS.bottom_margin; | |
360 #endif | |
361 | |
362 cfg_write(); | |
363 wsXDone(); | |
364 } | |
365 | |
366 int guiCMDArray[] = | |
367 { | |
368 evLoadPlay, | |
369 evLoadSubtitle, | |
370 evAbout, | |
371 evPlay, | |
372 evStop, | |
373 evPlayList, | |
374 evPreferences, | |
375 evFullScreen, | |
376 evSkinBrowser | |
377 }; | |
378 | |
379 extern int stream_dump_type; | |
380 extern int vcd_track; | |
381 extern m_obj_settings_t * vf_settings; | |
382 | |
383 void guiLoadFont( void ) | |
384 { | |
385 #ifdef HAVE_FREETYPE | |
23341
74f5109611e2
missed part of gui code change while introducing -subfont option (patch by Piotr Kaczuba)
ben
parents:
23158
diff
changeset
|
386 load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name); |
23077 | 387 #else |
388 if ( vo_font ) | |
389 { | |
390 int i; | |
391 if ( vo_font->name ) free( vo_font->name ); | |
392 if ( vo_font->fpath ) free( vo_font->fpath ); | |
393 for ( i=0;i<16;i++ ) | |
394 if ( vo_font->pic_a[i] ) | |
395 { | |
396 if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp ); | |
397 if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal ); | |
398 } | |
399 for ( i=0;i<16;i++ ) | |
400 if ( vo_font->pic_b[i] ) | |
401 { | |
402 if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp ); | |
403 if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal ); | |
404 } | |
405 free( vo_font ); vo_font=NULL; | |
406 } | |
407 if ( font_name ) | |
408 { | |
409 vo_font=read_font_desc( font_name,font_factor,0 ); | |
410 if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name ); | |
411 } | |
412 else | |
413 { | |
414 font_name=gstrdup( get_path( "font/font.desc" ) ); | |
415 vo_font=read_font_desc( font_name,font_factor,0 ); | |
416 if ( !vo_font ) | |
417 { | |
418 gfree( (void **)&font_name ); font_name=gstrdup(MPLAYER_DATADIR "/font/font.desc" ); | |
419 vo_font=read_font_desc( font_name,font_factor,0 ); | |
420 } | |
421 } | |
422 #endif | |
423 } | |
424 | |
425 extern mp_osd_obj_t* vo_osd_list; | |
426 | |
427 extern char **sub_name; | |
428 | |
429 void guiLoadSubtitle( char * name ) | |
430 { | |
431 if ( guiIntfStruct.Playing == 0 ) | |
432 { | |
433 guiIntfStruct.SubtitleChanged=1; //what is this for? (mw) | |
434 return; | |
435 } | |
436 if ( subdata ) | |
437 { | |
438 mp_msg( MSGT_GPLAYER,MSGL_INFO,MSGTR_DeletingSubtitles ); | |
439 sub_free( subdata ); | |
440 subdata=NULL; | |
441 vo_sub=NULL; | |
442 if ( vo_osd_list ) | |
443 { | |
444 int len; | |
445 mp_osd_obj_t * osd = vo_osd_list; | |
446 while ( osd ) | |
447 { | |
448 if ( osd->type == OSDTYPE_SUBTITLE ) break; | |
449 osd=osd->next; | |
450 } | |
451 if ( osd && osd->flags&OSDFLAG_VISIBLE ) | |
452 { | |
453 len=osd->stride * ( osd->bbox.y2 - osd->bbox.y1 ); | |
454 memset( osd->bitmap_buffer,0,len ); | |
455 memset( osd->alpha_buffer,0,len ); | |
456 } | |
457 } | |
458 } | |
459 if ( name ) | |
460 { | |
461 mp_msg( MSGT_GPLAYER,MSGL_INFO,MSGTR_LoadingSubtitles,name ); | |
462 subdata=sub_read_file( name, guiIntfStruct.FPS ); | |
463 if ( !subdata ) mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_CantLoadSub,name ); | |
464 sub_name = (malloc(2 * sizeof(char*))); //when mplayer will be restarted | |
465 sub_name[0] = strdup(name); //sub_name[0] will be read | |
466 sub_name[1] = NULL; | |
467 } | |
468 update_set_of_subtitles(); | |
469 | |
470 } | |
471 | |
472 static void add_vf( char * str ) | |
473 { | |
474 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_AddingVideoFilter,str ); | |
475 if ( vf_settings ) | |
476 { | |
477 int i = 0; | |
478 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { i=-1; break; } | |
479 if ( i != -1 ) | |
480 { vf_settings=realloc( vf_settings,( i + 2 ) * sizeof( m_obj_settings_t ) ); vf_settings[i].name=strdup( str );vf_settings[i].attribs = NULL; vf_settings[i+1].name=NULL; } | |
481 } else { vf_settings=malloc( 2 * sizeof( m_obj_settings_t ) ); vf_settings[0].name=strdup( str );vf_settings[0].attribs = NULL; vf_settings[1].name=NULL; } | |
482 } | |
483 | |
484 static void remove_vf( char * str ) | |
485 { | |
486 int n = 0; | |
487 | |
488 if ( !vf_settings ) return; | |
489 | |
490 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_RemovingVideoFilter,str ); | |
491 | |
492 while ( vf_settings[n++].name ); n--; | |
493 if ( n > -1 ) | |
494 { | |
495 int i = 0,m = -1; | |
496 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { m=i - 1; break; } | |
497 i--; | |
498 if ( m > -1 ) | |
499 { | |
500 if ( n == 1 ) { free( vf_settings[0].name );free( vf_settings[0].attribs ); free( vf_settings ); vf_settings=NULL; } | |
501 else { free( vf_settings[i].name );free( vf_settings[i].attribs ); memcpy( &vf_settings[i],&vf_settings[i + 1],( n - i ) * sizeof( m_obj_settings_t ) ); } | |
502 } | |
503 } | |
504 } | |
505 | |
506 int guiGetEvent( int type,char * arg ) | |
507 { | |
508 ao_functions_t *audio_out = NULL; | |
509 vo_functions_t *video_out = NULL; | |
510 mixer_t *mixer = NULL; | |
511 | |
512 stream_t * stream = (stream_t *) arg; | |
513 #ifdef USE_DVDREAD | |
514 dvd_priv_t * dvdp = (dvd_priv_t *) arg; | |
515 #endif | |
516 | |
517 if (guiIntfStruct.mpcontext) { | |
518 audio_out = mpctx_get_audio_out(guiIntfStruct.mpcontext); | |
519 video_out = mpctx_get_video_out(guiIntfStruct.mpcontext); | |
520 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); | |
521 } | |
522 | |
523 switch ( type ) | |
524 { | |
525 case guiXEvent: | |
526 guiIntfStruct.event_struct=(void *)arg; | |
527 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
528 gtkEventHandling(); | |
529 break; | |
530 case guiCEvent: | |
531 switch ( (int)arg ) | |
532 { | |
533 case guiSetPlay: | |
534 guiIntfStruct.Playing=1; | |
535 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
536 break; | |
537 case guiSetStop: | |
538 guiIntfStruct.Playing=0; | |
539 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
540 break; | |
541 case guiSetPause: guiIntfStruct.Playing=2; break; | |
542 } | |
543 mplState(); | |
544 break; | |
545 case guiSetState: | |
546 mplState(); | |
547 break; | |
548 case guiSetFileName: | |
549 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
550 break; | |
551 case guiSetAudioOnly: | |
552 guiIntfStruct.AudioOnly=(int)arg; | |
553 if ( (int)arg ) { guiIntfStruct.NoWindow=True; wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); } | |
554 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
555 break; | |
556 case guiSetContext: | |
557 guiIntfStruct.mpcontext=(void *)arg; | |
558 case guiSetDemuxer: | |
559 guiIntfStruct.demuxer=(void *)arg; | |
560 break; | |
561 case guiSetAfilter: | |
562 guiIntfStruct.afilter=(void *)arg; | |
563 break; | |
564 case guiSetShVideo: | |
565 { | |
566 if ( !appMPlayer.subWindow.isFullScreen ) | |
567 { | |
568 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
569 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
570 } | |
571 guiIntfStruct.MovieWidth=vo_dwidth; | |
572 guiIntfStruct.MovieHeight=vo_dheight; | |
573 if (guiWinID>=0) | |
574 wsMoveWindow( &appMPlayer.mainWindow,0,0, vo_dheight); | |
575 } | |
576 break; | |
577 #ifdef USE_DVDREAD | |
578 case guiSetDVD: | |
579 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
580 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
581 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
582 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
583 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
584 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
585 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
586 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
587 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
588 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
589 guiIntfStruct.Track=dvd_title + 1; | |
590 break; | |
591 #endif | |
592 case guiSetStream: | |
593 guiIntfStruct.StreamType=stream->type; | |
594 switch( stream->type ) | |
595 { | |
596 #ifdef USE_DVDREAD | |
597 case STREAMTYPE_DVD: | |
598 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
599 break; | |
600 #endif | |
601 #ifdef HAVE_VCD | |
602 case STREAMTYPE_VCD: | |
603 { | |
604 int i; | |
605 | |
606 if (!stream->priv) | |
607 { | |
608 guiIntfStruct.VCDTracks=0; | |
609 break; | |
610 } | |
611 for ( i=1;i < 100;i++ ) | |
612 if ( vcd_seek_to_track( stream->priv,i ) < 0 ) break; | |
613 vcd_seek_to_track( stream->priv,vcd_track ); | |
614 guiIntfStruct.VCDTracks=--i; | |
615 break; | |
616 } | |
617 #endif | |
618 default: break; | |
619 } | |
620 break; | |
621 case guiIEvent: | |
622 mp_msg( MSGT_GPLAYER,MSGL_V,"cmd: %d\n",(int)arg ); | |
623 switch( (int)arg ) | |
624 { | |
625 case MP_CMD_QUIT: | |
626 mplEventHandling( evExit,0 ); | |
627 break; | |
628 case MP_CMD_VO_FULLSCREEN: | |
629 mplEventHandling( evFullScreen,0 ); | |
630 break; | |
631 default: | |
632 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
633 } | |
634 break; | |
635 case guiReDraw: | |
636 mplEventHandling( evRedraw,0 ); | |
637 break; | |
638 case guiSetVolume: | |
639 if ( audio_out ) | |
640 { | |
641 float l,r; | |
642 mixer_getvolume( mixer,&l,&r ); | |
643 guiIntfStruct.Volume=(r>l?r:l); | |
644 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
645 else guiIntfStruct.Balance=50.0f; | |
646 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
647 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
648 } | |
649 break; | |
650 case guiSetFileFormat: | |
651 guiIntfStruct.FileFormat=(int)arg; | |
652 break; | |
653 case guiSetValues: | |
654 // -- video | |
655 guiIntfStruct.sh_video=arg; | |
656 if ( arg ) | |
657 { | |
658 sh_video_t * sh = (sh_video_t *)arg; | |
659 guiIntfStruct.FPS=sh->fps; | |
660 } | |
661 | |
662 if ( guiIntfStruct.NoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
663 | |
664 if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM ) btnSet( evSetMoviePosition,btnDisabled ); | |
665 else btnSet( evSetMoviePosition,btnReleased ); | |
666 | |
667 // -- audio | |
668 if ( audio_out ) | |
669 { | |
670 float l,r; | |
671 mixer_getvolume( mixer,&l,&r ); | |
672 guiIntfStruct.Volume=(r>l?r:l); | |
673 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
674 else guiIntfStruct.Balance=50.0f; | |
675 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
676 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
677 } | |
678 | |
679 if ( gtkEnableAudioEqualizer ) | |
680 { | |
681 equalizer_t eq; | |
682 int i,j; | |
683 for ( i=0;i<6;i++ ) | |
684 for ( j=0;j<10;j++ ) | |
685 { | |
686 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
687 gtkSet( gtkSetEqualizer,0,&eq ); | |
688 } | |
689 } | |
690 // -- subtitle | |
691 #ifdef HAVE_DXR3 | |
692 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) && guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS | |
693 #ifdef USE_LIBAVCODEC | |
694 && !gtkVfLAVC | |
695 #endif | |
696 ) | |
697 { | |
698 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEEDLAVC ); | |
699 guiIntfStruct.Playing=0; | |
700 return True; | |
701 } | |
702 #endif | |
703 break; | |
704 case guiSetDefaults: | |
705 // if ( guiIntfStruct.Playing == 1 && guiIntfStruct.FilenameChanged ) | |
706 if ( guiIntfStruct.FilenameChanged ) | |
707 { | |
708 audio_id=-1; | |
709 video_id=-1; | |
710 dvdsub_id=-1; | |
711 vobsub_id=-1; | |
712 stream_cache_size=-1; | |
713 autosync=0; | |
714 vcd_track=0; | |
715 dvd_title=0; | |
716 force_fps=0; | |
717 } | |
718 guiIntfStruct.demuxer=NULL; | |
719 guiIntfStruct.sh_video=NULL; | |
720 wsPostRedisplay( &appMPlayer.subWindow ); | |
721 break; | |
722 case guiSetParameters: | |
723 guiGetEvent( guiSetDefaults,NULL ); | |
724 switch ( guiIntfStruct.StreamType ) | |
725 { | |
726 case STREAMTYPE_PLAYLIST: | |
727 break; | |
728 #ifdef HAVE_VCD | |
729 case STREAMTYPE_VCD: | |
730 { | |
731 char tmp[512]; | |
732 sprintf( tmp,"vcd://%d",guiIntfStruct.Track + 1 ); | |
733 guiSetFilename( guiIntfStruct.Filename,tmp ); | |
734 } | |
735 break; | |
736 #endif | |
737 #ifdef USE_DVDREAD | |
738 case STREAMTYPE_DVD: | |
739 { | |
740 char tmp[512]; | |
741 sprintf( tmp,"dvd://%d",guiIntfStruct.Title ); | |
742 guiSetFilename( guiIntfStruct.Filename,tmp ); | |
743 } | |
744 dvd_chapter=guiIntfStruct.Chapter; | |
745 dvd_angle=guiIntfStruct.Angle; | |
746 break; | |
747 #endif | |
748 } | |
749 //if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! | |
750 { | |
751 if ( guiIntfStruct.Filename ) filename=gstrdup( guiIntfStruct.Filename ); | |
752 else if ( filename ) guiSetFilename( guiIntfStruct.Filename,filename ); | |
753 } | |
754 // --- video opts | |
755 | |
756 if ( !video_driver_list ) | |
757 { | |
758 int i = 0; | |
759 while ( video_out_drivers[i++] ) | |
760 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
761 { | |
762 gaddlist( &video_driver_list,(char *)video_out_drivers[i - 1]->info->short_name ); | |
763 break; | |
764 } | |
765 } | |
766 | |
767 if ( !video_driver_list && !video_driver_list[0] ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player( "gui init" ); } | |
768 | |
769 { | |
770 int i = 0; | |
771 guiIntfStruct.NoWindow=False; | |
772 while ( video_out_drivers[i++] ) | |
773 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
774 { | |
775 if ( ( video_driver_list && !gstrcmp( video_driver_list[0],(char *)video_out_drivers[i - 1]->info->short_name ) )&&( video_out_drivers[i - 1]->control( VOCTRL_GUI_NOWINDOW,NULL ) == VO_TRUE ) ) | |
776 { guiIntfStruct.NoWindow=True; break; } | |
777 } | |
778 } | |
779 | |
780 #ifdef HAVE_DXR3 | |
781 #ifdef USE_LIBAVCODEC | |
782 remove_vf( "lavc" ); | |
783 #endif | |
784 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) ) | |
785 { | |
786 if ( ( guiIntfStruct.StreamType != STREAMTYPE_DVD)&&( guiIntfStruct.StreamType != STREAMTYPE_VCD ) ) | |
787 { | |
788 #ifdef USE_LIBAVCODEC | |
789 if ( gtkVfLAVC ) add_vf( "lavc" ); | |
790 #endif | |
791 } | |
792 } | |
793 #endif | |
794 // --- | |
795 if ( gtkVfPP ) add_vf( "pp" ); | |
796 else remove_vf( "pp" ); | |
797 | |
798 // --- audio opts | |
799 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
800 if (gtkAONorm) | |
801 greplace(&af_cfg.list, "volnorm", "volnorm"); | |
802 if (gtkEnableAudioEqualizer) | |
803 greplace(&af_cfg.list, "equalizer", "equalizer"); | |
804 if ( gtkAOExtraStereo ) | |
805 { | |
806 char *name = malloc(12 + 20 + 1); | |
807 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
808 name[12 + 20] = 0; | |
809 greplace(&af_cfg.list, "extrastereo", name); | |
810 free(name); | |
811 } | |
812 #ifdef USE_OSS_AUDIO | |
813 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"oss",3 ) ) | |
814 { | |
815 char *tmp; | |
816 mixer_device = gtkAOOSSMixer; | |
817 mixer_channel = gtkAOOSSMixerChannel; | |
818 if (gtkAOOSSDevice) { | |
819 tmp = calloc( 1,strlen( gtkAOOSSDevice ) + 7 ); | |
820 sprintf( tmp,"oss:%s",gtkAOOSSDevice ); | |
821 } else | |
822 tmp = strdup("oss"); | |
823 gaddlist( &audio_driver_list,tmp ); | |
824 free(tmp); | |
825 } | |
826 #endif | |
827 #if defined(HAVE_ALSA9) || defined (HAVE_ALSA1X) | |
828 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"alsa",4 ) ) | |
829 { | |
830 char *tmp; | |
831 mixer_device = gtkAOALSAMixer; | |
832 mixer_channel = gtkAOALSAMixerChannel; | |
833 if (gtkAOALSADevice) { | |
834 tmp = calloc( 1,strlen( gtkAOALSADevice ) + 14 ); | |
835 sprintf( tmp,"alsa:device=%s",gtkAOALSADevice ); | |
836 } else | |
837 tmp = strdup("alsa"); | |
838 gaddlist( &audio_driver_list,tmp ); | |
839 free(tmp); | |
840 } | |
841 #endif | |
842 #ifdef HAVE_SDL | |
843 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"sdl",3 ) ) | |
844 { | |
845 char *tmp; | |
846 if (gtkAOSDLDriver) { | |
847 tmp = calloc( 1,strlen( gtkAOSDLDriver ) + 10 ); | |
848 sprintf( tmp,"sdl:%s",gtkAOSDLDriver ); | |
849 } else | |
850 tmp = strdup("sdl"); | |
851 gaddlist( &audio_driver_list,tmp ); | |
852 free(tmp); | |
853 } | |
854 #endif | |
855 #ifdef USE_ESD | |
856 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"esd",3 ) ) | |
857 { | |
858 char *tmp; | |
859 if (gtkAOESDDevice) { | |
860 tmp = calloc( 1,strlen( gtkAOESDDevice ) + 10 ); | |
861 sprintf( tmp,"esd:%s",gtkAOESDDevice ); | |
862 } else | |
863 tmp = strdup("esd"); | |
864 gaddlist( &audio_driver_list,tmp ); | |
865 free(tmp); | |
866 } | |
867 #endif | |
868 // -- subtitle | |
869 //subdata->filename=gstrdup( guiIntfStruct.Subtitlename ); | |
870 stream_dump_type=0; | |
871 if ( gtkSubDumpMPSub ) stream_dump_type=4; | |
872 if ( gtkSubDumpSrt ) stream_dump_type=6; | |
873 gtkSubDumpMPSub=gtkSubDumpSrt=0; | |
874 guiLoadFont(); | |
875 | |
876 // --- misc | |
877 if ( gtkCacheOn ) stream_cache_size=gtkCacheSize; | |
878 if ( gtkAutoSyncOn ) autosync=gtkAutoSync; | |
879 | |
880 if ( guiIntfStruct.AudioFile ) audio_stream=gstrdup( guiIntfStruct.AudioFile ); | |
881 else if ( guiIntfStruct.FilenameChanged ) gfree( (void**)&audio_stream ); | |
882 //audio_stream=NULL; | |
883 | |
884 guiIntfStruct.DiskChanged=0; | |
885 guiIntfStruct.FilenameChanged=0; | |
886 guiIntfStruct.NewPlay=0; | |
887 | |
888 #ifdef USE_ASS | |
889 ass_enabled = gtkASS.enabled; | |
890 ass_use_margins = gtkASS.use_margins; | |
891 ass_top_margin = gtkASS.top_margin; | |
892 ass_bottom_margin = gtkASS.bottom_margin; | |
893 #endif | |
894 | |
895 break; | |
896 } | |
897 return False; | |
898 } | |
899 | |
900 void guiEventHandling( void ) | |
901 { | |
902 if ( !guiIntfStruct.Playing || guiIntfStruct.NoWindow ) wsHandleEvents(); | |
903 gtkEventHandling(); | |
904 } | |
905 | |
906 // --- | |
907 | |
908 float gtkEquChannels[6][10]; | |
909 | |
910 plItem * plCurrent = NULL; | |
911 plItem * plList = NULL; | |
912 plItem * plLastPlayed = NULL; | |
913 | |
914 URLItem *URLList = NULL; | |
915 | |
916 char *fsHistory[fsPersistant_MaxPos] = { NULL,NULL,NULL,NULL,NULL }; | |
917 | |
918 #if defined( MP_DEBUG ) && 0 | |
919 void list( void ) | |
920 { | |
921 plItem * next = plList; | |
922 printf( "--- list ---\n" ); | |
923 while( next || next->next ) | |
924 { | |
925 printf( "item: %s/%s\n",next->path,next->name ); | |
926 if ( next->next ) next=next->next; else break; | |
927 } | |
928 printf( "--- end of list ---\n" ); | |
929 } | |
930 #else | |
931 #define list(); | |
932 #endif | |
933 | |
934 void * gtkSet( int cmd,float fparam, void * vparam ) | |
935 { | |
936 equalizer_t * eq = (equalizer_t *)vparam; | |
937 plItem * item = (plItem *)vparam; | |
938 | |
939 URLItem * url_item = (URLItem *)vparam; | |
940 int is_added = True; | |
941 | |
942 switch ( cmd ) | |
943 { | |
944 // --- handle playlist | |
945 case gtkAddPlItem: // add item to playlist | |
946 if ( plList ) | |
947 { | |
948 plItem * next = plList; | |
949 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } | |
950 next->next=item; item->prev=next; | |
951 } else { item->prev=item->next=NULL; plCurrent=plList=item; } | |
952 list(); | |
953 return NULL; | |
954 case gtkInsertPlItem: // add item into playlist after current | |
955 if ( plCurrent ) | |
956 { | |
957 plItem * curr = plCurrent; | |
958 item->next=curr->next; | |
959 if (item->next) | |
960 item->next->prev=item; | |
961 item->prev=curr; | |
962 curr->next=item; | |
963 plCurrent=plCurrent->next; | |
964 return plCurrent; | |
965 } | |
966 else | |
967 return gtkSet(gtkAddPlItem,0,(void*)item); | |
968 return NULL; | |
969 case gtkGetNextPlItem: // get current item from playlist | |
970 if ( plCurrent && plCurrent->next) | |
971 { | |
972 plCurrent=plCurrent->next; | |
973 /*if ( !plCurrent && plList ) | |
974 { | |
975 plItem * next = plList; | |
976 while ( next->next ) { if ( !next->next ) break; next=next->next; } | |
977 plCurrent=next; | |
978 }*/ | |
979 return plCurrent; | |
980 } | |
981 return NULL; | |
982 case gtkGetPrevPlItem: | |
983 if ( plCurrent && plCurrent->prev) | |
984 { | |
985 plCurrent=plCurrent->prev; | |
986 //if ( !plCurrent && plList ) plCurrent=plList; | |
987 return plCurrent; | |
988 } | |
989 return NULL; | |
990 case gtkSetCurrPlItem: // set current item | |
991 plCurrent=item; | |
992 return plCurrent; | |
993 case gtkGetCurrPlItem: // get current item | |
994 return plCurrent; | |
995 case gtkDelCurrPlItem: // delete current item | |
996 { | |
997 plItem * curr = plCurrent; | |
998 | |
999 if (!curr) | |
1000 return NULL; | |
1001 if (curr->prev) | |
1002 curr->prev->next=curr->next; | |
1003 if (curr->next) | |
1004 curr->next->prev=curr->prev; | |
1005 if (curr==plList) | |
1006 plList=curr->next; | |
1007 plCurrent=curr->next; | |
1008 // Free it | |
1009 if ( curr->path ) free( curr->path ); | |
1010 if ( curr->name ) free( curr->name ); | |
1011 free( curr ); | |
1012 } | |
1013 mplCurr(); // Instead of using mplNext && mplPrev | |
1014 | |
1015 return plCurrent; | |
1016 case gtkDelPl: // delete list | |
1017 { | |
1018 plItem * curr = plList; | |
1019 plItem * next; | |
1020 if ( !plList ) return NULL; | |
1021 if ( !curr->next ) | |
1022 { | |
1023 if ( curr->path ) free( curr->path ); | |
1024 if ( curr->name ) free( curr->name ); | |
1025 free( curr ); | |
1026 } | |
1027 else | |
1028 { | |
1029 while ( curr->next ) | |
1030 { | |
1031 next=curr->next; | |
1032 if ( curr->path ) free( curr->path ); | |
1033 if ( curr->name ) free( curr->name ); | |
1034 free( curr ); | |
1035 curr=next; | |
1036 } | |
1037 } | |
1038 plList=NULL; plCurrent=NULL; | |
1039 } | |
1040 return NULL; | |
1041 // ----- Handle url | |
1042 case gtkAddURLItem: | |
1043 if ( URLList ) | |
1044 { | |
1045 URLItem * next_url = URLList; | |
1046 is_added = False; | |
1047 while ( next_url->next ) | |
1048 { | |
1049 if ( !gstrcmp( next_url->url,url_item->url ) ) | |
1050 { | |
1051 is_added=True; | |
1052 break; | |
1053 } | |
1054 next_url=next_url->next; | |
1055 } | |
1056 if ( ( !is_added )&&( gstrcmp( next_url->url,url_item->url ) ) ) next_url->next=url_item; | |
1057 } else { url_item->next=NULL; URLList=url_item; } | |
1058 return NULL; | |
1059 // --- subtitle | |
1060 #ifndef HAVE_FREETYPE | |
1061 case gtkSetFontFactor: | |
1062 font_factor=fparam; | |
1063 guiLoadFont(); | |
1064 return NULL; | |
1065 #else | |
1066 case gtkSetFontOutLine: | |
1067 subtitle_font_thickness=( 8.0f / 100.0f ) * fparam; | |
1068 guiLoadFont(); | |
1069 return NULL; | |
1070 case gtkSetFontBlur: | |
1071 subtitle_font_radius=( 8.0f / 100.0f ) * fparam; | |
1072 guiLoadFont(); | |
1073 return NULL; | |
1074 case gtkSetFontTextScale: | |
1075 text_font_scale_factor=fparam; | |
1076 guiLoadFont(); | |
1077 return NULL; | |
1078 case gtkSetFontOSDScale: | |
1079 osd_font_scale_factor=fparam; | |
1080 guiLoadFont(); | |
1081 return NULL; | |
1082 case gtkSetFontEncoding: | |
1083 gfree( (void **)&subtitle_font_encoding ); | |
1084 subtitle_font_encoding=gstrdup( (char *)vparam ); | |
1085 guiLoadFont(); | |
1086 return NULL; | |
1087 case gtkSetFontAutoScale: | |
1088 subtitle_autoscale=(int)fparam; | |
1089 guiLoadFont(); | |
1090 return NULL; | |
1091 #endif | |
1092 #ifdef USE_ICONV | |
1093 case gtkSetSubEncoding: | |
1094 gfree( (void **)&sub_cp ); | |
1095 sub_cp=gstrdup( (char *)vparam ); | |
1096 break; | |
1097 #endif | |
1098 // --- misc | |
1099 case gtkClearStruct: | |
1100 if ( (unsigned int)vparam & guiFilenames ) | |
1101 { | |
1102 gfree( (void **)&guiIntfStruct.Filename ); | |
1103 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
1104 gfree( (void **)&guiIntfStruct.AudioFile ); | |
1105 gtkSet( gtkDelPl,0,NULL ); | |
1106 } | |
1107 #ifdef USE_DVDREAD | |
1108 if ( (unsigned int)vparam & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); | |
1109 #endif | |
1110 #ifdef HAVE_VCD | |
1111 if ( (unsigned int)vparam & guiVCD ) guiIntfStruct.VCDTracks=0; | |
1112 #endif | |
1113 return NULL; | |
1114 case gtkSetExtraStereo: | |
1115 gtkAOExtraStereoMul=fparam; | |
1116 if (guiIntfStruct.afilter) | |
1117 af_control_any_rev(guiIntfStruct.afilter, | |
1118 AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); | |
1119 return NULL; | |
1120 case gtkSetPanscan: | |
1121 { | |
1122 mp_cmd_t * mp_cmd; | |
1123 mp_cmd=calloc( 1,sizeof( *mp_cmd ) ); | |
1124 mp_cmd->id=MP_CMD_PANSCAN; mp_cmd->name=strdup( "panscan" ); | |
1125 mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
1126 mp_input_queue_cmd( mp_cmd ); | |
1127 } | |
1128 return NULL; | |
1129 case gtkSetAutoq: | |
1130 auto_quality=(int)fparam; | |
1131 return NULL; | |
1132 // --- set equalizers | |
1133 case gtkSetContrast: | |
1134 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"contrast",(int)fparam ); | |
1135 return NULL; | |
1136 case gtkSetBrightness: | |
1137 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"brightness",(int)fparam ); | |
1138 return NULL; | |
1139 case gtkSetHue: | |
1140 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"hue",(int)fparam ); | |
1141 return NULL; | |
1142 case gtkSetSaturation: | |
1143 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"saturation",(int)fparam ); | |
1144 return NULL; | |
1145 case gtkSetEqualizer: | |
1146 { | |
1147 af_control_ext_t tmp; | |
1148 if ( eq ) | |
1149 { | |
1150 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
1151 tmp.ch = eq->channel; | |
1152 tmp.arg = gtkEquChannels[eq->channel]; | |
1153 if (guiIntfStruct.afilter) | |
1154 af_control_any_rev(guiIntfStruct.afilter, | |
1155 AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
1156 } | |
1157 else | |
1158 { | |
1159 int i; | |
1160 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
1161 if (guiIntfStruct.afilter) | |
1162 for ( i=0;i<6;i++ ) | |
1163 { | |
1164 tmp.ch = i; | |
1165 tmp.arg = gtkEquChannels[i]; | |
1166 af_control_any_rev(guiIntfStruct.afilter, | |
1167 AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
1168 } | |
1169 } | |
1170 return NULL; | |
1171 } | |
1172 } | |
1173 return NULL; | |
1174 } | |
1175 | |
1176 #define mp_basename(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1)) | |
1177 | |
1178 #include "playtree.h" | |
1179 | |
1180 //This function adds/inserts one file into the gui playlist | |
1181 | |
1182 int import_file_into_gui(char* temp, int insert) | |
1183 { | |
1184 char *filename, *pathname; | |
1185 plItem * item; | |
1186 | |
1187 filename = strdup(mp_basename(temp)); | |
1188 pathname = strdup(temp); | |
1189 if (strlen(pathname)-strlen(filename)>0) | |
1190 pathname[strlen(pathname)-strlen(filename)-1]='\0'; // We have some path so remove / at end | |
1191 else | |
1192 pathname[strlen(pathname)-strlen(filename)]='\0'; | |
1193 mp_msg(MSGT_PLAYTREE,MSGL_V, "Adding filename %s && pathname %s\n",filename,pathname); //FIXME: Change to MSGL_DBG2 ? | |
1194 item=calloc( 1,sizeof( plItem ) ); | |
1195 if (!item) | |
1196 return 0; | |
1197 item->name=filename; | |
1198 item->path=pathname; | |
1199 if (insert) | |
1200 gtkSet( gtkInsertPlItem,0,(void*)item ); // Inserts the item after current, and makes current=item | |
1201 else | |
1202 gtkSet( gtkAddPlItem,0,(void*)item ); | |
1203 return 1; | |
1204 } | |
1205 | |
1206 | |
1207 // This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
1208 // by either: | |
1209 // - overwriting gui pl (enqueue=0) | |
1210 // - appending it to gui pl (enqueue=1) | |
1211 | |
1212 int import_initial_playtree_into_gui(play_tree_t* my_playtree, m_config_t* config, int enqueue) | |
1213 { | |
1214 play_tree_iter_t* my_pt_iter=NULL; | |
1215 int result=0; | |
1216 | |
1217 if (!enqueue) // Delete playlist before "appending" | |
1218 gtkSet(gtkDelPl,0,0); | |
1219 | |
1220 if((my_pt_iter=pt_iter_create(&my_playtree,config))) | |
1221 { | |
1222 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL) | |
1223 { | |
1224 if (import_file_into_gui(filename, 0)) // Add it to end of list | |
1225 result=1; | |
1226 } | |
1227 } | |
1228 | |
1229 mplCurr(); // Update filename | |
1230 mplGotoTheNext=1; | |
1231 | |
1232 if (!enqueue) | |
1233 filename=guiIntfStruct.Filename; // Backward compatibility; if file is specified on commandline, | |
1234 // gmplayer does directly start in Play-Mode. | |
1235 else | |
1236 filename=NULL; | |
1237 | |
1238 return result; | |
1239 } | |
1240 | |
1241 // This function imports and inserts an playtree, that is created "on the fly", for example by | |
1242 // parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
1243 // | |
1244 // The file which contained the playlist is thereby replaced with it's contents. | |
1245 | |
1246 int import_playtree_playlist_into_gui(play_tree_t* my_playtree, m_config_t* config) | |
1247 { | |
1248 play_tree_iter_t* my_pt_iter=NULL; | |
1249 int result=0; | |
1250 plItem * save=(plItem*)gtkSet( gtkGetCurrPlItem, 0, 0); // Save current item | |
1251 | |
1252 if((my_pt_iter=pt_iter_create(&my_playtree,config))) | |
1253 { | |
1254 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL) | |
1255 { | |
1256 if (import_file_into_gui(filename, 1)) // insert it into the list and set plCurrent=new item | |
1257 result=1; | |
1258 } | |
1259 pt_iter_destroy(&my_pt_iter); | |
1260 } | |
1261 | |
1262 if (save) | |
1263 gtkSet(gtkSetCurrPlItem, 0, (void*)save); | |
1264 else | |
1265 gtkSet(gtkSetCurrPlItem, 0, (void*)plList); // go to head, if plList was empty before | |
1266 | |
1267 if (save && result) | |
1268 gtkSet(gtkDelCurrPlItem, 0, 0); | |
1269 | |
1270 mplCurr(); // Update filename | |
1271 filename=NULL; | |
1272 | |
1273 return result; | |
1274 } | |
1275 | |
1276 // wrapper function for mp_msg to display a message box for errors and warnings. | |
1277 | |
1278 void guiMessageBox(int level, char * str) { | |
1279 switch(level) { | |
1280 case MSGL_FATAL: | |
1281 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, str); | |
1282 break; | |
1283 case MSGL_ERR: | |
1284 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, str); | |
1285 break; | |
1286 #if 0 | |
1287 // WARNING! Do NOT enable this! There are too many non-critical messages with | |
1288 // MSGL_WARN, for example: broken SPU packets, codec's bit error messages, | |
1289 // etc etc, they should not raise up a new window every time. | |
1290 case MSGL_WARN: | |
1291 gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, str); | |
1292 break; | |
1293 #endif | |
1294 } | |
1295 } |