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