ephyr: Remove the host/server split for XV attributes.
v2: Fix leaks of xcb replies (caught by Julien) Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org>
This commit is contained in:
		
							parent
							
								
									1342a93c49
								
							
						
					
					
						commit
						41134d393a
					
				| 
						 | 
					@ -120,30 +120,6 @@ ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings, int a_num_encodings)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    free(a_encodings);
 | 
					    free(a_encodings);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
ephyrHostAttributesDelete(xcb_xv_query_port_attributes_reply_t *a_attributes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    free(a_attributes);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Bool
 | 
					 | 
				
			||||||
ephyrHostXVQueryPortAttributes(int a_port_id,
 | 
					 | 
				
			||||||
                               xcb_xv_query_port_attributes_reply_t **a_attributes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    xcb_xv_query_port_attributes_cookie_t cookie;
 | 
					 | 
				
			||||||
    xcb_xv_query_port_attributes_reply_t *reply;
 | 
					 | 
				
			||||||
    xcb_connection_t *conn = hostx_get_xcbconn();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_attributes, FALSE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cookie = xcb_xv_query_port_attributes(conn, a_port_id);
 | 
					 | 
				
			||||||
    reply = xcb_xv_query_port_attributes_reply(conn, cookie, NULL);
 | 
					 | 
				
			||||||
    *a_attributes = reply;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return (reply != NULL);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Bool
 | 
					Bool
 | 
				
			||||||
ephyrHostXVQueryImageFormats(int a_port_id,
 | 
					ephyrHostXVQueryImageFormats(int a_port_id,
 | 
				
			||||||
                             EphyrHostImageFormat ** a_formats,
 | 
					                             EphyrHostImageFormat ** a_formats,
 | 
				
			||||||
| 
						 | 
					@ -199,51 +175,6 @@ ephyrHostXVQueryImageFormats(int a_port_id,
 | 
				
			||||||
    return TRUE;
 | 
					    return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Bool
 | 
					 | 
				
			||||||
ephyrHostXVSetPortAttribute(int a_port_id, int a_atom, int a_attr_value)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    EPHYR_LOG("atom,value: (%d,%d)\n", a_atom, a_attr_value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    xcb_xv_set_port_attribute(hostx_get_xcbconn(),
 | 
					 | 
				
			||||||
                              a_port_id,
 | 
					 | 
				
			||||||
                              a_atom,
 | 
					 | 
				
			||||||
                              a_attr_value);
 | 
					 | 
				
			||||||
    xcb_flush(hostx_get_xcbconn());
 | 
					 | 
				
			||||||
    EPHYR_LOG("leave\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return TRUE;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Bool
 | 
					 | 
				
			||||||
ephyrHostXVGetPortAttribute(int a_port_id, int a_atom, int *a_attr_value)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    Bool ret = FALSE;
 | 
					 | 
				
			||||||
    xcb_connection_t *conn = hostx_get_xcbconn();
 | 
					 | 
				
			||||||
    xcb_xv_get_port_attribute_cookie_t cookie;
 | 
					 | 
				
			||||||
    xcb_xv_get_port_attribute_reply_t *reply;
 | 
					 | 
				
			||||||
    xcb_generic_error_t *e;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_attr_value, FALSE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    EPHYR_LOG("enter, a_port_id: %d, a_atomid: %d\n", a_port_id, a_atom);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cookie = xcb_xv_get_port_attribute(conn, a_port_id, a_atom);
 | 
					 | 
				
			||||||
    reply = xcb_xv_get_port_attribute_reply(conn, cookie, &e);
 | 
					 | 
				
			||||||
    if (e) {
 | 
					 | 
				
			||||||
        EPHYR_LOG_ERROR ("XvGetPortAttribute() failed: %d \n", e->error_code);
 | 
					 | 
				
			||||||
        free(e);
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    *a_attr_value = reply->value;
 | 
					 | 
				
			||||||
    EPHYR_LOG("atom,value: (%d, %d)\n", a_atom, *a_attr_value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ret = TRUE;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 out:
 | 
					 | 
				
			||||||
    EPHYR_LOG("leave\n");
 | 
					 | 
				
			||||||
    return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Bool
 | 
					Bool
 | 
				
			||||||
ephyrHostXVQueryBestSize(int a_port_id,
 | 
					ephyrHostXVQueryBestSize(int a_port_id,
 | 
				
			||||||
                         Bool a_motion,
 | 
					                         Bool a_motion,
 | 
				
			||||||
| 
						 | 
					@ -285,44 +216,6 @@ out:
 | 
				
			||||||
    return is_ok;
 | 
					    return is_ok;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Bool
 | 
					 | 
				
			||||||
ephyrHostXVQueryImageAttributes(int a_port_id,
 | 
					 | 
				
			||||||
                                int a_image_id /*image fourcc code */ ,
 | 
					 | 
				
			||||||
                                unsigned short *a_width,
 | 
					 | 
				
			||||||
                                unsigned short *a_height,
 | 
					 | 
				
			||||||
                                int *a_image_size,
 | 
					 | 
				
			||||||
                                int *a_pitches, int *a_offsets)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    xcb_connection_t *conn = hostx_get_xcbconn ();
 | 
					 | 
				
			||||||
    xcb_xv_query_image_attributes_cookie_t cookie;
 | 
					 | 
				
			||||||
    xcb_xv_query_image_attributes_reply_t *reply;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_width, FALSE);
 | 
					 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_height, FALSE);
 | 
					 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_image_size, FALSE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cookie = xcb_xv_query_image_attributes(conn,
 | 
					 | 
				
			||||||
                                           a_port_id, a_image_id,
 | 
					 | 
				
			||||||
                                           *a_width, *a_height);
 | 
					 | 
				
			||||||
    reply = xcb_xv_query_image_attributes_reply(conn, cookie, NULL);
 | 
					 | 
				
			||||||
    if (!reply)
 | 
					 | 
				
			||||||
        return FALSE;
 | 
					 | 
				
			||||||
    if (a_pitches && a_offsets) {
 | 
					 | 
				
			||||||
        memcpy(a_pitches,
 | 
					 | 
				
			||||||
               xcb_xv_query_image_attributes_pitches(reply),
 | 
					 | 
				
			||||||
               reply->num_planes << 2);
 | 
					 | 
				
			||||||
        memcpy(a_offsets,
 | 
					 | 
				
			||||||
               xcb_xv_query_image_attributes_offsets(reply),
 | 
					 | 
				
			||||||
               reply->num_planes << 2);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    *a_width = reply->width;
 | 
					 | 
				
			||||||
    *a_height = reply->height;
 | 
					 | 
				
			||||||
    *a_image_size = reply->data_size;
 | 
					 | 
				
			||||||
    free(reply);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return TRUE;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Bool
 | 
					Bool
 | 
				
			||||||
ephyrHostGetAtom(const char *a_name, Bool a_create_if_not_exists, int *a_atom)
 | 
					ephyrHostGetAtom(const char *a_name, Bool a_create_if_not_exists, int *a_atom)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,14 +97,6 @@ Bool ephyrHostXVQueryEncodings(int a_port_id,
 | 
				
			||||||
void ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings,
 | 
					void ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings,
 | 
				
			||||||
                              int a_num_encodings);
 | 
					                              int a_num_encodings);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * attribute
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
Bool ephyrHostXVQueryPortAttributes(int a_port_id,
 | 
					 | 
				
			||||||
                                    xcb_xv_query_port_attributes_reply_t **a_attributes);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ephyrHostAttributesDelete(xcb_xv_query_port_attributes_reply_t *a_attributes);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * image format
 | 
					 * image format
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -112,11 +104,6 @@ void ephyrHostAttributesDelete(xcb_xv_query_port_attributes_reply_t *a_attribute
 | 
				
			||||||
Bool ephyrHostXVQueryImageFormats(int a_port_id,
 | 
					Bool ephyrHostXVQueryImageFormats(int a_port_id,
 | 
				
			||||||
                                  EphyrHostImageFormat ** a_formats,
 | 
					                                  EphyrHostImageFormat ** a_formats,
 | 
				
			||||||
                                  int *a_num_format);
 | 
					                                  int *a_num_format);
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * Port Attribute Get/Set
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
Bool ephyrHostXVSetPortAttribute(int a_port_id, int a_atom, int a_attr_value);
 | 
					 | 
				
			||||||
Bool ephyrHostXVGetPortAttribute(int a_port_id, int a_atom, int *a_attr_value);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 *size query
 | 
					 *size query
 | 
				
			||||||
| 
						 | 
					@ -130,12 +117,6 @@ Bool ephyrHostXVQueryBestSize(int a_port_id,
 | 
				
			||||||
                              unsigned int *a_actual_w,
 | 
					                              unsigned int *a_actual_w,
 | 
				
			||||||
                              unsigned int *a_actual_h);
 | 
					                              unsigned int *a_actual_h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Bool ephyrHostXVQueryImageAttributes(int a_port_id,
 | 
					 | 
				
			||||||
                                     int a_image_id /*image fourcc code */ ,
 | 
					 | 
				
			||||||
                                     unsigned short *a_width,
 | 
					 | 
				
			||||||
                                     unsigned short *a_height,
 | 
					 | 
				
			||||||
                                     int *a_image_size,
 | 
					 | 
				
			||||||
                                     int *a_pitches, int *a_offsets);
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * atom
 | 
					 * atom
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -352,32 +352,48 @@ videoEncodingDup(EphyrHostEncoding * a_encodings, int a_num_encodings)
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static KdAttributePtr
 | 
					static Bool
 | 
				
			||||||
portAttributesDup(const xcb_xv_query_port_attributes_reply_t *a_encodings)
 | 
					translate_xv_attributes(KdVideoAdaptorPtr adaptor,
 | 
				
			||||||
 | 
					                        xcb_xv_adaptor_info_t *host_adaptor)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    xcb_connection_t *conn = hostx_get_xcbconn();
 | 
				
			||||||
    int i = 0;
 | 
					    int i = 0;
 | 
				
			||||||
    KdAttributePtr result = NULL;
 | 
					 | 
				
			||||||
    xcb_xv_attribute_info_iterator_t it;
 | 
					    xcb_xv_attribute_info_iterator_t it;
 | 
				
			||||||
 | 
					    xcb_xv_query_port_attributes_cookie_t cookie =
 | 
				
			||||||
 | 
					        xcb_xv_query_port_attributes(conn, host_adaptor->base_id);
 | 
				
			||||||
 | 
					    xcb_xv_query_port_attributes_reply_t *reply =
 | 
				
			||||||
 | 
					        xcb_xv_query_port_attributes_reply(conn, cookie, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_encodings, NULL);
 | 
					    if (!reply)
 | 
				
			||||||
 | 
					        return FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    result = calloc(a_encodings->num_attributes, sizeof(KdAttributeRec));
 | 
					    adaptor->nAttributes = reply->num_attributes;
 | 
				
			||||||
    if (!result) {
 | 
					    adaptor->pAttributes = calloc(reply->num_attributes,
 | 
				
			||||||
 | 
					                                  sizeof(*adaptor->pAttributes));
 | 
				
			||||||
 | 
					    if (!adaptor->pAttributes) {
 | 
				
			||||||
        EPHYR_LOG_ERROR("failed to allocate attributes\n");
 | 
					        EPHYR_LOG_ERROR("failed to allocate attributes\n");
 | 
				
			||||||
        return NULL;
 | 
					        free(reply);
 | 
				
			||||||
 | 
					        return FALSE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    it = xcb_xv_query_port_attributes_attributes_iterator(a_encodings);
 | 
					
 | 
				
			||||||
    for (i = 0;
 | 
					    it = xcb_xv_query_port_attributes_attributes_iterator(reply);
 | 
				
			||||||
         i < a_encodings->num_attributes;
 | 
					    for (i = 0; i < reply->num_attributes; i++) {
 | 
				
			||||||
         xcb_xv_attribute_info_next(&it), i++) {
 | 
					        KdAttributePtr attribute = &adaptor->pAttributes[i];
 | 
				
			||||||
        result[i].flags = it.data->flags;
 | 
					
 | 
				
			||||||
        result[i].min_value = it.data->min;
 | 
					        attribute->flags = it.data->flags;
 | 
				
			||||||
        result[i].max_value = it.data->max;
 | 
					        attribute->min_value = it.data->min;
 | 
				
			||||||
        result[i].name = malloc(it.data->size + 1);
 | 
					        attribute->max_value = it.data->max;
 | 
				
			||||||
	memcpy (result[i].name, xcb_xv_attribute_info_name(it.data), it.data->size);
 | 
					        attribute->name = strndup(xcb_xv_attribute_info_name(it.data),
 | 
				
			||||||
	result[i].name[it.data->size] = '\0';
 | 
					                                  it.data->size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* make sure atoms of attrs names are created in xephyr */
 | 
				
			||||||
 | 
					        MakeAtom(xcb_xv_attribute_info_name(it.data), it.data->size, TRUE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        xcb_xv_attribute_info_next(&it);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return result;
 | 
					
 | 
				
			||||||
 | 
					    free(reply);
 | 
				
			||||||
 | 
					    return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static Bool
 | 
					static Bool
 | 
				
			||||||
| 
						 | 
					@ -387,7 +403,6 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
 | 
				
			||||||
    xcb_screen_t *xscreen = xcb_aux_get_screen(conn, hostx_get_screen());
 | 
					    xcb_screen_t *xscreen = xcb_aux_get_screen(conn, hostx_get_screen());
 | 
				
			||||||
    EphyrHostVideoFormat *video_formats = NULL;
 | 
					    EphyrHostVideoFormat *video_formats = NULL;
 | 
				
			||||||
    EphyrHostEncoding *encodings = NULL;
 | 
					    EphyrHostEncoding *encodings = NULL;
 | 
				
			||||||
    xcb_xv_query_port_attributes_reply_t *attributes = NULL;
 | 
					 | 
				
			||||||
    EphyrHostImageFormat *image_formats = NULL;
 | 
					    EphyrHostImageFormat *image_formats = NULL;
 | 
				
			||||||
    int num_video_formats = 0, base_port_id = 0,
 | 
					    int num_video_formats = 0, base_port_id = 0,
 | 
				
			||||||
        num_formats = 0, i = 0, port_priv_offset = 0;
 | 
					        num_formats = 0, i = 0, port_priv_offset = 0;
 | 
				
			||||||
| 
						 | 
					@ -485,20 +500,15 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
 | 
				
			||||||
            port_priv->xv_priv = a_this;
 | 
					            port_priv->xv_priv = a_this;
 | 
				
			||||||
            a_this->adaptors[i].pPortPrivates[j].ptr = port_priv;
 | 
					            a_this->adaptors[i].pPortPrivates[j].ptr = port_priv;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!ephyrHostXVQueryPortAttributes(base_port_id, &attributes)) {
 | 
					
 | 
				
			||||||
 | 
					        if (!translate_xv_attributes(&a_this->adaptors[i], cur_host_adaptor)) {
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            EPHYR_LOG_ERROR("failed to get port attribute "
 | 
					            EPHYR_LOG_ERROR("failed to get port attribute "
 | 
				
			||||||
                            "for adaptor %d\n", i);
 | 
					                            "for adaptor %d\n", i);
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        a_this->adaptors[i].pAttributes =
 | 
					 | 
				
			||||||
            portAttributesDup(attributes);
 | 
					 | 
				
			||||||
        a_this->adaptors[i].nAttributes = attributes->num_attributes;
 | 
					 | 
				
			||||||
        /*make sure atoms of attrs names are created in xephyr */
 | 
					 | 
				
			||||||
        for (j = 0; j < a_this->adaptors[i].nAttributes; j++) {
 | 
					 | 
				
			||||||
            if (a_this->adaptors[i].pAttributes[j].name)
 | 
					 | 
				
			||||||
                MakeAtom(a_this->adaptors[i].pAttributes[j].name,
 | 
					 | 
				
			||||||
                         strlen(a_this->adaptors[i].pAttributes[j].name), TRUE);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!ephyrHostXVQueryImageFormats(base_port_id,
 | 
					        if (!ephyrHostXVQueryImageFormats(base_port_id,
 | 
				
			||||||
                                          &image_formats, &num_formats)) {
 | 
					                                          &image_formats, &num_formats)) {
 | 
				
			||||||
            EPHYR_LOG_ERROR("failed to get image formats "
 | 
					            EPHYR_LOG_ERROR("failed to get image formats "
 | 
				
			||||||
| 
						 | 
					@ -517,10 +527,6 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
 | 
				
			||||||
        ephyrHostEncodingsDelete(encodings, num_encodings);
 | 
					        ephyrHostEncodingsDelete(encodings, num_encodings);
 | 
				
			||||||
        encodings = NULL;
 | 
					        encodings = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (attributes) {
 | 
					 | 
				
			||||||
        ephyrHostAttributesDelete(attributes);
 | 
					 | 
				
			||||||
        attributes = NULL;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    EPHYR_LOG("leave\n");
 | 
					    EPHYR_LOG("leave\n");
 | 
				
			||||||
    return is_ok;
 | 
					    return is_ok;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -650,20 +656,27 @@ ephyrXVPrivGetImageBufSize(int a_port_id,
 | 
				
			||||||
                           unsigned short a_width,
 | 
					                           unsigned short a_width,
 | 
				
			||||||
                           unsigned short a_height, int *a_size)
 | 
					                           unsigned short a_height, int *a_size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    xcb_connection_t *conn = hostx_get_xcbconn();
 | 
				
			||||||
 | 
					    xcb_xv_query_image_attributes_cookie_t cookie;
 | 
				
			||||||
 | 
					    xcb_xv_query_image_attributes_reply_t *reply;
 | 
				
			||||||
    Bool is_ok = FALSE;
 | 
					    Bool is_ok = FALSE;
 | 
				
			||||||
    unsigned short width = a_width, height = a_height;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_size, FALSE);
 | 
					    EPHYR_RETURN_VAL_IF_FAIL(a_size, FALSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EPHYR_LOG("enter\n");
 | 
					    EPHYR_LOG("enter\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!ephyrHostXVQueryImageAttributes(a_port_id, a_image_id,
 | 
					    cookie = xcb_xv_query_image_attributes(conn,
 | 
				
			||||||
                                         &width, &height, a_size, NULL, NULL)) {
 | 
					                                           a_port_id, a_image_id,
 | 
				
			||||||
        EPHYR_LOG_ERROR("failed to get image attributes\n");
 | 
					                                           a_width, a_height);
 | 
				
			||||||
 | 
					    reply = xcb_xv_query_image_attributes_reply(conn, cookie, NULL);
 | 
				
			||||||
 | 
					    if (!reply)
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					
 | 
				
			||||||
 | 
					    *a_size = reply->data_size;
 | 
				
			||||||
    is_ok = TRUE;
 | 
					    is_ok = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    free(reply);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 out:
 | 
					 out:
 | 
				
			||||||
    EPHYR_LOG("leave\n");
 | 
					    EPHYR_LOG("leave\n");
 | 
				
			||||||
    return is_ok;
 | 
					    return is_ok;
 | 
				
			||||||
| 
						 | 
					@ -715,6 +728,7 @@ static int
 | 
				
			||||||
ephyrSetPortAttribute(KdScreenInfo * a_info,
 | 
					ephyrSetPortAttribute(KdScreenInfo * a_info,
 | 
				
			||||||
                      Atom a_attr_name, int a_attr_value, pointer a_port_priv)
 | 
					                      Atom a_attr_name, int a_attr_value, pointer a_port_priv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    xcb_connection_t *conn = hostx_get_xcbconn();
 | 
				
			||||||
    int res = Success, host_atom = 0;
 | 
					    int res = Success, host_atom = 0;
 | 
				
			||||||
    EphyrPortPriv *port_priv = a_port_priv;
 | 
					    EphyrPortPriv *port_priv = a_port_priv;
 | 
				
			||||||
    Bool is_attr_valid = FALSE;
 | 
					    Bool is_attr_valid = FALSE;
 | 
				
			||||||
| 
						 | 
					@ -755,12 +769,9 @@ ephyrSetPortAttribute(KdScreenInfo * a_info,
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!ephyrHostXVSetPortAttribute(port_priv->port_number,
 | 
					    xcb_xv_set_port_attribute(conn, port_priv->port_number,
 | 
				
			||||||
                                     host_atom, a_attr_value)) {
 | 
					                              host_atom, a_attr_value);
 | 
				
			||||||
        EPHYR_LOG_ERROR("failed to set port attribute\n");
 | 
					    xcb_flush(conn);
 | 
				
			||||||
        res = BadMatch;
 | 
					 | 
				
			||||||
        goto out;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    res = Success;
 | 
					    res = Success;
 | 
				
			||||||
 out:
 | 
					 out:
 | 
				
			||||||
| 
						 | 
					@ -772,8 +783,12 @@ static int
 | 
				
			||||||
ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
 | 
					ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
 | 
				
			||||||
                      Atom a_attr_name, int *a_attr_value, pointer a_port_priv)
 | 
					                      Atom a_attr_name, int *a_attr_value, pointer a_port_priv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    xcb_connection_t *conn = hostx_get_xcbconn();
 | 
				
			||||||
    int res = Success, host_atom = 0;
 | 
					    int res = Success, host_atom = 0;
 | 
				
			||||||
    EphyrPortPriv *port_priv = a_port_priv;
 | 
					    EphyrPortPriv *port_priv = a_port_priv;
 | 
				
			||||||
 | 
					    xcb_generic_error_t *e;
 | 
				
			||||||
 | 
					    xcb_xv_get_port_attribute_cookie_t cookie;
 | 
				
			||||||
 | 
					    xcb_xv_get_port_attribute_reply_t *reply;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(port_priv, BadMatch);
 | 
					    EPHYR_RETURN_VAL_IF_FAIL(port_priv, BadMatch);
 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(ValidAtom(a_attr_name), BadMatch);
 | 
					    EPHYR_RETURN_VAL_IF_FAIL(ValidAtom(a_attr_name), BadMatch);
 | 
				
			||||||
| 
						 | 
					@ -788,12 +803,17 @@ ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!ephyrHostXVGetPortAttribute(port_priv->port_number,
 | 
					    cookie = xcb_xv_get_port_attribute(conn, port_priv->port_number, host_atom);
 | 
				
			||||||
                                     host_atom, a_attr_value)) {
 | 
					    reply = xcb_xv_get_port_attribute_reply(conn, cookie, &e);
 | 
				
			||||||
        EPHYR_LOG_ERROR("failed to get port attribute\n");
 | 
					    if (e) {
 | 
				
			||||||
 | 
					        EPHYR_LOG_ERROR ("XvGetPortAttribute() failed: %d \n", e->error_code);
 | 
				
			||||||
 | 
					        free(e);
 | 
				
			||||||
        res = BadMatch;
 | 
					        res = BadMatch;
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    *a_attr_value = reply->value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    free(reply);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    res = Success;
 | 
					    res = Success;
 | 
				
			||||||
 out:
 | 
					 out:
 | 
				
			||||||
| 
						 | 
					@ -1130,6 +1150,9 @@ ephyrQueryImageAttributes(KdScreenInfo * a_info,
 | 
				
			||||||
                          unsigned short *a_w,
 | 
					                          unsigned short *a_w,
 | 
				
			||||||
                          unsigned short *a_h, int *a_pitches, int *a_offsets)
 | 
					                          unsigned short *a_h, int *a_pitches, int *a_offsets)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    xcb_connection_t *conn = hostx_get_xcbconn();
 | 
				
			||||||
 | 
					    xcb_xv_query_image_attributes_cookie_t cookie;
 | 
				
			||||||
 | 
					    xcb_xv_query_image_attributes_reply_t *reply;
 | 
				
			||||||
    int image_size = 0;
 | 
					    int image_size = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EPHYR_RETURN_VAL_IF_FAIL(a_w && a_h, FALSE);
 | 
					    EPHYR_RETURN_VAL_IF_FAIL(a_w && a_h, FALSE);
 | 
				
			||||||
| 
						 | 
					@ -1137,13 +1160,25 @@ ephyrQueryImageAttributes(KdScreenInfo * a_info,
 | 
				
			||||||
    EPHYR_LOG("enter: dim (%dx%d), pitches: %p, offsets: %p\n",
 | 
					    EPHYR_LOG("enter: dim (%dx%d), pitches: %p, offsets: %p\n",
 | 
				
			||||||
              *a_w, *a_h, a_pitches, a_offsets);
 | 
					              *a_w, *a_h, a_pitches, a_offsets);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!ephyrHostXVQueryImageAttributes(s_base_port_id,
 | 
					    cookie = xcb_xv_query_image_attributes(conn,
 | 
				
			||||||
                                         a_id,
 | 
					                                           s_base_port_id, a_id,
 | 
				
			||||||
                                         a_w, a_h,
 | 
					                                           *a_w, *a_h);
 | 
				
			||||||
                                         &image_size, a_pitches, a_offsets)) {
 | 
					    reply = xcb_xv_query_image_attributes_reply(conn, cookie, NULL);
 | 
				
			||||||
        EPHYR_LOG_ERROR("EphyrHostXVQueryImageAttributes() failed\n");
 | 
					    if (!reply)
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *a_w = reply->width;
 | 
				
			||||||
 | 
					    *a_h = reply->height;
 | 
				
			||||||
 | 
					    if (a_pitches && a_offsets) {
 | 
				
			||||||
 | 
					        memcpy(a_pitches, xcb_xv_query_image_attributes_pitches(reply),
 | 
				
			||||||
 | 
					               reply->num_planes << 2);
 | 
				
			||||||
 | 
					        memcpy(a_offsets, xcb_xv_query_image_attributes_offsets(reply),
 | 
				
			||||||
 | 
					               reply->num_planes << 2);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    image_size = reply->data_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    free(reply);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EPHYR_LOG("image size: %d, dim (%dx%d)\n", image_size, *a_w, *a_h);
 | 
					    EPHYR_LOG("image size: %d, dim (%dx%d)\n", image_size, *a_w, *a_h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 out:
 | 
					 out:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue