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