Mercurial > mplayer.hg
annotate gui/interface.c @ 33395:4e9058b47bde
Cosmetic: Remove braces and adjust indent after r33481.
| author | ib |
|---|---|
| date | Sun, 22 May 2011 19:55:18 +0000 |
| parents | a97ab6658993 |
| children | 3feb6b8799a1 |
| rev | line source |
|---|---|
| 26458 | 1 /* |
| 2 * This file is part of MPlayer. | |
| 3 * | |
| 4 * MPlayer is free software; you can redistribute it and/or modify | |
| 5 * it under the terms of the GNU General Public License as published by | |
| 6 * the Free Software Foundation; either version 2 of the License, or | |
| 7 * (at your option) any later version. | |
| 8 * | |
| 9 * MPlayer is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU General Public License along | |
| 15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
| 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 17 */ | |
| 23077 | 18 |
| 19 #include <stdlib.h> | |
| 20 #include <string.h> | |
| 21 | |
| 32984 | 22 #include "interface.h" |
| 23 #include "app.h" | |
| 24 #include "mplayer/gmplayer.h" | |
| 25 #include "mplayer/widgets.h" | |
| 26 #include "skin/skin.h" | |
| 23077 | 27 #include "wm/ws.h" |
| 28 #include "wm/wsxdnd.h" | |
| 29 | |
| 30 #include "access_mpcontext.h" | |
| 32984 | 31 #include "config.h" |
| 23077 | 32 #include "help_mp.h" |
| 32984 | 33 #include "input/input.h" |
| 34 #include "libaf/equalizer.h" | |
| 35 #include "libmpcodecs/dec_audio.h" | |
| 36 #include "libmpcodecs/dec_video.h" | |
| 37 #include "libmpcodecs/vd.h" | |
| 38 #include "libmpcodecs/vf.h" | |
| 39 #include "libvo/x11_common.h" | |
| 40 #include "mixer.h" | |
| 41 #include "mp_msg.h" | |
| 32032 | 42 #include "mpcommon.h" |
|
30536
39a4dd7ec420
Move GUI-related extern declarations to a GUI header file.
diego
parents:
30535
diff
changeset
|
43 #include "mplayer.h" |
| 32984 | 44 #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
|
45 #include "sub/font_load.h" |
| 32467 | 46 #include "sub/sub.h" |
| 23077 | 47 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
48 #ifdef CONFIG_DVDREAD |
| 23077 | 49 #include "stream/stream_dvd.h" |
| 50 #endif | |
| 51 | |
| 32984 | 52 guiInterface_t guiIntfStruct; |
| 23077 | 53 |
| 32984 | 54 int guiWinID = -1; |
| 23077 | 55 |
| 32900 | 56 char *skinName; |
| 57 char *skinDirInHome; | |
| 58 char *skinMPlayerDir; | |
| 59 | |
| 32984 | 60 plItem *plCurrent = NULL; |
| 61 plItem *plList = NULL; | |
| 62 plItem *plLastPlayed = NULL; | |
| 63 | |
| 64 URLItem *URLList = NULL; | |
| 65 | |
| 66 char *fsHistory[fsPersistant_MaxPos] = { NULL, NULL, NULL, NULL, NULL }; | |
| 67 | |
| 68 float gtkEquChannels[6][10]; | |
| 69 | |
| 33265 | 70 static int initialized; |
| 71 | |
| 32984 | 72 int gstrcmp(const char *a, const char *b) |
| 23077 | 73 { |
| 32984 | 74 if (!a && !b) |
| 75 return 0; | |
| 76 if (!a || !b) | |
| 77 return -1; | |
| 23077 | 78 |
| 32984 | 79 return strcmp(a, b); |
| 23077 | 80 } |
| 81 | |
| 32984 | 82 static int gstrncmp(const char *a, const char *b, int size) |
| 23077 | 83 { |
| 32984 | 84 if (!a && !b) |
| 85 return 0; | |
| 86 if (!a || !b) | |
| 87 return -1; | |
| 88 | |
| 89 return strncmp(a, b, size); | |
| 23077 | 90 } |
| 91 | |
| 32984 | 92 char *gstrdup(const char *str) |
| 23077 | 93 { |
| 32984 | 94 if (!str) |
| 95 return NULL; | |
| 96 | |
| 97 return strdup(str); | |
| 23077 | 98 } |
| 99 | |
| 32984 | 100 char *gstrchr(char *str, int c) |
| 23077 | 101 { |
| 32984 | 102 if (!str) |
| 103 return NULL; | |
| 104 | |
| 105 return strchr(str, c); | |
| 106 } | |
| 107 | |
| 108 void gfree(void **p) | |
| 109 { | |
| 110 free(*p); | |
| 111 *p = NULL; | |
| 23077 | 112 } |
| 113 | |
| 114 /** | |
| 32984 | 115 * \brief This actually creates a new list containing only one element... |
| 23077 | 116 */ |
| 32984 | 117 void gaddlist(char ***list, const char *entry) |
| 23077 | 118 { |
| 32984 | 119 int i; |
| 23077 | 120 |
| 32984 | 121 if (*list) { |
| 122 for (i = 0; (*list)[i]; i++) | |
| 123 free((*list)[i]); | |
| 23077 | 124 |
| 32984 | 125 free(*list); |
| 126 } | |
| 127 | |
| 128 *list = malloc(2 * sizeof(char **)); | |
| 129 (*list)[0] = gstrdup(entry); | |
| 130 (*list)[1] = NULL; | |
| 23077 | 131 } |
| 132 | |
| 133 /** | |
| 32984 | 134 * \brief This replaces a string starting with search by replace. |
| 23077 | 135 * If not found, replace is appended. |
| 136 */ | |
|
30535
016e5fc1dead
GUI: Mark functions that are not used outside their files as static.
diego
parents:
30516
diff
changeset
|
137 static void greplace(char ***list, const char *search, const char *replace) |
| 23077 | 138 { |
| 32984 | 139 int i = 0; |
| 140 int len = (search ? strlen(search) : 0); | |
| 23077 | 141 |
| 32984 | 142 if (*list) { |
| 143 for (i = 0; (*list)[i]; i++) { | |
| 144 if (search && (strncmp((*list)[i], search, len) == 0)) { | |
| 145 free((*list)[i]); | |
| 146 (*list)[i] = gstrdup(replace); | |
| 147 return; | |
| 148 } | |
| 149 } | |
| 23077 | 150 |
| 32984 | 151 *list = realloc(*list, (i + 2) * sizeof(char *)); |
| 152 } else | |
| 153 *list = malloc(2 * sizeof(char *)); | |
| 154 | |
| 155 (*list)[i] = gstrdup(replace); | |
| 156 (*list)[i + 1] = NULL; | |
| 23077 | 157 } |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
158 |
| 32984 | 159 void guiInit(void) |
| 23077 | 160 { |
| 32984 | 161 int i; |
| 23077 | 162 |
| 32984 | 163 memset(&guiIntfStruct, 0, sizeof(guiIntfStruct)); |
| 164 guiIntfStruct.Balance = 50.0f; | |
| 165 guiIntfStruct.StreamType = -1; | |
| 166 | |
| 167 memset(>kEquChannels, 0, sizeof(gtkEquChannels)); | |
| 23077 | 168 |
| 32984 | 169 #ifdef CONFIG_DXR3 |
| 170 if (!gtkDXR3Device) | |
| 171 gtkDXR3Device = strdup("/dev/em8300-0"); | |
| 172 #endif | |
| 32927 | 173 |
| 32984 | 174 if (stream_cache_size > 0) { |
| 175 gtkCacheOn = 1; | |
| 176 gtkCacheSize = stream_cache_size; | |
| 177 } else if (stream_cache_size == 0) | |
| 178 gtkCacheOn = 0; | |
| 179 | |
| 180 if (autosync && (autosync != gtkAutoSync)) { | |
| 181 gtkAutoSyncOn = 1; | |
| 182 gtkAutoSync = autosync; | |
| 183 } | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
184 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
185 #ifdef CONFIG_ASS |
| 32984 | 186 gtkASS.enabled = ass_enabled; |
| 187 gtkASS.use_margins = ass_use_margins; | |
| 188 gtkASS.top_margin = ass_top_margin; | |
| 189 gtkASS.bottom_margin = ass_bottom_margin; | |
| 23077 | 190 #endif |
| 191 | |
| 32984 | 192 gtkInit(); |
| 193 | |
| 194 // initialize X | |
| 195 wsXInit((void *)mDisplay); | |
| 196 | |
| 197 // load skin | |
| 198 | |
| 199 skinDirInHome = get_path("skins"); | |
| 200 skinMPlayerDir = MPLAYER_DATADIR "/skins"; | |
| 201 | |
| 202 mp_msg(MSGT_GPLAYER, MSGL_V, "SKIN dir 1: '%s'\n", skinDirInHome); | |
| 203 mp_msg(MSGT_GPLAYER, MSGL_V, "SKIN dir 2: '%s'\n", skinMPlayerDir); | |
| 204 | |
| 205 if (!skinName) | |
| 206 skinName = strdup("default"); | |
| 207 | |
| 208 i = skinRead(skinName); | |
| 209 | |
| 210 if (i == -1 && strcmp(skinName, "default") != 0) { | |
| 211 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_SKIN_SKINCFG_SelectedSkinNotFound, skinName); | |
| 212 | |
| 213 skinName = strdup("default"); | |
| 214 i = skinRead(skinName); | |
| 215 } | |
| 216 | |
| 217 switch (i) { | |
| 218 case -1: | |
| 33024 | 219 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinNotFound, skinName); |
| 33263 | 220 guiExit(EXIT_ERROR); |
| 23077 | 221 |
| 32984 | 222 case -2: |
| 33025 | 223 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinCfgError, skinName); |
| 33263 | 224 guiExit(EXIT_ERROR); |
| 32984 | 225 } |
| 226 | |
| 227 // initialize windows | |
| 228 | |
| 229 mplDrawBuffer = malloc(appMPlayer.main.Bitmap.ImageSize); | |
| 230 | |
| 231 if (!mplDrawBuffer) { | |
| 33024 | 232 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
| 33263 | 233 guiExit(EXIT_ERROR); |
| 32984 | 234 } |
| 23077 | 235 |
| 32984 | 236 if (gui_save_pos) { |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
237 if (gui_main_pos_x != -3) |
| 33219 | 238 appMPlayer.main.x = gui_main_pos_x; |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
239 if (gui_main_pos_y != -3) |
| 33219 | 240 appMPlayer.main.y = gui_main_pos_y; |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
241 if (gui_sub_pos_x != -3) |
| 33219 | 242 appMPlayer.sub.x = gui_sub_pos_x; |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
243 if (gui_sub_pos_y != -3) |
| 33219 | 244 appMPlayer.sub.y = gui_sub_pos_y; |
| 32984 | 245 } |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
246 |
| 32984 | 247 if (WinID > 0) { |
| 248 appMPlayer.subWindow.Parent = WinID; | |
| 249 appMPlayer.sub.x = 0; | |
| 250 appMPlayer.sub.y = 0; | |
| 251 } | |
| 23077 | 252 |
| 32984 | 253 if (guiWinID >= 0) |
| 254 appMPlayer.mainWindow.Parent = guiWinID; | |
| 23077 | 255 |
| 32984 | 256 wsCreateWindow(&appMPlayer.subWindow, appMPlayer.sub.x, appMPlayer.sub.y, appMPlayer.sub.width, appMPlayer.sub.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsHideWindow, "MPlayer - Video"); |
| 257 wsDestroyImage(&appMPlayer.subWindow); | |
| 258 wsCreateImage(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Width, appMPlayer.sub.Bitmap.Height); | |
| 259 wsXDNDMakeAwareness(&appMPlayer.subWindow); | |
| 260 | |
| 261 mplMenuInit(); | |
| 262 mplPBInit(); | |
| 23077 | 263 |
| 264 // i=wsHideFrame|wsMaxSize|wsHideWindow; | |
| 265 // if ( appMPlayer.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow; | |
| 32984 | 266 i = wsShowFrame | wsMaxSize | wsHideWindow; |
| 267 wsCreateWindow(&appMPlayer.mainWindow, appMPlayer.main.x, appMPlayer.main.y, appMPlayer.main.width, appMPlayer.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, i, "MPlayer"); | |
| 268 wsSetShape(&appMPlayer.mainWindow, appMPlayer.main.Mask.Image); | |
| 269 wsXDNDMakeAwareness(&appMPlayer.mainWindow); | |
| 23077 | 270 |
| 271 #ifdef DEBUG | |
| 32984 | 272 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[main] depth on screen: %d\n", wsDepthOnScreen); |
| 273 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[main] parent: 0x%x\n", (int)appMPlayer.mainWindow.WindowID); | |
| 274 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[main] sub: 0x%x\n", (int)appMPlayer.subWindow.WindowID); | |
| 23077 | 275 #endif |
| 276 | |
| 32984 | 277 appMPlayer.mainWindow.ReDraw = (void *)mplMainDraw; |
| 278 appMPlayer.mainWindow.MouseHandler = mplMainMouseHandle; | |
| 279 appMPlayer.mainWindow.KeyHandler = mplMainKeyHandle; | |
| 280 appMPlayer.mainWindow.DandDHandler = mplDandDHandler; | |
| 281 | |
| 282 appMPlayer.subWindow.ReDraw = (void *)mplSubDraw; | |
| 283 appMPlayer.subWindow.MouseHandler = mplSubMouseHandle; | |
| 284 appMPlayer.subWindow.KeyHandler = mplMainKeyHandle; | |
| 285 appMPlayer.subWindow.DandDHandler = mplDandDHandler; | |
| 23077 | 286 |
| 32984 | 287 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); |
| 288 wsClearWindow(appMPlayer.subWindow); | |
| 23077 | 289 |
| 32984 | 290 if (appMPlayer.sub.Bitmap.Image) |
| 291 wsConvert(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Image, appMPlayer.sub.Bitmap.ImageSize); | |
| 292 | |
| 293 btnModify(evSetVolume, guiIntfStruct.Volume); | |
| 294 btnModify(evSetBalance, guiIntfStruct.Balance); | |
| 295 btnModify(evSetMoviePosition, guiIntfStruct.Position); | |
| 23077 | 296 |
| 32984 | 297 wsSetIcon(wsDisplay, appMPlayer.mainWindow.WindowID, guiIcon, guiIconMask); |
| 298 wsSetIcon(wsDisplay, appMPlayer.subWindow.WindowID, guiIcon, guiIconMask); | |
| 299 | |
| 300 guiIntfStruct.Playing = 0; | |
| 23077 | 301 |
| 32984 | 302 if (!appMPlayer.mainDecoration) |
| 303 wsWindowDecoration(&appMPlayer.mainWindow, 0); | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
304 |
| 32984 | 305 wsVisibleWindow(&appMPlayer.mainWindow, wsShowWindow); |
| 23077 | 306 |
| 307 #if 0 | |
| 32984 | 308 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); |
| 309 { | |
| 310 XEvent xev; | |
| 23077 | 311 |
| 32984 | 312 do |
| 313 XNextEvent(wsDisplay, &xev); | |
| 314 while (xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID); | |
| 315 | |
| 316 appMPlayer.subWindow.Mapped = wsMapped; | |
| 317 } | |
| 318 | |
| 319 if (!fullscreen) | |
| 320 fullscreen = gtkLoadFullscreen; | |
| 23077 | 321 |
| 32984 | 322 if (fullscreen) { |
| 23077 | 323 mplFullScreen(); |
| 32984 | 324 btnModify(evFullScreen, btnPressed); |
| 325 } | |
| 326 #else | |
| 327 if (!fullscreen) | |
| 328 fullscreen = gtkLoadFullscreen; | |
| 329 | |
| 330 if (gtkShowVideoWindow) { | |
| 331 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
| 332 { | |
| 333 XEvent xev; | |
| 334 | |
| 335 do | |
| 336 XNextEvent(wsDisplay, &xev); | |
| 337 while (xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID); | |
| 338 | |
| 339 appMPlayer.subWindow.Mapped = wsMapped; | |
| 340 } | |
| 23077 | 341 |
| 32984 | 342 if (fullscreen) { |
| 343 mplFullScreen(); | |
| 344 btnModify(evFullScreen, btnPressed); | |
| 345 } | |
| 346 } else { | |
| 347 if (fullscreen) { | |
| 348 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
| 349 { | |
| 350 XEvent xev; | |
| 351 | |
| 352 do | |
| 353 XNextEvent(wsDisplay, &xev); | |
| 354 while (xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID); | |
| 355 | |
| 356 appMPlayer.subWindow.Mapped = wsMapped; | |
| 357 } | |
| 358 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
| 359 mplFullScreen(); | |
| 360 btnModify(evFullScreen, btnPressed); | |
| 361 } | |
| 362 } | |
| 23077 | 363 #endif |
| 32984 | 364 |
| 365 mplSubRender = 1; | |
| 366 | |
| 367 if (filename) | |
| 368 mplSetFileName(NULL, filename, STREAMTYPE_FILE); | |
| 23077 | 369 |
| 32984 | 370 if (plCurrent && !filename) |
| 371 mplSetFileName(plCurrent->path, plCurrent->name, STREAMTYPE_FILE); | |
| 372 | |
| 373 if (subdata) | |
| 374 guiSetFilename(guiIntfStruct.Subtitlename, subdata->filename); | |
| 375 | |
| 376 guiLoadFont(); | |
| 33265 | 377 |
| 378 initialized = 1; | |
| 23077 | 379 } |
| 380 | |
| 32984 | 381 void guiDone(void) |
| 23077 | 382 { |
| 33307 | 383 if (initialized) { |
| 33308 | 384 mplMainRender = 0; |
| 32984 | 385 |
| 33308 | 386 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] done.\n"); |
| 23077 | 387 |
| 33308 | 388 if (gui_save_pos) { |
| 389 gui_main_pos_x = appMPlayer.mainWindow.X; | |
| 390 gui_main_pos_y = appMPlayer.mainWindow.Y; | |
| 391 gui_sub_pos_x = appMPlayer.subWindow.X; | |
| 392 gui_sub_pos_y = appMPlayer.subWindow.Y; | |
| 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(); |
| 407 | |
| 408 if (gui_conf) { | |
| 409 m_config_free(gui_conf); | |
| 410 gui_conf = NULL; | |
| 411 } | |
| 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) | |
| 452 mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name); | |
| 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 { |
| 32984 | 468 if (guiIntfStruct.Playing == 0) { |
| 469 guiIntfStruct.SubtitleChanged = 1; // what is this for? (mw) | |
| 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 | |
| 504 subdata = sub_read_file(name, guiIntfStruct.FPS); | |
| 505 | |
| 506 if (!subdata) | |
| 507 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name); | |
| 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 | |
| 32984 | 549 mp_msg(MSGT_GPLAYER, MSGL_STATUS, 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 |
|
33395
4e9058b47bde
Cosmetic: Remove braces and adjust indent after r33481.
ib
parents:
33394
diff
changeset
|
562 if (guiIntfStruct.mpcontext) |
|
4e9058b47bde
Cosmetic: Remove braces and adjust indent after r33481.
ib
parents:
33394
diff
changeset
|
563 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); |
| 23077 | 564 |
| 32984 | 565 switch (type) { |
| 566 case guiXEvent: | |
| 567 guiIntfStruct.event_struct = arg; | |
| 568 wsEvents(wsDisplay, arg, NULL); | |
| 23077 | 569 gtkEventHandling(); |
| 570 break; | |
| 32984 | 571 |
| 572 case guiCEvent: | |
| 573 | |
| 574 switch ((int)arg) { | |
| 575 case guiSetPlay: | |
| 576 guiIntfStruct.Playing = 1; | |
| 577 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
| 578 break; | |
| 579 | |
| 580 case guiSetStop: | |
| 581 guiIntfStruct.Playing = 0; | |
| 582 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
| 583 break; | |
| 584 | |
| 585 case guiSetPause: | |
| 586 guiIntfStruct.Playing = 2; | |
| 587 break; | |
| 588 } | |
| 589 | |
| 590 mplState(); | |
| 23077 | 591 break; |
| 32984 | 592 |
| 593 case guiSetState: | |
| 594 mplState(); | |
| 595 break; | |
| 596 | |
| 597 case guiSetFileName: | |
| 598 if (arg) | |
| 599 guiSetFilename(guiIntfStruct.Filename, arg); | |
| 23077 | 600 break; |
| 32984 | 601 |
| 602 case guiSetAudioOnly: | |
| 603 | |
| 604 guiIntfStruct.AudioOnly = (int)arg; | |
| 605 | |
| 606 if ((int)arg) { | |
| 607 guiIntfStruct.NoWindow = True; | |
| 608 wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow); | |
| 609 } else | |
| 610 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
| 611 | |
| 23077 | 612 break; |
| 32984 | 613 |
| 614 case guiSetContext: | |
| 615 guiIntfStruct.mpcontext = arg; | |
| 616 // NOTE TO MYSELF: is break missing? | |
| 617 | |
| 618 case guiSetDemuxer: | |
| 619 guiIntfStruct.demuxer = arg; | |
| 620 break; | |
| 621 | |
| 622 case guiSetAfilter: | |
| 623 guiIntfStruct.afilter = arg; | |
| 624 break; | |
| 625 | |
| 626 case guiSetShVideo: | |
| 627 | |
| 628 if (!appMPlayer.subWindow.isFullScreen) { | |
| 629 wsResizeWindow(&appMPlayer.subWindow, vo_dwidth, vo_dheight); | |
| 630 wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y); | |
| 631 } | |
| 632 | |
| 633 guiIntfStruct.MovieWidth = vo_dwidth; | |
| 634 guiIntfStruct.MovieHeight = vo_dheight; | |
| 635 | |
| 636 if (guiWinID >= 0) | |
| 637 wsMoveWindow(&appMPlayer.mainWindow, 0, 0, vo_dheight); | |
| 638 | |
| 639 WinID = appMPlayer.subWindow.WindowID; | |
| 640 break; | |
| 641 | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
642 #ifdef CONFIG_DVDREAD |
| 32984 | 643 case guiSetDVD: |
| 644 guiIntfStruct.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
| 645 guiIntfStruct.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
| 646 guiIntfStruct.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
| 647 guiIntfStruct.DVD.nr_of_audio_channels = dvdp->nr_of_channels; | |
| 648 memcpy(guiIntfStruct.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
| 649 guiIntfStruct.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
| 650 memcpy(guiIntfStruct.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
| 651 guiIntfStruct.DVD.current_title = dvd_title + 1; | |
| 652 guiIntfStruct.DVD.current_chapter = dvd_chapter + 1; | |
| 653 guiIntfStruct.DVD.current_angle = dvd_angle + 1; | |
| 654 guiIntfStruct.Track = dvd_title + 1; | |
| 23077 | 655 break; |
| 656 #endif | |
| 32984 | 657 |
| 658 case guiSetStream: | |
| 659 | |
| 660 guiIntfStruct.StreamType = stream->type; | |
| 661 | |
| 662 switch (stream->type) { | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
663 #ifdef CONFIG_DVDREAD |
| 32984 | 664 case STREAMTYPE_DVD: |
| 665 guiGetEvent(guiSetDVD, (char *)stream->priv); | |
| 666 break; | |
| 23077 | 667 #endif |
| 32984 | 668 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
669 #ifdef CONFIG_VCD |
| 32984 | 670 case STREAMTYPE_VCD: |
| 33006 | 671 guiIntfStruct.VCDTracks = 0; |
| 672 stream_control(stream, STREAM_CTRL_GET_NUM_CHAPTERS, &guiIntfStruct.VCDTracks); | |
| 32984 | 673 break; |
| 23077 | 674 #endif |
| 32984 | 675 |
| 676 default: | |
| 677 break; | |
| 678 } | |
| 679 | |
| 680 break; | |
| 681 | |
| 682 case guiIEvent: | |
| 683 | |
| 684 mp_msg(MSGT_GPLAYER, MSGL_V, "cmd: %d\n", (int)arg); | |
| 685 | |
| 686 switch ((int)arg) { | |
| 687 case MP_CMD_QUIT: | |
| 688 mplEventHandling(evExit, 0); | |
| 689 break; | |
| 23077 | 690 |
| 32984 | 691 case MP_CMD_VO_FULLSCREEN: |
| 692 mplEventHandling(evFullScreen, 0); | |
| 693 break; | |
| 694 } | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
695 |
| 32984 | 696 break; |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
697 |
| 32984 | 698 case guiReDraw: |
| 699 mplEventHandling(evRedraw, 0); | |
| 700 break; | |
| 701 | |
| 702 case guiSetVolume: | |
|
33393
eda1d0125255
Use mixer directly without checking for an audio_out.
reimar
parents:
33392
diff
changeset
|
703 if (mixer) { |
| 32984 | 704 float l, r; |
| 705 | |
| 706 mixer_getvolume(mixer, &l, &r); | |
| 707 guiIntfStruct.Volume = (r > l ? r : l); | |
| 23077 | 708 |
| 32984 | 709 if (r != l) |
| 710 guiIntfStruct.Balance = ((r - l) + 100) * 0.5f; | |
| 711 else | |
| 712 guiIntfStruct.Balance = 50.0f; | |
| 713 | |
| 714 btnModify(evSetVolume, guiIntfStruct.Volume); | |
| 715 btnModify(evSetBalance, guiIntfStruct.Balance); | |
| 716 } | |
| 717 break; | |
| 718 | |
| 719 case guiSetFileFormat: | |
| 720 guiIntfStruct.FileFormat = (int)arg; | |
| 721 break; | |
| 722 | |
| 723 case guiSetValues: | |
| 724 | |
| 725 // video | |
| 726 | |
| 727 guiIntfStruct.sh_video = arg; | |
| 728 | |
| 729 if (arg) { | |
| 730 sh_video_t *sh = arg; | |
| 731 guiIntfStruct.FPS = sh->fps; | |
| 732 } | |
| 733 | |
| 734 if (guiIntfStruct.NoWindow) | |
| 735 wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow); | |
| 736 | |
| 737 if (guiIntfStruct.StreamType == STREAMTYPE_STREAM) | |
| 738 btnSet(evSetMoviePosition, btnDisabled); | |
| 739 else | |
| 740 btnSet(evSetMoviePosition, btnReleased); | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
741 |
| 32984 | 742 // audio |
| 743 | |
|
33393
eda1d0125255
Use mixer directly without checking for an audio_out.
reimar
parents:
33392
diff
changeset
|
744 if (mixer) { |
| 32984 | 745 float l, r; |
| 746 | |
| 747 mixer_getvolume(mixer, &l, &r); | |
| 748 guiIntfStruct.Volume = (r > l ? r : l); | |
| 749 | |
| 750 if (r != l) | |
| 751 guiIntfStruct.Balance = ((r - l) + 100) * 0.5f; | |
| 752 else | |
| 753 guiIntfStruct.Balance = 50.0f; | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
754 |
| 32984 | 755 btnModify(evSetVolume, guiIntfStruct.Volume); |
| 756 btnModify(evSetBalance, guiIntfStruct.Balance); | |
| 757 } | |
| 758 | |
| 759 if (gtkEnableAudioEqualizer) { | |
| 760 equalizer_t eq; | |
| 761 int i, j; | |
| 23077 | 762 |
| 32984 | 763 for (i = 0; i < 6; i++) { |
| 764 for (j = 0; j < 10; j++) { | |
| 765 eq.channel = i; | |
| 766 eq.band = j; | |
| 767 eq.gain = gtkEquChannels[i][j]; | |
| 768 gtkSet(gtkSetEqualizer, 0, &eq); | |
| 769 } | |
| 770 } | |
| 771 } | |
| 772 | |
| 773 // subtitle | |
| 23077 | 774 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
775 #ifdef CONFIG_DXR3 |
| 32984 | 776 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3") && (guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS) && !gtkVfLAVC) { |
| 777 gtkMessageBox(GTK_MB_FATAL, MSGTR_NEEDLAVC); | |
| 778 guiIntfStruct.Playing = 0; | |
| 779 return True; | |
| 780 } | |
| 23077 | 781 #endif |
| 32984 | 782 |
| 783 break; | |
| 784 | |
| 785 case guiSetDefaults: | |
| 786 | |
| 787 // if ( guiIntfStruct.Playing == 1 && guiIntfStruct.FilenameChanged ) | |
| 788 if (guiIntfStruct.FilenameChanged) { | |
| 789 audio_id = -1; | |
| 790 video_id = -1; | |
| 791 dvdsub_id = -1; | |
| 792 vobsub_id = -1; | |
| 793 stream_cache_size = -1; | |
| 794 autosync = 0; | |
| 795 dvd_title = 0; | |
| 796 force_fps = 0; | |
| 797 } | |
| 798 | |
| 799 guiIntfStruct.demuxer = NULL; | |
| 800 guiIntfStruct.sh_video = NULL; | |
| 801 wsPostRedisplay(&appMPlayer.subWindow); | |
| 802 | |
| 803 break; | |
| 804 | |
| 805 case guiSetParameters: | |
| 806 | |
| 807 guiGetEvent(guiSetDefaults, NULL); | |
| 808 | |
| 809 switch (guiIntfStruct.StreamType) { | |
| 810 case STREAMTYPE_PLAYLIST: | |
| 811 break; | |
| 812 | |
| 813 #ifdef CONFIG_VCD | |
| 814 case STREAMTYPE_VCD: | |
| 815 { | |
| 816 char tmp[512]; | |
| 817 | |
| 818 sprintf(tmp, "vcd://%d", guiIntfStruct.Track + 1); | |
| 819 guiSetFilename(guiIntfStruct.Filename, tmp); | |
| 820 } | |
| 821 break; | |
| 822 #endif | |
| 823 | |
| 824 #ifdef CONFIG_DVDREAD | |
| 825 case STREAMTYPE_DVD: | |
| 826 { | |
| 827 char tmp[512]; | |
| 828 | |
| 829 sprintf(tmp, "dvd://%d", guiIntfStruct.Title); | |
| 830 guiSetFilename(guiIntfStruct.Filename, tmp); | |
| 831 } | |
| 832 | |
| 833 dvd_chapter = guiIntfStruct.Chapter; | |
| 834 dvd_angle = guiIntfStruct.Angle; | |
| 835 | |
| 836 break; | |
| 837 #endif | |
| 838 } | |
| 839 | |
| 840 // if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! | |
| 841 { | |
| 842 if (guiIntfStruct.Filename) | |
| 843 filename = gstrdup(guiIntfStruct.Filename); | |
| 844 else if (filename) | |
| 845 guiSetFilename(guiIntfStruct.Filename, filename); | |
| 846 } | |
| 847 | |
| 848 // video opts | |
| 849 | |
| 850 if (!video_driver_list) { | |
| 851 int i = 0; | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
852 |
| 32984 | 853 while (video_out_drivers[i++]) { |
| 854 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
| 855 gaddlist(&video_driver_list, (char *)video_out_drivers[i - 1]->info->short_name); | |
| 856 break; | |
| 857 } | |
| 858 } | |
| 859 } | |
| 860 | |
| 861 if (!video_driver_list && !video_driver_list[0]) { | |
| 33024 | 862 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_IDFGCVD); |
| 33263 | 863 guiExit(EXIT_ERROR); |
| 32984 | 864 } |
| 865 | |
| 866 { | |
| 867 int i = 0; | |
| 868 | |
| 869 guiIntfStruct.NoWindow = False; | |
| 870 | |
| 871 while (video_out_drivers[i++]) { | |
| 872 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
| 873 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)) { | |
| 874 guiIntfStruct.NoWindow = True; | |
| 875 break; | |
| 876 } | |
| 877 } | |
| 878 } | |
| 879 } | |
| 880 | |
| 881 #ifdef CONFIG_DXR3 | |
| 882 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3")) | |
| 883 if (guiIntfStruct.StreamType != STREAMTYPE_DVD && guiIntfStruct.StreamType != STREAMTYPE_VCD) | |
| 884 if (gtkVfLAVC) | |
| 885 add_vf("lavc"); | |
| 886 #endif | |
| 887 | |
| 888 if (gtkVfPP) | |
| 889 add_vf("pp"); | |
| 890 | |
| 891 // audio opts | |
| 892 | |
| 893 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
| 894 if (gtkAONorm) | |
| 895 greplace(&af_cfg.list, "volnorm", "volnorm"); | |
| 896 | |
| 897 if (gtkEnableAudioEqualizer) | |
| 898 greplace(&af_cfg.list, "equalizer", "equalizer"); | |
| 899 | |
| 900 if (gtkAOExtraStereo) { | |
| 901 char *name; | |
| 902 | |
| 903 name = malloc(12 + 20 + 1); | |
| 904 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
| 905 name[12 + 20] = 0; | |
| 906 greplace(&af_cfg.list, "extrastereo", name); | |
| 907 free(name); | |
| 908 } | |
| 909 | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
910 #ifdef CONFIG_OSS_AUDIO |
| 32984 | 911 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "oss", 3)) { |
| 912 char *tmp; | |
| 913 | |
| 914 mixer_device = gtkAOOSSMixer; | |
| 915 mixer_channel = gtkAOOSSMixerChannel; | |
| 916 | |
| 917 if (gtkAOOSSDevice) { | |
| 918 tmp = calloc(1, strlen(gtkAOOSSDevice) + 7); | |
| 919 sprintf(tmp, "oss:%s", gtkAOOSSDevice); | |
| 920 } else | |
| 921 tmp = strdup("oss"); | |
| 922 | |
| 923 gaddlist(&audio_driver_list, tmp); | |
| 924 free(tmp); | |
| 925 } | |
| 23077 | 926 #endif |
| 32984 | 927 |
|
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27387
diff
changeset
|
928 #ifdef CONFIG_ALSA |
| 32984 | 929 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "alsa", 4)) { |
| 930 char *tmp; | |
| 931 | |
| 932 mixer_device = gtkAOALSAMixer; | |
| 933 mixer_channel = gtkAOALSAMixerChannel; | |
| 934 | |
| 935 if (gtkAOALSADevice) { | |
| 936 tmp = calloc(1, strlen(gtkAOALSADevice) + 14); | |
| 937 sprintf(tmp, "alsa:device=%s", gtkAOALSADevice); | |
| 938 } else | |
| 939 tmp = strdup("alsa"); | |
| 940 | |
| 941 gaddlist(&audio_driver_list, tmp); | |
| 942 free(tmp); | |
| 943 } | |
| 23077 | 944 #endif |
| 32984 | 945 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
946 #ifdef CONFIG_SDL |
| 32984 | 947 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "sdl", 3)) { |
| 948 char *tmp; | |
| 949 | |
| 950 if (gtkAOSDLDriver) { | |
| 951 tmp = calloc(1, strlen(gtkAOSDLDriver) + 10); | |
| 952 sprintf(tmp, "sdl:%s", gtkAOSDLDriver); | |
| 953 } else | |
| 954 tmp = strdup("sdl"); | |
| 955 | |
| 956 gaddlist(&audio_driver_list, tmp); | |
| 957 free(tmp); | |
| 958 } | |
| 23077 | 959 #endif |
| 32984 | 960 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
961 #ifdef CONFIG_ESD |
| 32984 | 962 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "esd", 3)) { |
| 963 char *tmp; | |
| 964 | |
| 965 if (gtkAOESDDevice) { | |
| 966 tmp = calloc(1, strlen(gtkAOESDDevice) + 10); | |
| 967 sprintf(tmp, "esd:%s", gtkAOESDDevice); | |
| 968 } else | |
| 969 tmp = strdup("esd"); | |
| 970 | |
| 971 gaddlist(&audio_driver_list, tmp); | |
| 972 free(tmp); | |
| 973 } | |
| 23077 | 974 #endif |
| 32984 | 975 |
| 976 // subtitle | |
| 977 | |
| 978 // subdata->filename=gstrdup( guiIntfStruct.Subtitlename ); | |
| 979 stream_dump_type = 0; | |
| 980 | |
| 981 if (gtkSubDumpMPSub) | |
| 982 stream_dump_type = 4; | |
| 983 | |
| 984 if (gtkSubDumpSrt) | |
| 985 stream_dump_type = 6; | |
| 986 | |
| 987 gtkSubDumpMPSub = gtkSubDumpSrt = 0; | |
| 23077 | 988 guiLoadFont(); |
| 989 | |
| 32984 | 990 // misc |
| 991 | |
| 992 if (gtkCacheOn) | |
| 993 stream_cache_size = gtkCacheSize; | |
| 994 | |
| 995 if (gtkAutoSyncOn) | |
| 996 autosync = gtkAutoSync; | |
| 23077 | 997 |
| 32984 | 998 if (guiIntfStruct.AudioFile) |
| 999 audio_stream = gstrdup(guiIntfStruct.AudioFile); | |
| 1000 else if (guiIntfStruct.FilenameChanged) | |
| 1001 gfree((void **)&audio_stream); | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1002 |
| 32984 | 1003 // audio_stream = NULL; |
| 1004 | |
| 1005 guiIntfStruct.DiskChanged = 0; | |
| 1006 guiIntfStruct.FilenameChanged = 0; | |
| 1007 guiIntfStruct.NewPlay = 0; | |
| 23077 | 1008 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
1009 #ifdef CONFIG_ASS |
| 32984 | 1010 ass_enabled = gtkASS.enabled; |
| 1011 ass_use_margins = gtkASS.use_margins; | |
| 1012 ass_top_margin = gtkASS.top_margin; | |
| 23077 | 1013 ass_bottom_margin = gtkASS.bottom_margin; |
| 1014 #endif | |
| 1015 | |
| 32984 | 1016 break; |
| 1017 } | |
| 1018 | |
| 1019 return False; | |
| 23077 | 1020 } |
| 1021 | |
| 32984 | 1022 void guiEventHandling(void) |
| 23077 | 1023 { |
| 32984 | 1024 if (!guiIntfStruct.Playing || guiIntfStruct.NoWindow) |
| 1025 wsHandleEvents(); | |
| 1026 | |
| 1027 gtkEventHandling(); | |
| 23077 | 1028 } |
| 1029 | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1030 // --- |
| 32984 | 1031 #if defined(MP_DEBUG) && 0 |
| 1032 void list(void) | |
| 1033 { | |
| 1034 plItem *next = plList; | |
| 23077 | 1035 |
| 32984 | 1036 printf("--- list ---\n"); |
| 23077 | 1037 |
| 32984 | 1038 while (next || next->next) { |
| 1039 printf("item: %s/%s\n", next->path, next->name); | |
| 1040 | |
| 1041 if (next->next) | |
| 1042 next = next->next; | |
| 1043 else | |
| 1044 break; | |
| 1045 } | |
| 1046 | |
| 1047 printf("--- end of list ---\n"); | |
| 23077 | 1048 } |
| 1049 #else | |
| 1050 #define list(); | |
| 1051 #endif | |
| 1052 | |
| 32984 | 1053 void *gtkSet(int cmd, float fparam, void *vparam) |
| 23077 | 1054 { |
| 32984 | 1055 equalizer_t *eq = (equalizer_t *)vparam; |
| 1056 plItem *item = (plItem *)vparam; | |
| 1057 URLItem *url_item = (URLItem *)vparam; | |
| 1058 int is_added = True; | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1059 |
| 32984 | 1060 switch (cmd) { |
| 1061 // handle playlist | |
| 1062 | |
| 1063 // add item to playlist | |
| 1064 case gtkAddPlItem: | |
| 23077 | 1065 |
| 32984 | 1066 if (plList) { |
| 1067 plItem *next = plList; | |
| 1068 | |
| 1069 while (next->next) | |
| 1070 // { | |
| 1071 // printf( "%s\n",next->name ); | |
| 1072 next = next->next; | |
| 1073 // } | |
| 1074 | |
| 1075 next->next = item; | |
| 1076 item->prev = next; | |
| 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 | |
| 1104 // get current item from playlist | |
| 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 |
| 1125 case gtkGetPrevPlItem: | |
| 1126 if (plCurrent && plCurrent->prev) { | |
| 1127 plCurrent = plCurrent->prev; | |
| 1128 // if ( !plCurrent && plList ) plCurrent=plList; | |
| 1129 return plCurrent; | |
| 1130 } | |
| 33053 | 1131 |
| 23077 | 1132 return NULL; |
| 32984 | 1133 |
| 1134 // set current item | |
| 1135 case gtkSetCurrPlItem: | |
| 1136 plCurrent = item; | |
| 1137 return plCurrent; | |
| 1138 | |
| 1139 // get current item | |
| 1140 case gtkGetCurrPlItem: | |
| 23077 | 1141 return plCurrent; |
| 32984 | 1142 |
| 1143 // delete current item | |
| 1144 case gtkDelCurrPlItem: | |
| 1145 { | |
| 1146 plItem *curr = plCurrent; | |
| 1147 | |
| 1148 if (!curr) | |
| 1149 return NULL; | |
| 23077 | 1150 |
| 32984 | 1151 if (curr->prev) |
| 1152 curr->prev->next = curr->next; | |
| 1153 if (curr->next) | |
| 1154 curr->next->prev = curr->prev; | |
| 1155 if (curr == plList) | |
| 1156 plList = curr->next; | |
| 1157 | |
| 1158 plCurrent = curr->next; | |
| 1159 | |
| 1160 // free it | |
| 1161 free(curr->path); | |
| 1162 free(curr->name); | |
| 1163 free(curr); | |
| 1164 } | |
| 1165 | |
| 1166 mplCurr(); // instead of using mplNext && mplPrev | |
| 33053 | 1167 |
| 32984 | 1168 return plCurrent; |
| 1169 | |
| 1170 // delete list | |
| 1171 case gtkDelPl: | |
| 1172 { | |
| 1173 plItem *curr = plList; | |
| 1174 plItem *next; | |
| 1175 | |
| 1176 if (!plList) | |
| 1177 return NULL; | |
| 23077 | 1178 |
| 32984 | 1179 if (!curr->next) { |
| 1180 free(curr->path); | |
| 1181 free(curr->name); | |
| 1182 free(curr); | |
| 1183 } else { | |
| 1184 while (curr->next) { | |
| 1185 next = curr->next; | |
| 1186 free(curr->path); | |
| 1187 free(curr->name); | |
| 1188 free(curr); | |
| 1189 curr = next; | |
| 1190 } | |
| 1191 } | |
| 1192 | |
| 1193 plList = NULL; | |
| 1194 plCurrent = NULL; | |
| 1195 } | |
| 33053 | 1196 |
| 23077 | 1197 return NULL; |
| 32984 | 1198 |
| 1199 // handle url | |
| 1200 case gtkAddURLItem: | |
| 1201 if (URLList) { | |
| 1202 URLItem *next_url = URLList; | |
| 1203 is_added = False; | |
| 1204 | |
| 1205 while (next_url->next) { | |
| 1206 if (!gstrcmp(next_url->url, url_item->url)) { | |
| 1207 is_added = True; | |
| 1208 break; | |
| 1209 } | |
| 1210 | |
| 1211 next_url = next_url->next; | |
| 1212 } | |
| 1213 | |
| 1214 if (!is_added && gstrcmp(next_url->url, url_item->url)) | |
| 1215 next_url->next = url_item; | |
| 1216 } else { | |
| 1217 url_item->next = NULL; | |
| 1218 URLList = url_item; | |
| 1219 } | |
| 33053 | 1220 |
| 23077 | 1221 return NULL; |
| 32984 | 1222 |
| 1223 // subtitle | |
| 1224 | |
| 27393 | 1225 #ifndef CONFIG_FREETYPE |
| 32984 | 1226 case gtkSetFontFactor: |
| 1227 font_factor = fparam; | |
| 1228 guiLoadFont(); | |
| 1229 return NULL; | |
| 23077 | 1230 #else |
| 32984 | 1231 case gtkSetFontOutLine: |
| 1232 subtitle_font_thickness = (8.0f / 100.0f) * fparam; | |
| 1233 guiLoadFont(); | |
| 1234 return NULL; | |
| 1235 | |
| 1236 case gtkSetFontBlur: | |
| 1237 subtitle_font_radius = (8.0f / 100.0f) * fparam; | |
| 1238 guiLoadFont(); | |
| 1239 return NULL; | |
| 1240 | |
| 1241 case gtkSetFontTextScale: | |
| 1242 text_font_scale_factor = fparam; | |
| 1243 guiLoadFont(); | |
| 1244 return NULL; | |
| 1245 | |
| 1246 case gtkSetFontOSDScale: | |
| 1247 osd_font_scale_factor = fparam; | |
| 1248 guiLoadFont(); | |
| 1249 return NULL; | |
| 1250 | |
| 1251 case gtkSetFontEncoding: | |
| 1252 gfree((void **)&subtitle_font_encoding); | |
| 1253 subtitle_font_encoding = gstrdup((char *)vparam); | |
| 1254 guiLoadFont(); | |
| 1255 return NULL; | |
| 1256 | |
| 1257 case gtkSetFontAutoScale: | |
| 1258 subtitle_autoscale = (int)fparam; | |
| 1259 guiLoadFont(); | |
| 1260 return NULL; | |
| 23077 | 1261 #endif |
| 32984 | 1262 |
| 27393 | 1263 #ifdef CONFIG_ICONV |
| 32984 | 1264 case gtkSetSubEncoding: |
| 1265 gfree((void **)&sub_cp); | |
| 1266 sub_cp = gstrdup((char *)vparam); | |
| 1267 break; | |
| 23077 | 1268 #endif |
| 32984 | 1269 |
| 1270 // misc | |
| 1271 | |
| 1272 case gtkClearStruct: | |
| 1273 | |
| 1274 if ((unsigned int)vparam & guiFilenames) { | |
| 1275 gfree((void **)&guiIntfStruct.Filename); | |
| 1276 gfree((void **)&guiIntfStruct.Subtitlename); | |
| 1277 gfree((void **)&guiIntfStruct.AudioFile); | |
| 1278 gtkSet(gtkDelPl, 0, NULL); | |
| 1279 } | |
| 1280 | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
1281 #ifdef CONFIG_DVDREAD |
| 32984 | 1282 if ((unsigned int)vparam & guiDVD) |
| 1283 memset(&guiIntfStruct.DVD, 0, sizeof(guiDVDStruct)); | |
| 23077 | 1284 #endif |
| 32984 | 1285 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
1286 #ifdef CONFIG_VCD |
| 32984 | 1287 if ((unsigned int)vparam & guiVCD) |
| 1288 guiIntfStruct.VCDTracks = 0; | |
| 23077 | 1289 #endif |
| 32984 | 1290 |
| 1291 return NULL; | |
| 1292 | |
| 1293 case gtkSetExtraStereo: | |
| 1294 gtkAOExtraStereoMul = fparam; | |
| 23077 | 1295 if (guiIntfStruct.afilter) |
| 32984 | 1296 af_control_any_rev(guiIntfStruct.afilter, AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); |
| 1297 return NULL; | |
| 1298 | |
| 1299 case gtkSetPanscan: | |
| 1300 { | |
| 1301 mp_cmd_t *mp_cmd; | |
| 1302 | |
| 1303 mp_cmd = calloc(1, sizeof(*mp_cmd)); | |
| 1304 mp_cmd->id = MP_CMD_PANSCAN; | |
| 1305 mp_cmd->name = strdup("panscan"); | |
| 1306 mp_cmd->args[0].v.f = fparam; | |
| 1307 mp_cmd->args[1].v.i = 1; | |
| 1308 mp_input_queue_cmd(mp_cmd); | |
| 1309 } | |
| 33053 | 1310 |
| 23077 | 1311 return NULL; |
| 32984 | 1312 |
| 1313 case gtkSetAutoq: | |
| 1314 auto_quality = (int)fparam; | |
| 1315 return NULL; | |
| 1316 | |
| 1317 // set equalizers | |
| 1318 | |
| 1319 case gtkSetContrast: | |
| 1320 if (guiIntfStruct.sh_video) | |
| 1321 set_video_colors(guiIntfStruct.sh_video, "contrast", (int)fparam); | |
| 1322 return NULL; | |
| 1323 | |
| 1324 case gtkSetBrightness: | |
| 1325 if (guiIntfStruct.sh_video) | |
| 1326 set_video_colors(guiIntfStruct.sh_video, "brightness", (int)fparam); | |
| 1327 return NULL; | |
| 1328 | |
| 1329 case gtkSetHue: | |
| 1330 if (guiIntfStruct.sh_video) | |
| 1331 set_video_colors(guiIntfStruct.sh_video, "hue", (int)fparam); | |
| 23077 | 1332 return NULL; |
| 32984 | 1333 |
| 1334 case gtkSetSaturation: | |
| 1335 if (guiIntfStruct.sh_video) | |
| 1336 set_video_colors(guiIntfStruct.sh_video, "saturation", (int)fparam); | |
| 1337 return NULL; | |
| 1338 | |
| 1339 case gtkSetEqualizer: | |
| 1340 { | |
| 23077 | 1341 af_control_ext_t tmp; |
| 32984 | 1342 |
| 1343 if (eq) { | |
| 1344 gtkEquChannels[eq->channel][eq->band] = eq->gain; | |
| 1345 tmp.ch = eq->channel; | |
| 1346 tmp.arg = gtkEquChannels[eq->channel]; | |
| 1347 | |
| 1348 if (guiIntfStruct.afilter) | |
| 1349 af_control_any_rev(guiIntfStruct.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
| 1350 } else { | |
| 1351 int i; | |
| 1352 | |
| 1353 memset(gtkEquChannels, 0, sizeof(gtkEquChannels)); | |
| 1354 | |
| 1355 if (guiIntfStruct.afilter) { | |
| 1356 for (i = 0; i < 6; i++) { | |
| 1357 tmp.ch = i; | |
| 1358 tmp.arg = gtkEquChannels[i]; | |
| 1359 af_control_any_rev(guiIntfStruct.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
| 1360 } | |
| 1361 } | |
| 1362 } | |
| 1363 | |
| 1364 return NULL; | |
| 1365 } | |
| 1366 } | |
| 1367 | |
| 1368 return NULL; | |
| 23077 | 1369 } |
| 1370 | |
| 32984 | 1371 // This function adds/inserts one file into the gui playlist. |
| 1372 static int import_file_into_gui(char *temp, int insert) | |
| 1373 { | |
| 1374 char *filename, *pathname; | |
| 1375 plItem *item; | |
| 23077 | 1376 |
| 32984 | 1377 filename = strdup(mp_basename(temp)); |
| 1378 pathname = strdup(temp); | |
| 1379 | |
| 1380 if (strlen(pathname) - strlen(filename) > 0) | |
| 1381 pathname[strlen(pathname) - strlen(filename) - 1] = 0; // we have some path, so remove / at end | |
| 1382 else | |
| 1383 pathname[strlen(pathname) - strlen(filename)] = 0; | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1384 |
| 32984 | 1385 // NOTE TO MYSELF: FIXME: Change to MSGL_DBG2? |
| 1386 mp_msg(MSGT_PLAYTREE, MSGL_V, "Adding filename %s && pathname %s\n", filename, pathname); | |
| 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 | |
| 32984 | 1423 mplCurr(); // update filename |
| 1424 mplGotoTheNext = 1; | |
| 23077 | 1425 |
| 32984 | 1426 if (!enqueue) |
| 1427 filename = guiIntfStruct.Filename; // Backward compatibility; if file is specified on commandline, | |
| 1428 // gmplayer does directly start in Play-Mode. | |
| 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 |
| 32984 | 1464 mplCurr(); // update filename |
| 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 } |
