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