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