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