make xvinfo work
* hw/kdrive/ephyr/ephyrhostvideo.c: (EphyrHostXVAdaptorGetVideoFormats): properly get visual class instead of returning the visual id. (EphyrHostXVQueryEncodings): properly copy the fields because simple casting does truncate some fields. (EphyrHostAttributesDelete): XFree the whole array instead of trying to free invidial members. * hw/kdrive/ephyr/ephyrvideo.c: (ephyrInitVideo): fix a typo (EphyrXVPrivQueryHostAdaptors): set XvWindowMask mask to adaptors type. use host adaptor name. Don't forget to set nImages field. (EphyrXVPrivRegisterAdaptors): report an error when KdXVScreenInit() fails.
This commit is contained in:
parent
aa2fae7b75
commit
b8cd313be4
|
@ -28,7 +28,7 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <kdrive-config.h>
|
#include <kdrive-config.h>
|
||||||
#endif
|
#endif
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/extensions/Xvlib.h>
|
#include <X11/extensions/Xvlib.h>
|
||||||
|
|
||||||
#include "hostx.h"
|
#include "hostx.h"
|
||||||
|
@ -125,15 +125,34 @@ EphyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this)
|
||||||
return ((XvAdaptorInfo*)a_this)->name ;
|
return ((XvAdaptorInfo*)a_this)->name ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EphyrHostVideoFormat*
|
EphyrHostVideoFormat*
|
||||||
EphyrHostXVAdaptorGetVideoFormats (const EphyrHostXVAdaptor *a_this,
|
EphyrHostXVAdaptorGetVideoFormats (const EphyrHostXVAdaptor *a_this,
|
||||||
int *a_nb_formats)
|
int *a_nb_formats)
|
||||||
{
|
{
|
||||||
|
EphyrHostVideoFormat *formats=NULL ;
|
||||||
|
int nb_formats=0, i=0 ;
|
||||||
|
XVisualInfo *visual_info, visual_info_template ;
|
||||||
|
int nb_visual_info ;
|
||||||
|
|
||||||
EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
|
EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
|
||||||
|
|
||||||
|
nb_formats = ((XvAdaptorInfo*)a_this)->num_formats ;
|
||||||
|
formats = Xcalloc (nb_formats * sizeof (EphyrHostVideoFormat)) ;
|
||||||
|
for (i=0; i < nb_formats; i++) {
|
||||||
|
memset (&visual_info_template, 0, sizeof (visual_info_template)) ;
|
||||||
|
visual_info_template.visualid =
|
||||||
|
((XvAdaptorInfo*)a_this)->formats[i].visual_id;
|
||||||
|
visual_info = XGetVisualInfo (hostx_get_display (),
|
||||||
|
VisualIDMask,
|
||||||
|
&visual_info_template,
|
||||||
|
&nb_visual_info) ;
|
||||||
|
formats[i].depth = ((XvAdaptorInfo*)a_this)->formats[i].depth ;
|
||||||
|
formats[i].visual_class = visual_info->class ;
|
||||||
|
XFree (visual_info) ;
|
||||||
|
}
|
||||||
if (a_nb_formats)
|
if (a_nb_formats)
|
||||||
*a_nb_formats = ((XvAdaptorInfo*)a_this)->num_formats ;
|
*a_nb_formats = nb_formats ;
|
||||||
return (EphyrHostVideoFormat*) ((XvAdaptorInfo*)a_this)->formats ;
|
return formats ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -157,16 +176,38 @@ EphyrHostXVQueryEncodings (int a_port_id,
|
||||||
EphyrHostEncoding **a_encodings,
|
EphyrHostEncoding **a_encodings,
|
||||||
unsigned int *a_num_encodings)
|
unsigned int *a_num_encodings)
|
||||||
{
|
{
|
||||||
int ret = 0 ;
|
EphyrHostEncoding *encodings=NULL ;
|
||||||
|
XvEncodingInfo *encoding_info=NULL ;
|
||||||
|
unsigned int num_encodings=0, i;
|
||||||
|
int ret=0 ;
|
||||||
|
|
||||||
EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, FALSE) ;
|
EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, FALSE) ;
|
||||||
|
|
||||||
ret = XvQueryEncodings (hostx_get_display (),
|
ret = XvQueryEncodings (hostx_get_display (),
|
||||||
a_port_id,
|
a_port_id,
|
||||||
a_num_encodings,
|
&num_encodings,
|
||||||
(XvEncodingInfo**)a_encodings) ;
|
&encoding_info) ;
|
||||||
if (ret == Success)
|
if (num_encodings && encoding_info) {
|
||||||
return TRUE ;
|
encodings = Xcalloc (num_encodings * sizeof (EphyrHostEncoding)) ;
|
||||||
return FALSE ;
|
for (i=0; i<num_encodings; i++) {
|
||||||
|
encodings[i].id = encoding_info[i].encoding_id ;
|
||||||
|
encodings[i].name = strdup (encoding_info[i].name) ;
|
||||||
|
encodings[i].width = encoding_info[i].width ;
|
||||||
|
encodings[i].height = encoding_info[i].height ;
|
||||||
|
encodings[i].rate.numerator = encoding_info[i].rate.numerator ;
|
||||||
|
encodings[i].rate.denominator = encoding_info[i].rate.denominator ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (encoding_info) {
|
||||||
|
XvFreeEncodingInfo (encoding_info) ;
|
||||||
|
encoding_info = NULL ;
|
||||||
|
}
|
||||||
|
*a_encodings = encodings ;
|
||||||
|
*a_num_encodings = num_encodings ;
|
||||||
|
|
||||||
|
if (ret != Success)
|
||||||
|
return FALSE ;
|
||||||
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -187,20 +228,11 @@ EphyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EphyrHostAttributesDelete (EphyrHostAttribute *a_attributes,
|
EphyrHostAttributesDelete (EphyrHostAttribute *a_attributes)
|
||||||
int a_num_attributes)
|
|
||||||
{
|
{
|
||||||
int i=0 ;
|
|
||||||
|
|
||||||
if (!a_attributes)
|
if (!a_attributes)
|
||||||
return ;
|
return ;
|
||||||
for (i=0; i < a_num_attributes; i++) {
|
XFree (a_attributes) ;
|
||||||
if (a_attributes[i].name) {
|
|
||||||
xfree (a_attributes[i].name) ;
|
|
||||||
a_attributes[i].name = NULL ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xfree (a_attributes) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
|
|
@ -28,13 +28,12 @@
|
||||||
#ifndef __EPHYRHOSTVIDEO_H__
|
#ifndef __EPHYRHOSTVIDEO_H__
|
||||||
#define __EPHYRHOSTVIDEO_H__
|
#define __EPHYRHOSTVIDEO_H__
|
||||||
|
|
||||||
|
|
||||||
typedef void* EphyrHostXVAdaptor ;
|
typedef void* EphyrHostXVAdaptor ;
|
||||||
typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray ;
|
typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray ;
|
||||||
|
|
||||||
typedef struct _EphyrHostVideoFormat {
|
typedef struct _EphyrHostVideoFormat {
|
||||||
char depth ;
|
char depth ;
|
||||||
unsigned long visual_id;
|
short visual_class;
|
||||||
} EphyrHostVideoFormat ;
|
} EphyrHostVideoFormat ;
|
||||||
|
|
||||||
typedef struct _EphyrHostRational {
|
typedef struct _EphyrHostRational {
|
||||||
|
@ -100,9 +99,7 @@ EphyrHostXVAdaptor* EphyrHostXVAdaptorArrayAt (const EphyrHostXVAdaptorArray *a_
|
||||||
|
|
||||||
char EphyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this) ;
|
char EphyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this) ;
|
||||||
const char* EphyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this) ;
|
const char* EphyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this) ;
|
||||||
const EphyrHostVideoFormat* EphyrHostXVAdaptorGetNbVideoFormats
|
EphyrHostVideoFormat* EphyrHostXVAdaptorGetVideoFormats
|
||||||
(const EphyrHostXVAdaptor *a_this) ;
|
|
||||||
const EphyrHostVideoFormat* EphyrHostXVAdaptorGetVideoFormats
|
|
||||||
(const EphyrHostXVAdaptor *a_this,
|
(const EphyrHostXVAdaptor *a_this,
|
||||||
int *a_nb_formats) ;
|
int *a_nb_formats) ;
|
||||||
int EphyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this) ;
|
int EphyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this) ;
|
||||||
|
@ -125,8 +122,7 @@ Bool EphyrHostXVQueryPortAttributes (int a_port_id,
|
||||||
EphyrHostAttribute **a_attributes,
|
EphyrHostAttribute **a_attributes,
|
||||||
int *a_num_attributes) ;
|
int *a_num_attributes) ;
|
||||||
|
|
||||||
void EphyrHostAttributesDelete (EphyrHostAttribute *a_attributes,
|
void EphyrHostAttributesDelete (EphyrHostAttribute *a_attributes) ;
|
||||||
int a_num_attributes) ;
|
|
||||||
/*
|
/*
|
||||||
* image format
|
* image format
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -121,7 +121,7 @@ ephyrInitVideo (ScreenPtr pScreen)
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EphyrXVPrivRegisterAdaptors (xv_priv, pScreen)) {
|
if (!EphyrXVPrivRegisterAdaptors (xv_priv, pScreen)) {
|
||||||
EPHYR_LOG_ERROR ("failed to register adaptors\n") ;
|
EPHYR_LOG_ERROR ("failed to register adaptors\n") ;
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
@ -266,11 +266,13 @@ EphyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this)
|
||||||
if (!cur_host_adaptor)
|
if (!cur_host_adaptor)
|
||||||
continue ;
|
continue ;
|
||||||
a_this->adaptors[i].type = EphyrHostXVAdaptorGetType (cur_host_adaptor) ;
|
a_this->adaptors[i].type = EphyrHostXVAdaptorGetType (cur_host_adaptor) ;
|
||||||
|
a_this->adaptors[i].type |= XvWindowMask ;
|
||||||
a_this->adaptors[i].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
|
a_this->adaptors[i].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
|
||||||
if (EphyrHostXVAdaptorGetName (cur_host_adaptor))
|
if (EphyrHostXVAdaptorGetName (cur_host_adaptor))
|
||||||
a_this->adaptors[i].name =
|
a_this->adaptors[i].name =
|
||||||
strdup (EphyrHostXVAdaptorGetName (cur_host_adaptor)) ;
|
strdup (EphyrHostXVAdaptorGetName (cur_host_adaptor)) ;
|
||||||
a_this->adaptors[i].name = "Xephyr Video Overlay";
|
else
|
||||||
|
a_this->adaptors[i].name = strdup ("Xephyr Video Overlay");
|
||||||
base_port_id = EphyrHostXVAdaptorGetFirstPortID (cur_host_adaptor) ;
|
base_port_id = EphyrHostXVAdaptorGetFirstPortID (cur_host_adaptor) ;
|
||||||
if (base_port_id < 0) {
|
if (base_port_id < 0) {
|
||||||
EPHYR_LOG_ERROR ("failed to get port id for adaptor %d\n", i) ;
|
EPHYR_LOG_ERROR ("failed to get port id for adaptor %d\n", i) ;
|
||||||
|
@ -306,6 +308,7 @@ EphyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this)
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
a_this->adaptors[i].pImages = (KdImagePtr) image_formats ;
|
a_this->adaptors[i].pImages = (KdImagePtr) image_formats ;
|
||||||
|
a_this->adaptors[i].nImages = num_formats ;
|
||||||
}
|
}
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
|
|
||||||
|
@ -315,13 +318,9 @@ out:
|
||||||
encodings = NULL ;
|
encodings = NULL ;
|
||||||
}
|
}
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
EphyrHostAttributesDelete (attributes, num_attributes) ;
|
EphyrHostAttributesDelete (attributes) ;
|
||||||
attributes = NULL ;
|
attributes = NULL ;
|
||||||
}
|
}
|
||||||
if (image_formats) {
|
|
||||||
xfree (image_formats) ;
|
|
||||||
image_formats = NULL ;
|
|
||||||
}
|
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
return is_ok ;
|
return is_ok ;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +373,11 @@ EphyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
|
||||||
for (i=0 ; i < a_this->num_adaptors; i++) {
|
for (i=0 ; i < a_this->num_adaptors; i++) {
|
||||||
*(adaptors + num_registered_adaptors + i) = &a_this->adaptors[i] ;
|
*(adaptors + num_registered_adaptors + i) = &a_this->adaptors[i] ;
|
||||||
}
|
}
|
||||||
KdXVScreenInit (a_screen, adaptors, num_adaptors);
|
if (!KdXVScreenInit (a_screen, adaptors, num_adaptors)) {
|
||||||
|
EPHYR_LOG_ERROR ("failed to register adaptors\n");
|
||||||
|
goto out ;
|
||||||
|
}
|
||||||
|
EPHYR_LOG ("registered %d adaptors\n", num_adaptors) ;
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in New Issue