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