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