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