| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
#ifdef HAVE_CONFIG_H |
|---|
| 31 |
# include "config.h" |
|---|
| 32 |
#endif |
|---|
| 33 |
|
|---|
| 34 |
#include <vlc_common.h> |
|---|
| 35 |
#include <vlc_interface.h> |
|---|
| 36 |
#include <vlc_playlist.h> |
|---|
| 37 |
#include <vlc_vout.h> |
|---|
| 38 |
#include <vlc_keys.h> |
|---|
| 39 |
|
|---|
| 40 |
#include <errno.h> |
|---|
| 41 |
|
|---|
| 42 |
#ifdef HAVE_MACHINE_PARAM_H |
|---|
| 43 |
|
|---|
| 44 |
# include <machine/param.h> |
|---|
| 45 |
# include <sys/types.h> |
|---|
| 46 |
# include <sys/ipc.h> |
|---|
| 47 |
#endif |
|---|
| 48 |
|
|---|
| 49 |
#ifndef WIN32 |
|---|
| 50 |
# include <netinet/in.h> |
|---|
| 51 |
#endif |
|---|
| 52 |
|
|---|
| 53 |
#ifdef HAVE_XSP |
|---|
| 54 |
#include <X11/extensions/Xsp.h> |
|---|
| 55 |
#endif |
|---|
| 56 |
|
|---|
| 57 |
#ifdef HAVE_SYS_SHM_H |
|---|
| 58 |
# include <sys/shm.h> |
|---|
| 59 |
#endif |
|---|
| 60 |
|
|---|
| 61 |
#include <X11/Xlib.h> |
|---|
| 62 |
#include <X11/Xproto.h> |
|---|
| 63 |
#include <X11/Xmd.h> |
|---|
| 64 |
#include <X11/Xutil.h> |
|---|
| 65 |
#include <X11/keysym.h> |
|---|
| 66 |
#include <X11/XF86keysym.h> |
|---|
| 67 |
#ifdef HAVE_SYS_SHM_H |
|---|
| 68 |
# include <X11/extensions/XShm.h> |
|---|
| 69 |
#endif |
|---|
| 70 |
#ifdef DPMSINFO_IN_DPMS_H |
|---|
| 71 |
# include <X11/extensions/dpms.h> |
|---|
| 72 |
#endif |
|---|
| 73 |
|
|---|
| 74 |
#if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc) |
|---|
| 75 |
# include <X11/extensions/Xv.h> |
|---|
| 76 |
# include <X11/extensions/Xvlib.h> |
|---|
| 77 |
#endif |
|---|
| 78 |
|
|---|
| 79 |
#ifdef MODULE_NAME_IS_glx |
|---|
| 80 |
# include <GL/glx.h> |
|---|
| 81 |
#endif |
|---|
| 82 |
|
|---|
| 83 |
#ifdef HAVE_XINERAMA |
|---|
| 84 |
# include <X11/extensions/Xinerama.h> |
|---|
| 85 |
#endif |
|---|
| 86 |
|
|---|
| 87 |
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H |
|---|
| 88 |
# include <X11/extensions/xf86vmode.h> |
|---|
| 89 |
#endif |
|---|
| 90 |
|
|---|
| 91 |
#ifdef MODULE_NAME_IS_xvmc |
|---|
| 92 |
# include <X11/extensions/vldXvMC.h> |
|---|
| 93 |
# include "../../codec/xvmc/accel_xvmc.h" |
|---|
| 94 |
#endif |
|---|
| 95 |
|
|---|
| 96 |
#include "xcommon.h" |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
int Activate ( vlc_object_t * ); |
|---|
| 102 |
void Deactivate ( vlc_object_t * ); |
|---|
| 103 |
|
|---|
| 104 |
static int InitVideo ( vout_thread_t * ); |
|---|
| 105 |
static void EndVideo ( vout_thread_t * ); |
|---|
| 106 |
static void DisplayVideo ( vout_thread_t *, picture_t * ); |
|---|
| 107 |
static int ManageVideo ( vout_thread_t * ); |
|---|
| 108 |
static int Control ( vout_thread_t *, int, va_list ); |
|---|
| 109 |
|
|---|
| 110 |
static int InitDisplay ( vout_thread_t * ); |
|---|
| 111 |
|
|---|
| 112 |
static int CreateWindow ( vout_thread_t *, x11_window_t * ); |
|---|
| 113 |
static void DestroyWindow ( vout_thread_t *, x11_window_t * ); |
|---|
| 114 |
|
|---|
| 115 |
static int NewPicture ( vout_thread_t *, picture_t * ); |
|---|
| 116 |
static void FreePicture ( vout_thread_t *, picture_t * ); |
|---|
| 117 |
|
|---|
| 118 |
#ifndef MODULE_NAME_IS_glx |
|---|
| 119 |
static IMAGE_TYPE *CreateImage ( vout_thread_t *, |
|---|
| 120 |
Display *, EXTRA_ARGS, int, int ); |
|---|
| 121 |
#endif |
|---|
| 122 |
|
|---|
| 123 |
#ifdef HAVE_SYS_SHM_H |
|---|
| 124 |
#ifndef MODULE_NAME_IS_glx |
|---|
| 125 |
IMAGE_TYPE *CreateShmImage ( vout_thread_t *, |
|---|
| 126 |
Display *, EXTRA_ARGS_SHM, int, int ); |
|---|
| 127 |
#endif |
|---|
| 128 |
static int i_shm_major = 0; |
|---|
| 129 |
#endif |
|---|
| 130 |
|
|---|
| 131 |
static void ToggleFullScreen ( vout_thread_t * ); |
|---|
| 132 |
|
|---|
| 133 |
static void EnableXScreenSaver ( vout_thread_t * ); |
|---|
| 134 |
static void DisableXScreenSaver ( vout_thread_t * ); |
|---|
| 135 |
|
|---|
| 136 |
static void CreateCursor ( vout_thread_t * ); |
|---|
| 137 |
static void DestroyCursor ( vout_thread_t * ); |
|---|
| 138 |
static void ToggleCursor ( vout_thread_t * ); |
|---|
| 139 |
|
|---|
| 140 |
#if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc) |
|---|
| 141 |
static int XVideoGetPort ( vout_thread_t *, vlc_fourcc_t, picture_heap_t * ); |
|---|
| 142 |
static void XVideoReleasePort( vout_thread_t *, int ); |
|---|
| 143 |
#endif |
|---|
| 144 |
|
|---|
| 145 |
#ifdef MODULE_NAME_IS_x11 |
|---|
| 146 |
static void SetPalette ( vout_thread_t *, |
|---|
| 147 |
uint16_t *, uint16_t *, uint16_t * ); |
|---|
| 148 |
#endif |
|---|
| 149 |
|
|---|
| 150 |
#ifdef MODULE_NAME_IS_xvmc |
|---|
| 151 |
static void RenderVideo ( vout_thread_t *, picture_t * ); |
|---|
| 152 |
static int xvmc_check_yv12( Display *display, XvPortID port ); |
|---|
| 153 |
static void xvmc_update_XV_DOUBLE_BUFFER( vout_thread_t *p_vout ); |
|---|
| 154 |
#endif |
|---|
| 155 |
|
|---|
| 156 |
static void TestNetWMSupport( vout_thread_t * ); |
|---|
| 157 |
static int ConvertKey( int ); |
|---|
| 158 |
|
|---|
| 159 |
static int WindowOnTop( vout_thread_t *, bool ); |
|---|
| 160 |
|
|---|
| 161 |
static int X11ErrorHandler( Display *, XErrorEvent * ); |
|---|
| 162 |
|
|---|
| 163 |
#ifdef HAVE_XSP |
|---|
| 164 |
static void EnablePixelDoubling( vout_thread_t *p_vout ); |
|---|
| 165 |
static void DisablePixelDoubling( vout_thread_t *p_vout ); |
|---|
| 166 |
#endif |
|---|
| 167 |
|
|---|
| 168 |
#ifdef HAVE_OSSO |
|---|
| 169 |
static const int i_backlight_on_interval = 300; |
|---|
| 170 |
#endif |
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
int Activate ( vlc_object_t *p_this ) |
|---|
| 182 |
{ |
|---|
| 183 |
vout_thread_t *p_vout = (vout_thread_t *)p_this; |
|---|
| 184 |
char * psz_display; |
|---|
| 185 |
vlc_value_t val; |
|---|
| 186 |
#if defined(MODULE_NAME_IS_xvmc) |
|---|
| 187 |
char *psz_value; |
|---|
| 188 |
#endif |
|---|
| 189 |
#if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc) |
|---|
| 190 |
char * psz_chroma; |
|---|
| 191 |
vlc_fourcc_t i_chroma = 0; |
|---|
| 192 |
bool b_chroma = 0; |
|---|
| 193 |
#endif |
|---|
| 194 |
|
|---|
| 195 |
p_vout->pf_init = InitVideo; |
|---|
| 196 |
p_vout->pf_end = EndVideo; |
|---|
| 197 |
p_vout->pf_manage = ManageVideo; |
|---|
| 198 |
#ifdef MODULE_NAME_IS_xvmc |
|---|
| 199 |
p_vout->pf_render = RenderVideo; |
|---|
| 200 |
#else |
|---|
| 201 |
p_vout->pf_render = NULL; |
|---|
| 202 |
#endif |
|---|
| 203 |
p_vout->pf_display = DisplayVideo; |
|---|
| 204 |
p_vout->pf_control = Control; |
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); |
|---|
| 208 |
if( p_vout->p_sys == NULL ) |
|---|
| 209 |
return VLC_ENOMEM; |
|---|
| 210 |
|
|---|
| 211 |
vlc_mutex_init( &p_vout->p_sys->lock ); |
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
psz_display = config_GetPsz( p_vout, MODULE_STRING "-display" ); |
|---|
| 216 |
|
|---|
| 217 |
p_vout->p_sys->p_display = XOpenDisplay( psz_display ); |
|---|
| 218 |
|
|---|
| 219 |
if( p_vout->p_sys->p_display == NULL ) |
|---|
| 220 |
{ |
|---|
| 221 |
msg_Err( p_vout, "cannot open display %s", |
|---|
| 222 |
XDisplayName( psz_display ) ); |
|---|
| 223 |
free( p_vout->p_sys ); |
|---|
| 224 |
free( psz_display ); |
|---|
| 225 |
return VLC_EGENERIC; |
|---|
| 226 |
} |
|---|
| 227 |
free( psz_display ); |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
XSetErrorHandler( X11ErrorHandler ); |
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display ); |
|---|
| 234 |
|
|---|
| 235 |
#if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc) |
|---|
| 236 |
psz_chroma = config_GetPsz( p_vout, "xvideo-chroma" ); |
|---|
| 237 |
if( psz_chroma ) |
|---|
| 238 |
{ |
|---|
| 239 |
if( strlen( psz_chroma ) >= 4 ) |
|---|
| 240 |
{ |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
memcpy(&i_chroma, psz_chroma, 4); |
|---|
| 244 |
b_chroma = 1; |
|---|
| 245 |
} |
|---|
| 246 |
|
|---|
| 247 |
free( psz_chroma ); |
|---|
| 248 |
} |
|---|
| 249 |
|
|---|
| 250 |
if( b_chroma ) |
|---|
| 251 |
{ |
|---|
| 252 |
msg_Dbg( p_vout, "forcing chroma 0x%.8x (%4.4s)", |
|---|
| 253 |
i_chroma, (char*)&i_chroma ); |
|---|
| 254 |
} |
|---|
| 255 |
else |
|---|
| 256 |
{ |
|---|
| 257 |
i_chroma = p_vout->render.i_chroma; |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
p_vout->p_sys->i_xvport = XVideoGetPort( p_vout, VLC2X11_FOURCC(i_chroma), |
|---|
| 262 |
&p_vout->output ); |
|---|
| 263 |
if( p_vout->p_sys->i_xvport < 0 ) |
|---|
| 264 |
{ |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
if( b_chroma ) |
|---|
| 268 |
{ |
|---|
| 269 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 270 |
free( p_vout->p_sys ); |
|---|
| 271 |
return VLC_EGENERIC; |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
p_vout->p_sys->i_xvport = |
|---|
| 278 |
XVideoGetPort( p_vout, X11_FOURCC('Y','U','Y','2'), |
|---|
| 279 |
&p_vout->output ); |
|---|
| 280 |
if( p_vout->p_sys->i_xvport < 0 ) |
|---|
| 281 |
{ |
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
p_vout->p_sys->i_xvport = |
|---|
| 286 |
XVideoGetPort( p_vout, X11_FOURCC('R','V','1','6'), |
|---|
| 287 |
&p_vout->output ); |
|---|
| 288 |
if( p_vout->p_sys->i_xvport < 0 ) |
|---|
| 289 |
{ |
|---|
| 290 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 291 |
free( p_vout->p_sys ); |
|---|
| 292 |
return VLC_EGENERIC; |
|---|
| 293 |
} |
|---|
| 294 |
} |
|---|
| 295 |
} |
|---|
| 296 |
p_vout->output.i_chroma = X112VLC_FOURCC(p_vout->output.i_chroma); |
|---|
| 297 |
#elif defined(MODULE_NAME_IS_glx) |
|---|
| 298 |
{ |
|---|
| 299 |
int i_opcode, i_evt, i_err = 0; |
|---|
| 300 |
int i_maj, i_min = 0; |
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 |
if( !XQueryExtension( p_vout->p_sys->p_display, "GLX", |
|---|
| 304 |
&i_opcode, &i_evt, &i_err ) ) |
|---|
| 305 |
{ |
|---|
| 306 |
msg_Err( p_this, "GLX extension not supported" ); |
|---|
| 307 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 308 |
free( p_vout->p_sys ); |
|---|
| 309 |
return VLC_EGENERIC; |
|---|
| 310 |
} |
|---|
| 311 |
if( !glXQueryExtension( p_vout->p_sys->p_display, &i_err, &i_evt ) ) |
|---|
| 312 |
{ |
|---|
| 313 |
msg_Err( p_this, "glXQueryExtension failed" ); |
|---|
| 314 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 315 |
free( p_vout->p_sys ); |
|---|
| 316 |
return VLC_EGENERIC; |
|---|
| 317 |
} |
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
if (!glXQueryVersion( p_vout->p_sys->p_display, &i_maj, &i_min ) ) |
|---|
| 321 |
{ |
|---|
| 322 |
msg_Err( p_this, "glXQueryVersion failed" ); |
|---|
| 323 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 324 |
free( p_vout->p_sys ); |
|---|
| 325 |
return VLC_EGENERIC; |
|---|
| 326 |
} |
|---|
| 327 |
if( i_maj <= 0 || ((i_maj == 1) && (i_min < 3)) ) |
|---|
| 328 |
{ |
|---|
| 329 |
p_vout->p_sys->b_glx13 = false; |
|---|
| 330 |
msg_Dbg( p_this, "using GLX 1.2 API" ); |
|---|
| 331 |
} |
|---|
| 332 |
else |
|---|
| 333 |
{ |
|---|
| 334 |
p_vout->p_sys->b_glx13 = true; |
|---|
| 335 |
msg_Dbg( p_this, "using GLX 1.3 API" ); |
|---|
| 336 |
} |
|---|
| 337 |
} |
|---|
| 338 |
#endif |
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
p_vout->p_sys->i_time_mouse_last_moved = mdate(); |
|---|
| 342 |
p_vout->p_sys->i_mouse_hide_timeout = |
|---|
| 343 |
var_GetInteger(p_vout, "mouse-hide-timeout") * 1000; |
|---|
| 344 |
p_vout->p_sys->b_mouse_pointer_visible = 1; |
|---|
| 345 |
CreateCursor( p_vout ); |
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 |
p_vout->p_sys->original_window.i_width = p_vout->i_window_width; |
|---|
| 349 |
p_vout->p_sys->original_window.i_height = p_vout->i_window_height; |
|---|
| 350 |
var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); |
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
if( CreateWindow( p_vout, &p_vout->p_sys->original_window ) ) |
|---|
| 354 |
{ |
|---|
| 355 |
msg_Err( p_vout, "cannot create X11 window" ); |
|---|
| 356 |
DestroyCursor( p_vout ); |
|---|
| 357 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 358 |
free( p_vout->p_sys ); |
|---|
| 359 |
return VLC_EGENERIC; |
|---|
| 360 |
} |
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
if( InitDisplay( p_vout ) ) |
|---|
| 364 |
{ |
|---|
| 365 |
msg_Err( p_vout, "cannot initialize X11 display" ); |
|---|
| 366 |
DestroyCursor( p_vout ); |
|---|
| 367 |
DestroyWindow( p_vout, &p_vout->p_sys->original_window ); |
|---|
| 368 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 369 |
free( p_vout->p_sys ); |
|---|
| 370 |
return VLC_EGENERIC; |
|---|
| 371 |
} |
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
DisableXScreenSaver( p_vout ); |
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
p_vout->p_sys->b_altfullscreen = 0; |
|---|
| 378 |
p_vout->p_sys->i_time_button_last_pressed = 0; |
|---|
| 379 |
|
|---|
| 380 |
TestNetWMSupport( p_vout ); |
|---|
| 381 |
|
|---|
| 382 |
#ifdef MODULE_NAME_IS_xvmc |
|---|
| 383 |
p_vout->p_sys->p_last_subtitle_save = NULL; |
|---|
| 384 |
psz_value = config_GetPsz( p_vout, "xvmc-deinterlace-mode" ); |
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 |
if( psz_value ) |
|---|
| 390 |
{ |
|---|
| 391 |
if( (strcmp(psz_value, "bob") == 0) || |
|---|
| 392 |
(strcmp(psz_value, "blend") == 0) ) |
|---|
| 393 |
p_vout->p_sys->xvmc_deinterlace_method = 2; |
|---|
| 394 |
else if (strcmp(psz_value, "discard") == 0) |
|---|
| 395 |
p_vout->p_sys->xvmc_deinterlace_method = 1; |
|---|
| 396 |
else |
|---|
| 397 |
p_vout->p_sys->xvmc_deinterlace_method = 0; |
|---|
| 398 |
free(psz_value ); |
|---|
| 399 |
} |
|---|
| 400 |
else |
|---|
| 401 |
p_vout->p_sys->xvmc_deinterlace_method = 0; |
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
psz_value = config_GetPsz( p_vout, "xvmc-crop-style" ); |
|---|
| 407 |
|
|---|
| 408 |
if( psz_value ) |
|---|
| 409 |
{ |
|---|
| 410 |
if( strncmp( psz_value, "eq", 2 ) == 0 ) |
|---|
| 411 |
p_vout->p_sys->xvmc_crop_style = 1; |
|---|
| 412 |
else if( strncmp( psz_value, "4-16", 4 ) == 0) |
|---|
| 413 |
p_vout->p_sys->xvmc_crop_style = 2; |
|---|
| 414 |
else if( strncmp( psz_value, "16-4", 4 ) == 0) |
|---|
| 415 |
p_vout->p_sys->xvmc_crop_style = 3; |
|---|
| 416 |
else |
|---|
| 417 |
p_vout->p_sys->xvmc_crop_style = 0; |
|---|
| 418 |
free( psz_value ); |
|---|
| 419 |
} |
|---|
| 420 |
else |
|---|
| 421 |
p_vout->p_sys->xvmc_crop_style = 0; |
|---|
| 422 |
|
|---|
| 423 |
msg_Dbg(p_vout, "Deinterlace = %d", p_vout->p_sys->xvmc_deinterlace_method); |
|---|
| 424 |
msg_Dbg(p_vout, "Crop = %d", p_vout->p_sys->xvmc_crop_style); |
|---|
| 425 |
|
|---|
| 426 |
if( checkXvMCCap( p_vout ) == VLC_EGENERIC ) |
|---|
| 427 |
{ |
|---|
| 428 |
msg_Err( p_vout, "no XVMC capability found" ); |
|---|
| 429 |
Deactivate( p_vout ); |
|---|
| 430 |
return VLC_EGENERIC; |
|---|
| 431 |
} |
|---|
| 432 |
subpicture_t sub_pic; |
|---|
| 433 |
sub_pic.p_sys = NULL; |
|---|
| 434 |
p_vout->p_sys->last_date = 0; |
|---|
| 435 |
#endif |
|---|
| 436 |
|
|---|
| 437 |
#ifdef HAVE_XSP |
|---|
| 438 |
p_vout->p_sys->i_hw_scale = 1; |
|---|
| 439 |
#endif |
|---|
| 440 |
|
|---|
| 441 |
#ifdef HAVE_OSSO |
|---|
| 442 |
p_vout->p_sys->i_backlight_on_counter = i_backlight_on_interval; |
|---|
| 443 |
p_vout->p_sys->p_octx = osso_initialize( "vlc", VERSION, 0, NULL ); |
|---|
| 444 |
if ( p_vout->p_sys->p_octx == NULL ) { |
|---|
| 445 |
msg_Err( p_vout, "Could not get osso context" ); |
|---|
| 446 |
} else { |
|---|
| 447 |
msg_Dbg( p_vout, "Initialized osso context" ); |
|---|
| 448 |
} |
|---|
| 449 |
#endif |
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
var_Get( p_vout, "video-on-top", &val ); |
|---|
| 454 |
var_Set( p_vout, "video-on-top", val ); |
|---|
| 455 |
|
|---|
| 456 |
return VLC_SUCCESS; |
|---|
| 457 |
} |
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 |
void Deactivate ( vlc_object_t *p_this ) |
|---|
| 465 |
{ |
|---|
| 466 |
vout_thread_t *p_vout = (vout_thread_t *)p_this; |
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 |
if( p_vout->b_fullscreen ) |
|---|
| 470 |
{ |
|---|
| 471 |
ToggleFullScreen( p_vout ); |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
|
|---|
| 475 |
if( !p_vout->p_sys->b_mouse_pointer_visible ) |
|---|
| 476 |
{ |
|---|
| 477 |
ToggleCursor( p_vout ); |
|---|
| 478 |
} |
|---|
| 479 |
|
|---|
| 480 |
#ifdef MODULE_NAME_IS_x11 |
|---|
| 481 |
|
|---|
| 482 |
if( XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 ) |
|---|
| 483 |
{ |
|---|
| 484 |
XFreeColormap( p_vout->p_sys->p_display, p_vout->p_sys->colormap ); |
|---|
| 485 |
} |
|---|
| 486 |
#elif defined(MODULE_NAME_IS_xvideo) |
|---|
| 487 |
XVideoReleasePort( p_vout, p_vout->p_sys->i_xvport ); |
|---|
| 488 |
#elif defined(MODULE_NAME_IS_xvmc) |
|---|
| 489 |
if( p_vout->p_sys->xvmc_cap ) |
|---|
| 490 |
{ |
|---|
| 491 |
xvmc_context_writer_lock( &p_vout->p_sys->xvmc_lock ); |
|---|
| 492 |
xxmc_dispose_context( p_vout ); |
|---|
| 493 |
if( p_vout->p_sys->old_subpic ) |
|---|
| 494 |
{ |
|---|
| 495 |
xxmc_xvmc_free_subpicture( p_vout, p_vout->p_sys->old_subpic ); |
|---|
| 496 |
p_vout->p_sys->old_subpic = NULL; |
|---|
| 497 |
} |
|---|
| 498 |
if( p_vout->p_sys->new_subpic ) |
|---|
| 499 |
{ |
|---|
| 500 |
xxmc_xvmc_free_subpicture( p_vout, p_vout->p_sys->new_subpic ); |
|---|
| 501 |
p_vout->p_sys->new_subpic = NULL; |
|---|
| 502 |
} |
|---|
| 503 |
free( p_vout->p_sys->xvmc_cap ); |
|---|
| 504 |
xvmc_context_writer_unlock( &p_vout->p_sys->xvmc_lock ); |
|---|
| 505 |
} |
|---|
| 506 |
#endif |
|---|
| 507 |
|
|---|
| 508 |
#ifdef HAVE_XSP |
|---|
| 509 |
DisablePixelDoubling(p_vout); |
|---|
| 510 |
#endif |
|---|
| 511 |
|
|---|
| 512 |
DestroyCursor( p_vout ); |
|---|
| 513 |
EnableXScreenSaver( p_vout ); |
|---|
| 514 |
DestroyWindow( p_vout, &p_vout->p_sys->original_window ); |
|---|
| 515 |
XCloseDisplay( p_vout->p_sys->p_display ); |
|---|
| 516 |
|
|---|
| 517 |
|
|---|
| 518 |
vlc_mutex_destroy( &p_vout->p_sys->lock ); |
|---|
| 519 |
#ifdef MODULE_NAME_IS_xvmc |
|---|
| 520 |
free_context_lock( &p_vout->p_sys->xvmc_lock ); |
|---|
| 521 |
#endif |
|---|
| 522 |
|
|---|
| 523 |
#ifdef HAVE_OSSO |
|---|
| 524 |
if ( p_vout->p_sys->p_octx != NULL ) { |
|---|
| 525 |
msg_Dbg( p_vout, "Deinitializing osso context" ); |
|---|
| 526 |
osso_deinitialize( p_vout->p_sys->p_octx ); |
|---|
| 527 |
} |
|---|
| 528 |
#endif |
|---|
| 529 |
|
|---|
| 530 |
free( p_vout->p_sys ); |
|---|
| 531 |
} |
|---|
| 532 |
|
|---|
| 533 |
#ifdef MODULE_NAME_IS_xvmc |
|---|
| 534 |
|
|---|
| 535 |
#define XINE_IMGFMT_YV12 (('2'<<24)|('1'<<16)|('V'<<8)|'Y') |
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
static int xvmc_check_yv12( Display *display, XvPortID port ) |
|---|
| 539 |
{ |
|---|
| 540 |
XvImageFormatValues *formatValues; |
|---|
| 541 |
int formats; |
|---|
| 542 |
int i; |
|---|
| 543 |
|
|---|
| 544 |
formatValues = XvListImageFormats( display, port, &formats ); |
|---|
| 545 |
|
|---|
| 546 |
for( i = 0; i < formats; i++ ) |
|---|
| 547 |
{ |
|---|
| 548 |
if( ( formatValues[i].id == XINE_IMGFMT_YV12 ) && |
|---|
| 549 |
( !( strncmp( formatValues[i].guid, "YV12", 4 ) ) ) ) |
|---|
| 550 |
{ |
|---|
| 551 |
XFree (formatValues); |
|---|
| 552 |
return 0; |
|---|
| 553 |
} |
|---|
| 554 |
} |
|---|
| 555 |
|
|---|
| 556 |
XFree (formatValues); |
|---|
| 557 |
return 1; |
|---|
| 558 |
} |
|---|
| 559 |
|
|---|
| 560 |
static void xvmc_sync_surface( vout_thread_t *p_vout, XvMCSurface * srf ) |
|---|
| 561 |
{ |
|---|
| 562 |
XvMCSyncSurface( p_vout->p_sys->p_display, srf ); |
|---|
| 563 |
} |
|---|
| 564 |
|
|---|
| 565 |
static void xvmc_update_XV_DOUBLE_BUFFER( vout_thread_t *p_vout ) |
|---|
| 566 |
{ |
|---|
| 567 |
Atom atom; |
|---|
| 568 |
int xv_double_buffer; |
|---|
| 569 |
|
|---|
| 570 |
xv_double_buffer = 1; |
|---|
| 571 |
|
|---|
| 572 |
XLockDisplay( p_vout->p_sys->p_display ); |
|---|
| 573 |
atom = XInternAtom( p_vout->p_sys->p_display, "XV_DOUBLE_BUFFER", False ); |
|---|
| 574 |
#if 0 |
|---|
| 575 |
XvSetPortAttribute (p_vout->p_sys->p_display, p_vout->p_sys->i_xvport, atom, xv_double_buffer); |
|---|
| 576 |
#endif |
|---|
| 577 |
XvMCSetAttribute( p_vout->p_sys->p_display, &p_vout->p_sys->context, atom, xv_double_buffer ); |
|---|
| 578 |
XUnlockDisplay( p_vout->p_sys->p_display ); |
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
|
|---|
| 582 |
} |
|---|
| 583 |
|
|---|
| 584 |
static void RenderVideo( vout_thread_t *p_vout, picture_t *p_pic ) |
|---|
| 585 |
{ |
|---|
| 586 |
vlc_xxmc_t *xxmc = NULL; |
|---|
| 587 |
|
|---|
| 588 |
vlc_mutex_lock( &p_vout->p_sys->lock ); |
|---|
| 589 |
xvmc_context_reader_lock( &p_vout->p_sys->xvmc_lock ); |
|---|
| 590 |
|
|---|
| 591 |
xxmc = &p_pic->p_sys->xxmc_data; |
|---|
| 592 |
if( (!xxmc->decoded || |
|---|
| 593 |
!xxmc_xvmc_surface_valid( p_vout, p_pic->p_sys->xvmc_surf )) ) |
|---|
| 594 |
{ |
|---|
| 595 |
vlc_mutex_unlock( &p_vout->p_sys->lock ); |
|---|
| 596 |
xvmc_context_reader_unlock( &p_vout->p_sys->xvmc_lock ); |
|---|
| 597 |
return; |
|---|
| 598 |
} |
|---|
| 599 |
|
|---|
| 600 |
#if 0 |
|---|
| 601 |
vlc_mutex_lock( &p_vout->lastsubtitle_lock ); |
|---|
| 602 |
if (p_vout->p_sys->p_last_subtitle != NULL) |
|---|
| 603 |
{ |
|---|
| 604 |
if( p_vout->p_sys->p_last_subtitle_save != p_vout->p_sys->p_last_subtitle ) |
|---|
| 605 |
{ |
|---|
| 606 |
p_vout->p_sys->new_subpic = |
|---|
| 607 |
xxmc_xvmc_alloc_subpicture( p_vout, &p_vout->p_sys->context, |
|---|
| 608 |
p_vout->p_sys->xvmc_width, |
|---|
| 609 |
p_vout->p_sys->xvmc_height, |
|---|
| 610 |
p_vout->p_sys->xvmc_cap[p_vout->p_sys->xvmc_cur_cap].subPicType.id ); |
|---|
| 611 |
|
|---|
| 612 |
if (p_vout->p_sys->new_subpic) |
|---|
| 613 |
{ |
|---|
| 614 |
XVMCLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 615 |
XvMCClearSubpicture( p_vout->p_sys->p_display, |
|---|
| 616 |
p_vout->p_sys->new_subpic, |
|---|
| 617 |
0, |
|---|
| 618 |
0, |
|---|
| 619 |
p_vout->p_sys->xvmc_width, |
|---|
| 620 |
p_vout->p_sys->xvmc_height, |
|---|
| 621 |
0x00 ); |
|---|
| 622 |
XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 623 |
clear_xx44_palette( &p_vout->p_sys->palette ); |
|---|
| 624 |
|
|---|
| 625 |
if( sub_pic.p_sys == NULL ) |
|---|
| 626 |
{ |
|---|
| 627 |
sub_pic.p_sys = malloc( sizeof( picture_sys_t ) ); |
|---|
| 628 |
if( sub_pic.p_sys != NULL ) |
|---|
| 629 |
{ |
|---|
| 630 |
sub_pic.p_sys->p_vout = p_vout; |
|---|
| 631 |
sub_pic.p_sys->xvmc_surf = NULL; |
|---|
| 632 |
sub_pic.p_sys->p_image = p_vout->p_sys->subImage; |
|---|
| 633 |
} |
|---|
| 634 |
} |
|---|
| 635 |
sub_pic.p_sys->p_image = p_vout->p_sys->subImage; |
|---|
| 636 |
sub_pic.p->p_pixels = sub_pic.p_sys->p_image->data; |
|---|
| 637 |
sub_pic.p->i_pitch = p_vout->output.i_width; |
|---|
| 638 |
|
|---|
| 639 |
memset( p_vout->p_sys->subImage->data, 0, |
|---|
| 640 |
(p_vout->p_sys->subImage->width * p_vout->p_sys->subImage->height) ); |
|---|
| 641 |
|
|---|
| 642 |
if (p_vout->p_last_subtitle != NULL) |
|---|
| 643 |
{ |
|---|
| 644 |
blend_xx44( p_vout->p_sys->subImage->data, |
|---|
| 645 |
p_vout->p_last_subtitle, |
|---|
| 646 |
p_vout->p_sys->subImage->width, |
|---|
| 647 |
p_vout->p_sys->subImage->height, |
|---|
| 648 |
p_vout->p_sys->subImage->width, |
|---|
| 649 |
&p_vout->p_sys->palette, |
|---|
| 650 |
(p_vout->p_sys->subImage->id == FOURCC_IA44) ); |
|---|
| 651 |
} |
|---|
| 652 |
|
|---|
| 653 |
XVMCLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 654 |
XvMCCompositeSubpicture( p_vout->p_sys->p_display, |
|---|
| 655 |
p_vout->p_sys->new_subpic, |
|---|
| 656 |
p_vout->p_sys->subImage, |
|---|
| 657 |
0, |
|---|
| 658 |
0, |
|---|
| 659 |
p_vout->output.i_width, |
|---|
| 660 |
p_vout->output.i_height, |
|---|
| 661 |
0, |
|---|
| 662 |
0 ); |
|---|
| 663 |
XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 664 |
if (p_vout->p_sys->old_subpic) |
|---|
| 665 |
{ |
|---|
| 666 |
xxmc_xvmc_free_subpicture( p_vout, |
|---|
| 667 |
p_vout->p_sys->old_subpic); |
|---|
| 668 |
p_vout->p_sys->old_subpic = NULL; |
|---|
| 669 |
} |
|---|
| 670 |
if (p_vout->p_sys->new_subpic) |
|---|
| 671 |
{ |
|---|
| 672 |
p_vout->p_sys->old_subpic = p_vout->p_sys->new_subpic; |
|---|
| 673 |
p_vout->p_sys->new_subpic = NULL; |
|---|
| 674 |
xx44_to_xvmc_palette( &p_vout->p_sys->palette, |
|---|
| 675 |
p_vout->p_sys->xvmc_palette, |
|---|
| 676 |
0, |
|---|
| 677 |
p_vout->p_sys->old_subpic->num_palette_entries, |
|---|
| 678 |
p_vout->p_sys->old_subpic->entry_bytes, |
|---|
| 679 |
p_vout->p_sys->old_subpic->component_order ); |
|---|
| 680 |
XVMCLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 681 |
XvMCSetSubpicturePalette( p_vout->p_sys->p_display, |
|---|
| 682 |
p_vout->p_sys->old_subpic, |
|---|
| 683 |
p_vout->p_sys->xvmc_palette ); |
|---|
| 684 |
XvMCFlushSubpicture( p_vout->p_sys->p_display, |
|---|
| 685 |
p_vout->p_sys->old_subpic); |
|---|
| 686 |
XvMCSyncSubpicture( p_vout->p_sys->p_display, |
|---|
| 687 |
p_vout->p_sys->old_subpic ); |
|---|
| 688 |
XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 689 |
} |
|---|
| 690 |
|
|---|
| 691 |
XVMCLOCKDISPLAY( p_vout->p_sys->p_display); |
|---|
| 692 |
if (p_vout->p_sys->xvmc_backend_subpic ) |
|---|
| 693 |
{ |
|---|
| 694 |
XvMCBlendSubpicture( p_vout->p_sys->p_display, |
|---|
| 695 |
p_pic->p_sys->xvmc_surf, |
|---|
| 696 |
p_vout->p_sys->old_subpic, |
|---|
| 697 |
0, |
|---|
| 698 |
0, |
|---|
| 699 |
p_vout->p_sys->xvmc_width, |
|---|
| 700 |
p_vout->p_sys->xvmc_height, |
|---|
| 701 |
0, |
|---|
| 702 |
0, |
|---|
| 703 |
p_vout->p_sys->xvmc_width, |
|---|
| 704 |
p_vout->p_sys->xvmc_height ); |
|---|
| 705 |
} |
|---|
| 706 |
else |
|---|
| 707 |
{ |
|---|
| 708 |
XvMCBlendSubpicture2( p_vout->p_sys->p_display, |
|---|
| 709 |
p_pic->p_sys->xvmc_surf, |
|---|
| 710 |
p_pic->p_sys->xvmc_surf, |
|---|
| 711 |
p_vout->p_sys->old_subpic, |
|---|
| 712 |
0, |
|---|
| 713 |
0, |
|---|
| 714 |
p_vout->p_sys->xvmc_width, |
|---|
| 715 |
p_vout->p_sys->xvmc_height, |
|---|
| 716 |
0, |
|---|
| 717 |
0, |
|---|
| 718 |
p_vout->p_sys->xvmc_width, |
|---|
| 719 |
p_vout->p_sys->xvmc_height ); |
|---|
| 720 |
} |
|---|
| 721 |
XVMCUNLOCKDISPLAY(p_vout->p_sys->p_display); |
|---|
| 722 |
} |
|---|
| 723 |
} |
|---|
| 724 |
else |
|---|
| 725 |
{ |
|---|
| 726 |
XVMCLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 727 |
if( p_vout->p_sys->xvmc_backend_subpic ) |
|---|
| 728 |
{ |
|---|
| 729 |
XvMCBlendSubpicture( p_vout->p_sys->p_display, |
|---|
| 730 |
p_pic->p_sys->xvmc_surf, |
|---|
| 731 |
p_vout->p_sys->old_subpic, |
|---|
| 732 |
0, 0, |
|---|
| 733 |
p_vout->p_sys->xvmc_width, |
|---|
| 734 |
p_vout->p_sys->xvmc_height, |
|---|
| 735 |
0, 0, |
|---|
| 736 |
p_vout->p_sys->xvmc_width, |
|---|
| 737 |
p_vout->p_sys->xvmc_height ); |
|---|
| 738 |
} |
|---|
| 739 |
else |
|---|
| 740 |
{ |
|---|
| 741 |
XvMCBlendSubpicture2( p_vout->p_sys->p_display, |
|---|
| 742 |
p_pic->p_sys->xvmc_surf, |
|---|
| 743 |
p_pic->p_sys->xvmc_surf, |
|---|
| 744 |
p_vout->p_sys->old_subpic, |
|---|
| 745 |
0, 0, |
|---|
| 746 |
p_vout->p_sys->xvmc_width, |
|---|
| 747 |
p_vout->p_sys->xvmc_height, |
|---|
| 748 |
0, 0, |
|---|
| 749 |
p_vout->p_sys->xvmc_width, |
|---|
| 750 |
p_vout->p_sys->xvmc_height ); |
|---|
| 751 |
} |
|---|
| 752 |
XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display ); |
|---|
| 753 |
} |
|---|
| 754 |
} |
|---|
| 755 |
p_vout->p_sys->p_last_subtitle_save = p_vout->p_last_subtitle; |
|---|
| 756 |
|
|---|
| 757 |
vlc_mutex_unlock( &p_vout->lastsubtitle_lock ); |
|---|
| 758 |
#endif |
|---|
| 759 |
xvmc_context_reader_unlock( &p_vout->p_sys->xvmc_lock ); |
|---|
| 760 |
|
|---|
| 761 |
vlc_mutex_unlock( &p_vout->p_sys->lock ); |
|---|
| 762 |
} |
|---|
| 763 |
#endif |
|---|
| 764 |
|
|---|
| 765 |
#ifdef HAVE_XSP |
|---|
| 766 |
|
|---|
| 767 |
|
|---|
| 768 |
|
|---|
| 769 |
|
|---|
| 770 |
|
|---|
| 771 |
|
|---|
| 772 |
static void EnablePixelDoubling( vout_thread_t *p_vout ) |
|---|
| 773 |
{ |
|---|
| 774 |
int i_hor_scale = ( p_vout->p_sys->p_win->i_width ) / p_vout->render.i_width; |
|---|
| 775 |
int i_vert_scale = ( p_vout->p_sys->p_win->i_height ) / p_vout->render.i_height; |
|---|
| 776 |
if ( ( i_hor_scale > 1 ) && ( i_vert_scale > 1 ) ) { |
|---|
| 777 |
p_vout->p_sys->i_hw_scale = 2; |
|---|
| 778 |
msg_Dbg( p_vout, "Enabling pixel doubling, scaling factor %d", p_vout->p_sys->i_hw_scale ); |
|---|
| 779 |
XSPSetPixelDoubling( p_vout->p_sys->p_display, 0, 1 ); |
|---|
| 780 |
} |
|---|
| 781 |
} |
|---|
| 782 |
|
|---|
| 783 |
|
|---|
| 784 |
|
|---|
| 785 |
|
|---|
| 786 |
|
|---|
| 787 |
|
|---|
| 788 |
static void DisablePixelDoubling( vout_thread_t *p_vout ) |
|---|
| 789 |
{ |
|---|
| 790 |
if ( p_vout->p_sys->i_hw_scale > 1 ) { |
|---|
| 791 |
msg_Dbg( p_vout, "Disabling pixel doubling" ); |
|---|
| 792 |
XSPSetPixelDoubling( p_vout->p_sys->p_display, 0, 0 ); |
|---|
| 793 |
p_vout->p_sys->i_hw_scale = 1; |
|---|
| 794 |
} |
|---|
| 795 |
} |
|---|
| 796 |
#endif |
|---|
| 797 |
|
|---|
| 798 |
|
|---|
| 799 |
|
|---|
| 800 |
|
|---|
| 801 |
|
|---|
| 802 |
|
|---|
| 803 |
|
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
static int InitVideo( vout_thread_t *p_vout ) |
|---|
| 807 |
{ |
|---|
| 808 |
unsigned int i_index = 0; |
|---|
| 809 |
picture_t *p_pic; |
|---|
| 810 |
|
|---|
| 811 |
I_OUTPUTPICTURES = 0; |
|---|
| 812 |
|
|---|
| 813 |
#if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc) |
|---|
| 814 |
|
|---|
| 815 |
|
|---|
| 816 |
|
|---|
| 817 |
p_vout->output.i_width = p_vout->render.i_width; |
|---|
| 818 |
p_vout->output.i_height = p_vout->render.i_height; |
|---|
| 819 |
p_vout->output.i_aspect = p_vout->render.i_aspect; |
|---|
| 820 |
|
|---|
| 821 |
p_vout->fmt_out = p_vout->fmt_in; |
|---|
| 822 |
p_vout->fmt_out.i_chroma = p_vout->output.i_chroma; |
|---|
| 823 |
|
|---|
| 824 |
#if XvVersion < 2 || ( XvVersion == 2 && XvRevision < 2 ) |
|---|
| 825 |
switch( p_vout->output.i_chroma ) |
|---|
| 826 |
{ |
|---|
| 827 |
case VLC_FOURCC('R','V','1','6'): |
|---|
| 828 |
#if defined( WORDS_BIGENDIAN ) |
|---|
| 829 |
p_vout->output.i_rmask = 0xf800; |
|---|
| 830 |
p_vout->output.i_gmask = 0x07e0; |
|---|
| 831 |
p_vout->output.i_bmask = 0x001f; |
|---|
| 832 |
#else |
|---|
| 833 |
p_vout->output.i_rmask = 0x001f; |
|---|
| 834 |
p_vout->output.i_gmask = 0x07e0; |
|---|
| 835 |
p_vout->output.i_bmask = 0xf800; |
|---|
|
|---|