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