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