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