diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c index 6c5891c9c..98b754947 100644 --- a/hw/kdrive/ephyr/ephyrhostvideo.c +++ b/hw/kdrive/ephyr/ephyrhostvideo.c @@ -28,7 +28,7 @@ #ifdef HAVE_CONFIG_H #include #endif -#include +#include #include #include "hostx.h" @@ -125,15 +125,34 @@ EphyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this) return ((XvAdaptorInfo*)a_this)->name ; } -const EphyrHostVideoFormat* +EphyrHostVideoFormat* EphyrHostXVAdaptorGetVideoFormats (const EphyrHostXVAdaptor *a_this, 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) ; + 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) - *a_nb_formats = ((XvAdaptorInfo*)a_this)->num_formats ; - return (EphyrHostVideoFormat*) ((XvAdaptorInfo*)a_this)->formats ; + *a_nb_formats = nb_formats ; + return formats ; } int @@ -157,16 +176,38 @@ EphyrHostXVQueryEncodings (int a_port_id, EphyrHostEncoding **a_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) ; ret = XvQueryEncodings (hostx_get_display (), a_port_id, - a_num_encodings, - (XvEncodingInfo**)a_encodings) ; - if (ret == Success) - return TRUE ; - return FALSE ; + &num_encodings, + &encoding_info) ; + if (num_encodings && encoding_info) { + encodings = Xcalloc (num_encodings * sizeof (EphyrHostEncoding)) ; + for (i=0; iadaptors[i].type = EphyrHostXVAdaptorGetType (cur_host_adaptor) ; + a_this->adaptors[i].type |= XvWindowMask ; a_this->adaptors[i].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; if (EphyrHostXVAdaptorGetName (cur_host_adaptor)) a_this->adaptors[i].name = 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) ; if (base_port_id < 0) { EPHYR_LOG_ERROR ("failed to get port id for adaptor %d\n", i) ; @@ -306,6 +308,7 @@ EphyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this) continue ; } a_this->adaptors[i].pImages = (KdImagePtr) image_formats ; + a_this->adaptors[i].nImages = num_formats ; } is_ok = TRUE ; @@ -315,13 +318,9 @@ out: encodings = NULL ; } if (attributes) { - EphyrHostAttributesDelete (attributes, num_attributes) ; + EphyrHostAttributesDelete (attributes) ; attributes = NULL ; } - if (image_formats) { - xfree (image_formats) ; - image_formats = NULL ; - } EPHYR_LOG ("leave\n") ; return is_ok ; } @@ -374,7 +373,11 @@ EphyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this, for (i=0 ; i < a_this->num_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 ; out: