Mercurial > mplayer.hg
annotate gui/interface.c @ 33673:38c765585fe5
Cosmetic: Adjust indent.
author | ib |
---|---|
date | Tue, 28 Jun 2011 18:18:32 +0000 |
parents | e576232a39d5 |
children | 2d3199623440 |
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; |
33672 | 690 static float last_balance = -1; |
32984 | 691 |
692 mixer_getvolume(mixer, &l, &r); | |
33672 | 693 |
33671 | 694 guiInfo.Volume = FFMAX(l, r); |
33672 | 695 btnModify(evSetVolume, guiInfo.Volume); |
23077 | 696 |
33672 | 697 if (guiInfo.Balance != last_balance) { |
33673 | 698 if (guiInfo.Volume) |
699 guiInfo.Balance = ((r - l) / guiInfo.Volume + 1.0) * 50.0; | |
700 else | |
701 guiInfo.Balance = 50.0f; | |
32984 | 702 |
33673 | 703 last_balance = guiInfo.Balance; |
704 btnModify(evSetBalance, guiInfo.Balance); | |
33672 | 705 } |
32984 | 706 } |
707 break; | |
708 | |
33660 | 709 case guiSetVideo: |
32984 | 710 |
711 // video | |
712 | |
33555 | 713 guiInfo.sh_video = arg; |
32984 | 714 |
715 if (arg) { | |
716 sh_video_t *sh = arg; | |
33555 | 717 guiInfo.FPS = sh->fps; |
32984 | 718 } |
719 | |
33555 | 720 if (guiInfo.StreamType == STREAMTYPE_STREAM) |
32984 | 721 btnSet(evSetMoviePosition, btnDisabled); |
722 else | |
723 btnSet(evSetMoviePosition, btnReleased); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
724 |
32984 | 725 // audio |
726 | |
33671 | 727 guiGetEvent(guiSetMixer, NULL); |
32984 | 728 |
729 if (gtkEnableAudioEqualizer) { | |
730 equalizer_t eq; | |
731 int i, j; | |
23077 | 732 |
32984 | 733 for (i = 0; i < 6; i++) { |
734 for (j = 0; j < 10; j++) { | |
735 eq.channel = i; | |
736 eq.band = j; | |
737 eq.gain = gtkEquChannels[i][j]; | |
738 gtkSet(gtkSetEqualizer, 0, &eq); | |
739 } | |
740 } | |
741 } | |
742 | |
743 // subtitle | |
23077 | 744 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
745 #ifdef CONFIG_DXR3 |
33656 | 746 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 | 747 gtkMessageBox(GTK_MB_FATAL, MSGTR_NEEDLAVC); |
33555 | 748 guiInfo.Playing = 0; |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33664
diff
changeset
|
749 return False; |
32984 | 750 } |
23077 | 751 #endif |
32984 | 752 |
753 break; | |
754 | |
755 case guiSetDefaults: | |
756 | |
33555 | 757 // if ( guiInfo.Playing == 1 && guiInfo.FilenameChanged ) |
758 if (guiInfo.FilenameChanged) { | |
32984 | 759 audio_id = -1; |
760 video_id = -1; | |
761 dvdsub_id = -1; | |
762 vobsub_id = -1; | |
763 stream_cache_size = -1; | |
764 autosync = 0; | |
765 dvd_title = 0; | |
766 force_fps = 0; | |
767 } | |
768 | |
33555 | 769 guiInfo.sh_video = NULL; |
770 wsPostRedisplay(&guiApp.subWindow); | |
32984 | 771 |
772 break; | |
773 | |
33658
3a617d41751a
Rename guiGetEvent type guiSetParameters guiPreparation.
ib
parents:
33657
diff
changeset
|
774 case guiPreparation: |
32984 | 775 |
776 guiGetEvent(guiSetDefaults, NULL); | |
777 | |
33555 | 778 switch (guiInfo.StreamType) { |
32984 | 779 case STREAMTYPE_PLAYLIST: |
780 break; | |
781 | |
782 #ifdef CONFIG_VCD | |
783 case STREAMTYPE_VCD: | |
784 { | |
785 char tmp[512]; | |
786 | |
33555 | 787 sprintf(tmp, "vcd://%d", guiInfo.Track + 1); |
788 guiSetFilename(guiInfo.Filename, tmp); | |
32984 | 789 } |
790 break; | |
791 #endif | |
792 | |
793 #ifdef CONFIG_DVDREAD | |
794 case STREAMTYPE_DVD: | |
795 { | |
796 char tmp[512]; | |
797 | |
33555 | 798 sprintf(tmp, "dvd://%d", guiInfo.Title); |
799 guiSetFilename(guiInfo.Filename, tmp); | |
32984 | 800 } |
801 | |
33555 | 802 dvd_chapter = guiInfo.Chapter; |
803 dvd_angle = guiInfo.Angle; | |
32984 | 804 |
805 break; | |
806 #endif | |
807 } | |
808 | |
33555 | 809 // if ( guiInfo.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! |
32984 | 810 { |
33555 | 811 if (guiInfo.Filename) |
812 filename = gstrdup(guiInfo.Filename); | |
32984 | 813 else if (filename) |
33555 | 814 guiSetFilename(guiInfo.Filename, filename); |
32984 | 815 } |
816 | |
817 // video opts | |
818 | |
819 if (!video_driver_list) { | |
820 int i = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
821 |
32984 | 822 while (video_out_drivers[i++]) { |
823 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
824 gaddlist(&video_driver_list, (char *)video_out_drivers[i - 1]->info->short_name); | |
825 break; | |
826 } | |
827 } | |
828 } | |
829 | |
830 if (!video_driver_list && !video_driver_list[0]) { | |
33024 | 831 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_IDFGCVD); |
33263 | 832 guiExit(EXIT_ERROR); |
32984 | 833 } |
834 | |
835 { | |
836 int i = 0; | |
837 | |
33655 | 838 guiInfo.MovieWindow = True; |
32984 | 839 |
840 while (video_out_drivers[i++]) { | |
841 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
842 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 | 843 guiInfo.MovieWindow = False; |
32984 | 844 break; |
845 } | |
846 } | |
847 } | |
848 } | |
849 | |
850 #ifdef CONFIG_DXR3 | |
851 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3")) | |
33555 | 852 if (guiInfo.StreamType != STREAMTYPE_DVD && guiInfo.StreamType != STREAMTYPE_VCD) |
32984 | 853 if (gtkVfLAVC) |
854 add_vf("lavc"); | |
855 #endif | |
856 | |
857 if (gtkVfPP) | |
858 add_vf("pp"); | |
859 | |
860 // audio opts | |
861 | |
862 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
863 if (gtkAONorm) | |
864 greplace(&af_cfg.list, "volnorm", "volnorm"); | |
865 | |
866 if (gtkEnableAudioEqualizer) | |
867 greplace(&af_cfg.list, "equalizer", "equalizer"); | |
868 | |
869 if (gtkAOExtraStereo) { | |
870 char *name; | |
871 | |
872 name = malloc(12 + 20 + 1); | |
873 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
874 name[12 + 20] = 0; | |
875 greplace(&af_cfg.list, "extrastereo", name); | |
876 free(name); | |
877 } | |
878 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
879 #ifdef CONFIG_OSS_AUDIO |
32984 | 880 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "oss", 3)) { |
881 char *tmp; | |
882 | |
883 mixer_device = gtkAOOSSMixer; | |
884 mixer_channel = gtkAOOSSMixerChannel; | |
885 | |
886 if (gtkAOOSSDevice) { | |
887 tmp = calloc(1, strlen(gtkAOOSSDevice) + 7); | |
888 sprintf(tmp, "oss:%s", gtkAOOSSDevice); | |
889 } else | |
890 tmp = strdup("oss"); | |
891 | |
892 gaddlist(&audio_driver_list, tmp); | |
893 free(tmp); | |
894 } | |
23077 | 895 #endif |
32984 | 896 |
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27387
diff
changeset
|
897 #ifdef CONFIG_ALSA |
32984 | 898 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "alsa", 4)) { |
899 char *tmp; | |
900 | |
901 mixer_device = gtkAOALSAMixer; | |
902 mixer_channel = gtkAOALSAMixerChannel; | |
903 | |
904 if (gtkAOALSADevice) { | |
905 tmp = calloc(1, strlen(gtkAOALSADevice) + 14); | |
906 sprintf(tmp, "alsa:device=%s", gtkAOALSADevice); | |
907 } else | |
908 tmp = strdup("alsa"); | |
909 | |
910 gaddlist(&audio_driver_list, tmp); | |
911 free(tmp); | |
912 } | |
23077 | 913 #endif |
32984 | 914 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
915 #ifdef CONFIG_SDL |
32984 | 916 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "sdl", 3)) { |
917 char *tmp; | |
918 | |
919 if (gtkAOSDLDriver) { | |
920 tmp = calloc(1, strlen(gtkAOSDLDriver) + 10); | |
921 sprintf(tmp, "sdl:%s", gtkAOSDLDriver); | |
922 } else | |
923 tmp = strdup("sdl"); | |
924 | |
925 gaddlist(&audio_driver_list, tmp); | |
926 free(tmp); | |
927 } | |
23077 | 928 #endif |
32984 | 929 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
930 #ifdef CONFIG_ESD |
32984 | 931 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "esd", 3)) { |
932 char *tmp; | |
933 | |
934 if (gtkAOESDDevice) { | |
935 tmp = calloc(1, strlen(gtkAOESDDevice) + 10); | |
936 sprintf(tmp, "esd:%s", gtkAOESDDevice); | |
937 } else | |
938 tmp = strdup("esd"); | |
939 | |
940 gaddlist(&audio_driver_list, tmp); | |
941 free(tmp); | |
942 } | |
23077 | 943 #endif |
32984 | 944 |
945 // subtitle | |
946 | |
33555 | 947 // subdata->filename=gstrdup( guiInfo.Subtitlename ); |
32984 | 948 stream_dump_type = 0; |
949 | |
950 if (gtkSubDumpMPSub) | |
951 stream_dump_type = 4; | |
952 | |
953 if (gtkSubDumpSrt) | |
954 stream_dump_type = 6; | |
955 | |
956 gtkSubDumpMPSub = gtkSubDumpSrt = 0; | |
23077 | 957 guiLoadFont(); |
958 | |
32984 | 959 // misc |
960 | |
961 if (gtkCacheOn) | |
962 stream_cache_size = gtkCacheSize; | |
963 | |
964 if (gtkAutoSyncOn) | |
965 autosync = gtkAutoSync; | |
23077 | 966 |
33555 | 967 if (guiInfo.AudioFile) |
968 audio_stream = gstrdup(guiInfo.AudioFile); | |
969 else if (guiInfo.FilenameChanged) | |
32984 | 970 gfree((void **)&audio_stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
971 |
32984 | 972 // audio_stream = NULL; |
973 | |
33555 | 974 guiInfo.DiskChanged = 0; |
975 guiInfo.FilenameChanged = 0; | |
976 guiInfo.NewPlay = 0; | |
23077 | 977 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
978 #ifdef CONFIG_ASS |
32984 | 979 ass_enabled = gtkASS.enabled; |
980 ass_use_margins = gtkASS.use_margins; | |
981 ass_top_margin = gtkASS.top_margin; | |
23077 | 982 ass_bottom_margin = gtkASS.bottom_margin; |
983 #endif | |
984 | |
32984 | 985 break; |
986 } | |
987 | |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33664
diff
changeset
|
988 return True; |
23077 | 989 } |
990 | |
32984 | 991 void guiEventHandling(void) |
23077 | 992 { |
33655 | 993 if (!guiInfo.Playing || !guiInfo.MovieWindow) |
32984 | 994 wsHandleEvents(); |
995 | |
996 gtkEventHandling(); | |
23077 | 997 } |
998 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
999 // --- |
32984 | 1000 #if defined(MP_DEBUG) && 0 |
1001 void list(void) | |
1002 { | |
1003 plItem *next = plList; | |
23077 | 1004 |
32984 | 1005 printf("--- list ---\n"); |
23077 | 1006 |
32984 | 1007 while (next || next->next) { |
1008 printf("item: %s/%s\n", next->path, next->name); | |
1009 | |
1010 if (next->next) | |
1011 next = next->next; | |
1012 else | |
1013 break; | |
1014 } | |
1015 | |
1016 printf("--- end of list ---\n"); | |
23077 | 1017 } |
1018 #else | |
1019 #define list(); | |
1020 #endif | |
1021 | |
32984 | 1022 void *gtkSet(int cmd, float fparam, void *vparam) |
23077 | 1023 { |
32984 | 1024 equalizer_t *eq = (equalizer_t *)vparam; |
1025 plItem *item = (plItem *)vparam; | |
33555 | 1026 urlItem *url_item = (urlItem *)vparam; |
32984 | 1027 int is_added = True; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1028 |
32984 | 1029 switch (cmd) { |
1030 // handle playlist | |
1031 | |
1032 // add item to playlist | |
1033 case gtkAddPlItem: | |
23077 | 1034 |
32984 | 1035 if (plList) { |
1036 plItem *next = plList; | |
1037 | |
1038 while (next->next) | |
1039 // { | |
1040 // printf( "%s\n",next->name ); | |
1041 next = next->next; | |
1042 // } | |
1043 | |
1044 next->next = item; | |
1045 item->prev = next; | |
33475
b1bda1dded08
When adding a playlist item, preventively set its next pointer to NULL.
ib
parents:
33473
diff
changeset
|
1046 item->next = NULL; |
32984 | 1047 } else { |
1048 item->prev = item->next = NULL; | |
1049 plCurrent = plList = item; | |
1050 } | |
1051 | |
23077 | 1052 list(); |
33053 | 1053 |
23077 | 1054 return NULL; |
32984 | 1055 |
1056 // add item into playlist after current | |
1057 case gtkInsertPlItem: | |
1058 if (plCurrent) { | |
1059 plItem *curr = plCurrent; | |
1060 item->next = curr->next; | |
1061 | |
1062 if (item->next) | |
1063 item->next->prev = item; | |
1064 | |
1065 item->prev = curr; | |
1066 curr->next = item; | |
1067 plCurrent = plCurrent->next; | |
1068 | |
1069 return plCurrent; | |
1070 } else | |
1071 return gtkSet(gtkAddPlItem, 0, (void *)item); | |
1072 return NULL; // NOTE TO MYSELF: remove this | |
1073 | |
33473 | 1074 // get next item from playlist |
32984 | 1075 case gtkGetNextPlItem: |
1076 if (plCurrent && plCurrent->next) { | |
1077 plCurrent = plCurrent->next; | |
1078 // if (!plCurrent && plList) | |
1079 // { | |
1080 // plItem *next = plList; | |
1081 // | |
1082 // while (next->next) | |
1083 // { | |
1084 // if (!next->next) break; | |
1085 // next = next->next; | |
1086 // } | |
1087 // | |
1088 // plCurrent = next; | |
1089 // } | |
1090 return plCurrent; | |
1091 } | |
33053 | 1092 |
23077 | 1093 return NULL; |
32984 | 1094 |
33473 | 1095 // get previous item from playlist |
32984 | 1096 case gtkGetPrevPlItem: |
1097 if (plCurrent && plCurrent->prev) { | |
1098 plCurrent = plCurrent->prev; | |
1099 // if ( !plCurrent && plList ) plCurrent=plList; | |
1100 return plCurrent; | |
1101 } | |
33053 | 1102 |
23077 | 1103 return NULL; |
32984 | 1104 |
1105 // set current item | |
1106 case gtkSetCurrPlItem: | |
1107 plCurrent = item; | |
1108 return plCurrent; | |
1109 | |
1110 // get current item | |
1111 case gtkGetCurrPlItem: | |
23077 | 1112 return plCurrent; |
32984 | 1113 |
1114 // delete current item | |
1115 case gtkDelCurrPlItem: | |
1116 { | |
1117 plItem *curr = plCurrent; | |
1118 | |
1119 if (!curr) | |
1120 return NULL; | |
23077 | 1121 |
32984 | 1122 if (curr->prev) |
1123 curr->prev->next = curr->next; | |
1124 if (curr->next) | |
1125 curr->next->prev = curr->prev; | |
1126 if (curr == plList) | |
1127 plList = curr->next; | |
1128 | |
1129 plCurrent = curr->next; | |
1130 | |
1131 // free it | |
1132 free(curr->path); | |
1133 free(curr->name); | |
1134 free(curr); | |
1135 } | |
1136 | |
33555 | 1137 uiCurr(); // instead of using uiNext && uiPrev |
33053 | 1138 |
32984 | 1139 return plCurrent; |
1140 | |
1141 // delete list | |
1142 case gtkDelPl: | |
1143 { | |
1144 plItem *curr = plList; | |
1145 plItem *next; | |
1146 | |
1147 if (!plList) | |
1148 return NULL; | |
23077 | 1149 |
32984 | 1150 if (!curr->next) { |
1151 free(curr->path); | |
1152 free(curr->name); | |
1153 free(curr); | |
1154 } else { | |
1155 while (curr->next) { | |
1156 next = curr->next; | |
1157 free(curr->path); | |
1158 free(curr->name); | |
1159 free(curr); | |
1160 curr = next; | |
1161 } | |
1162 } | |
1163 | |
1164 plList = NULL; | |
1165 plCurrent = NULL; | |
1166 } | |
33053 | 1167 |
23077 | 1168 return NULL; |
32984 | 1169 |
1170 // handle url | |
1171 case gtkAddURLItem: | |
1172 if (URLList) { | |
33555 | 1173 urlItem *next_url = URLList; |
32984 | 1174 is_added = False; |
1175 | |
1176 while (next_url->next) { | |
1177 if (!gstrcmp(next_url->url, url_item->url)) { | |
1178 is_added = True; | |
1179 break; | |
1180 } | |
1181 | |
1182 next_url = next_url->next; | |
1183 } | |
1184 | |
1185 if (!is_added && gstrcmp(next_url->url, url_item->url)) | |
1186 next_url->next = url_item; | |
1187 } else { | |
1188 url_item->next = NULL; | |
1189 URLList = url_item; | |
1190 } | |
33053 | 1191 |
23077 | 1192 return NULL; |
32984 | 1193 |
1194 // subtitle | |
1195 | |
27393 | 1196 #ifndef CONFIG_FREETYPE |
32984 | 1197 case gtkSetFontFactor: |
1198 font_factor = fparam; | |
1199 guiLoadFont(); | |
1200 return NULL; | |
23077 | 1201 #else |
32984 | 1202 case gtkSetFontOutLine: |
1203 subtitle_font_thickness = (8.0f / 100.0f) * fparam; | |
1204 guiLoadFont(); | |
1205 return NULL; | |
1206 | |
1207 case gtkSetFontBlur: | |
1208 subtitle_font_radius = (8.0f / 100.0f) * fparam; | |
1209 guiLoadFont(); | |
1210 return NULL; | |
1211 | |
1212 case gtkSetFontTextScale: | |
1213 text_font_scale_factor = fparam; | |
1214 guiLoadFont(); | |
1215 return NULL; | |
1216 | |
1217 case gtkSetFontOSDScale: | |
1218 osd_font_scale_factor = fparam; | |
1219 guiLoadFont(); | |
1220 return NULL; | |
1221 | |
1222 case gtkSetFontEncoding: | |
1223 gfree((void **)&subtitle_font_encoding); | |
1224 subtitle_font_encoding = gstrdup((char *)vparam); | |
1225 guiLoadFont(); | |
1226 return NULL; | |
1227 | |
1228 case gtkSetFontAutoScale: | |
1229 subtitle_autoscale = (int)fparam; | |
1230 guiLoadFont(); | |
1231 return NULL; | |
23077 | 1232 #endif |
32984 | 1233 |
27393 | 1234 #ifdef CONFIG_ICONV |
32984 | 1235 case gtkSetSubEncoding: |
1236 gfree((void **)&sub_cp); | |
1237 sub_cp = gstrdup((char *)vparam); | |
1238 break; | |
23077 | 1239 #endif |
32984 | 1240 |
1241 // misc | |
1242 | |
1243 case gtkClearStruct: | |
1244 | |
1245 if ((unsigned int)vparam & guiFilenames) { | |
33555 | 1246 gfree((void **)&guiInfo.Filename); |
1247 gfree((void **)&guiInfo.Subtitlename); | |
1248 gfree((void **)&guiInfo.AudioFile); | |
32984 | 1249 gtkSet(gtkDelPl, 0, NULL); |
1250 } | |
1251 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
1252 #ifdef CONFIG_DVDREAD |
32984 | 1253 if ((unsigned int)vparam & guiDVD) |
33555 | 1254 memset(&guiInfo.DVD, 0, sizeof(guiDVDStruct)); |
23077 | 1255 #endif |
32984 | 1256 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
1257 #ifdef CONFIG_VCD |
32984 | 1258 if ((unsigned int)vparam & guiVCD) |
33555 | 1259 guiInfo.VCDTracks = 0; |
23077 | 1260 #endif |
32984 | 1261 |
1262 return NULL; | |
1263 | |
1264 case gtkSetExtraStereo: | |
1265 gtkAOExtraStereoMul = fparam; | |
33555 | 1266 if (guiInfo.afilter) |
1267 af_control_any_rev(guiInfo.afilter, AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); | |
32984 | 1268 return NULL; |
1269 | |
1270 case gtkSetPanscan: | |
1271 { | |
1272 mp_cmd_t *mp_cmd; | |
1273 | |
1274 mp_cmd = calloc(1, sizeof(*mp_cmd)); | |
1275 mp_cmd->id = MP_CMD_PANSCAN; | |
1276 mp_cmd->name = strdup("panscan"); | |
1277 mp_cmd->args[0].v.f = fparam; | |
1278 mp_cmd->args[1].v.i = 1; | |
1279 mp_input_queue_cmd(mp_cmd); | |
1280 } | |
33053 | 1281 |
23077 | 1282 return NULL; |
32984 | 1283 |
1284 case gtkSetAutoq: | |
1285 auto_quality = (int)fparam; | |
1286 return NULL; | |
1287 | |
1288 // set equalizers | |
1289 | |
1290 case gtkSetContrast: | |
33555 | 1291 if (guiInfo.sh_video) |
1292 set_video_colors(guiInfo.sh_video, "contrast", (int)fparam); | |
32984 | 1293 return NULL; |
1294 | |
1295 case gtkSetBrightness: | |
33555 | 1296 if (guiInfo.sh_video) |
1297 set_video_colors(guiInfo.sh_video, "brightness", (int)fparam); | |
32984 | 1298 return NULL; |
1299 | |
1300 case gtkSetHue: | |
33555 | 1301 if (guiInfo.sh_video) |
1302 set_video_colors(guiInfo.sh_video, "hue", (int)fparam); | |
23077 | 1303 return NULL; |
32984 | 1304 |
1305 case gtkSetSaturation: | |
33555 | 1306 if (guiInfo.sh_video) |
1307 set_video_colors(guiInfo.sh_video, "saturation", (int)fparam); | |
32984 | 1308 return NULL; |
1309 | |
1310 case gtkSetEqualizer: | |
1311 { | |
23077 | 1312 af_control_ext_t tmp; |
32984 | 1313 |
1314 if (eq) { | |
1315 gtkEquChannels[eq->channel][eq->band] = eq->gain; | |
1316 tmp.ch = eq->channel; | |
1317 tmp.arg = gtkEquChannels[eq->channel]; | |
1318 | |
33555 | 1319 if (guiInfo.afilter) |
1320 af_control_any_rev(guiInfo.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
32984 | 1321 } else { |
1322 int i; | |
1323 | |
1324 memset(gtkEquChannels, 0, sizeof(gtkEquChannels)); | |
1325 | |
33555 | 1326 if (guiInfo.afilter) { |
32984 | 1327 for (i = 0; i < 6; i++) { |
1328 tmp.ch = i; | |
1329 tmp.arg = gtkEquChannels[i]; | |
33555 | 1330 af_control_any_rev(guiInfo.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); |
32984 | 1331 } |
1332 } | |
1333 } | |
1334 | |
1335 return NULL; | |
1336 } | |
1337 } | |
1338 | |
1339 return NULL; | |
23077 | 1340 } |
1341 | |
32984 | 1342 // This function adds/inserts one file into the gui playlist. |
1343 static int import_file_into_gui(char *temp, int insert) | |
1344 { | |
1345 char *filename, *pathname; | |
1346 plItem *item; | |
23077 | 1347 |
32984 | 1348 filename = strdup(mp_basename(temp)); |
1349 pathname = strdup(temp); | |
1350 | |
1351 if (strlen(pathname) - strlen(filename) > 0) | |
1352 pathname[strlen(pathname) - strlen(filename) - 1] = 0; // we have some path, so remove / at end | |
1353 else | |
1354 pathname[strlen(pathname) - strlen(filename)] = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1355 |
33530 | 1356 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] playtree, add: %s/%s\n", pathname, filename); |
32984 | 1357 |
1358 item = calloc(1, sizeof(plItem)); | |
1359 | |
1360 if (!item) | |
1361 return 0; | |
1362 | |
1363 item->name = filename; | |
1364 item->path = pathname; | |
1365 | |
1366 if (insert) | |
1367 gtkSet(gtkInsertPlItem, 0, (void *)item); // inserts the item after current, and makes current=item | |
1368 else | |
1369 gtkSet(gtkAddPlItem, 0, (void *)item); | |
1370 | |
1371 return 1; | |
23077 | 1372 } |
1373 | |
32984 | 1374 // This function imports the initial playtree (based on cmd-line files) |
1375 // into the gui playlist by either: | |
1376 // - overwriting gui pl (enqueue=0) | |
1377 // - appending it to gui pl (enqueue=1) | |
1378 int import_initial_playtree_into_gui(play_tree_t *my_playtree, m_config_t *config, int enqueue) | |
1379 { | |
1380 play_tree_iter_t *my_pt_iter = NULL; | |
1381 int result = 0; | |
23077 | 1382 |
32984 | 1383 if (!enqueue) |
1384 gtkSet(gtkDelPl, 0, 0); // delete playlist before "appending" | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1385 |
32984 | 1386 if ((my_pt_iter = pt_iter_create(&my_playtree, config))) { |
1387 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
1388 // add it to end of list | |
1389 if (import_file_into_gui(filename, 0)) | |
1390 result = 1; | |
23077 | 1391 } |
1392 | |
33555 | 1393 uiCurr(); // update filename |
1394 uiGotoTheNext = 1; | |
23077 | 1395 |
32984 | 1396 if (!enqueue) |
33555 | 1397 filename = guiInfo.Filename; // Backward compatibility; if file is specified on commandline, |
1398 // gmplayer does directly start in Play-Mode. | |
32984 | 1399 else |
1400 filename = NULL; | |
23077 | 1401 |
32984 | 1402 return result; |
23077 | 1403 } |
1404 | |
32984 | 1405 // This function imports and inserts an playtree, that is created "on the fly", |
1406 // for example by parsing some MOV-Reference-File; or by loading an playlist | |
1407 // with "File Open". | |
23077 | 1408 // The file which contained the playlist is thereby replaced with it's contents. |
32984 | 1409 int import_playtree_playlist_into_gui(play_tree_t *my_playtree, m_config_t *config) |
1410 { | |
1411 play_tree_iter_t *my_pt_iter = NULL; | |
1412 int result = 0; | |
1413 plItem *save; | |
23077 | 1414 |
32984 | 1415 save = (plItem *)gtkSet(gtkGetCurrPlItem, 0, 0); // save current item |
23077 | 1416 |
32984 | 1417 if ((my_pt_iter = pt_iter_create(&my_playtree, config))) { |
1418 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
1419 // insert it into the list and set plCurrent=new item | |
1420 if (import_file_into_gui(filename, 1)) | |
1421 result = 1; | |
1422 | |
1423 pt_iter_destroy(&my_pt_iter); | |
23077 | 1424 } |
1425 | |
32984 | 1426 if (save) |
1427 gtkSet(gtkSetCurrPlItem, 0, (void *)save); | |
1428 else | |
1429 gtkSet(gtkSetCurrPlItem, 0, (void *)plList); // go to head, if plList was empty before | |
23077 | 1430 |
32984 | 1431 if (save && result) |
1432 gtkSet(gtkDelCurrPlItem, 0, 0); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1433 |
33555 | 1434 uiCurr(); // update filename |
32984 | 1435 filename = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1436 |
32984 | 1437 return result; |
23077 | 1438 } |
33023 | 1439 |
1440 // NOTE TO MYSELF: This function is nonsense. | |
33289 | 1441 // MPlayer should pass messages to the GUI |
1442 // which must decide then which message has | |
1443 // to be shown (MSGL_FATAL, for example). | |
1444 // But with this function it is at least | |
1445 // possible to show GUI's very critical or | |
1446 // abort messages. | |
33023 | 1447 void gmp_msg(int mod, int lev, const char *format, ...) |
1448 { | |
1449 char msg[512]; | |
1450 va_list va; | |
1451 | |
1452 va_start(va, format); | |
1453 vsnprintf(msg, sizeof(msg), format, va); | |
1454 va_end(va); | |
1455 | |
1456 mp_msg(mod, lev, msg); | |
1457 | |
1458 if (mp_msg_test(mod, lev)) | |
1459 gtkMessageBox(GTK_MB_FATAL, msg); | |
1460 } |