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