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