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