Mercurial > mplayer.hg
annotate gui/interface.c @ 37080:0b0528ba3344
Add remove_vf().
(Currently unused, but we will need it soon.)
author | ib |
---|---|
date | Thu, 24 Apr 2014 13:51:20 +0000 |
parents | 83aa0570d6be |
children | e8559b9913ff |
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 |
33754 | 19 #include <stdarg.h> |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
20 #include <stdint.h> |
33754 | 21 #include <stdio.h> |
23077 | 22 #include <stdlib.h> |
23 #include <string.h> | |
24 | |
32984 | 25 #include "interface.h" |
35525 | 26 #include "app/app.h" |
36429 | 27 #include "app/cfg.h" |
35525 | 28 #include "app/gui.h" |
35529 | 29 #include "dialog/dialog.h" |
32984 | 30 #include "skin/skin.h" |
35772 | 31 #include "ui/actions.h" |
35528 | 32 #include "ui/ui.h" |
33741 | 33 #include "util/list.h" |
33739 | 34 #include "util/mem.h" |
33737 | 35 #include "util/string.h" |
23077 | 36 #include "wm/ws.h" |
37 #include "wm/wsxdnd.h" | |
38 | |
39 #include "access_mpcontext.h" | |
35462 | 40 #include "codec-cfg.h" |
32984 | 41 #include "config.h" |
23077 | 42 #include "help_mp.h" |
36032 | 43 #include "mixer.h" |
44 #include "mp_msg.h" | |
45 #include "mpcommon.h" | |
46 #include "mplayer.h" | |
47 #include "path.h" | |
32984 | 48 #include "input/input.h" |
49 #include "libaf/equalizer.h" | |
33689
8d0290220239
Replace numeric constants for gtkEquChannels array size.
ib
parents:
33688
diff
changeset
|
50 #include "libavutil/common.h" |
36966 | 51 #include "libmpcodecs/ad.h" |
32984 | 52 #include "libmpcodecs/dec_audio.h" |
53 #include "libmpcodecs/dec_video.h" | |
54 #include "libmpcodecs/vd.h" | |
55 #include "libmpcodecs/vf.h" | |
33398 | 56 #include "libvo/video_out.h" |
32984 | 57 #include "libvo/x11_common.h" |
36292 | 58 #include "osdep/timer.h" |
36869 | 59 #include "stream/stream.h" |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
60 #ifdef CONFIG_DVDREAD |
23077 | 61 #include "stream/stream_dvd.h" |
62 #endif | |
35523 | 63 #include "sub/font_load.h" |
64 #include "sub/sub.h" | |
65 #include "sub/subreader.h" | |
23077 | 66 |
35524 | 67 /** |
68 * @brief Initialize interface data. | |
69 */ | |
33662 | 70 guiInterface_t guiInfo = { |
35430
2d55540614a9
Move uiProcessNextInPlaylist to the guiInfo structure.
ib
parents:
35429
diff
changeset
|
71 .StreamType = STREAMTYPE_DUMMY, |
36960 | 72 .Volume = 50.0f, |
35430
2d55540614a9
Move uiProcessNextInPlaylist to the guiInfo structure.
ib
parents:
35429
diff
changeset
|
73 .Balance = 50.0f, |
35493 | 74 .PlaylistNext = True |
33662 | 75 }; |
23077 | 76 |
36049 | 77 static int guiInitialized; |
36650 | 78 static int orig_fontconfig; |
79 | |
80 /** | |
81 * @brief Set option 'fontconfig' depending on #font_name. | |
82 */ | |
83 static void set_fontconfig(void) | |
84 { | |
85 font_fontconfig = (font_name && strchr(font_name, '/') ? -1 : orig_fontconfig); | |
86 } | |
33265 | 87 |
37078 | 88 /** |
89 * @brief Add a video filter | |
90 * (or change the parameter/value pairs of an existing one). | |
91 * | |
92 * @param vf video filter to be added or changed | |
93 * @param argvf pointer to an array of (new) parameter/value pairs | |
94 */ | |
95 static void add_vf(const char *vf, const char *const *argvf) | |
96 { | |
97 if (vf_settings) { | |
98 int i = 0; | |
99 | |
100 while (vf_settings[i].name) { | |
101 if (strcmp(vf_settings[i].name, vf) == 0) | |
102 break; | |
103 | |
104 i++; | |
105 } | |
106 | |
107 if (vf_settings[i].name) { | |
108 listFree(&vf_settings[i].attribs); | |
109 vf_settings[i].attribs = listDup(argvf); | |
110 } else { | |
111 void *settings = realloc(vf_settings, (i + 2) * sizeof(m_obj_settings_t)); | |
112 | |
113 if (!settings) | |
114 return; | |
115 | |
116 vf_settings = settings; | |
117 vf_settings[i].name = strdup(vf); | |
118 vf_settings[i].attribs = listDup(argvf); | |
119 memset(&vf_settings[i + 1], 0, sizeof(m_obj_settings_t)); | |
120 } | |
121 } else { | |
122 vf_settings = calloc(2, sizeof(m_obj_settings_t)); | |
123 | |
124 if (!vf_settings) | |
125 return; | |
126 | |
127 vf_settings[0].name = strdup(vf); | |
128 vf_settings[0].attribs = listDup(argvf); | |
129 } | |
130 | |
131 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_AddingVideoFilter, vf); | |
132 } | |
133 | |
37079 | 134 /** |
135 * @brief Get a video filter's array of parameter/value pairs. | |
136 * | |
137 * @param vf video filter in question | |
138 * | |
139 * @return pointer to the array of parameter/value pairs | |
140 */ | |
141 static char **get_vf(const char *vf) | |
142 { | |
143 char **attribs = NULL; | |
144 | |
145 if (vf_settings) { | |
146 int i = 0; | |
147 | |
148 while (vf_settings[i].name) { | |
149 if (strcmp(vf_settings[i].name, vf) == 0) { | |
150 attribs = vf_settings[i].attribs; | |
151 break; | |
152 } | |
153 | |
154 i++; | |
155 } | |
156 } | |
157 | |
158 return attribs; | |
159 } | |
160 | |
37080 | 161 /** |
162 * @brief Remove a video filter. | |
163 * | |
164 * @param vf video filter to be removed | |
165 */ | |
166 static void remove_vf(char *vf) | |
167 { | |
168 if (vf_settings) { | |
169 int i = 0; | |
170 | |
171 while (vf_settings[i].name) { | |
172 if (strcmp(vf_settings[i].name, vf) == 0) { | |
173 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_RemovingVideoFilter, vf); | |
174 | |
175 free(vf_settings[i].name); | |
176 listFree(&vf_settings[i].attribs); | |
177 | |
178 do | |
179 memcpy(&vf_settings[i], &vf_settings[i + 1], sizeof(m_obj_settings_t)); | |
180 while (vf_settings[++i].name); | |
181 | |
182 break; | |
183 } | |
184 | |
185 i++; | |
186 } | |
187 } | |
188 } | |
189 | |
33745 | 190 /* MPlayer -> GUI */ |
191 | |
35524 | 192 /** |
193 * @brief Initialize and start the GUI. | |
194 */ | |
32984 | 195 void guiInit(void) |
23077 | 196 { |
35794 | 197 int ret; |
34664
4df4d842d5fb
Remove global variable pointing to current playlist item.
ib
parents:
34663
diff
changeset
|
198 plItem *playlist; |
23077 | 199 |
33530 | 200 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI init.\n"); |
201 | |
35627 | 202 /* check options */ |
203 | |
34403 | 204 if (!cdrom_device) |
205 cdrom_device = strdup(DEFAULT_CDROM_DEVICE); | |
206 if (!dvd_device) | |
207 dvd_device = strdup(DEFAULT_DVD_DEVICE); | |
35625 | 208 #ifdef CONFIG_DXR3 |
32984 | 209 if (!gtkDXR3Device) |
210 gtkDXR3Device = strdup("/dev/em8300-0"); | |
35625 | 211 #endif |
32927 | 212 |
32984 | 213 if (stream_cache_size > 0) { |
35493 | 214 gtkCacheOn = True; |
32984 | 215 gtkCacheSize = stream_cache_size; |
216 } else if (stream_cache_size == 0) | |
35493 | 217 gtkCacheOn = False; |
32984 | 218 |
219 if (autosync && (autosync != gtkAutoSync)) { | |
35493 | 220 gtkAutoSyncOn = True; |
32984 | 221 gtkAutoSync = autosync; |
222 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
223 |
32984 | 224 gtkASS.enabled = ass_enabled; |
225 gtkASS.use_margins = ass_use_margins; | |
226 gtkASS.top_margin = ass_top_margin; | |
227 gtkASS.bottom_margin = ass_bottom_margin; | |
23077 | 228 |
35627 | 229 /* initialize graphical user interfaces */ |
230 | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
231 wsInit(mDisplay); |
35629 | 232 gtkInit(mDisplayName); |
32984 | 233 |
34684 | 234 /* load skin */ |
32984 | 235 |
36043 | 236 skinDirInHome = get_path("skins"); |
237 skinDirInData = MPLAYER_DATADIR "/skins"; | |
32984 | 238 |
33985 | 239 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] skin directory #1: %s\n", skinDirInHome); |
36043 | 240 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] skin directory #2: %s\n", skinDirInData); |
32984 | 241 |
242 if (!skinName) | |
243 skinName = strdup("default"); | |
244 | |
35794 | 245 ret = skinRead(skinName); |
32984 | 246 |
35794 | 247 if (ret == -1 && strcmp(skinName, "default") != 0) { |
36694 | 248 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_GUI_MSG_SkinCfgSelectedNotFound, skinName); |
32984 | 249 |
250 skinName = strdup("default"); | |
35794 | 251 ret = skinRead(skinName); |
32984 | 252 } |
253 | |
35794 | 254 switch (ret) { |
32984 | 255 case -1: |
36694 | 256 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_GUI_MSG_SkinCfgNotFound, skinName); |
33768 | 257 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
23077 | 258 |
32984 | 259 case -2: |
36694 | 260 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_GUI_MSG_SkinCfgError, skinName); |
33768 | 261 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32984 | 262 } |
263 | |
34684 | 264 /* initialize windows */ |
32984 | 265 |
266 if (gui_save_pos) { | |
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
267 if (gui_main_pos_x != -3) |
33555 | 268 guiApp.main.x = gui_main_pos_x; |
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
269 if (gui_main_pos_y != -3) |
33555 | 270 guiApp.main.y = gui_main_pos_y; |
34697 | 271 if (gui_video_pos_x != -3) |
272 guiApp.video.x = gui_video_pos_x; | |
273 if (gui_video_pos_y != -3) | |
274 guiApp.video.y = gui_video_pos_y; | |
32984 | 275 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
276 |
32984 | 277 if (WinID > 0) { |
34697 | 278 guiApp.videoWindow.Parent = WinID; |
279 guiApp.video.x = 0; | |
280 guiApp.video.y = 0; | |
32984 | 281 } |
23077 | 282 |
32984 | 283 if (guiWinID >= 0) |
33555 | 284 guiApp.mainWindow.Parent = guiWinID; |
23077 | 285 |
35780 | 286 uiMainInit(); // main window must be first! |
35781 | 287 uiVideoInit(); // video window must be second! |
35780 | 288 uiPlaybarInit(); |
289 uiMenuInit(); | |
23077 | 290 |
36843 | 291 WinID = (Window)guiApp.videoWindow.WindowID; |
32984 | 292 |
36959
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
293 btnValue(evSetVolume, &guiInfo.Volume); |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
294 btnValue(evSetBalance, &guiInfo.Balance); |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
295 btnValue(evSetMoviePosition, &guiInfo.Position); |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
296 |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
297 if (guiInfo.Position) |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
298 uiEvent(evSetMoviePosition, guiInfo.Position); |
23077 | 299 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
300 wsWindowVisibility(&guiApp.mainWindow, wsShowWindow); |
23077 | 301 |
32984 | 302 if (gtkShowVideoWindow) { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
303 wsWindowVisibility(&guiApp.videoWindow, wsShowWindow); |
33960 | 304 |
35654 | 305 guiInfo.VideoWindow = True; |
23077 | 306 |
33960 | 307 if (gtkLoadFullscreen) |
33555 | 308 uiFullScreen(); |
33960 | 309 } else |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
310 wsWindowBackground(&guiApp.videoWindow, 0, 0, 0); |
32984 | 311 |
33960 | 312 if (gtkLoadFullscreen) |
33978 | 313 btnSet(evFullScreen, btnPressed); |
32984 | 314 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
315 guiInfo.Playing = GUI_STOP; |
33609 | 316 |
34664
4df4d842d5fb
Remove global variable pointing to current playlist item.
ib
parents:
34663
diff
changeset
|
317 playlist = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
4df4d842d5fb
Remove global variable pointing to current playlist item.
ib
parents:
34663
diff
changeset
|
318 |
4df4d842d5fb
Remove global variable pointing to current playlist item.
ib
parents:
34663
diff
changeset
|
319 if (playlist && !filename) { |
35452 | 320 uiSetFile(playlist->path, playlist->name, STREAMTYPE_FILE); |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
321 guiInfo.Tracks = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, 0); |
35489 | 322 guiInfo.Track = 1; |
323 filename = NULL; // don't start playing | |
34064 | 324 } |
32984 | 325 |
326 if (subdata) | |
33897 | 327 setdup(&guiInfo.SubtitleFilename, subdata->filename); |
32984 | 328 |
36650 | 329 orig_fontconfig = font_fontconfig; |
330 set_fontconfig(); | |
331 | |
36049 | 332 guiInitialized = True; |
23077 | 333 } |
334 | |
35524 | 335 /** |
336 * @brief Stop and finalize the GUI. | |
337 */ | |
32984 | 338 void guiDone(void) |
23077 | 339 { |
36049 | 340 if (guiInitialized) { |
33308 | 341 if (gui_save_pos) { |
34698 | 342 gui_main_pos_x = guiApp.mainWindow.X; |
343 gui_main_pos_y = guiApp.mainWindow.Y; | |
35664 | 344 gui_video_pos_x = guiApp.videoWindow.X; |
345 gui_video_pos_y = guiApp.videoWindow.Y; | |
33308 | 346 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
347 |
33308 | 348 ass_enabled = gtkASS.enabled; |
349 ass_use_margins = gtkASS.use_margins; | |
350 ass_top_margin = gtkASS.top_margin; | |
351 ass_bottom_margin = gtkASS.bottom_margin; | |
23077 | 352 |
33308 | 353 cfg_write(); |
35746 | 354 |
35796
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35794
diff
changeset
|
355 if (guiApp.menuIsPresent) |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35794
diff
changeset
|
356 uiMenuDone(); |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35794
diff
changeset
|
357 if (guiApp.playbarIsPresent) |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35794
diff
changeset
|
358 uiPlaybarDone(); |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35794
diff
changeset
|
359 |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35794
diff
changeset
|
360 uiVideoDone(); |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35794
diff
changeset
|
361 uiMainDone(); |
35746 | 362 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
363 wsDone(); |
33307 | 364 } |
33263 | 365 |
35549 | 366 uiUnsetFile(); |
34663 | 367 listMgr(PLAYLIST_DELETE, 0); |
368 listMgr(URLLIST_DELETE, 0); | |
35550 | 369 appFreeStruct(); |
33542 | 370 free(guiIcon.collection); |
33307 | 371 |
372 if (gui_conf) { | |
373 m_config_free(gui_conf); | |
374 gui_conf = NULL; | |
375 } | |
33530 | 376 |
377 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI done.\n"); | |
33263 | 378 } |
379 | |
35524 | 380 /** |
381 * @brief Issue a command to the GUI. | |
382 * | |
383 * @note The GUI is controlled by giving it commands. | |
384 * | |
385 * @param what command to be performed | |
386 * @param data pointer to data needed for the command | |
387 * | |
388 * @return #True (ok) or #False (error) | |
389 */ | |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
390 int gui(int what, void *data) |
23077 | 391 { |
36959
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
392 static float last_balance = -1.0f; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
393 #ifdef CONFIG_DVDREAD |
33687 | 394 dvd_priv_t *dvd; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
395 #endif |
36779 | 396 int idata = (intptr_t)data, msg, state; |
36456 | 397 stream_t *stream = NULL; |
36455 | 398 sh_audio_t *sh_audio; |
36966 | 399 const ad_functions_t *ad; |
36454 | 400 mixer_t *mixer; |
36944 | 401 float l, r, b; |
36457 | 402 plItem *next = NULL; |
23077 | 403 |
33726 | 404 switch (what) { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
405 case GUI_SET_CONTEXT: |
35541 | 406 |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
407 guiInfo.mpcontext = data; |
23077 | 408 break; |
32984 | 409 |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
410 case GUI_SET_STATE: |
32984 | 411 |
36779 | 412 switch (idata) { |
33631 | 413 case GUI_STOP: |
33614 | 414 case GUI_PLAY: |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
415 // if ( !gtkShowVideoWindow ) wsWindowVisibility( &guiApp.videoWindow,wsHideWindow ); |
33614 | 416 case GUI_PAUSE: |
36779 | 417 guiInfo.Playing = idata; |
32984 | 418 break; |
419 } | |
420 | |
33555 | 421 uiState(); |
23077 | 422 break; |
32984 | 423 |
36294 | 424 case GUI_REDRAW: |
425 | |
426 uiEvent(ivRedraw, 0); | |
35541 | 427 |
33901 | 428 if (!guiInfo.Playing || !guiInfo.VideoWindow) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
429 wsEvents(); |
36068 | 430 /* else it's handled by the vo driver calling GUI_HANDLE_X_EVENT */ |
35541 | 431 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
432 wsMouseAutohide(); |
36070 | 433 gtkEvents(); |
35541 | 434 |
33732 | 435 break; |
436 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
437 case GUI_RUN_COMMAND: |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
438 |
36779 | 439 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] GUI_RUN_COMMAND: %d\n", idata); |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
440 |
36779 | 441 switch (idata) { |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
442 case MP_CMD_VO_FULLSCREEN: |
35773 | 443 uiEvent(evFullScreen, True); |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
444 break; |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
445 |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
446 case MP_CMD_PLAY_TREE_STEP: |
35773 | 447 uiEvent(evNext, 0); |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
448 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
449 |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
450 case -MP_CMD_PLAY_TREE_STEP: |
35773 | 451 uiEvent(evPrev, 0); |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
452 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
453 |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
454 case MP_CMD_STOP: |
35773 | 455 uiEvent(evStop, 0); |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
456 break; |
33697 | 457 |
458 case MP_CMD_QUIT: | |
35773 | 459 uiEvent(evExit, 0); |
33697 | 460 break; |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
461 } |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
462 |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
463 break; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
464 |
34339 | 465 case GUI_RUN_MESSAGE: |
35541 | 466 |
34339 | 467 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] GUI_RUN_MESSAGE: %s\n", (const char *)data); |
468 msg = appFindMessage((const char *)data); | |
35541 | 469 |
34458 | 470 if ((msg == evMenu) || appFindItem(msg)) |
35773 | 471 uiEvent(msg, 0); |
35541 | 472 |
34339 | 473 break; |
474 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
475 case GUI_PREPARE: |
32984 | 476 |
36292 | 477 uiEvent(ivRedraw, True); |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
478 wsMouseVisibility(&guiApp.videoWindow, wsHideMouseCursor); |
36292 | 479 usec_sleep(20000); |
480 wsEvents(); | |
32984 | 481 |
36937
ad939f49bb28
Cosmetic: Rename guiInfo member NewPlay MediumChanged.
ib
parents:
36936
diff
changeset
|
482 if (guiInfo.MediumChanged == GUI_MEDIUM_NEW) { |
34052 | 483 audio_id = -1; |
484 video_id = -1; | |
485 dvdsub_id = -1; | |
486 vobsub_id = -1; | |
487 | |
488 stream_cache_size = -1; | |
489 autosync = 0; | |
490 force_fps = 0; | |
491 } | |
34032 | 492 |
33555 | 493 switch (guiInfo.StreamType) { |
34073 | 494 case STREAMTYPE_FILE: |
495 case STREAMTYPE_STREAM: | |
35484 | 496 filename = guiInfo.Filename; |
32984 | 497 break; |
498 | |
34387 | 499 case STREAMTYPE_CDDA: |
500 { | |
501 char tmp[512]; | |
502 | |
503 sprintf(tmp, "cdda://%d", guiInfo.Track); | |
35452 | 504 uiSetFile(NULL, tmp, SAME_STREAMTYPE); |
34387 | 505 } |
506 break; | |
507 | |
32984 | 508 case STREAMTYPE_VCD: |
509 { | |
510 char tmp[512]; | |
511 | |
33874 | 512 sprintf(tmp, "vcd://%d", guiInfo.Track); |
35452 | 513 uiSetFile(NULL, tmp, SAME_STREAMTYPE); |
32984 | 514 } |
515 break; | |
516 | |
517 case STREAMTYPE_DVD: | |
518 { | |
519 char tmp[512]; | |
520 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
521 sprintf(tmp, "dvd://%d", guiInfo.Track); |
35452 | 522 uiSetFile(NULL, tmp, SAME_STREAMTYPE); |
32984 | 523 } |
35168 | 524 #ifdef CONFIG_DVDREAD |
33555 | 525 dvd_chapter = guiInfo.Chapter; |
526 dvd_angle = guiInfo.Angle; | |
35168 | 527 #endif |
32984 | 528 break; |
36429 | 529 |
530 case STREAMTYPE_TV: | |
531 case STREAMTYPE_DVB: | |
532 { | |
533 char tmp[512]; | |
534 | |
535 sprintf(tmp, "%s://", guiTV[gui_tv_digital].SchemeName); | |
536 uiSetFile(NULL, tmp, SAME_STREAMTYPE); | |
537 } | |
32984 | 538 } |
539 | |
34684 | 540 /* video opts */ |
32984 | 541 |
542 if (!video_driver_list) { | |
543 int i = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
544 |
32984 | 545 while (video_out_drivers[i++]) { |
546 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
36841 | 547 listSet(&video_driver_list, video_out_drivers[i - 1]->info->short_name); |
32984 | 548 break; |
549 } | |
550 } | |
551 } | |
552 | |
553 if (!video_driver_list && !video_driver_list[0]) { | |
36694 | 554 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_GUI_MSG_VideoOutError); |
33768 | 555 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32984 | 556 } |
557 | |
558 { | |
559 int i = 0; | |
560 | |
36863 | 561 guiInfo.VideoWindow = False; |
32984 | 562 |
563 while (video_out_drivers[i++]) { | |
36864 | 564 if ((video_driver_list && !gstrcmp(video_driver_list[0], video_out_drivers[i - 1]->info->short_name)) && (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE)) { |
565 guiInfo.VideoWindow = True; | |
566 break; | |
567 } | |
32984 | 568 } |
569 } | |
570 | |
571 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3")) | |
33555 | 572 if (guiInfo.StreamType != STREAMTYPE_DVD && guiInfo.StreamType != STREAMTYPE_VCD) |
32984 | 573 if (gtkVfLAVC) |
37075 | 574 add_vf("lavc", NULL); |
32984 | 575 |
576 if (gtkVfPP) | |
37075 | 577 add_vf("pp", NULL); |
32984 | 578 |
34684 | 579 /* audio opts */ |
32984 | 580 |
581 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
582 if (gtkAONorm) | |
34610 | 583 listRepl(&af_cfg.list, "volnorm", "volnorm"); |
32984 | 584 |
585 if (gtkEnableAudioEqualizer) | |
34610 | 586 listRepl(&af_cfg.list, "equalizer", "equalizer"); |
32984 | 587 |
588 if (gtkAOExtraStereo) { | |
589 char *name; | |
590 | |
591 name = malloc(12 + 20 + 1); | |
592 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
593 name[12 + 20] = 0; | |
34610 | 594 listRepl(&af_cfg.list, "extrastereo", name); |
32984 | 595 free(name); |
596 } | |
597 | |
598 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "oss", 3)) { | |
599 mixer_device = gtkAOOSSMixer; | |
600 mixer_channel = gtkAOOSSMixerChannel; | |
601 | |
602 if (gtkAOOSSDevice) { | |
34625 | 603 char *tmp; |
34624 | 604 |
32984 | 605 tmp = calloc(1, strlen(gtkAOOSSDevice) + 7); |
606 sprintf(tmp, "oss:%s", gtkAOOSSDevice); | |
34625 | 607 listSet(&audio_driver_list, tmp); |
608 free(tmp); | |
34624 | 609 } |
32984 | 610 } |
611 | |
612 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "alsa", 4)) { | |
613 mixer_device = gtkAOALSAMixer; | |
614 mixer_channel = gtkAOALSAMixerChannel; | |
615 | |
616 if (gtkAOALSADevice) { | |
34625 | 617 char *tmp; |
34624 | 618 |
32984 | 619 tmp = calloc(1, strlen(gtkAOALSADevice) + 14); |
620 sprintf(tmp, "alsa:device=%s", gtkAOALSADevice); | |
34625 | 621 listSet(&audio_driver_list, tmp); |
622 free(tmp); | |
34624 | 623 } |
32984 | 624 } |
625 | |
626 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "sdl", 3)) { | |
34624 | 627 if (gtkAOSDLDriver) { |
34625 | 628 char *tmp; |
32984 | 629 |
630 tmp = calloc(1, strlen(gtkAOSDLDriver) + 10); | |
631 sprintf(tmp, "sdl:%s", gtkAOSDLDriver); | |
34625 | 632 listSet(&audio_driver_list, tmp); |
633 free(tmp); | |
34624 | 634 } |
32984 | 635 } |
636 | |
637 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "esd", 3)) { | |
34624 | 638 if (gtkAOESDDevice) { |
34625 | 639 char *tmp; |
32984 | 640 |
641 tmp = calloc(1, strlen(gtkAOESDDevice) + 10); | |
642 sprintf(tmp, "esd:%s", gtkAOESDDevice); | |
34625 | 643 listSet(&audio_driver_list, tmp); |
644 free(tmp); | |
34624 | 645 } |
32984 | 646 } |
647 | |
34684 | 648 /* subtitle */ |
32984 | 649 |
33897 | 650 // subdata->filename=gstrdup( guiInfo.SubtitleFilename ); |
32984 | 651 stream_dump_type = 0; |
652 | |
653 if (gtkSubDumpMPSub) | |
654 stream_dump_type = 4; | |
655 | |
656 if (gtkSubDumpSrt) | |
657 stream_dump_type = 6; | |
658 | |
35493 | 659 gtkSubDumpMPSub = gtkSubDumpSrt = False; |
23077 | 660 |
34684 | 661 /* misc */ |
32984 | 662 |
663 if (gtkCacheOn) | |
664 stream_cache_size = gtkCacheSize; | |
665 | |
666 if (gtkAutoSyncOn) | |
667 autosync = gtkAutoSync; | |
23077 | 668 |
33897 | 669 if (guiInfo.AudioFilename) |
670 audio_stream = gstrdup(guiInfo.AudioFilename); | |
36937
ad939f49bb28
Cosmetic: Rename guiInfo member NewPlay MediumChanged.
ib
parents:
36936
diff
changeset
|
671 else if (guiInfo.MediumChanged == GUI_MEDIUM_NEW) |
33739 | 672 nfree(audio_stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
673 |
32984 | 674 // audio_stream = NULL; |
675 | |
36939 | 676 guiInfo.MediumChanged = False; |
23077 | 677 |
32984 | 678 ass_enabled = gtkASS.enabled; |
679 ass_use_margins = gtkASS.use_margins; | |
680 ass_top_margin = gtkASS.top_margin; | |
23077 | 681 ass_bottom_margin = gtkASS.bottom_margin; |
682 | |
32984 | 683 break; |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
684 |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
685 case GUI_SET_STREAM: |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
686 |
34859 | 687 if (guiInfo.StreamType == STREAMTYPE_PLAYLIST) |
688 guiInfo.mpcontext->file_format = DEMUXER_TYPE_PLAYLIST; | |
36456 | 689 else { |
36457 | 690 stream = data; |
691 guiInfo.StreamType = stream->type; | |
36456 | 692 } |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
693 |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
694 switch (guiInfo.StreamType) { |
34424 | 695 case STREAMTYPE_FILE: |
696 case STREAMTYPE_STREAM: | |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
697 guiInfo.Tracks = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, 0); |
34424 | 698 break; |
699 | |
34387 | 700 case STREAMTYPE_CDDA: |
701 guiInfo.Tracks = 0; | |
702 stream_control(stream, STREAM_CTRL_GET_NUM_TITLES, &guiInfo.Tracks); | |
36437
eb6cdd6b9b86
Update track information at GUI_SET_STREAM for CDDA and VCD.
ib
parents:
36430
diff
changeset
|
703 if (stream_control(stream, STREAM_CTRL_GET_CURRENT_TITLE, &guiInfo.Track) == STREAM_OK) |
eb6cdd6b9b86
Update track information at GUI_SET_STREAM for CDDA and VCD.
ib
parents:
36430
diff
changeset
|
704 guiInfo.Track++; |
34387 | 705 break; |
706 | |
34077 | 707 case STREAMTYPE_VCD: |
708 guiInfo.Tracks = 0; | |
34388
9ee95c78e85f
Replace VCD's STREAM_CTRL_GET_NUM_CHAPTERS by STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34387
diff
changeset
|
709 stream_control(stream, STREAM_CTRL_GET_NUM_TITLES, &guiInfo.Tracks); |
36437
eb6cdd6b9b86
Update track information at GUI_SET_STREAM for CDDA and VCD.
ib
parents:
36430
diff
changeset
|
710 if (stream_control(stream, STREAM_CTRL_GET_CURRENT_TITLE, &guiInfo.Track) == STREAM_OK) |
eb6cdd6b9b86
Update track information at GUI_SET_STREAM for CDDA and VCD.
ib
parents:
36430
diff
changeset
|
711 guiInfo.Track++; |
34077 | 712 break; |
713 | |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
714 case STREAMTYPE_DVD: |
34389
b2d661762e90
Retrieve DVD's titles, chapters and angles by stream control commands.
ib
parents:
34388
diff
changeset
|
715 guiInfo.Tracks = 0; |
b2d661762e90
Retrieve DVD's titles, chapters and angles by stream control commands.
ib
parents:
34388
diff
changeset
|
716 stream_control(stream, STREAM_CTRL_GET_NUM_TITLES, &guiInfo.Tracks); |
b2d661762e90
Retrieve DVD's titles, chapters and angles by stream control commands.
ib
parents:
34388
diff
changeset
|
717 guiInfo.Chapters = 0; |
b2d661762e90
Retrieve DVD's titles, chapters and angles by stream control commands.
ib
parents:
34388
diff
changeset
|
718 stream_control(stream, STREAM_CTRL_GET_NUM_CHAPTERS, &guiInfo.Chapters); |
b2d661762e90
Retrieve DVD's titles, chapters and angles by stream control commands.
ib
parents:
34388
diff
changeset
|
719 guiInfo.Angles = 0; |
b2d661762e90
Retrieve DVD's titles, chapters and angles by stream control commands.
ib
parents:
34388
diff
changeset
|
720 stream_control(stream, STREAM_CTRL_GET_NUM_ANGLES, &guiInfo.Angles); |
36430
08f21a09a545
Don't discard current DVD track information without cause.
ib
parents:
36429
diff
changeset
|
721 if (stream_control(stream, STREAM_CTRL_GET_CURRENT_TITLE, &guiInfo.Track) == STREAM_OK) |
08f21a09a545
Don't discard current DVD track information without cause.
ib
parents:
36429
diff
changeset
|
722 guiInfo.Track++; |
35168 | 723 // guiInfo.Chapter will be set by mplayer |
724 guiInfo.Angle = 1; | |
725 stream_control(stream, STREAM_CTRL_GET_ANGLE, &guiInfo.Angle); | |
34454 | 726 #ifdef CONFIG_DVDREAD |
33730 | 727 dvd = stream->priv; |
33902 | 728 guiInfo.AudioStreams = dvd->nr_of_channels; |
729 memcpy(guiInfo.AudioStream, dvd->audio_streams, sizeof(dvd->audio_streams)); | |
730 guiInfo.Subtitles = dvd->nr_of_subtitles; | |
731 memcpy(guiInfo.Subtitle, dvd->subtitles, sizeof(dvd->subtitles)); | |
34454 | 732 #endif |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
733 break; |
36429 | 734 |
735 case STREAMTYPE_TV: | |
736 case STREAMTYPE_DVB: | |
36437
eb6cdd6b9b86
Update track information at GUI_SET_STREAM for CDDA and VCD.
ib
parents:
36430
diff
changeset
|
737 guiInfo.Tracks = guiInfo.Track = 1; |
36429 | 738 break; |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
739 } |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
740 |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
741 break; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
742 |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
743 case GUI_SET_VIDEO: |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
744 |
34684 | 745 /* video */ |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
746 |
36265 | 747 guiInfo.sh_video = data; |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
748 |
35462 | 749 nfree(guiInfo.CodecName); |
750 | |
751 if (guiInfo.sh_video) | |
752 guiInfo.CodecName = strdup(guiInfo.sh_video->codec->name); | |
753 | |
36429 | 754 state = (isSeekableStreamtype ? btnReleased : btnDisabled); |
34074
360ed500a6e9
Set all buttons related to seek operations according to stream type.
ib
parents:
34073
diff
changeset
|
755 btnSet(evForward10sec, state); |
360ed500a6e9
Set all buttons related to seek operations according to stream type.
ib
parents:
34073
diff
changeset
|
756 btnSet(evBackward10sec, state); |
360ed500a6e9
Set all buttons related to seek operations according to stream type.
ib
parents:
34073
diff
changeset
|
757 btnSet(evForward1min, state); |
360ed500a6e9
Set all buttons related to seek operations according to stream type.
ib
parents:
34073
diff
changeset
|
758 btnSet(evBackward1min, state); |
360ed500a6e9
Set all buttons related to seek operations according to stream type.
ib
parents:
34073
diff
changeset
|
759 btnSet(evForward10min, state); |
360ed500a6e9
Set all buttons related to seek operations according to stream type.
ib
parents:
34073
diff
changeset
|
760 btnSet(evBackward10min, state); |
360ed500a6e9
Set all buttons related to seek operations according to stream type.
ib
parents:
34073
diff
changeset
|
761 btnSet(evSetMoviePosition, state); |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
762 |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
763 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3") && (((demuxer_t *)mpctx_get_demuxer(guiInfo.mpcontext))->file_format != DEMUXER_TYPE_MPEG_PS) && !gtkVfLAVC) { |
36694 | 764 gtkMessageBox(MSGBOX_FATAL, MSGTR_GUI_MSG_DXR3NeedsLavc); |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
765 return False; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
766 } |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
767 |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
768 break; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
769 |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
770 case GUI_SET_AUDIO: |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
771 |
36455 | 772 sh_audio = data; |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
773 |
36966 | 774 ad = sh_audio->ad_driver; |
775 guiInfo.AudioPassthrough = (gstrcmp(ad->info->short_name, "hwac3") == 0); | |
776 | |
36976 | 777 guiInfo.AudioChannels = (sh_audio ? sh_audio->channels : 0); |
36455 | 778 |
36972 | 779 if (guiInfo.AudioPassthrough) |
780 btnSet(evSetVolume, btnDisabled); | |
36971 | 781 if (guiInfo.AudioChannels < 2 || guiInfo.AudioPassthrough) |
36954
44dcc6c54014
Disable balance control if number of audio channels is too small.
ib
parents:
36946
diff
changeset
|
782 btnSet(evSetBalance, btnDisabled); |
44dcc6c54014
Disable balance control if number of audio channels is too small.
ib
parents:
36946
diff
changeset
|
783 |
36455 | 784 if (sh_audio && !guiInfo.sh_video) { |
33901 | 785 guiInfo.VideoWindow = False; |
35454 | 786 guiInfo.VideoWidth = 0; |
787 guiInfo.VideoHeight = 0; | |
788 } | |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
789 |
36959
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
790 if (last_balance < 0.0f) { |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
791 uiEvent(ivSetVolume, guiInfo.Volume); |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
792 |
36968 | 793 if (guiInfo.AudioChannels == 2 && !guiInfo.AudioPassthrough) |
794 uiEvent(ivSetBalance, guiInfo.Balance); | |
36959
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
795 |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
796 last_balance = guiInfo.Balance; |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
797 } |
97a4746e7888
Utilize item defaults given in the skin configuration as start values.
ib
parents:
36954
diff
changeset
|
798 |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
799 if (gtkEnableAudioEqualizer) { |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
800 equalizer_t eq; |
33693
006a2db8bd55
Use unsigned index variable for comparison with array size.
ib
parents:
33692
diff
changeset
|
801 unsigned int i, j; |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
802 |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
803 for (i = 0; i < FF_ARRAY_ELEMS(gtkEquChannels); i++) { |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
804 for (j = 0; j < FF_ARRAY_ELEMS(*gtkEquChannels); j++) { |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
805 eq.channel = i; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
806 eq.band = j; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
807 eq.gain = gtkEquChannels[i][j]; |
33766 | 808 mplayer(MPLAYER_SET_EQUALIZER, 0, &eq); |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
809 } |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
810 } |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
811 } |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
812 |
33960 | 813 // These must be done here (in the last call from MPlayer before |
814 // playback starts) and not in GUI_SETUP_VIDEO_WINDOW, because... | |
815 | |
816 // ...without video there will be no call to GUI_SETUP_VIDEO_WINDOW | |
817 if (!guiInfo.VideoWindow) { | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
818 wsWindowVisibility(&guiApp.videoWindow, wsHideWindow); |
36975 | 819 btnSet(evFullScreen, gtkLoadFullscreen ? btnPressed : btnReleased); |
33960 | 820 } |
821 | |
822 // ...option variable fullscreen determines whether MPlayer will handle | |
823 // the window given by WinID as fullscreen window (and will do aspect | |
824 // scaling then) or not - quite rubbish | |
825 fullscreen = gtkLoadFullscreen; | |
826 | |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
827 break; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
828 |
36946
cbaa08dbc9aa
Cosmetic: Rename GUI_SET_MIXER GUI_SET_VOLUME_BALANCE.
ib
parents:
36945
diff
changeset
|
829 case GUI_SET_VOLUME_BALANCE: |
35535 | 830 |
36454 | 831 mixer = data; |
35535 | 832 |
36945 | 833 mixer_getvolume(mixer, &l, &r); |
834 guiInfo.Volume = FFMAX(l, r); | |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
835 |
36945 | 836 mixer_getbalance(mixer, &b); |
837 guiInfo.Balance = (b + 1.0) * 50.0; // transform -1..1 to 0..100 | |
35542 | 838 |
36945 | 839 if (guiInfo.Balance != last_balance) { |
840 uiEvent(ivSetVolume, guiInfo.Volume); | |
841 last_balance = guiInfo.Balance; | |
842 } | |
35541 | 843 |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
844 break; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
845 |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
846 case GUI_SETUP_VIDEO_WINDOW: |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
847 |
33901 | 848 guiInfo.VideoWidth = vo_dwidth; |
849 guiInfo.VideoHeight = vo_dheight; | |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
850 |
34697 | 851 if (!guiApp.videoWindow.isFullScreen || !guiApp.videoWindow.Mapped) { |
852 if (!guiApp.videoWindow.isFullScreen) | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
853 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight); |
34697 | 854 if (!guiApp.videoWindow.Mapped) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
855 wsWindowVisibility(&guiApp.videoWindow, wsShowWindow); |
33960 | 856 } |
857 | |
34697 | 858 if (gtkLoadFullscreen ^ guiApp.videoWindow.isFullScreen) |
35773 | 859 uiEvent(evFullScreen, True); |
33960 | 860 |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
861 if (guiWinID >= 0) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
862 wsWindowMove(&guiApp.mainWindow, True, 0, guiInfo.VideoHeight); |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
863 |
35755
589cf8a5f165
Realize a smooth and flicker-free video when resizing during playback.
ib
parents:
35748
diff
changeset
|
864 wsWindowBackground(&guiApp.videoWindow, -1, -1, -1); |
589cf8a5f165
Realize a smooth and flicker-free video when resizing during playback.
ib
parents:
35748
diff
changeset
|
865 |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
866 break; |
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
867 |
33733 | 868 case GUI_HANDLE_X_EVENT: |
35541 | 869 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
870 wsEvent(data); |
33692
0e9a5c0194ed
Cosmetic: Arrange guiGetEvent() types in the sequence they are called.
ib
parents:
33691
diff
changeset
|
871 break; |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
872 |
36940
6410fe917eac
Cosmetic: Rename symbolic constant GUI_END_FILE GUI_END_PLAY.
ib
parents:
36939
diff
changeset
|
873 case GUI_END_PLAY: |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
874 |
35330 | 875 guiInfo.sh_video = NULL; |
34035 | 876 |
36972 | 877 btnSet(evSetVolume, btnReleased); |
36954
44dcc6c54014
Disable balance control if number of audio channels is too small.
ib
parents:
36946
diff
changeset
|
878 btnSet(evSetBalance, btnReleased); |
44dcc6c54014
Disable balance control if number of audio channels is too small.
ib
parents:
36946
diff
changeset
|
879 |
35773 | 880 uiEvent(ivRedraw, True); |
34052 | 881 |
35565
5f7a983fc838
Embrace several individual "if (guiInfo.Playing)" conditions.
ib
parents:
35564
diff
changeset
|
882 if (guiInfo.Playing) { |
35566 | 883 if (!guiInfo.PlaylistNext) { |
884 guiInfo.PlaylistNext = True; | |
885 break; | |
886 } | |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
887 |
35566 | 888 if (guiInfo.StreamType == STREAMTYPE_CDDA && guiInfo.Track < guiInfo.Tracks) { |
889 uiNext(); | |
890 break; | |
891 } | |
34387 | 892 |
35468
047fc4746236
Cosmetic: Adjust indent and move guiInfo member CodecName in structure.
ib
parents:
35467
diff
changeset
|
893 next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0); |
35565
5f7a983fc838
Embrace several individual "if (guiInfo.Playing)" conditions.
ib
parents:
35564
diff
changeset
|
894 } |
34669
697aaedfe59e
Remove global variable pointing to playlist item last played.
ib
parents:
34667
diff
changeset
|
895 |
35565
5f7a983fc838
Embrace several individual "if (guiInfo.Playing)" conditions.
ib
parents:
35564
diff
changeset
|
896 if (next) { |
35452 | 897 uiSetFile(next->path, next->name, STREAMTYPE_FILE); |
36937
ad939f49bb28
Cosmetic: Rename guiInfo member NewPlay MediumChanged.
ib
parents:
36936
diff
changeset
|
898 guiInfo.MediumChanged = GUI_MEDIUM_NEW; |
36938 | 899 guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, next); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
900 } else { |
36937
ad939f49bb28
Cosmetic: Rename guiInfo member NewPlay MediumChanged.
ib
parents:
36936
diff
changeset
|
901 if (guiInfo.MediumChanged == GUI_MEDIUM_NEW) |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
902 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
903 |
34113 | 904 filename = NULL; |
905 | |
35546
cd2c85083fdd
Reset playlist to first item after playback has stopped.
ib
parents:
35544
diff
changeset
|
906 if (isPlaylistStreamtype) { |
35555 | 907 plItem *curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
908 | |
909 if (!curr) | |
35547 | 910 uiUnsetFile(); |
35558 | 911 else if ((curr != listMgr(PLAYLIST_GET, 0)) && guiInfo.Playing) { |
35555 | 912 curr = listMgr(PLAYLIST_ITEM_SET_CURR, listMgr(PLAYLIST_GET, 0)); |
35546
cd2c85083fdd
Reset playlist to first item after playback has stopped.
ib
parents:
35544
diff
changeset
|
913 uiSetFile(curr->path, curr->name, STREAMTYPE_FILE); |
35551
99a11b051705
Set track number after resetting playlist to first item.
ib
parents:
35550
diff
changeset
|
914 guiInfo.Track = 1; |
35546
cd2c85083fdd
Reset playlist to first item after playback has stopped.
ib
parents:
35544
diff
changeset
|
915 } |
35559
14e36699a6e7
Relocate code to set Track, Chapter and Angle start values.
ib
parents:
35558
diff
changeset
|
916 } else if (guiInfo.Playing) { |
35563
d4a84f674401
Reset media information for CD/VCD/DVD after playback.
ib
parents:
35559
diff
changeset
|
917 int first = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1); |
35559
14e36699a6e7
Relocate code to set Track, Chapter and Angle start values.
ib
parents:
35558
diff
changeset
|
918 |
35563
d4a84f674401
Reset media information for CD/VCD/DVD after playback.
ib
parents:
35559
diff
changeset
|
919 if (guiInfo.Track != first) { |
35568 | 920 uiUnsetMedia(True); |
35563
d4a84f674401
Reset media information for CD/VCD/DVD after playback.
ib
parents:
35559
diff
changeset
|
921 guiInfo.Track = first; |
d4a84f674401
Reset media information for CD/VCD/DVD after playback.
ib
parents:
35559
diff
changeset
|
922 } |
35564
8d4a7387d592
Relocate and change code to set Chapter and Angle start values.
ib
parents:
35563
diff
changeset
|
923 |
8d4a7387d592
Relocate and change code to set Chapter and Angle start values.
ib
parents:
35563
diff
changeset
|
924 if (guiInfo.StreamType == STREAMTYPE_DVD) { |
8d4a7387d592
Relocate and change code to set Chapter and Angle start values.
ib
parents:
35563
diff
changeset
|
925 guiInfo.Chapter = 1; |
8d4a7387d592
Relocate and change code to set Chapter and Angle start values.
ib
parents:
35563
diff
changeset
|
926 guiInfo.Angle = 1; |
8d4a7387d592
Relocate and change code to set Chapter and Angle start values.
ib
parents:
35563
diff
changeset
|
927 } |
35546
cd2c85083fdd
Reset playlist to first item after playback has stopped.
ib
parents:
35544
diff
changeset
|
928 } |
35381
746e2e0577b2
Without current playlist item, reset guiInfo's Filename and StreamType.
ib
parents:
35376
diff
changeset
|
929 |
35413 | 930 guiInfo.ElapsedTime = 0; |
36279 | 931 guiInfo.Position = 0.0f; |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
932 |
33960 | 933 if (gtkShowVideoWindow) { |
934 guiInfo.VideoWindow = True; | |
935 | |
35663
d1f84b219340
Don't unnecessarily and annoyingly move the video window.
ib
parents:
35658
diff
changeset
|
936 if (!guiApp.videoWindow.isFullScreen) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
937 wsWindowResize(&guiApp.videoWindow, guiApp.video.width, guiApp.video.height); |
33960 | 938 |
34697 | 939 if (!guiApp.videoWindow.Mapped) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
940 wsWindowVisibility(&guiApp.videoWindow, wsShowWindow); |
33960 | 941 |
34697 | 942 if (gtkLoadFullscreen ^ guiApp.videoWindow.isFullScreen) |
35773 | 943 uiEvent(evFullScreen, False); |
33960 | 944 } else { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
945 wsWindowVisibility(&guiApp.videoWindow, wsHideWindow); |
33960 | 946 guiInfo.VideoWindow = False; |
36975 | 947 btnSet(evFullScreen, gtkLoadFullscreen ? btnPressed : btnReleased); |
33960 | 948 } |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
949 |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
950 gui(GUI_SET_STATE, (void *)GUI_STOP); |
33959 | 951 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
952 wsWindowRedraw(&guiApp.videoWindow); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35678
diff
changeset
|
953 wsMouseVisibility(&guiApp.videoWindow, wsShowMouseCursor); |
36293 | 954 wsEvents(); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
955 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
956 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33693
diff
changeset
|
957 break; |
32984 | 958 } |
959 | |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33664
diff
changeset
|
960 return True; |
23077 | 961 } |
962 | |
35517 | 963 /** |
964 * @brief Initialize the GUI playlist (i.e. import files that had been given | |
965 * on the command line) or add files "on the fly" (i.e. replace the | |
966 * current one (a playlist file) by other ones (its content)). | |
967 * | |
968 * @param what command (#GUI_PLAYLIST_INIT or #GUI_PLAYLIST_ADD) to be performed | |
969 * @param playtree MPlayer playtree to read from | |
970 * @param config MPlayer config context | |
971 * @param enqueue whether to overwrite GUI playlist (#False) or to append to it (#True) | |
972 * | |
973 * @return #True (ok) or #False (error) | |
974 */ | |
35512 | 975 int guiPlaylist(int what, play_tree_t *playtree, m_config_t *config, int enqueue) |
35510 | 976 { |
35513 | 977 play_tree_iter_t *pt_iter; |
35519
7f1be403a640
Don't unnecessarily use global MPlayer variable filename.
ib
parents:
35518
diff
changeset
|
978 const char *file; |
35510 | 979 int added = False; |
35512 | 980 plItem *curr; |
35510 | 981 |
35513 | 982 pt_iter = pt_iter_create(&playtree, config); |
983 | |
984 if (!pt_iter) | |
985 return False; | |
986 | |
35510 | 987 switch (what) { |
988 case GUI_PLAYLIST_INIT: | |
33746 | 989 |
35511 | 990 if (!enqueue) |
35517 | 991 listMgr(PLAYLIST_DELETE, 0); |
33746 | 992 |
35519
7f1be403a640
Don't unnecessarily use global MPlayer variable filename.
ib
parents:
35518
diff
changeset
|
993 while ((file = pt_iter_get_next_file(pt_iter))) |
7f1be403a640
Don't unnecessarily use global MPlayer variable filename.
ib
parents:
35518
diff
changeset
|
994 if (add_to_gui_playlist(file, PLAYLIST_ITEM_APPEND)) |
35514 | 995 added = True; |
33746 | 996 |
35511 | 997 uiCurr(); // update filename |
998 guiInfo.PlaylistNext = True; | |
33746 | 999 |
35518 | 1000 if (added) |
1001 guiInfo.Track = 1; | |
1002 | |
35511 | 1003 if (enqueue) |
1004 filename = NULL; // don't start playing | |
33746 | 1005 |
35510 | 1006 break; |
33746 | 1007 |
35510 | 1008 case GUI_PLAYLIST_ADD: |
33746 | 1009 |
35516 | 1010 curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
33746 | 1011 |
35519
7f1be403a640
Don't unnecessarily use global MPlayer variable filename.
ib
parents:
35518
diff
changeset
|
1012 while ((file = pt_iter_get_next_file(pt_iter))) |
7f1be403a640
Don't unnecessarily use global MPlayer variable filename.
ib
parents:
35518
diff
changeset
|
1013 if (add_to_gui_playlist(file, PLAYLIST_ITEM_INSERT)) |
35514 | 1014 added = True; |
33746 | 1015 |
35512 | 1016 if (curr) |
1017 listMgr(PLAYLIST_ITEM_SET_CURR, curr); | |
35511 | 1018 else |
35517 | 1019 listMgr(PLAYLIST_ITEM_SET_CURR, listMgr(PLAYLIST_GET, 0)); |
33746 | 1020 |
35512 | 1021 if (curr && added) |
35511 | 1022 listMgr(PLAYLIST_ITEM_DEL_CURR, 0); |
33746 | 1023 |
35511 | 1024 uiCurr(); // update filename |
33746 | 1025 |
35510 | 1026 break; |
1027 } | |
1028 | |
35513 | 1029 pt_iter_destroy(&pt_iter); |
1030 | |
35494 | 1031 return added; |
33746 | 1032 } |
1033 | |
1034 /* GUI -> MPlayer */ | |
1035 | |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1036 void mplayer(int what, float value, void *data) |
23077 | 1037 { |
36461 | 1038 af_stream_t *afilter; |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1039 equalizer_t *eq = (equalizer_t *)data; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1040 |
33765 | 1041 switch (what) { |
34684 | 1042 /* subtitle */ |
32984 | 1043 |
33766 | 1044 case MPLAYER_SET_FONT_FACTOR: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1045 font_factor = value; |
36658 | 1046 mplayer(MPLAYER_LOAD_FONT, 0, 0); |
33744 | 1047 break; |
34454 | 1048 |
33766 | 1049 case MPLAYER_SET_FONT_OUTLINE: |
36282
872298702c15
Increase precision of calculation by using constants of type double.
ib
parents:
36279
diff
changeset
|
1050 subtitle_font_thickness = 8.0 * value / 100.0; // transform 0..100 to 0..8 |
36658 | 1051 mplayer(MPLAYER_LOAD_FONT, 0, 0); |
33744 | 1052 break; |
32984 | 1053 |
33766 | 1054 case MPLAYER_SET_FONT_BLUR: |
36282
872298702c15
Increase precision of calculation by using constants of type double.
ib
parents:
36279
diff
changeset
|
1055 subtitle_font_radius = 8.0 * value / 100.0; // transform 0..100 to 0..8 |
36658 | 1056 mplayer(MPLAYER_LOAD_FONT, 0, 0); |
33744 | 1057 break; |
32984 | 1058 |
33766 | 1059 case MPLAYER_SET_FONT_TEXTSCALE: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1060 text_font_scale_factor = value; |
36658 | 1061 mplayer(MPLAYER_LOAD_FONT, 0, 0); |
33744 | 1062 break; |
32984 | 1063 |
33766 | 1064 case MPLAYER_SET_FONT_OSDSCALE: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1065 osd_font_scale_factor = value; |
36658 | 1066 mplayer(MPLAYER_LOAD_FONT, 0, 0); |
33744 | 1067 break; |
32984 | 1068 |
33766 | 1069 case MPLAYER_SET_FONT_ENCODING: |
33739 | 1070 nfree(subtitle_font_encoding); |
36842 | 1071 subtitle_font_encoding = gstrdup(data); |
36658 | 1072 mplayer(MPLAYER_LOAD_FONT, 0, 0); |
33744 | 1073 break; |
32984 | 1074 |
33766 | 1075 case MPLAYER_SET_FONT_AUTOSCALE: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1076 subtitle_autoscale = (int)value; |
36658 | 1077 mplayer(MPLAYER_LOAD_FONT, 0, 0); |
1078 break; | |
1079 | |
1080 case MPLAYER_LOAD_FONT: | |
1081 #ifdef CONFIG_FREETYPE | |
1082 set_fontconfig(); | |
1083 | |
1084 force_load_font = 1; | |
1085 #else | |
1086 free_font_desc(vo_font); | |
1087 | |
1088 if (font_name) { | |
1089 vo_font = read_font_desc(font_name, font_factor, 0); | |
1090 | |
1091 if (!vo_font) | |
1092 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name); | |
1093 } else { | |
1094 char *fname = get_path("font/font.desc"); | |
1095 | |
1096 setdup(&font_name, fname); | |
1097 free(fname); | |
1098 vo_font = read_font_desc(font_name, font_factor, 0); | |
1099 | |
1100 if (!vo_font) { | |
1101 setdup(&font_name, MPLAYER_DATADIR "/font/font.desc"); | |
1102 vo_font = read_font_desc(font_name, font_factor, 0); | |
1103 } | |
1104 } | |
1105 #endif | |
33744 | 1106 break; |
32984 | 1107 |
33766 | 1108 case MPLAYER_SET_SUB_ENCODING: |
33739 | 1109 nfree(sub_cp); |
36842 | 1110 sub_cp = gstrdup(data); |
32984 | 1111 break; |
1112 | |
33766 | 1113 case MPLAYER_SET_EXTRA_STEREO: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1114 gtkAOExtraStereoMul = value; |
36461 | 1115 afilter = mpctx_get_afilter(guiInfo.mpcontext); |
1116 if (afilter) | |
1117 af_control_any_rev(afilter, AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); | |
33744 | 1118 break; |
32984 | 1119 |
33766 | 1120 case MPLAYER_SET_PANSCAN: |
32984 | 1121 { |
1122 mp_cmd_t *mp_cmd; | |
1123 | |
1124 mp_cmd = calloc(1, sizeof(*mp_cmd)); | |
1125 mp_cmd->id = MP_CMD_PANSCAN; | |
1126 mp_cmd->name = strdup("panscan"); | |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1127 mp_cmd->args[0].v.f = value; |
32984 | 1128 mp_cmd->args[1].v.i = 1; |
1129 mp_input_queue_cmd(mp_cmd); | |
1130 } | |
33744 | 1131 break; |
32984 | 1132 |
33766 | 1133 case MPLAYER_SET_AUTO_QUALITY: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1134 auto_quality = (int)value; |
33744 | 1135 break; |
32984 | 1136 |
34684 | 1137 /* set equalizers */ |
32984 | 1138 |
33766 | 1139 case MPLAYER_SET_CONTRAST: |
33555 | 1140 if (guiInfo.sh_video) |
36842 | 1141 set_video_colors(guiInfo.sh_video, "contrast", value); |
33744 | 1142 break; |
32984 | 1143 |
33766 | 1144 case MPLAYER_SET_BRIGHTNESS: |
33555 | 1145 if (guiInfo.sh_video) |
36842 | 1146 set_video_colors(guiInfo.sh_video, "brightness", value); |
33744 | 1147 break; |
32984 | 1148 |
33766 | 1149 case MPLAYER_SET_HUE: |
33555 | 1150 if (guiInfo.sh_video) |
36842 | 1151 set_video_colors(guiInfo.sh_video, "hue", value); |
33744 | 1152 break; |
32984 | 1153 |
33766 | 1154 case MPLAYER_SET_SATURATION: |
33555 | 1155 if (guiInfo.sh_video) |
36842 | 1156 set_video_colors(guiInfo.sh_video, "saturation", value); |
33744 | 1157 break; |
32984 | 1158 |
33766 | 1159 case MPLAYER_SET_EQUALIZER: |
32984 | 1160 { |
23077 | 1161 af_control_ext_t tmp; |
32984 | 1162 |
36461 | 1163 afilter = mpctx_get_afilter(guiInfo.mpcontext); |
1164 | |
32984 | 1165 if (eq) { |
1166 gtkEquChannels[eq->channel][eq->band] = eq->gain; | |
1167 tmp.ch = eq->channel; | |
1168 tmp.arg = gtkEquChannels[eq->channel]; | |
1169 | |
36461 | 1170 if (afilter) |
1171 af_control_any_rev(afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
32984 | 1172 } else { |
33693
006a2db8bd55
Use unsigned index variable for comparison with array size.
ib
parents:
33692
diff
changeset
|
1173 unsigned int i; |
32984 | 1174 |
1175 memset(gtkEquChannels, 0, sizeof(gtkEquChannels)); | |
1176 | |
36461 | 1177 if (afilter) { |
33689
8d0290220239
Replace numeric constants for gtkEquChannels array size.
ib
parents:
33688
diff
changeset
|
1178 for (i = 0; i < FF_ARRAY_ELEMS(gtkEquChannels); i++) { |
32984 | 1179 tmp.ch = i; |
1180 tmp.arg = gtkEquChannels[i]; | |
36461 | 1181 af_control_any_rev(afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); |
32984 | 1182 } |
1183 } | |
1184 } | |
1185 | |
33744 | 1186 break; |
32984 | 1187 } |
33768 | 1188 |
1189 case MPLAYER_EXIT_GUI: | |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33790
diff
changeset
|
1190 exit_player_with_rc((enum exit_reason)value, (enum exit_reason)value >= EXIT_ERROR); |
33768 | 1191 break; |
32984 | 1192 } |
23077 | 1193 } |
1194 | |
33790
ab6d06f5b98b
Add const to some string pointer arguments that will not be modified.
ib
parents:
33775
diff
changeset
|
1195 void mplayerLoadSubtitle(const char *name) |
33745 | 1196 { |
35495 | 1197 if (guiInfo.Playing == GUI_STOP) |
33745 | 1198 return; |
1199 | |
1200 if (subdata) { | |
36694 | 1201 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_RemovingSubtitle); |
33745 | 1202 |
1203 sub_free(subdata); | |
1204 subdata = NULL; | |
1205 vo_sub = NULL; | |
1206 | |
1207 if (vo_osd_list) { | |
1208 int len; | |
1209 mp_osd_obj_t *osd; | |
1210 | |
1211 osd = vo_osd_list; | |
1212 | |
1213 while (osd) { | |
1214 if (osd->type == OSDTYPE_SUBTITLE) | |
1215 break; | |
1216 | |
1217 osd = osd->next; | |
1218 } | |
1219 | |
1220 if (osd && (osd->flags & OSDFLAG_VISIBLE)) { | |
1221 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1); | |
1222 memset(osd->bitmap_buffer, 0, len); | |
1223 memset(osd->alpha_buffer, 0, len); | |
1224 } | |
1225 } | |
1226 } | |
1227 | |
1228 if (name) { | |
36694 | 1229 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_LoadingSubtitle, name); |
33745 | 1230 |
36975 | 1231 subdata = sub_read_file(name, guiInfo.sh_video ? guiInfo.sh_video->fps : 0); |
33745 | 1232 |
1233 if (!subdata) | |
1234 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name); | |
1235 | |
1236 sub_name = (malloc(2 * sizeof(char *))); // when mplayer will be restarted | |
1237 sub_name[0] = strdup(name); // sub_name[0] will be read | |
1238 sub_name[1] = NULL; | |
1239 } | |
1240 | |
1241 update_set_of_subtitles(); | |
1242 } | |
1243 | |
33023 | 1244 // NOTE TO MYSELF: This function is nonsense. |
33289 | 1245 // MPlayer should pass messages to the GUI |
1246 // which must decide then which message has | |
1247 // to be shown (MSGL_FATAL, for example). | |
1248 // But with this function it is at least | |
1249 // possible to show GUI's very critical or | |
1250 // abort messages. | |
33023 | 1251 void gmp_msg(int mod, int lev, const char *format, ...) |
1252 { | |
1253 char msg[512]; | |
1254 va_list va; | |
1255 | |
1256 va_start(va, format); | |
1257 vsnprintf(msg, sizeof(msg), format, va); | |
1258 va_end(va); | |
1259 | |
36644
8d39d6874ec0
Do not use non-literal arguments for mp_msg format string
al
parents:
36461
diff
changeset
|
1260 mp_msg(mod, lev, "%s", msg); |
33023 | 1261 |
1262 if (mp_msg_test(mod, lev)) | |
36036 | 1263 gtkMessageBox(MSGBOX_FATAL, msg); |
33023 | 1264 } |