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