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