Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
15c2fab7
Commit
15c2fab7
authored
Jan 24, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XCB: support for MIT-SHM
parent
6f7922f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
15 deletions
+124
-15
modules/video_output/Modules.am
modules/video_output/Modules.am
+5
-2
modules/video_output/xcb/xcb.c
modules/video_output/xcb/xcb.c
+119
-13
No files found.
modules/video_output/Modules.am
View file @
15c2fab7
...
@@ -22,13 +22,16 @@ SOURCES_yuv = yuv.c
...
@@ -22,13 +22,16 @@ SOURCES_yuv = yuv.c
# TODO: move to configure.ac once/if xcb plugin gets more functional
# TODO: move to configure.ac once/if xcb plugin gets more functional
XCB_LIBS = -lxcb
XCB_LIBS = -lxcb
XCB_SHM_LIBS = -lxcb-shm
XCB_AUX_LIBS = -lxcb-aux
XCB_AUX_LIBS = -lxcb-aux
XCB_IMAGE_LIBS = -lxcb-image
XCB_IMAGE_LIBS = -lxcb-image
libxcb_plugin_la_SOURCES = xcb/xcb.c
libxcb_plugin_la_SOURCES = xcb/xcb.c
libxcb_plugin_la_CFLAGS = $(AM_CFLAGS) \
libxcb_plugin_la_CFLAGS = $(AM_CFLAGS) \
$(XCB_CFLAGS) $(XCB_AUX_CFLAGS) $(XCB_IMAGE_CFLAGS)
$(XCB_CFLAGS) $(XCB_SHM) \
$(XCB_AUX_CFLAGS) $(XCB_IMAGE_CFLAGS)
libxcb_plugin_la_LIBADD = $(AM_LIBADD) \
libxcb_plugin_la_LIBADD = $(AM_LIBADD) \
$(XCB_LIBS) $(XCB_AUX_LIBS) $(XCB_IMAGE_LIBS)
$(XCB_LIBS) $(XCB_SHM) \
$(XCB_AUX_LIBS) $(XCB_IMAGE_LIBS)
libxcb_plugin_la_DEPENDENCIES =
libxcb_plugin_la_DEPENDENCIES =
EXTRA_LTLIBRARIES += libxcb_plugin.la
EXTRA_LTLIBRARIES += libxcb_plugin.la
modules/video_output/xcb/xcb.c
View file @
15c2fab7
...
@@ -27,7 +27,12 @@
...
@@ -27,7 +27,12 @@
#include <stdlib.h>
#include <stdlib.h>
#include <assert.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <xcb/xcb.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_image.h>
...
@@ -41,6 +46,10 @@
...
@@ -41,6 +46,10 @@
"X11 hardware display to use. By default VLC will " \
"X11 hardware display to use. By default VLC will " \
"use the value of the DISPLAY environment variable.")
"use the value of the DISPLAY environment variable.")
#define SHM_TEXT N_("Use shared memory")
#define SHM_LONGTEXT N_( \
"Use shared memory to communicate between VLC and the X server.")
static
int
Open
(
vlc_object_t
*
);
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
...
@@ -57,6 +66,7 @@ vlc_module_begin ()
...
@@ -57,6 +66,7 @@ vlc_module_begin ()
add_string
(
"x11-display"
,
NULL
,
NULL
,
add_string
(
"x11-display"
,
NULL
,
NULL
,
DISPLAY_TEXT
,
DISPLAY_LONGTEXT
,
true
)
DISPLAY_TEXT
,
DISPLAY_LONGTEXT
,
true
)
add_bool
(
"x11-shm"
,
true
,
NULL
,
SHM_TEXT
,
SHM_LONGTEXT
,
true
)
vlc_module_end
()
vlc_module_end
()
struct
vout_sys_t
struct
vout_sys_t
...
@@ -69,6 +79,7 @@ struct vout_sys_t
...
@@ -69,6 +79,7 @@ struct vout_sys_t
xcb_window_t
parent
;
/* parent X window */
xcb_window_t
parent
;
/* parent X window */
xcb_window_t
window
;
/* drawable X window */
xcb_window_t
window
;
/* drawable X window */
xcb_gcontext_t
gc
;
/* context to put images */
xcb_gcontext_t
gc
;
/* context to put images */
bool
shm
;
/* whether to use MIT-SHM */
uint8_t
bpp
;
/* bits per pixel */
uint8_t
bpp
;
/* bits per pixel */
};
};
...
@@ -151,6 +162,23 @@ static int Open (vlc_object_t *obj)
...
@@ -151,6 +162,23 @@ static int Open (vlc_object_t *obj)
}
}
p_sys
->
vid
=
vt
->
visual_id
;
p_sys
->
vid
=
vt
->
visual_id
;
p_sys
->
shm
=
var_CreateGetBool
(
vout
,
"x11-shm"
)
>
0
;
if
(
p_sys
->
shm
)
{
xcb_shm_query_version_cookie_t
ck
;
xcb_shm_query_version_reply_t
*
r
;
xcb_generic_error_t
*
err
;
ck
=
xcb_shm_query_version
(
p_sys
->
conn
);
r
=
xcb_shm_query_version_reply
(
p_sys
->
conn
,
ck
,
&
err
);
if
(
!
r
)
{
msg_Err
(
vout
,
"shared memory (MIT-SHM) not available"
);
msg_Warn
(
vout
,
"display will be slow"
);
p_sys
->
shm
=
false
;
}
}
vout
->
pf_init
=
Init
;
vout
->
pf_init
=
Init
;
vout
->
pf_end
=
Deinit
;
vout
->
pf_end
=
Deinit
;
vout
->
pf_display
=
Display
;
vout
->
pf_display
=
Display
;
...
@@ -179,10 +207,14 @@ static void Close (vlc_object_t *obj)
...
@@ -179,10 +207,14 @@ static void Close (vlc_object_t *obj)
struct
picture_sys_t
struct
picture_sys_t
{
{
xcb_connection_t
*
conn
;
xcb_image_t
*
image
;
xcb_image_t
*
image
;
xcb_shm_seg_t
segment
;
};
};
static
void
PictureRelease
(
picture_t
*
pic
);
static
void
PictureRelease
(
picture_t
*
pic
);
static
void
PictureShmRelease
(
picture_t
*
pic
);
#define SHM_ERR ((void *)(intptr_t)(-1))
static
int
PictureInit
(
vout_thread_t
*
vout
,
picture_t
*
pic
)
static
int
PictureInit
(
vout_thread_t
*
vout
,
picture_t
*
pic
)
{
{
...
@@ -197,6 +229,43 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic)
...
@@ -197,6 +229,43 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic)
vout
->
output
.
i_width
,
vout
->
output
.
i_height
,
vout
->
output
.
i_width
,
vout
->
output
.
i_height
,
vout
->
output
.
i_aspect
);
vout
->
output
.
i_aspect
);
void
*
shm
=
SHM_ERR
;
const
size_t
size
=
pic
->
p
->
i_pitch
*
pic
->
p
->
i_lines
;
if
(
p_sys
->
shm
)
{
/* Allocate shared memory segment */
int
id
=
shmget
(
IPC_PRIVATE
,
size
,
IPC_CREAT
|
0700
);
if
(
id
==
-
1
)
{
msg_Err
(
vout
,
"shared memory allocation error: %m"
);
goto
error
;
}
/* Attach the segment to VLC */
shm
=
shmat
(
id
,
NULL
,
0
/* read/write */
);
if
(
shm
==
SHM_ERR
)
{
msg_Err
(
vout
,
"shared memory attachment error: %m"
);
shmctl
(
id
,
IPC_RMID
,
0
);
goto
error
;
}
/* Attach the segment to X */
xcb_void_cookie_t
ck
;
priv
->
segment
=
xcb_generate_id
(
p_sys
->
conn
);
ck
=
xcb_shm_attach_checked
(
p_sys
->
conn
,
priv
->
segment
,
id
,
1
);
shmctl
(
id
,
IPC_RMID
,
0
);
if
(
CheckError
(
vout
,
"shared memory server-side error"
,
ck
))
{
msg_Info
(
vout
,
"using buggy X (remote) server? SSH?"
);
shmdt
(
shm
);
shm
=
SHM_ERR
;
}
}
const
unsigned
real_width
=
pic
->
p
->
i_pitch
/
(
p_sys
->
bpp
>>
3
);
const
unsigned
real_width
=
pic
->
p
->
i_pitch
/
(
p_sys
->
bpp
>>
3
);
/* FIXME: anyway to getthing more intuitive than that?? */
/* FIXME: anyway to getthing more intuitive than that?? */
...
@@ -211,20 +280,36 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic)
...
@@ -211,20 +280,36 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic)
XCB_IMAGE_ORDER_LSB_FIRST
,
XCB_IMAGE_ORDER_LSB_FIRST
,
#endif
#endif
XCB_IMAGE_ORDER_MSB_FIRST
,
XCB_IMAGE_ORDER_MSB_FIRST
,
NULL
,
0
,
NULL
);
NULL
,
(
shm
!=
SHM_ERR
)
?
size
:
0
,
(
shm
!=
SHM_ERR
)
?
shm
:
NULL
);
if
(
img
==
NULL
)
if
(
img
==
NULL
)
{
if
(
shm
!=
SHM_ERR
)
xcb_shm_detach
(
p_sys
->
conn
,
priv
->
segment
);
goto
error
;
goto
error
;
}
if
(
shm
!=
SHM_ERR
&&
xcb_image_native
(
p_sys
->
conn
,
img
,
0
)
==
NULL
)
{
msg_Err
(
vout
,
"incompatible X server image format"
);
xcb_image_destroy
(
img
);
goto
error
;
}
priv
->
conn
=
p_sys
->
conn
;
priv
->
image
=
img
;
priv
->
image
=
img
;
pic
->
p_sys
=
priv
;
pic
->
p_sys
=
priv
;
pic
->
p
->
p_pixels
=
img
->
data
;
pic
->
p
->
p_pixels
=
img
->
data
;
pic
->
pf_release
=
PictureRelease
;
pic
->
pf_release
=
(
shm
!=
SHM_ERR
)
?
PictureShmRelease
:
PictureRelease
;
pic
->
i_status
=
DESTROYED_PICTURE
;
pic
->
i_status
=
DESTROYED_PICTURE
;
pic
->
i_type
=
DIRECT_PICTURE
;
pic
->
i_type
=
DIRECT_PICTURE
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
error:
if
(
shm
!=
SHM_ERR
)
shmdt
(
shm
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -241,6 +326,18 @@ static void PictureRelease (picture_t *pic)
...
@@ -241,6 +326,18 @@ static void PictureRelease (picture_t *pic)
free
(
p_sys
);
free
(
p_sys
);
}
}
/**
* Release shared memory picture private data
*/
static
void
PictureShmRelease
(
picture_t
*
pic
)
{
struct
picture_sys_t
*
p_sys
=
pic
->
p_sys
;
xcb_shm_detach
(
p_sys
->
conn
,
p_sys
->
segment
);
shmdt
(
p_sys
->
image
->
data
);
PictureRelease
(
pic
);
}
/**
/**
* Allocate drawable window and picture buffers.
* Allocate drawable window and picture buffers.
*/
*/
...
@@ -364,23 +461,32 @@ static void Deinit (vout_thread_t *vout)
...
@@ -364,23 +461,32 @@ static void Deinit (vout_thread_t *vout)
static
void
Display
(
vout_thread_t
*
vout
,
picture_t
*
pic
)
static
void
Display
(
vout_thread_t
*
vout
,
picture_t
*
pic
)
{
{
vout_sys_t
*
p_sys
=
vout
->
p_sys
;
vout_sys_t
*
p_sys
=
vout
->
p_sys
;
xcb_image_t
*
img
=
pic
->
p_sys
->
image
;
picture_sys_t
*
priv
=
pic
->
p_sys
;
xcb_image_t
*
img
=
priv
->
image
;
if
(
img
->
base
==
NULL
)
{
xcb_shm_segment_info_t
info
=
{
.
shmseg
=
priv
->
segment
,
.
shmid
=
-
1
,
/* lost track of it, unimportant */
.
shmaddr
=
img
->
data
,
};
xcb_image_shm_put
(
p_sys
->
conn
,
p_sys
->
window
,
p_sys
->
gc
,
img
,
info
,
0
,
0
,
0
,
0
,
img
->
width
,
img
->
height
,
0
);
}
else
{
xcb_image_t
*
native
=
xcb_image_native
(
p_sys
->
conn
,
img
,
1
);
xcb_image_t
*
native
=
xcb_image_native
(
p_sys
->
conn
,
img
,
1
);
if
(
native
==
NULL
)
if
(
native
==
NULL
)
{
msg_Err
(
vout
,
"image conversion failure"
);
return
;
return
;
}
xcb_image_put
(
p_sys
->
conn
,
p_sys
->
window
,
p_sys
->
gc
,
native
,
0
,
0
,
0
);
xcb_image_put
(
p_sys
->
conn
,
p_sys
->
window
,
p_sys
->
gc
,
native
,
0
,
0
,
0
);
xcb_flush
(
p_sys
->
conn
);
if
(
native
!=
img
)
if
(
native
!=
img
)
{
/*msg_Warn (vout, "image not in native X11 pixmap format");*/
xcb_image_destroy
(
native
);
xcb_image_destroy
(
native
);
}
}
xcb_flush
(
p_sys
->
conn
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment