Skip to content
Snippets Groups Projects
Commit 46130b4f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont Committed by Hugo Beauzée-Luyssen
Browse files

vdpau: remove dead code

parent 0a82e325
No related branches found
No related tags found
No related merge requests found
vdpaudir = $(pluginsdir)/vdpau
libvlc_vdpau_la_SOURCES = hw/vdpau/vlc_vdpau.c hw/vdpau/vlc_vdpau.h hw/vdpau/instance.c
libvlc_vdpau_la_SOURCES = hw/vdpau/vlc_vdpau.c hw/vdpau/vlc_vdpau.h
libvlc_vdpau_la_CFLAGS = $(VDPAU_CFLAGS)
libvlc_vdpau_la_LIBADD = $(X_LIBS) $(X_PRE_LIBS) -lX11 $(LIBDL)
libvlc_vdpau_la_LDFLAGS = \
......
/*****************************************************************************
* instance.c: VDPAU instance management for VLC
*****************************************************************************
* Copyright (C) 2013 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <pthread.h>
#include <X11/Xlib.h>
#include <vlc_common.h>
#include "vlc_vdpau.h"
#pragma GCC visibility push(default)
typedef struct vdp_instance
{
Display *display;
vdp_t *vdp;
VdpDevice device;
struct vdp_instance *next;
} vdp_instance_t;
static vdp_instance_t *vdp_instance_create(const char *name, int num)
{
vdp_instance_t *vi = malloc(sizeof (*vi));
if (unlikely(vi == NULL))
return NULL;
vi->display = XOpenDisplay(name);
if (vi->display == NULL)
{
free(vi);
return NULL;
}
if (num < 0)
num = XDefaultScreen(vi->display);
VdpStatus err = vdp_create_x11(vi->display, num, &vi->vdp, &vi->device);
if (err != VDP_STATUS_OK)
{
XCloseDisplay(vi->display);
free(vi);
return NULL;
}
vi->next = NULL;
return vi;
}
static void vdp_instance_destroy(vdp_instance_t *vi)
{
vdp_device_destroy(vi->vdp, vi->device);
vdp_destroy_x11(vi->vdp);
XCloseDisplay(vi->display);
free(vi);
}
static vdp_instance_t *list = NULL;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
/** Finds an existing VDPAU instance for the given X11 display and screen.
* If not found, (try to) create a new one.
* @param display_name X11 display string, NULL for default
* @param snum X11 screen number, strictly negative for default
**/
VdpStatus vdp_get_x11(const char *display_name, int snum,
vdp_t **restrict vdpp, VdpDevice *restrict devicep)
{
vdp_instance_t *vi = vdp_instance_create(display_name, snum);
if (vi == NULL)
return VDP_STATUS_ERROR;
pthread_mutex_lock(&lock);
vi->next = list;
list = vi;
pthread_mutex_unlock(&lock);
*vdpp = vi->vdp;
*devicep = vi->device;
return VDP_STATUS_OK;
}
void vdp_release_x11(vdp_t *vdp)
{
vdp_instance_t *vi, **pp = &list;
pthread_mutex_lock(&lock);
for (;;)
{
vi = *pp;
assert(vi != NULL);
if (vi->vdp == vdp)
break;
pp = &vi->next;
}
*pp = vi->next; /* Unlink the instance */
pthread_mutex_unlock(&lock);
if (vi != NULL)
vdp_instance_destroy(vi);
}
......@@ -172,32 +172,6 @@ VdpStatus vdp_create_x11(void *dpy, int snum, vdp_t **vdpp, VdpDevice *devp);
*/
void vdp_destroy_x11(vdp_t *);
/* Instance reuse */
/**
* Creates a VDPAU instance.
*
* This function connects to the X11 server and creates a VDPAU instance and
* VDPAU device matching the specified screen number.
*
* @param name X11 display name
* @param snum X11 screen number
* @param vdp memory location to hold the VDPAU instance pointer [OUT]
* @param dev memory location to hold the VDPAU device handle [OUT]
* @return VDP_STATUS_OK on success, otherwise a VDPAU error code.
*
* @note Use vdp_release_x11() to release the instance. <b>Do not use</b>
* vdp_device_destroy() and/or vdp_destroy_x11() with vdp_get_x11().
*/
VdpStatus vdp_get_x11(const char *name, int num, vdp_t **vdp, VdpDevice *dev);
/**
* Decreases the reference count of a VDPAU instance created by vdp_get_x11().
* If it reaches zero, destroy the corresponding VDPAU device, then the VDPAU
* instance and remove the pair from the process-wide list.
*/
void vdp_release_x11(vdp_t *);
/* VLC specifics */
# include <stdatomic.h>
# include <stdbool.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment