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