]> git.sesse.net Git - vlc/blob - modules/video_output/msw/vout.h
Fixed a potential race condition between "event thread" and manage() (msw).
[vlc] / modules / video_output / msw / vout.h
1 /*****************************************************************************
2  * vout.h: Windows video output header file
3  *****************************************************************************
4  * Copyright (C) 2001-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *          Damien Fouilleul <damienf@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * event_thread_t: event thread
27  *****************************************************************************/
28 typedef struct
29 {
30     vout_thread_t *p_vout;
31
32     /* */
33     vlc_thread_t thread;
34     vlc_mutex_t  lock;
35     vlc_cond_t   wait;
36     bool         b_ready;
37     bool         b_done;
38     bool         b_error;
39
40     /* Mouse */
41     volatile bool    b_cursor_hidden;
42     volatile mtime_t i_lastmoved;
43     mtime_t          i_mouse_hide_timeout;
44
45     /* Title */
46     char *psz_title;
47
48     /* */
49     unsigned i_changes;
50
51 } event_thread_t;
52
53 #ifdef MODULE_NAME_IS_wingapi
54     typedef struct GXDisplayProperties {
55         DWORD cxWidth;
56         DWORD cyHeight;
57         long cbxPitch;
58         long cbyPitch;
59         long cBPP;
60         DWORD ffFormat;
61     } GXDisplayProperties;
62
63     typedef struct GXScreenRect {
64         DWORD dwTop;
65         DWORD dwLeft;
66         DWORD dwWidth;
67         DWORD dwHeight;
68     } GXScreenRect;
69
70 #   define GX_FULLSCREEN    0x01
71 #   define GX_NORMALKEYS    0x02
72 #   define GX_LANDSCAPEKEYS 0x03
73
74 #   ifndef kfLandscape
75 #       define kfLandscape      0x8
76 #       define kfPalette        0x10
77 #       define kfDirect         0x20
78 #       define kfDirect555      0x40
79 #       define kfDirect565      0x80
80 #       define kfDirect888      0x100
81 #       define kfDirect444      0x200
82 #       define kfDirectInverted 0x400
83 #   endif
84
85 #endif
86
87 struct vout_window_t;
88
89 /*****************************************************************************
90  * vout_sys_t: video output method descriptor
91  *****************************************************************************
92  * This structure is part of the video output thread descriptor.
93  * It describes the module specific properties of an output thread.
94  *****************************************************************************/
95 struct vout_sys_t
96 {
97     HWND                 hwnd;                  /* Handle of the main window */
98     HWND                 hvideownd;        /* Handle of the video sub-window */
99     struct vout_window_t *parent_window;         /* Parent window VLC object */
100     HWND                 hparent;             /* Handle of the parent window */
101     HWND                 hfswnd;          /* Handle of the fullscreen window */
102
103     /* Multi-monitor support */
104     HMONITOR             hmonitor;          /* handle of the current monitor */
105     GUID                 *p_display_driver;
106     HMONITOR             (WINAPI* MonitorFromWindow)( HWND, DWORD );
107     BOOL                 (WINAPI* GetMonitorInfo)( HMONITOR, LPMONITORINFO );
108
109     /* size of the display */
110     RECT         rect_display;
111     int          i_display_depth;
112
113     /* size of the overall window (including black bands) */
114     RECT         rect_parent;
115
116     /* Window position and size */
117     int          i_window_x;
118     int          i_window_y;
119     int          i_window_width;
120     int          i_window_height;
121     int          i_window_style;
122
123     volatile uint16_t i_changes;        /* changes made to the video display */
124
125     /* Misc */
126     bool      b_on_top_change;
127
128 #ifndef UNDER_CE
129
130     /* screensaver system settings to be restored when vout is closed */
131     UINT i_spi_lowpowertimeout;
132     UINT i_spi_powerofftimeout;
133     UINT i_spi_screensavetimeout;
134
135 #endif
136
137     /* Coordinates of src and dest images (used when blitting to display) */
138     RECT         rect_src;
139     RECT         rect_src_clipped;
140     RECT         rect_dest;
141     RECT         rect_dest_clipped;
142
143     bool   b_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
144
145
146 #ifdef MODULE_NAME_IS_directx
147     /* Overlay alignment restrictions */
148     int          i_align_src_boundary;
149     int          i_align_src_size;
150     int          i_align_dest_boundary;
151     int          i_align_dest_size;
152
153     bool      b_wallpaper;    /* show as desktop wallpaper ? */
154
155     bool   b_using_overlay;         /* Are we using an overlay surface */
156     bool   b_use_sysmem;   /* Should we use system memory for surfaces */
157     bool   b_3buf_overlay;   /* Should we use triple buffered overlays */
158
159     /* DDraw capabilities */
160     int          b_caps_overlay_clipping;
161
162     unsigned int    i_rgb_colorkey;      /* colorkey in RGB used by the overlay */
163     unsigned int    i_colorkey;                 /* colorkey used by the overlay */
164
165     COLORREF        color_bkg;
166     COLORREF        color_bkgtxt;
167
168     LPDIRECTDRAW2        p_ddobject;                    /* DirectDraw object */
169     LPDIRECTDRAWSURFACE2 p_display;                        /* Display device */
170     LPDIRECTDRAWSURFACE2 p_current_surface;   /* surface currently displayed */
171     LPDIRECTDRAWCLIPPER  p_clipper;             /* clipper used for blitting */
172     HINSTANCE            hddraw_dll;       /* handle of the opened ddraw dll */
173 #endif
174
175 #ifdef MODULE_NAME_IS_glwin32
176     HDC hGLDC;
177     HGLRC hGLRC;
178 #endif
179
180 #ifdef MODULE_NAME_IS_direct3d
181     /* show video on desktop window ? */
182     bool      b_desktop;
183
184     // core objects
185     HINSTANCE               hd3d9_dll;       /* handle of the opened d3d9 dll */
186     LPDIRECT3D9             p_d3dobj;
187     LPDIRECT3DDEVICE9       p_d3ddev;
188     D3DFORMAT               bbFormat;
189     // scene objects
190     LPDIRECT3DTEXTURE9      p_d3dtex;
191     LPDIRECT3DVERTEXBUFFER9 p_d3dvtc;
192 #endif
193
194 #ifdef MODULE_NAME_IS_wingdi
195
196     int  i_depth;
197
198     /* Our offscreen bitmap and its framebuffer */
199     HDC        off_dc;
200     HBITMAP    off_bitmap;
201     uint8_t *  p_pic_buffer;
202     int        i_pic_pitch;
203     int        i_pic_pixel_pitch;
204
205     BITMAPINFO bitmapinfo;
206     RGBQUAD    red;
207     RGBQUAD    green;
208     RGBQUAD    blue;
209 #endif
210
211 #ifdef MODULE_NAME_IS_wingapi
212     int        i_depth;
213     int        render_width;
214     int        render_height;
215             /* Our offscreen bitmap and its framebuffer */
216     HDC        off_dc;
217     HBITMAP    off_bitmap;
218     uint8_t *  p_pic_buffer;
219     int        i_pic_pitch;
220     int        i_pic_pixel_pitch;
221
222     BITMAPINFO bitmapinfo;
223     RGBQUAD    red;
224     RGBQUAD    green;
225     RGBQUAD    blue;
226
227     HINSTANCE  gapi_dll;                   /* handle of the opened gapi dll */
228
229     /* GAPI functions */
230     int (*GXOpenDisplay)( HWND hWnd, DWORD dwFlags );
231     int (*GXCloseDisplay)();
232     void *(*GXBeginDraw)();
233     int (*GXEndDraw)();
234     GXDisplayProperties (*GXGetDisplayProperties)();
235     int (*GXSuspend)();
236     int (*GXResume)();
237 #endif
238
239 #ifndef UNDER_CE
240     /* suspend display */
241     bool   b_suspend_display;
242 #endif
243
244     event_thread_t *p_event;
245     vlc_mutex_t    lock;
246 };
247
248 #ifdef MODULE_NAME_IS_wingapi
249 #   define GXOpenDisplay p_vout->p_sys->GXOpenDisplay
250 #   define GXCloseDisplay p_vout->p_sys->GXCloseDisplay
251 #   define GXBeginDraw p_vout->p_sys->GXBeginDraw
252 #   define GXEndDraw p_vout->p_sys->GXEndDraw
253 #   define GXGetDisplayProperties p_vout->p_sys->GXGetDisplayProperties
254 #   define GXSuspend p_vout->p_sys->GXSuspend
255 #   define GXResume p_vout->p_sys->GXResume
256 #endif
257
258 /*****************************************************************************
259  * Prototypes from directx.c
260  *****************************************************************************/
261 int DirectDrawUpdateOverlay( vout_thread_t *p_vout );
262
263 /*****************************************************************************
264  * Prototypes from events.c
265  *****************************************************************************/
266 event_thread_t *EventThreadCreate( vout_thread_t * );
267 void            EventThreadDestroy( event_thread_t * );
268 int             EventThreadStart( event_thread_t * );
269 void            EventThreadStop( event_thread_t * );
270
271 void            EventThreadMouseAutoHide( event_thread_t * );
272 void            EventThreadUpdateTitle( event_thread_t *, const char *psz_fallback );
273 unsigned        EventThreadRetreiveChanges( event_thread_t * );
274
275 /*****************************************************************************
276  * Prototypes from common.c
277  *****************************************************************************/
278 int  CommonInit( vout_thread_t * );
279 void CommonClean( vout_thread_t * );
280 void CommonManage( vout_thread_t * );
281
282 int Control( vout_thread_t *p_vout, int i_query, va_list args );
283
284 void UpdateRects ( vout_thread_t *p_vout, bool b_force );
285 void Win32ToggleFullscreen ( vout_thread_t *p_vout );
286 void ExitFullscreen( vout_thread_t *p_vout );
287 #ifndef UNDER_CE
288 void DisableScreensaver ( vout_thread_t *p_vout );
289 void RestoreScreensaver ( vout_thread_t *p_vout );
290 #endif
291
292 /*****************************************************************************
293  * Constants
294  *****************************************************************************/
295 #define WM_VLC_HIDE_MOUSE WM_APP
296 #define WM_VLC_SHOW_MOUSE WM_APP + 1
297 #define WM_VLC_CHANGE_TEXT WM_APP + 2
298 #define IDM_TOGGLE_ON_TOP WM_USER + 1
299 #define DX_POSITION_CHANGE 0x1000
300 #define DX_WALLPAPER_CHANGE 0x2000
301 #define DX_DESKTOP_CHANGE 0x4000
302
303 /*****************************************************************************
304  * WinCE helpers
305  *****************************************************************************/
306 #ifdef UNDER_CE
307
308 #define AdjustWindowRect(a,b,c)
309
310 #ifndef GCL_HBRBACKGROUND
311 #   define GCL_HBRBACKGROUND (-10)
312 #endif
313
314 //#define FindWindowEx(a,b,c,d) 0
315
316 #define GetWindowPlacement(a,b)
317 #define SetWindowPlacement(a,b)
318 /*typedef struct _WINDOWPLACEMENT {
319     UINT length;
320     UINT flags;
321     UINT showCmd;
322     POINT ptMinPosition;
323     POINT ptMaxPosition;
324     RECT rcNormalPosition;
325 } WINDOWPLACEMENT;*/
326
327 #ifndef WM_NCMOUSEMOVE
328 #   define WM_NCMOUSEMOVE 160
329 #endif
330 #ifndef CS_OWNDC
331 #   define CS_OWNDC 32
332 #endif
333 #ifndef SC_SCREENSAVE
334 #   define SC_SCREENSAVE 0xF140
335 #endif
336 #ifndef SC_MONITORPOWER
337 #   define SC_MONITORPOWER 0xF170
338 #endif
339 #ifndef WM_NCPAINT
340 #   define WM_NCPAINT 133
341 #endif
342 #ifndef WS_OVERLAPPEDWINDOW
343 #   define WS_OVERLAPPEDWINDOW 0xcf0000
344 #endif
345 #ifndef WS_EX_NOPARENTNOTIFY
346 #   define WS_EX_NOPARENTNOTIFY 4
347 #endif
348 #ifndef WS_EX_APPWINDOW
349 #define WS_EX_APPWINDOW 0x40000
350 #endif
351
352 //#define SetWindowLongPtr SetWindowLong
353 //#define GetWindowLongPtr GetWindowLong
354 //#define GWLP_USERDATA GWL_USERDATA
355
356 #endif //UNDER_CE