vo_xv: make number of buffers configurable

This commit is contained in:
wm4 2015-05-20 23:07:47 +02:00
parent 9bd3ae311f
commit 8724e3e2dd
2 changed files with 14 additions and 3 deletions

View File

@ -69,6 +69,12 @@ Available video output drivers are:
``no-colorkey`` ``no-colorkey``
Disables color-keying. Disables color-keying.
``buffers=<number>``
Number of image buffers to use for the internal ringbuffer (default: 2).
Increasing this will use more memory, but might help with the X server
not responding quickly enough if video FPS is close to or higher than
the display refresh rate.
``x11`` (X11 only) ``x11`` (X11 only)
Shared memory video output driver without hardware acceleration that works Shared memory video output driver without hardware acceleration that works
whenever X11 is present. whenever X11 is present.

View File

@ -63,6 +63,8 @@
#define CK_SRC_SET 1 // use and set specified / default colorkey #define CK_SRC_SET 1 // use and set specified / default colorkey
#define CK_SRC_CUR 2 // use current colorkey (get it from xv) #define CK_SRC_CUR 2 // use current colorkey (get it from xv)
#define MAX_BUFFERS 10
struct xvctx { struct xvctx {
struct xv_ck_info_s { struct xv_ck_info_s {
int method; // CK_METHOD_* constants int method; // CK_METHOD_* constants
@ -72,13 +74,14 @@ struct xvctx {
unsigned long xv_colorkey; unsigned long xv_colorkey;
int xv_port; int xv_port;
int cfg_xv_adaptor; int cfg_xv_adaptor;
int cfg_buffers;
XvAdaptorInfo *ai; XvAdaptorInfo *ai;
XvImageFormatValues *fo; XvImageFormatValues *fo;
unsigned int formats, adaptors, xv_format; unsigned int formats, adaptors, xv_format;
int current_buf; int current_buf;
int current_ip_buf; int current_ip_buf;
int num_buffers; int num_buffers;
XvImage *xvimage[2]; XvImage *xvimage[MAX_BUFFERS];
struct mp_image *original_image; struct mp_image *original_image;
uint32_t image_width; uint32_t image_width;
uint32_t image_height; uint32_t image_height;
@ -89,7 +92,7 @@ struct xvctx {
uint32_t max_width, max_height; // zero means: not set uint32_t max_width, max_height; // zero means: not set
int Shmem_Flag; int Shmem_Flag;
#if HAVE_SHM && HAVE_XEXT #if HAVE_SHM && HAVE_XEXT
XShmSegmentInfo Shminfo[2]; XShmSegmentInfo Shminfo[MAX_BUFFERS];
int Shm_Warned_Slow; int Shm_Warned_Slow;
#endif #endif
}; };
@ -463,7 +466,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
for (i = 0; i < ctx->num_buffers; i++) for (i = 0; i < ctx->num_buffers; i++)
deallocate_xvimage(vo, i); deallocate_xvimage(vo, i);
ctx->num_buffers = 2; ctx->num_buffers = ctx->cfg_buffers;
for (i = 0; i < ctx->num_buffers; i++) { for (i = 0; i < ctx->num_buffers; i++) {
if (!allocate_xvimage(vo, i)) { if (!allocate_xvimage(vo, i)) {
@ -848,6 +851,7 @@ const struct vo_driver video_out_xv = {
.xv_ck_info = {CK_METHOD_MANUALFILL, CK_SRC_CUR}, .xv_ck_info = {CK_METHOD_MANUALFILL, CK_SRC_CUR},
.colorkey = 0x0000ff00, // default colorkey is green .colorkey = 0x0000ff00, // default colorkey is green
// (0xff000000 means that colorkey has been disabled) // (0xff000000 means that colorkey has been disabled)
.cfg_buffers = 2,
}, },
.options = (const struct m_option[]) { .options = (const struct m_option[]) {
OPT_INT("port", xv_port, M_OPT_MIN, .min = 0), OPT_INT("port", xv_port, M_OPT_MIN, .min = 0),
@ -862,6 +866,7 @@ const struct vo_driver video_out_xv = {
{"auto", CK_METHOD_AUTOPAINT})), {"auto", CK_METHOD_AUTOPAINT})),
OPT_INT("colorkey", colorkey, 0), OPT_INT("colorkey", colorkey, 0),
OPT_FLAG_STORE("no-colorkey", colorkey, 0, 0x1000000), OPT_FLAG_STORE("no-colorkey", colorkey, 0, 0x1000000),
OPT_INTRANGE("buffers", cfg_buffers, 0, 1, MAX_BUFFERS),
{0} {0}
}, },
}; };