Mercurial > mplayer.hg
annotate gui/win32/interface.c @ 34399:f2c03009068d
Don't explicitly set stream type if the type doesn't change.
Use a self-explanatory symbolic constant which makes the code
more easily understandable.
author | ib |
---|---|
date | Mon, 02 Jan 2012 15:16:55 +0000 |
parents | 4c8bdc633648 |
children | 19b68f388735 |
rev | line source |
---|---|
23077 | 1 /* |
23079 | 2 * MPlayer GUI for Win32 |
3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de> | |
4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com> | |
5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
6 * | |
7 * This file is part of MPlayer. | |
8 * | |
9 * MPlayer is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * MPlayer is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
26457 | 19 * You should have received a copy of the GNU General Public License along |
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
23079 | 22 */ |
23077 | 23 |
24 #include <windows.h> | |
33358 | 25 |
34115 | 26 #if defined(__CYGWIN__) || defined(__WINE__) |
33358 | 27 #define _beginthreadex CreateThread |
34392 | 28 #ifdef __WINE__ |
29 #include <winioctl.h> | |
30 #define WINE_MOUNTMGR_EXTENSIONS | |
31 #include <ddk/mountmgr.h> | |
32 #endif | |
33358 | 33 #else |
34 #include <process.h> | |
35 #endif | |
36 | |
30901 | 37 #include "path.h" |
26372
76413880bfad
Update include paths to account for build system changes.
diego
parents:
26193
diff
changeset
|
38 #include "gui/interface.h" |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
39 #include "m_option.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
40 #include "mixer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
41 #include "mp_msg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
42 #include "help_mp.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
43 #include "codec-cfg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
44 #include "stream/stream.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
45 #include "libmpdemux/demuxer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
46 #include "libmpdemux/stheader.h" |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
47 #ifdef CONFIG_DVDREAD |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
48 #include "stream/stream_dvd.h" |
23077 | 49 #endif |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
50 #include "input/input.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
51 #include "libvo/video_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
52 #include "libao2/audio_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
53 #include "access_mpcontext.h" |
30558 | 54 #include "libmpcodecs/vd.h" |
31425
2392ad3cec9c
Move af_cfg extern variable declaration to dec_audio.h.
diego
parents:
31312
diff
changeset
|
55 #include "libmpcodecs/dec_audio.h" |
33761 | 56 #include "gui/ui/actions.h" |
33557 | 57 #include "gui/ui/gmplayer.h" |
33770 | 58 #include "gui/util/mem.h" |
33761 | 59 #include "gui/util/list.h" |
60 #include "gui/util/string.h" | |
30558 | 61 #include "mp_core.h" |
32093 | 62 #include "mpcommon.h" |
23077 | 63 #include "gui.h" |
64 #include "dialogs.h" | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
65 #ifdef CONFIG_LIBCDIO |
23077 | 66 #include <cdio/cdio.h> |
67 #endif | |
68 | |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34393
diff
changeset
|
69 #define SAME_STREAMTYPE (STREAMTYPE_DUMMY - 1) |
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34393
diff
changeset
|
70 |
23077 | 71 int guiWinID = 0; |
72 | |
73 char *skinName = NULL; | |
74 char *codecname = NULL; | |
33555 | 75 int uiGotoTheNext = 1; |
23077 | 76 static gui_t *mygui = NULL; |
77 static int update_subwindow(void); | |
78 static RECT old_rect; | |
79 static DWORD style; | |
24992 | 80 static HANDLE hThread; |
81 static unsigned threadId; | |
25765
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
82 const ao_functions_t *audio_out = NULL; |
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
83 const vo_functions_t *video_out = NULL; |
23077 | 84 mixer_t *mixer = NULL; |
85 | |
34392 | 86 #ifdef __WINE__ |
87 /** | |
34393
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
88 * @brief Convert a Windows style path to a file name into an Unix style one. |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
89 * |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
90 * @param filename pointer to the file path to be converted |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
91 * |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
92 * @return pointer to the converted file path |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
93 */ |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
94 static char *unix_name (char *filename) |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
95 { |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
96 static char *unix_filename; |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
97 LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
98 int wchar_conv; |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
99 |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
100 if (*filename && (filename[1] == ':')) |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
101 { |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
102 wine_get_unix_file_name_ptr = (void *) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_unix_file_name"); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
103 wchar_conv = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
104 |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
105 if (wine_get_unix_file_name_ptr && wchar_conv) |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
106 { |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
107 WCHAR *ntpath; |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
108 char *unix_name; |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
109 |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
110 ntpath = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath) * (wchar_conv + 1)); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
111 MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, ntpath, wchar_conv); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
112 unix_name = wine_get_unix_file_name_ptr(ntpath); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
113 setdup(&unix_filename, unix_name); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
114 filename = unix_filename; |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
115 HeapFree(GetProcessHeap(), 0, unix_name); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
116 HeapFree(GetProcessHeap(), 0, ntpath); |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
117 } |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
118 } |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
119 |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
120 return filename; |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
121 } |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
122 |
4c8bdc633648
Cosmetic: Collect together Wine port related functions.
ib
parents:
34392
diff
changeset
|
123 /** |
34392 | 124 * @brief Convert a Windows style device name into an Unix style one. |
125 * | |
126 * @param device pointer to the device name to be converted | |
127 * | |
128 * @return pointer to the converted device name | |
129 */ | |
130 static char *unix_device (char *device) | |
131 { | |
132 static char *unix_devname; | |
133 HANDLE mgr; | |
134 DWORD size = 1024; | |
135 | |
136 mgr = CreateFileW(MOUNTMGR_DOS_DEVICE_NAME, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); | |
137 | |
138 if (mgr != INVALID_HANDLE_VALUE) | |
139 { | |
140 struct mountmgr_unix_drive input; | |
141 struct mountmgr_unix_drive *data; | |
142 | |
143 data = HeapAlloc(GetProcessHeap(), 0, size); | |
144 | |
145 if (data) | |
146 { | |
147 memset(&input, 0, sizeof(input)); | |
148 input.letter = *device; | |
149 | |
150 if (DeviceIoControl(mgr, IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE, &input, sizeof(input), data, size, NULL, NULL)) | |
151 { | |
152 if (data->device_offset) | |
153 { | |
154 setdup(&unix_devname, (char *) data + data->device_offset); | |
155 device = unix_devname; | |
156 } | |
157 } | |
158 | |
159 HeapFree(GetProcessHeap(), 0, data); | |
160 } | |
161 | |
162 CloseHandle(mgr); | |
163 } | |
164 | |
165 return device; | |
166 } | |
167 #endif | |
168 | |
23077 | 169 /* test for playlist files, no need to specify -playlist on the commandline. |
170 * add any conceivable playlist extensions here. | |
171 * - Erik | |
172 */ | |
173 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear) | |
174 { | |
175 if(clear) | |
176 mygui->playlist->clear_playlist(mygui->playlist); | |
177 | |
178 if(strstr(file, ".m3u") || strstr(file, ".pls")) | |
179 { | |
180 playtree = parse_playlist_file(file); | |
33752 | 181 guiPlaylistAdd(playtree, mconfig); |
23077 | 182 return 1; |
183 } | |
184 return 0; | |
185 } | |
186 | |
187 /* this function gets called by the gui to update mplayer */ | |
188 static void guiSetEvent(int event) | |
189 { | |
33555 | 190 if(guiInfo.mpcontext) |
191 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
23077 | 192 |
193 switch(event) | |
194 { | |
195 case evPlay: | |
196 case evPlaySwitchToPause: | |
23148
71efd1fc20c8
add missing case value, fixes functionality when using some skins.
vayne
parents:
23147
diff
changeset
|
197 case evPauseSwitchToPlay: |
33555 | 198 uiPlay(); |
23077 | 199 break; |
200 case evPause: | |
33555 | 201 uiPause(); |
23077 | 202 break; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
203 #ifdef CONFIG_DVDREAD |
23077 | 204 case evPlayDVD: |
205 { | |
206 static char dvdname[MAX_PATH]; | |
34391 | 207 guiInfo.Track = 1; |
208 guiInfo.Chapter = 1; | |
209 guiInfo.Angle = 1; | |
33890 | 210 guiInfo.NewPlay = GUI_FILE_SAME; |
23077 | 211 |
34392 | 212 #ifdef __WINE__ |
213 // dvd_device is in the Windows style (D:\), which needs to be | |
214 // converted for MPlayer, so that it will find the device in the | |
215 // Linux filesystem. | |
216 dvd_device = unix_device(dvd_device); | |
217 #endif | |
33555 | 218 uiSetFileName(NULL, dvd_device, STREAMTYPE_DVD); |
23077 | 219 dvdname[0] = 0; |
220 strcat(dvdname, "DVD Movie"); | |
221 GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
222 capitalize(dvdname); | |
223 mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); | |
224 mygui->playlist->clear_playlist(mygui->playlist); | |
225 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); | |
34391 | 226 uiPlay(); |
23077 | 227 break; |
228 } | |
229 #endif | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
230 #ifdef CONFIG_LIBCDIO |
23077 | 231 case evPlayCD: |
232 { | |
233 int i; | |
234 char track[10]; | |
235 char trackname[10]; | |
236 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN); | |
237 track_t i_tracks; | |
238 | |
239 if(p_cdio == NULL) printf("Couldn't find a driver.\n"); | |
240 i_tracks = cdio_get_num_tracks(p_cdio); | |
241 | |
242 mygui->playlist->clear_playlist(mygui->playlist); | |
243 for(i=0;i<i_tracks;i++) | |
244 { | |
245 sprintf(track, "cdda://%d", i+1); | |
246 sprintf(trackname, "Track %d", i+1); | |
247 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); | |
248 } | |
249 cdio_destroy(p_cdio); | |
250 mygui->startplay(mygui); | |
251 break; | |
252 } | |
253 #endif | |
254 case evFullScreen: | |
255 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
256 break; | |
257 case evExit: | |
258 { | |
259 /* We are asking mplayer to exit, later it will ask us after uninit is made | |
260 this should be the only safe way to quit */ | |
261 mygui->activewidget = NULL; | |
262 mp_input_queue_cmd(mp_input_parse_cmd("quit")); | |
263 break; | |
264 } | |
265 case evStop: | |
33555 | 266 if(guiInfo.Playing) |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
267 gui(GUI_SET_STATE, (void *) GUI_STOP); |
23077 | 268 break; |
269 case evSetMoviePosition: | |
270 { | |
33555 | 271 rel_seek_secs = guiInfo.Position / 100.0f; |
23077 | 272 abs_seek_pos = 3; |
273 break; | |
274 } | |
275 case evForward10sec: | |
276 { | |
277 rel_seek_secs = 10.0f; | |
278 abs_seek_pos = 0; | |
279 break; | |
280 } | |
281 case evBackward10sec: | |
282 { | |
283 rel_seek_secs = -10.0f; | |
284 abs_seek_pos = 0; | |
285 break; | |
286 } | |
287 case evSetBalance: | |
288 case evSetVolume: | |
289 { | |
290 float l,r; | |
291 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
292 if (guiInfo.Playing == GUI_STOP) |
23077 | 293 break; |
294 | |
33555 | 295 if (guiInfo.Balance == 50.0f) |
296 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); | |
23077 | 297 |
33555 | 298 l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); |
299 r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); | |
23077 | 300 |
33555 | 301 if (l > guiInfo.Volume) l=guiInfo.Volume; |
302 if (r > guiInfo.Volume) r=guiInfo.Volume; | |
23077 | 303 mixer_setvolume(mixer, l, r); |
304 /* Check for balance support on mixer - there is a better way ?? */ | |
305 if (r != l) | |
306 { | |
307 mixer_getvolume(mixer, &l, &r); | |
308 if (r == l) | |
309 { | |
310 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); | |
33555 | 311 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); |
312 guiInfo.Balance = 50.0f; | |
23077 | 313 } |
314 } | |
315 break; | |
316 } | |
317 case evMute: | |
318 { | |
319 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
320 cmd->id=MP_CMD_MUTE; | |
321 cmd->name=strdup("mute"); | |
322 mp_input_queue_cmd(cmd); | |
323 break; | |
324 } | |
325 case evLoadPlay: | |
326 { | |
33555 | 327 switch(guiInfo.StreamType) |
23077 | 328 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
329 #ifdef CONFIG_DVDREAD |
23077 | 330 case STREAMTYPE_DVD: |
331 { | |
33890 | 332 guiInfo.NewPlay = GUI_FILE_SAME; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
333 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 334 break; |
335 } | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23123
diff
changeset
|
336 #endif |
23077 | 337 default: |
338 { | |
33890 | 339 guiInfo.NewPlay = GUI_FILE_NEW; |
23077 | 340 update_playlistwindow(); |
33555 | 341 uiGotoTheNext = guiInfo.Playing? 0 : 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
342 gui(GUI_SET_STATE, (void *) GUI_STOP); |
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
343 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 344 break; |
345 } | |
346 } | |
347 break; | |
348 } | |
349 case evNext: | |
33555 | 350 uiNext(); |
23077 | 351 break; |
352 case evPrev: | |
33555 | 353 uiPrev(); |
23077 | 354 break; |
355 } | |
356 } | |
357 | |
33555 | 358 void uiPlay( void ) |
23077 | 359 { |
33555 | 360 if((!guiInfo.Filename ) || (guiInfo.Filename[0] == 0)) |
23077 | 361 return; |
362 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
363 if(guiInfo.Playing > GUI_STOP) |
23077 | 364 { |
33555 | 365 uiPause(); |
23077 | 366 return; |
367 } | |
33890 | 368 guiInfo.NewPlay = GUI_FILE_NEW; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
369 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 370 } |
371 | |
33555 | 372 void uiPause( void ) |
23077 | 373 { |
33555 | 374 if(!guiInfo.Playing) return; |
23077 | 375 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
376 if(guiInfo.Playing == GUI_PLAY) |
23077 | 377 { |
378 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
379 cmd->id=MP_CMD_PAUSE; | |
380 cmd->name=strdup("pause"); | |
381 mp_input_queue_cmd(cmd); | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
382 } else guiInfo.Playing = GUI_PLAY; |
23077 | 383 } |
384 | |
33555 | 385 void uiNext(void) |
23077 | 386 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
387 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 388 switch(guiInfo.StreamType) |
23077 | 389 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
390 #ifdef CONFIG_DVDREAD |
23077 | 391 case STREAMTYPE_DVD: |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
392 if(guiInfo.Chapter == (guiInfo.Chapters - 1)) |
23077 | 393 return; |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
394 guiInfo.Chapter++; |
23077 | 395 break; |
396 #endif | |
397 default: | |
398 if(mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
399 return; | |
33555 | 400 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, |
34075 | 401 STREAMTYPE_FILE); |
23077 | 402 break; |
403 } | |
404 mygui->startplay(mygui); | |
405 } | |
406 | |
33555 | 407 void uiPrev(void) |
23077 | 408 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
409 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 410 switch(guiInfo.StreamType) |
23077 | 411 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
412 #ifdef CONFIG_DVDREAD |
23077 | 413 case STREAMTYPE_DVD: |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
414 if(guiInfo.Chapter == 1) |
23077 | 415 return; |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
416 guiInfo.Chapter--; |
23077 | 417 break; |
418 #endif | |
419 default: | |
420 if(mygui->playlist->current == 0) | |
421 return; | |
33555 | 422 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename, |
34075 | 423 STREAMTYPE_FILE); |
23077 | 424 break; |
425 } | |
426 mygui->startplay(mygui); | |
427 } | |
428 | |
33555 | 429 void uiSetFileName(char *dir, char *name, int type) |
23077 | 430 { |
431 if(!name) return; | |
432 if(!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
433 setdup(&guiInfo.Filename, name); |
23077 | 434 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
435 setddup(&guiInfo.Filename, dir, name); |
23077 | 436 |
34064 | 437 filename = guiInfo.Filename; |
34115 | 438 #ifdef __WINE__ |
34127
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
439 // When the GUI receives the files to be played in guiPlaylistInitialize() |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
440 // and guiPlaylistAdd(), it calls import_file_into_gui() where the call of |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
441 // Wine's GetFullPathName() converts each file name into the Windows style |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
442 // (C:\path\to\file), which needs to be reconverted for MPlayer, so that |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
443 // it will find the filename in the Linux filesystem. |
34123 | 444 filename = unix_name(filename); |
34115 | 445 #endif |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34393
diff
changeset
|
446 |
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34393
diff
changeset
|
447 if (type != SAME_STREAMTYPE) |
33555 | 448 guiInfo.StreamType = type; |
34064 | 449 |
33897 | 450 nfree(guiInfo.AudioFilename); |
451 nfree(guiInfo.SubtitleFilename); | |
23077 | 452 } |
453 | |
33555 | 454 void uiFullScreen( void ) |
23077 | 455 { |
33555 | 456 if(!guiInfo.sh_video) return; |
23077 | 457 |
458 if(sub_window) | |
459 { | |
460 if(!fullscreen && IsWindowVisible(mygui->subwindow) && !IsIconic(mygui->subwindow)) | |
461 GetWindowRect(mygui->subwindow, &old_rect); | |
462 | |
463 if(fullscreen) | |
464 { | |
465 fullscreen = 0; | |
466 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; | |
467 } else { | |
468 fullscreen = 1; | |
469 style = WS_VISIBLE | WS_POPUP; | |
470 } | |
471 SetWindowLong(mygui->subwindow, GWL_STYLE, style); | |
472 update_subwindow(); | |
473 } | |
474 video_out->control(VOCTRL_FULLSCREEN, 0); | |
475 if(sub_window) ShowWindow(mygui->subwindow, SW_SHOW); | |
476 } | |
477 | |
24992 | 478 static unsigned __stdcall GuiThread(void* param) |
23077 | 479 { |
480 MSG msg; | |
481 | |
482 if(!skinName) skinName = strdup("Blue"); | |
33781 | 483 if(!mygui) mygui = create_gui(get_path("skins"), guiSetEvent); |
30558 | 484 if(!mygui) exit_player(EXIT_ERROR); |
23077 | 485 |
486 if(autosync && autosync != gtkAutoSync) | |
487 { | |
488 gtkAutoSyncOn = 1; | |
489 gtkAutoSync = autosync; | |
490 } | |
491 | |
24992 | 492 while(GetMessage(&msg, NULL, 0, 0)) |
23077 | 493 { |
494 TranslateMessage(&msg); | |
495 DispatchMessage(&msg); | |
496 } | |
23078 | 497 fprintf(stderr, "[GUI] GUI thread terminated.\n"); |
23077 | 498 fflush(stderr); |
499 return 0; | |
500 } | |
501 | |
502 void guiInit(void) | |
503 { | |
33555 | 504 memset(&guiInfo, 0, sizeof(guiInfo)); |
23077 | 505 /* Create The gui thread */ |
506 if (!mygui) | |
507 { | |
33358 | 508 hThread = _beginthreadex(NULL, 0, GuiThread, NULL, 0, &threadId); |
23077 | 509 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", threadId); |
510 } | |
511 | |
512 /* Wait until the gui is created */ | |
513 while(!mygui) Sleep(100); | |
23078 | 514 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] GUI thread started.\n"); |
23077 | 515 } |
516 | |
517 void guiDone(void) | |
518 { | |
519 if(mygui) | |
520 { | |
521 fprintf(stderr, "[GUI] Closed by main mplayer window\n"); | |
522 fflush(stderr); | |
24992 | 523 PostThreadMessage(threadId, WM_QUIT, 0, 0); |
524 WaitForSingleObject(hThread, INFINITE); | |
525 CloseHandle(hThread); | |
23077 | 526 mygui->uninit(mygui); |
33770 | 527 nfree(mygui); |
23077 | 528 } |
529 /* Remove tray icon */ | |
530 Shell_NotifyIcon(NIM_DELETE, &nid); | |
531 cfg_write(); | |
532 } | |
533 | |
534 /* this function gets called by mplayer to update the gui */ | |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
535 int gui(int what, void *data) |
23077 | 536 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
537 stream_t *stream = data; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
538 #ifdef CONFIG_DVDREAD |
33730 | 539 dvd_priv_t *dvdp; |
23077 | 540 #endif |
541 if(!mygui || !mygui->skin) return 0; | |
542 | |
33555 | 543 if(guiInfo.mpcontext) |
23077 | 544 { |
33555 | 545 audio_out = mpctx_get_audio_out(guiInfo.mpcontext); |
546 video_out = mpctx_get_video_out(guiInfo.mpcontext); | |
547 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
548 playtree = mpctx_get_playtree_iter(guiInfo.mpcontext); | |
23077 | 549 } |
550 | |
33726 | 551 switch (what) |
23077 | 552 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
553 case GUI_PREPARE: |
23077 | 554 { |
34052 | 555 audio_id = -1; |
556 video_id = -1; | |
557 dvdsub_id = -1; | |
558 vobsub_id = -1; | |
559 stream_cache_size = -1; | |
560 autosync = 0; | |
561 dvd_title = 0; | |
562 force_fps = 0; | |
563 if(!mygui->playlist->tracks) return 0; | |
34391 | 564 switch(guiInfo.StreamType) |
565 { | |
566 case STREAMTYPE_FILE: | |
567 case STREAMTYPE_STREAM: | |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34393
diff
changeset
|
568 uiSetFileName(NULL, mygui->playlist->tracks[mygui->playlist->current]->filename, SAME_STREAMTYPE); |
34391 | 569 guiInfo.Track = mygui->playlist->current + 1; |
570 break; | |
571 #ifdef CONFIG_DVDREAD | |
572 case STREAMTYPE_DVD: | |
573 { | |
574 char tmp[512]; | |
575 dvd_chapter = guiInfo.Chapter; | |
576 dvd_angle = guiInfo.Angle; | |
577 sprintf(tmp,"dvd://%d", guiInfo.Track); | |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34393
diff
changeset
|
578 uiSetFileName(NULL, tmp, SAME_STREAMTYPE); |
34391 | 579 break; |
580 } | |
581 #endif | |
582 } | |
34126 | 583 guiInfo.VideoWindow = 1; |
34052 | 584 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); |
585 if(gtkAOExtraStereo) | |
586 { | |
587 char *name = malloc(12 + 20 + 1); | |
588 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
589 name[12 + 20] = 0; | |
590 greplace(&af_cfg.list, "extrastereo", name); | |
591 free(name); | |
592 } | |
593 if(gtkCacheOn) stream_cache_size = gtkCacheSize; | |
594 if(gtkAutoSyncOn) autosync = gtkAutoSync; | |
33555 | 595 guiInfo.NewPlay = 0; |
23077 | 596 break; |
597 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
598 case GUI_SET_AUDIO: |
23077 | 599 { |
34126 | 600 if (data && !guiInfo.sh_video) guiInfo.VideoWindow = 0; |
601 if(IsWindowVisible(mygui->subwindow) && !guiInfo.VideoWindow) | |
23077 | 602 ShowWindow(mygui->subwindow, SW_HIDE); |
603 break; | |
604 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
605 case GUI_SET_CONTEXT: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
606 guiInfo.mpcontext = data; |
23077 | 607 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
608 case GUI_SET_VIDEO: |
23077 | 609 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
610 guiInfo.sh_video = data; |
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
611 if (data) |
23077 | 612 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
613 sh_video_t *sh = data; |
23077 | 614 codecname = sh->codec->name; |
615 | |
616 /* we have video, show the subwindow */ | |
617 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) | |
618 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
619 if(WinID == -1) | |
620 update_subwindow(); | |
621 | |
622 } | |
623 break; | |
624 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
625 case GUI_SETUP_VIDEO_WINDOW: |
23077 | 626 { |
33901 | 627 guiInfo.VideoWidth = vo_dwidth; |
628 guiInfo.VideoHeight = vo_dheight; | |
23077 | 629 |
33901 | 630 sub_aspect = (float)guiInfo.VideoWidth/guiInfo.VideoHeight; |
23077 | 631 if(WinID != -1) |
632 update_subwindow(); | |
633 break; | |
634 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
635 case GUI_SET_STREAM: |
23077 | 636 { |
33555 | 637 guiInfo.StreamType = stream->type; |
23077 | 638 switch(stream->type) |
639 { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
640 #ifdef CONFIG_DVDREAD |
23077 | 641 case STREAMTYPE_DVD: |
33730 | 642 dvdp = stream->priv; |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
643 guiInfo.Tracks = dvdp->vmg_file->tt_srpt->nr_of_srpts; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
644 guiInfo.Chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
645 guiInfo.Angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; |
33902 | 646 guiInfo.AudioStreams = dvdp->nr_of_channels; |
647 memcpy(guiInfo.AudioStream, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
648 guiInfo.Subtitles = dvdp->nr_of_subtitles; | |
649 memcpy(guiInfo.Subtitle, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
650 guiInfo.Chapter = dvd_chapter + 1; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
651 guiInfo.Angle = dvd_angle + 1; |
33730 | 652 guiInfo.Track = dvd_title + 1; |
23077 | 653 break; |
654 #endif | |
655 } | |
656 break; | |
657 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
658 case GUI_REDRAW: |
23077 | 659 mygui->updatedisplay(mygui, mygui->mainwindow); |
660 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
661 case GUI_SET_AFILTER: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
662 guiInfo.afilter = data; |
23077 | 663 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
664 case GUI_SET_STATE: |
23077 | 665 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
666 guiInfo.Playing = (int) data; |
33555 | 667 switch (guiInfo.Playing) |
23077 | 668 { |
33614 | 669 case GUI_PLAY: |
23077 | 670 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
671 guiInfo.Playing = GUI_PLAY; |
23077 | 672 break; |
673 } | |
33614 | 674 case GUI_STOP: |
23077 | 675 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
676 guiInfo.Playing = GUI_STOP; |
23077 | 677 if(movie_aspect >= 0) |
678 movie_aspect = -1; | |
679 update_subwindow(); | |
680 break; | |
681 } | |
33614 | 682 case GUI_PAUSE: |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
683 guiInfo.Playing = GUI_PAUSE; |
23077 | 684 break; |
685 } | |
686 break; | |
687 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
688 case GUI_RUN_COMMAND: |
23077 | 689 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
690 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) data); |
23077 | 691 /* MPlayer asks us to quit */ |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
692 switch((int) data) |
23077 | 693 { |
31312
0b7792622c88
Remove Gui-specific slave commands and associated key-bindings and other code.
reimar
parents:
30901
diff
changeset
|
694 case MP_CMD_VO_FULLSCREEN: |
33555 | 695 uiFullScreen(); |
23077 | 696 break; |
697 case MP_CMD_QUIT: | |
698 { | |
699 mygui->uninit(mygui); | |
33770 | 700 nfree(mygui); |
30558 | 701 exit_player(EXIT_QUIT); |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
702 return 1; |
23077 | 703 } |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
704 case MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
705 guiSetEvent(evNext); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
706 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
707 case -MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
708 guiSetEvent(evPrev); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
709 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
710 case MP_CMD_STOP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
711 guiSetEvent(evStop); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
712 break; |
23077 | 713 default: |
714 break; | |
715 } | |
716 break; | |
717 } | |
34339 | 718 case GUI_RUN_MESSAGE: |
719 break; | |
33732 | 720 case GUI_HANDLE_EVENTS: |
721 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
722 case GUI_SET_MIXER: |
23077 | 723 { |
724 if(audio_out) | |
725 { | |
726 /* Some audio_out drivers do not support balance e.g. dsound */ | |
727 /* FIXME this algo is not correct */ | |
728 float l, r; | |
729 mixer_getvolume(mixer, &l, &r); | |
33555 | 730 guiInfo.Volume = (r > l ? r : l); /* max(r,l) */ |
23077 | 731 if (r != l) |
33555 | 732 guiInfo.Balance = ((r-l) + 100.0f) * 0.5f; |
23077 | 733 else |
33555 | 734 guiInfo.Balance = 50.0f; |
23077 | 735 } |
736 break; | |
737 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
738 case GUI_END_FILE: |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
739 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
740 if(!uiGotoTheNext && guiInfo.Playing) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
741 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
742 uiGotoTheNext = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
743 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
744 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
745 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
746 if(uiGotoTheNext && guiInfo.Playing && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
747 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
748 guiInfo.StreamType != STREAMTYPE_DVD && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
749 guiInfo.StreamType != STREAMTYPE_DVDNAV) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
750 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
751 /* we've finished this file, reset the aspect */ |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
752 if(movie_aspect >= 0) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
753 movie_aspect = -1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
754 |
33894 | 755 uiGotoTheNext = 1; |
33890 | 756 guiInfo.NewPlay = GUI_FILE_NEW; |
34075 | 757 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_FILE); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
758 //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
759 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
760 |
33894 | 761 if(guiInfo.NewPlay == GUI_FILE_NEW) |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
762 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
763 |
33897 | 764 guiInfo.ElapsedTime = 0; |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
765 guiInfo.Position = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
766 guiInfo.AudioChannels = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
767 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
768 #ifdef CONFIG_DVDREAD |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
769 guiInfo.Track = 1; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
770 guiInfo.Chapter = 1; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
771 guiInfo.Angle = 1; |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
772 #endif |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
773 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
774 if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
775 mygui->playlist->current = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
776 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
777 fullscreen = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
778 if(style == WS_VISIBLE | WS_POPUP) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
779 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
780 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
781 SetWindowLong(mygui->subwindow, GWL_STYLE, style); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
782 } |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
783 gui(GUI_SET_STATE, (void *) GUI_STOP); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
784 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
785 } |
23077 | 786 default: |
33726 | 787 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", what); |
23077 | 788 } |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
789 return 1; |
23077 | 790 } |
791 | |
792 /* This function adds/inserts one file into the gui playlist */ | |
33579 | 793 static int import_file_into_gui(char *pathname, int insert) |
23077 | 794 { |
795 char filename[MAX_PATH]; | |
796 char *filepart = filename; | |
797 | |
798 if (strstr(pathname, "://")) | |
799 { | |
800 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname); | |
801 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0); | |
802 return 1; | |
803 } | |
804 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart)) | |
805 { | |
806 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)) | |
807 { | |
808 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename); | |
809 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0); | |
810 return 1; | |
811 } | |
812 else | |
813 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename); | |
814 } | |
815 | |
816 return 0; | |
817 } | |
818 | |
819 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
820 by either: | |
821 - overwriting gui pl (enqueue=0) */ | |
822 | |
33752 | 823 int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue) |
23077 | 824 { |
825 play_tree_iter_t *my_pt_iter = NULL; | |
826 int result = 0; | |
827 | |
828 if(!mygui) guiInit(); | |
829 | |
830 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
831 { | |
832 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
833 { | |
834 if (parse_filename(filename, my_playtree, config, 0)) | |
835 result = 1; | |
836 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */ | |
837 result = 1; | |
838 } | |
839 } | |
33555 | 840 uiGotoTheNext = 1; |
23077 | 841 |
842 if (result) | |
843 { | |
844 mygui->playlist->current = 0; | |
34068 | 845 uiSetFileName(NULL, mygui->playlist->tracks[0]->filename, STREAMTYPE_FILE); |
23077 | 846 } |
34084 | 847 |
848 if (enqueue) filename = NULL; | |
849 | |
23077 | 850 return result; |
851 } | |
852 | |
853 /* This function imports and inserts an playtree, that is created "on the fly", for example by | |
854 parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
855 The file which contained the playlist is thereby replaced with it's contents. */ | |
856 | |
33752 | 857 int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config) |
23077 | 858 { |
859 play_tree_iter_t *my_pt_iter = NULL; | |
860 int result = 0; | |
861 | |
862 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
863 { | |
864 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
865 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */ | |
866 result = 1; | |
867 pt_iter_destroy(&my_pt_iter); | |
868 } | |
869 return result; | |
870 } | |
871 | |
872 static int update_subwindow(void) | |
873 { | |
874 int x,y; | |
875 RECT rd; | |
876 WINDOWPOS wp; | |
877 | |
878 if(!sub_window) | |
879 { | |
33567 | 880 WinID = -1; |
23077 | 881 |
33555 | 882 if(IsWindowVisible(mygui->subwindow) && guiInfo.sh_video && guiInfo.Playing) |
23077 | 883 { |
884 ShowWindow(mygui->subwindow, SW_HIDE); | |
885 return 0; | |
886 } | |
33901 | 887 else if(!guiInfo.VideoWindow) |
23077 | 888 return 0; |
889 else ShowWindow(mygui->subwindow, SW_SHOW); | |
890 } | |
891 | |
892 /* we've come out of fullscreen at the end of file */ | |
33901 | 893 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && guiInfo.VideoWindow) |
23077 | 894 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); |
895 | |
896 /* get our current window coordinates */ | |
897 GetWindowRect(mygui->subwindow, &rd); | |
898 | |
899 x = rd.left; | |
900 y = rd.top; | |
901 | |
902 /* restore sub window position when coming out of fullscreen */ | |
903 if(x <= 0) x = old_rect.left; | |
904 if(y <= 0) y = old_rect.top; | |
905 | |
33555 | 906 if(!guiInfo.Playing) |
23077 | 907 { |
908 window *desc = NULL; | |
909 int i; | |
910 | |
911 for (i=0; i<mygui->skin->windowcount; i++) | |
912 if(mygui->skin->windows[i]->type == wiSub) | |
913 desc = mygui->skin->windows[i]; | |
914 | |
915 rd.right = rd.left+desc->base->bitmap[0]->width; | |
916 rd.bottom = rd.top+desc->base->bitmap[0]->height; | |
917 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top); | |
918 } | |
919 else | |
920 { | |
33901 | 921 rd.right = rd.left+guiInfo.VideoWidth; |
922 rd.bottom = rd.top+guiInfo.VideoHeight; | |
23077 | 923 |
924 if (movie_aspect > 0.0) // forced aspect from the cmdline | |
925 sub_aspect = movie_aspect; | |
926 } | |
927 | |
928 | |
929 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
930 SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
931 | |
932 wp.hwnd = mygui->subwindow; | |
933 wp.x = rd.left; | |
934 wp.y = rd.top; | |
935 wp.cx = rd.right-rd.left; | |
936 wp.cy = rd.bottom-rd.top; | |
937 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW; | |
938 | |
939 /* erase the bitmap image if there's video */ | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
940 if(guiInfo.Playing != GUI_STOP && guiInfo.sh_video) |
23077 | 941 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0); |
942 | |
943 /* reset the window aspect */ | |
944 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); | |
945 return 0; | |
946 } |