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