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