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