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