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