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