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