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