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