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