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