2006-11-26 11:13:41 -07:00
|
|
|
/***********************************************************
|
|
|
|
Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
|
|
|
|
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
2006-11-26 11:13:41 -07:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2015-09-16 13:10:19 -06:00
|
|
|
both that copyright notice and this permission notice appear in
|
2006-11-26 11:13:41 -07:00
|
|
|
supporting documentation, and that the names of Digital or MIT not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
2015-09-16 13:10:19 -06:00
|
|
|
software without specific, written prior permission.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*
|
2015-09-16 13:10:19 -06:00
|
|
|
** File:
|
2006-11-26 11:13:41 -07:00
|
|
|
**
|
|
|
|
** xvmain.c --- Xv server extension main device independent module.
|
2015-09-16 13:10:19 -06:00
|
|
|
**
|
|
|
|
** Author:
|
2006-11-26 11:13:41 -07:00
|
|
|
**
|
|
|
|
** David Carver (Digital Workstation Engineering/Project Athena)
|
|
|
|
**
|
|
|
|
** Revisions:
|
|
|
|
**
|
|
|
|
** 04.09.91 Carver
|
|
|
|
** - change: stop video always generates an event even when video
|
|
|
|
** wasn't active
|
|
|
|
**
|
|
|
|
** 29.08.91 Carver
|
|
|
|
** - change: unrealizing windows no longer preempts video
|
|
|
|
**
|
|
|
|
** 11.06.91 Carver
|
|
|
|
** - changed SetPortControl to SetPortAttribute
|
|
|
|
** - changed GetPortControl to GetPortAttribute
|
|
|
|
** - changed QueryBestSize
|
|
|
|
**
|
|
|
|
** 28.05.91 Carver
|
|
|
|
** - fixed Put and Get requests to not preempt operations to same drawable
|
|
|
|
**
|
|
|
|
** 15.05.91 Carver
|
|
|
|
** - version 2.0 upgrade
|
|
|
|
**
|
|
|
|
** 19.03.91 Carver
|
|
|
|
** - fixed Put and Get requests to honor grabbed ports.
|
|
|
|
** - fixed Video requests to update di structure with new drawable, and
|
|
|
|
** client after calling ddx.
|
|
|
|
**
|
|
|
|
** 24.01.91 Carver
|
|
|
|
** - version 1.4 upgrade
|
2015-09-16 13:10:19 -06:00
|
|
|
**
|
2006-11-26 11:13:41 -07:00
|
|
|
** Notes:
|
|
|
|
**
|
|
|
|
** Port structures reference client structures in a two different
|
|
|
|
** ways: when grabs, or video is active. Each reference is encoded
|
|
|
|
** as fake client resources and thus when the client is goes away so
|
|
|
|
** does the reference (it is zeroed). No other action is taken, so
|
|
|
|
** video doesn't necessarily stop. It probably will as a result of
|
|
|
|
** other resources going away, but if a client starts video using
|
|
|
|
** none of its own resources, then the video will continue to play
|
|
|
|
** after the client disappears.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "os.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "pixmapstr.h"
|
2015-09-16 13:10:19 -06:00
|
|
|
#include "gcstruct.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "extnsionst.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "opaque.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
#define GLOBAL
|
|
|
|
|
|
|
|
#include <X11/extensions/Xv.h>
|
|
|
|
#include <X11/extensions/Xvproto.h>
|
|
|
|
#include "xvdix.h"
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
#include "panoramiX.h"
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
#endif
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "xvdisp.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static DevPrivateKeyRec XvScreenKeyRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define XvScreenKey (&XvScreenKeyRec)
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned long XvExtensionGeneration = 0;
|
|
|
|
unsigned long XvScreenGeneration = 0;
|
|
|
|
unsigned long XvResourceGeneration = 0;
|
|
|
|
|
|
|
|
int XvReqCode;
|
|
|
|
int XvEventBase;
|
|
|
|
int XvErrorBase;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
RESTYPE XvRTPort;
|
|
|
|
RESTYPE XvRTEncoding;
|
|
|
|
RESTYPE XvRTGrab;
|
|
|
|
RESTYPE XvRTVideoNotify;
|
|
|
|
RESTYPE XvRTVideoNotifyList;
|
|
|
|
RESTYPE XvRTPortNotify;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* EXTERNAL */
|
|
|
|
|
|
|
|
static void WriteSwappedVideoNotifyEvent(xvEvent *, xvEvent *);
|
|
|
|
static void WriteSwappedPortNotifyEvent(xvEvent *, xvEvent *);
|
|
|
|
static Bool CreateResourceTypes(void);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static Bool XvCloseScreen(ScreenPtr);
|
2006-11-26 11:13:41 -07:00
|
|
|
static Bool XvDestroyPixmap(PixmapPtr);
|
|
|
|
static Bool XvDestroyWindow(WindowPtr);
|
2012-06-10 07:21:05 -06:00
|
|
|
static void XvResetProc(ExtensionEntry *);
|
2014-09-27 11:52:59 -06:00
|
|
|
static int XvdiDestroyGrab(void *, XID);
|
|
|
|
static int XvdiDestroyEncoding(void *, XID);
|
|
|
|
static int XvdiDestroyVideoNotify(void *, XID);
|
|
|
|
static int XvdiDestroyPortNotify(void *, XID);
|
|
|
|
static int XvdiDestroyVideoNotifyList(void *, XID);
|
|
|
|
static int XvdiDestroyPort(void *, XID);
|
2006-11-26 11:13:41 -07:00
|
|
|
static int XvdiSendVideoNotify(XvPortPtr, DrawablePtr, int);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** XvExtensionInit
|
|
|
|
**
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
XvExtensionInit(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ExtensionEntry *extEntry;
|
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
|
|
|
|
return;
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
/* Look to see if any screens were initialized; if not then
|
|
|
|
init global variables so the extension can function */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XvScreenGeneration != serverGeneration) {
|
|
|
|
if (!CreateResourceTypes()) {
|
|
|
|
ErrorF("XvExtensionInit: Unable to allocate resource types\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
XineramaRegisterConnectionBlockCallback(XineramifyXv);
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
XvScreenGeneration = serverGeneration;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XvExtensionGeneration != serverGeneration) {
|
|
|
|
XvExtensionGeneration = serverGeneration;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
extEntry = AddExtension(XvName, XvNumEvents, XvNumErrors,
|
|
|
|
ProcXvDispatch, SProcXvDispatch,
|
|
|
|
XvResetProc, StandardMinorOpcode);
|
|
|
|
if (!extEntry) {
|
|
|
|
FatalError("XvExtensionInit: AddExtensions failed\n");
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvReqCode = extEntry->base;
|
|
|
|
XvEventBase = extEntry->eventBase;
|
|
|
|
XvErrorBase = extEntry->errorBase;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EventSwapVector[XvEventBase + XvVideoNotify] =
|
|
|
|
(EventSwapPtr) WriteSwappedVideoNotifyEvent;
|
|
|
|
EventSwapVector[XvEventBase + XvPortNotify] =
|
|
|
|
(EventSwapPtr) WriteSwappedPortNotifyEvent;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
SetResourceTypeErrorValue(XvRTPort, _XvBadPort);
|
|
|
|
(void) MakeAtom(XvName, strlen(XvName), xTrue);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2007-11-24 10:55:21 -07:00
|
|
|
CreateResourceTypes(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XvResourceGeneration == serverGeneration)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
XvResourceGeneration = serverGeneration;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(XvRTPort = CreateNewResourceType(XvdiDestroyPort, "XvRTPort"))) {
|
|
|
|
ErrorF("CreateResourceTypes: failed to allocate port resource.\n");
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(XvRTGrab = CreateNewResourceType(XvdiDestroyGrab, "XvRTGrab"))) {
|
|
|
|
ErrorF("CreateResourceTypes: failed to allocate grab resource.\n");
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(XvRTEncoding = CreateNewResourceType(XvdiDestroyEncoding,
|
|
|
|
"XvRTEncoding"))) {
|
|
|
|
ErrorF("CreateResourceTypes: failed to allocate encoding resource.\n");
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(XvRTVideoNotify = CreateNewResourceType(XvdiDestroyVideoNotify,
|
|
|
|
"XvRTVideoNotify"))) {
|
|
|
|
ErrorF
|
|
|
|
("CreateResourceTypes: failed to allocate video notify resource.\n");
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!
|
|
|
|
(XvRTVideoNotifyList =
|
|
|
|
CreateNewResourceType(XvdiDestroyVideoNotifyList,
|
|
|
|
"XvRTVideoNotifyList"))) {
|
|
|
|
ErrorF
|
|
|
|
("CreateResourceTypes: failed to allocate video notify list resource.\n");
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(XvRTPortNotify = CreateNewResourceType(XvdiDestroyPortNotify,
|
|
|
|
"XvRTPortNotify"))) {
|
|
|
|
ErrorF
|
|
|
|
("CreateResourceTypes: failed to allocate port notify resource.\n");
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2006-11-26 11:13:41 -07:00
|
|
|
XvScreenInit(ScreenPtr pScreen)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvScreenPtr pxvs;
|
|
|
|
|
|
|
|
if (XvScreenGeneration != serverGeneration) {
|
|
|
|
if (!CreateResourceTypes()) {
|
|
|
|
ErrorF("XvScreenInit: Unable to allocate resource types\n");
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
XineramaRegisterConnectionBlockCallback(XineramifyXv);
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
XvScreenGeneration = serverGeneration;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
|
|
|
|
return BadAlloc;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey)) {
|
|
|
|
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* ALLOCATE SCREEN PRIVATE RECORD */
|
|
|
|
|
|
|
|
pxvs = malloc(sizeof(XvScreenRec));
|
|
|
|
if (!pxvs) {
|
|
|
|
ErrorF("XvScreenInit: Unable to allocate screen private structure\n");
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
|
|
|
|
|
|
|
|
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
|
|
|
|
pxvs->DestroyWindow = pScreen->DestroyWindow;
|
|
|
|
pxvs->CloseScreen = pScreen->CloseScreen;
|
|
|
|
|
|
|
|
pScreen->DestroyPixmap = XvDestroyPixmap;
|
|
|
|
pScreen->DestroyWindow = XvDestroyWindow;
|
|
|
|
pScreen->CloseScreen = XvCloseScreen;
|
|
|
|
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2013-06-07 11:28:45 -06:00
|
|
|
XvCloseScreen(ScreenPtr pScreen)
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvScreenPtr pxvs;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->DestroyPixmap = pxvs->DestroyPixmap;
|
|
|
|
pScreen->DestroyWindow = pxvs->DestroyWindow;
|
|
|
|
pScreen->CloseScreen = pxvs->CloseScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
free(pxvs);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
return (*pScreen->CloseScreen) (pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XvResetProc(ExtensionEntry * extEntry)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
XvResetProcVector();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
DevPrivateKey
|
2008-11-02 08:26:08 -07:00
|
|
|
XvGetScreenKey(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
return XvScreenKey;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
unsigned long
|
2007-11-24 10:55:21 -07:00
|
|
|
XvGetRTPort(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvRTPort;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static void
|
|
|
|
XvStopAdaptors(DrawablePtr pDrawable)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen = pDrawable->pScreen;
|
|
|
|
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
|
|
|
|
XvAdaptorPtr pa = pxvs->pAdaptors;
|
|
|
|
int na = pxvs->nAdaptors;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
/* CHECK TO SEE IF THIS PORT IS IN USE */
|
|
|
|
while (na--) {
|
2016-05-29 06:02:34 -06:00
|
|
|
XvPortPtr pp = pa->pPorts;
|
|
|
|
int np = pa->nPorts;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
while (np--) {
|
2016-05-29 06:02:34 -06:00
|
|
|
if (pp->pDraw == pDrawable) {
|
|
|
|
XvdiSendVideoNotify(pp, pDrawable, XvPreempted);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
(void) (*pp->pAdaptor->ddStopVideo) (pp, pDrawable);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
pp->pDraw = NULL;
|
|
|
|
pp->client = NULL;
|
|
|
|
pp->time = currentTime;
|
|
|
|
}
|
|
|
|
pp++;
|
|
|
|
}
|
|
|
|
pa++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static Bool
|
|
|
|
XvDestroyPixmap(PixmapPtr pPix)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pPix->drawable.pScreen;
|
|
|
|
Bool status;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (pPix->refcnt == 1)
|
|
|
|
XvStopAdaptors(&pPix->drawable);
|
|
|
|
|
|
|
|
SCREEN_PROLOGUE(pScreen, DestroyPixmap);
|
|
|
|
status = (*pScreen->DestroyPixmap) (pPix);
|
2012-06-10 07:21:05 -06:00
|
|
|
SCREEN_EPILOGUE(pScreen, DestroyPixmap, XvDestroyPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
XvDestroyWindow(WindowPtr pWin)
|
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool status;
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
XvStopAdaptors(&pWin->drawable);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
SCREEN_PROLOGUE(pScreen, DestroyWindow);
|
|
|
|
status = (*pScreen->DestroyWindow) (pWin);
|
|
|
|
SCREEN_EPILOGUE(pScreen, DestroyWindow, XvDestroyWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
XvdiDestroyPort(void *pPort, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2015-09-16 13:10:19 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
XvdiDestroyGrab(void *pGrab, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
((XvGrabPtr) pGrab)->client = NULL;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
XvdiDestroyVideoNotify(void *pn, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
/* JUST CLEAR OUT THE client POINTER FIELD */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
((XvVideoNotifyPtr) pn)->client = NULL;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
XvdiDestroyPortNotify(void *pn, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
/* JUST CLEAR OUT THE client POINTER FIELD */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
((XvPortNotifyPtr) pn)->client = NULL;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
XvdiDestroyVideoNotifyList(void *pn, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvVideoNotifyPtr npn, cpn;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* ACTUALLY DESTROY THE NOTITY LIST */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
cpn = (XvVideoNotifyPtr) pn;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (cpn) {
|
|
|
|
npn = cpn->next;
|
|
|
|
if (cpn->client)
|
|
|
|
FreeResource(cpn->id, XvRTVideoNotify);
|
|
|
|
free(cpn);
|
|
|
|
cpn = npn;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
XvdiDestroyEncoding(void *value, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvVideoNotifyPtr pn;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pn, pDraw->id, XvRTVideoNotifyList,
|
2012-06-10 07:21:05 -06:00
|
|
|
serverClient, DixReadAccess);
|
|
|
|
|
|
|
|
while (pn) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xvEvent event = {
|
|
|
|
.u.videoNotify.reason = reason,
|
|
|
|
.u.videoNotify.time = currentTime.milliseconds,
|
|
|
|
.u.videoNotify.drawable = pDraw->id,
|
|
|
|
.u.videoNotify.port = pPort->id
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.u.type = XvEventBase + XvVideoNotify;
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
|
2012-06-10 07:21:05 -06:00
|
|
|
pn = pn->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiSendPortNotify(XvPortPtr pPort, Atom attribute, INT32 value)
|
|
|
|
{
|
|
|
|
XvPortNotifyPtr pn;
|
|
|
|
|
|
|
|
pn = pPort->pNotify;
|
|
|
|
|
|
|
|
while (pn) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xvEvent event = {
|
|
|
|
.u.portNotify.time = currentTime.milliseconds,
|
|
|
|
.u.portNotify.port = pPort->id,
|
|
|
|
.u.portNotify.attribute = attribute,
|
|
|
|
.u.portNotify.value = value
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.u.type = XvEventBase + XvPortNotify;
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
|
2012-06-10 07:21:05 -06:00
|
|
|
pn = pn->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK_SIZE(dw, dh, sw, sh) { \
|
|
|
|
if(!dw || !dh || !sw || !sh) return Success; \
|
|
|
|
/* The region code will break these if they are too large */ \
|
|
|
|
if((dw > 32767) || (dh > 32767) || (sw > 32767) || (sh > 32767)) \
|
|
|
|
return BadValue; \
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiPutVideo(ClientPtr client,
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
XvPortPtr pPort,
|
|
|
|
GCPtr pGC,
|
|
|
|
INT16 vid_x, INT16 vid_y,
|
|
|
|
CARD16 vid_w, CARD16 vid_h,
|
|
|
|
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
|
|
|
|
{
|
|
|
|
DrawablePtr pOldDraw;
|
|
|
|
|
|
|
|
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
|
|
|
|
|
|
|
|
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
|
|
|
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
|
|
|
|
INFORM CLIENT OF ITS FAILURE */
|
|
|
|
|
|
|
|
if (pPort->grab.client && (pPort->grab.client != client)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* CHECK TO SEE IF PORT IS IN USE; IF SO THEN WE MUST DELIVER INTERRUPTED
|
|
|
|
EVENTS TO ANY CLIENTS WHO WANT THEM */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pOldDraw = pPort->pDraw;
|
|
|
|
if ((pOldDraw) && (pOldDraw != pDraw)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
(void) (*pPort->pAdaptor->ddPutVideo) (pDraw, pPort, pGC,
|
2012-06-10 07:21:05 -06:00
|
|
|
vid_x, vid_y, vid_w, vid_h,
|
|
|
|
drw_x, drw_y, drw_w, drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pPort->pDraw) && (pOldDraw != pDraw)) {
|
|
|
|
pPort->client = client;
|
|
|
|
XvdiSendVideoNotify(pPort, pPort->pDraw, XvStarted);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiPutStill(ClientPtr client,
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
XvPortPtr pPort,
|
|
|
|
GCPtr pGC,
|
|
|
|
INT16 vid_x, INT16 vid_y,
|
|
|
|
CARD16 vid_w, CARD16 vid_h,
|
|
|
|
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
|
|
|
|
|
|
|
|
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
|
|
|
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
|
|
|
|
INFORM CLIENT OF ITS FAILURE */
|
|
|
|
|
|
|
|
if (pPort->grab.client && (pPort->grab.client != client)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
status = (*pPort->pAdaptor->ddPutStill) (pDraw, pPort, pGC,
|
2012-06-10 07:21:05 -06:00
|
|
|
vid_x, vid_y, vid_w, vid_h,
|
|
|
|
drw_x, drw_y, drw_w, drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiPutImage(ClientPtr client,
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
XvPortPtr pPort,
|
|
|
|
GCPtr pGC,
|
|
|
|
INT16 src_x, INT16 src_y,
|
|
|
|
CARD16 src_w, CARD16 src_h,
|
|
|
|
INT16 drw_x, INT16 drw_y,
|
|
|
|
CARD16 drw_w, CARD16 drw_h,
|
|
|
|
XvImagePtr image,
|
|
|
|
unsigned char *data, Bool sync, CARD16 width, CARD16 height)
|
|
|
|
{
|
|
|
|
CHECK_SIZE(drw_w, drw_h, src_w, src_h);
|
|
|
|
|
|
|
|
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
|
|
|
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
|
|
|
|
INFORM CLIENT OF ITS FAILURE */
|
|
|
|
|
|
|
|
if (pPort->grab.client && (pPort->grab.client != client)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
return (*pPort->pAdaptor->ddPutImage) (pDraw, pPort, pGC,
|
2012-06-10 07:21:05 -06:00
|
|
|
src_x, src_y, src_w, src_h,
|
|
|
|
drw_x, drw_y, drw_w, drw_h,
|
|
|
|
image, data, sync, width, height);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiGetVideo(ClientPtr client,
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
XvPortPtr pPort,
|
|
|
|
GCPtr pGC,
|
|
|
|
INT16 vid_x, INT16 vid_y,
|
|
|
|
CARD16 vid_w, CARD16 vid_h,
|
|
|
|
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
|
|
|
|
{
|
|
|
|
DrawablePtr pOldDraw;
|
|
|
|
|
|
|
|
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
|
|
|
|
|
|
|
|
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
|
|
|
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
|
|
|
|
INFORM CLIENT OF ITS FAILURE */
|
|
|
|
|
|
|
|
if (pPort->grab.client && (pPort->grab.client != client)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* CHECK TO SEE IF PORT IS IN USE; IF SO THEN WE MUST DELIVER INTERRUPTED
|
|
|
|
EVENTS TO ANY CLIENTS WHO WANT THEM */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pOldDraw = pPort->pDraw;
|
|
|
|
if ((pOldDraw) && (pOldDraw != pDraw)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
(void) (*pPort->pAdaptor->ddGetVideo) (pDraw, pPort, pGC,
|
2012-06-10 07:21:05 -06:00
|
|
|
vid_x, vid_y, vid_w, vid_h,
|
|
|
|
drw_x, drw_y, drw_w, drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pPort->pDraw) && (pOldDraw != pDraw)) {
|
|
|
|
pPort->client = client;
|
|
|
|
XvdiSendVideoNotify(pPort, pPort->pDraw, XvStarted);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiGetStill(ClientPtr client,
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
XvPortPtr pPort,
|
|
|
|
GCPtr pGC,
|
|
|
|
INT16 vid_x, INT16 vid_y,
|
|
|
|
CARD16 vid_w, CARD16 vid_h,
|
|
|
|
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
|
|
|
|
|
|
|
|
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
|
|
|
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
|
|
|
|
INFORM CLIENT OF ITS FAILURE */
|
|
|
|
|
|
|
|
if (pPort->grab.client && (pPort->grab.client != client)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
status = (*pPort->pAdaptor->ddGetStill) (pDraw, pPort, pGC,
|
2012-06-10 07:21:05 -06:00
|
|
|
vid_x, vid_y, vid_w, vid_h,
|
|
|
|
drw_x, drw_y, drw_w, drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiGrabPort(ClientPtr client, XvPortPtr pPort, Time ctime, int *p_result)
|
|
|
|
{
|
|
|
|
unsigned long id;
|
|
|
|
TimeStamp time;
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
time = ClientTimeToServerTime(ctime);
|
|
|
|
|
|
|
|
if (pPort->grab.client && (client != pPort->grab.client)) {
|
|
|
|
*p_result = XvAlreadyGrabbed;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((CompareTimeStamps(time, currentTime) == LATER) ||
|
|
|
|
(CompareTimeStamps(time, pPort->time) == EARLIER)) {
|
|
|
|
*p_result = XvInvalidTime;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client == pPort->grab.client) {
|
|
|
|
*p_result = Success;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
id = FakeClientID(client->index);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!AddResource(id, XvRTGrab, &pPort->grab)) {
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* IF THERE IS ACTIVE VIDEO THEN STOP IT */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pPort->pDraw) && (client != pPort->client)) {
|
|
|
|
XvdiStopVideo(NULL, pPort, pPort->pDraw);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->grab.client = client;
|
|
|
|
pPort->grab.id = id;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
*p_result = Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiUngrabPort(ClientPtr client, XvPortPtr pPort, Time ctime)
|
|
|
|
{
|
|
|
|
TimeStamp time;
|
|
|
|
|
|
|
|
UpdateCurrentTime();
|
|
|
|
time = ClientTimeToServerTime(ctime);
|
|
|
|
|
|
|
|
if ((!pPort->grab.client) || (client != pPort->grab.client)) {
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((CompareTimeStamps(time, currentTime) == LATER) ||
|
|
|
|
(CompareTimeStamps(time, pPort->time) == EARLIER)) {
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* FREE THE GRAB RESOURCE; AND SET THE GRAB CLIENT TO NULL */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResource(pPort->grab.id, XvRTGrab);
|
|
|
|
pPort->grab.client = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
|
|
|
|
{
|
|
|
|
XvVideoNotifyPtr pn, tpn, fpn;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* FIND VideoNotify LIST */
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pn, pDraw->id,
|
2012-06-10 07:21:05 -06:00
|
|
|
XvRTVideoNotifyList, client, DixWriteAccess);
|
|
|
|
if (rc != Success && rc != BadValue)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* IF ONE DONES'T EXIST AND NO MASK, THEN JUST RETURN */
|
|
|
|
|
|
|
|
if (!onoff && !pn)
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
/* IF ONE DOESN'T EXIST CREATE IT AND ADD A RESOURCE SO THAT THE LIST
|
|
|
|
WILL BE DELETED WHEN THE DRAWABLE IS DESTROYED */
|
|
|
|
|
|
|
|
if (!pn) {
|
|
|
|
if (!(tpn = malloc(sizeof(XvVideoNotifyRec))))
|
|
|
|
return BadAlloc;
|
|
|
|
tpn->next = NULL;
|
2016-05-29 06:02:34 -06:00
|
|
|
tpn->client = NULL;
|
|
|
|
if (!AddResource(pDraw->id, XvRTVideoNotifyList, tpn))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
/* LOOK TO SEE IF ENTRY ALREADY EXISTS */
|
|
|
|
|
|
|
|
fpn = NULL;
|
|
|
|
tpn = pn;
|
|
|
|
while (tpn) {
|
|
|
|
if (tpn->client == client) {
|
|
|
|
if (!onoff)
|
|
|
|
tpn->client = NULL;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
if (!tpn->client)
|
|
|
|
fpn = tpn; /* TAKE NOTE OF FREE ENTRY */
|
|
|
|
tpn = tpn->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IF TUNNING OFF, THEN JUST RETURN */
|
|
|
|
|
|
|
|
if (!onoff)
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
/* IF ONE ISN'T FOUND THEN ALLOCATE ONE AND LINK IT INTO THE LIST */
|
|
|
|
|
|
|
|
if (fpn) {
|
|
|
|
tpn = fpn;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!(tpn = malloc(sizeof(XvVideoNotifyRec))))
|
|
|
|
return BadAlloc;
|
|
|
|
tpn->next = pn->next;
|
|
|
|
pn->next = tpn;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* INIT CLIENT PTR IN CASE WE CAN'T ADD RESOURCE */
|
|
|
|
/* ADD RESOURCE SO THAT IF CLIENT EXITS THE CLIENT PTR WILL BE CLEARED */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
tpn->client = NULL;
|
|
|
|
tpn->id = FakeClientID(client->index);
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!AddResource(tpn->id, XvRTVideoNotify, tpn))
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
tpn->client = client;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiSelectPortNotify(ClientPtr client, XvPortPtr pPort, BOOL onoff)
|
|
|
|
{
|
|
|
|
XvPortNotifyPtr pn, tpn;
|
|
|
|
|
|
|
|
/* SEE IF CLIENT IS ALREADY IN LIST */
|
|
|
|
|
|
|
|
tpn = NULL;
|
|
|
|
pn = pPort->pNotify;
|
|
|
|
while (pn) {
|
|
|
|
if (!pn->client)
|
|
|
|
tpn = pn; /* TAKE NOTE OF FREE ENTRY */
|
|
|
|
if (pn->client == client)
|
|
|
|
break;
|
|
|
|
pn = pn->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* IS THE CLIENT ALREADY ON THE LIST? */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pn) {
|
|
|
|
/* REMOVE IT? */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!onoff) {
|
|
|
|
pn->client = NULL;
|
|
|
|
FreeResource(pn->id, XvRTPortNotify);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
/* DIDN'T FIND IT; SO REUSE LIST ELEMENT IF ONE IS FREE OTHERWISE
|
2012-06-10 07:21:05 -06:00
|
|
|
CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!tpn) {
|
|
|
|
if (!(tpn = malloc(sizeof(XvPortNotifyRec))))
|
|
|
|
return BadAlloc;
|
|
|
|
tpn->next = pPort->pNotify;
|
|
|
|
pPort->pNotify = tpn;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
tpn->client = client;
|
|
|
|
tpn->id = FakeClientID(client->index);
|
2016-05-29 06:02:34 -06:00
|
|
|
if (!AddResource(tpn->id, XvRTPortNotify, tpn))
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
/* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
|
|
|
|
|
|
|
|
if (!pPort->pDraw || (pPort->pDraw != pDraw)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvStopped);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
|
|
|
|
INFORM CLIENT OF ITS FAILURE */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((client) && (pPort->grab.client) && (pPort->grab.client != client)) {
|
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiSendVideoNotify(pPort, pDraw, XvStopped);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
status = (*pPort->pAdaptor->ddStopVideo) (pPort, pDraw);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->pDraw = NULL;
|
|
|
|
pPort->client = (ClientPtr) client;
|
|
|
|
pPort->time = currentTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiMatchPort(XvPortPtr pPort, DrawablePtr pDraw)
|
|
|
|
{
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvAdaptorPtr pa;
|
|
|
|
XvFormatPtr pf;
|
|
|
|
int nf;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pa = pPort->pAdaptor;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pa->pScreen != pDraw->pScreen)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
nf = pa->nFormats;
|
|
|
|
pf = pa->pFormats;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (nf--) {
|
|
|
|
if (pf->depth == pDraw->depth)
|
|
|
|
return Success;
|
|
|
|
pf++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiSetPortAttribute(ClientPtr client,
|
|
|
|
XvPortPtr pPort, Atom attribute, INT32 value)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status =
|
2015-09-16 13:10:19 -06:00
|
|
|
(*pPort->pAdaptor->ddSetPortAttribute) (pPort, attribute,
|
2012-06-10 07:21:05 -06:00
|
|
|
value);
|
|
|
|
if (status == Success)
|
|
|
|
XvdiSendPortNotify(pPort, attribute, value);
|
|
|
|
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiGetPortAttribute(ClientPtr client,
|
|
|
|
XvPortPtr pPort, Atom attribute, INT32 *p_value)
|
|
|
|
{
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return
|
2015-09-16 13:10:19 -06:00
|
|
|
(*pPort->pAdaptor->ddGetPortAttribute) (pPort, attribute,
|
2012-06-10 07:21:05 -06:00
|
|
|
p_value);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteSwappedVideoNotifyEvent(xvEvent * from, xvEvent * to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
to->u.u.type = from->u.u.type;
|
|
|
|
to->u.u.detail = from->u.u.detail;
|
|
|
|
cpswaps(from->u.videoNotify.sequenceNumber,
|
|
|
|
to->u.videoNotify.sequenceNumber);
|
|
|
|
cpswapl(from->u.videoNotify.time, to->u.videoNotify.time);
|
|
|
|
cpswapl(from->u.videoNotify.drawable, to->u.videoNotify.drawable);
|
|
|
|
cpswapl(from->u.videoNotify.port, to->u.videoNotify.port);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteSwappedPortNotifyEvent(xvEvent * from, xvEvent * to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
to->u.u.type = from->u.u.type;
|
|
|
|
to->u.u.detail = from->u.u.detail;
|
|
|
|
cpswaps(from->u.portNotify.sequenceNumber, to->u.portNotify.sequenceNumber);
|
|
|
|
cpswapl(from->u.portNotify.time, to->u.portNotify.time);
|
|
|
|
cpswapl(from->u.portNotify.port, to->u.portNotify.port);
|
|
|
|
cpswapl(from->u.portNotify.value, to->u.portNotify.value);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
2015-09-16 13:10:19 -06:00
|
|
|
|
|
|
|
void
|
|
|
|
XvFreeAdaptor(XvAdaptorPtr pAdaptor)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
free(pAdaptor->name);
|
|
|
|
pAdaptor->name = NULL;
|
|
|
|
|
|
|
|
if (pAdaptor->pEncodings) {
|
|
|
|
XvEncodingPtr pEncode = pAdaptor->pEncodings;
|
|
|
|
|
|
|
|
for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
|
|
|
|
free(pEncode->name);
|
|
|
|
free(pAdaptor->pEncodings);
|
|
|
|
pAdaptor->pEncodings = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pAdaptor->pFormats);
|
|
|
|
pAdaptor->pFormats = NULL;
|
|
|
|
|
|
|
|
free(pAdaptor->pPorts);
|
|
|
|
pAdaptor->pPorts = NULL;
|
|
|
|
|
|
|
|
if (pAdaptor->pAttributes) {
|
|
|
|
XvAttributePtr pAttribute = pAdaptor->pAttributes;
|
|
|
|
|
|
|
|
for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
|
|
|
|
free(pAttribute->name);
|
|
|
|
free(pAdaptor->pAttributes);
|
|
|
|
pAdaptor->pAttributes = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pAdaptor->pImages);
|
|
|
|
pAdaptor->pImages = NULL;
|
|
|
|
|
|
|
|
free(pAdaptor->devPriv.ptr);
|
|
|
|
pAdaptor->devPriv.ptr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
ChangeGCVal pval[2];
|
|
|
|
BoxPtr pbox = RegionRects(region);
|
|
|
|
int i, nbox = RegionNumRects(region);
|
|
|
|
xRectangle *rects;
|
|
|
|
GCPtr gc;
|
|
|
|
|
|
|
|
gc = GetScratchGC(pDraw->depth, pScreen);
|
|
|
|
if (!gc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pval[0].val = key;
|
|
|
|
pval[1].val = IncludeInferiors;
|
|
|
|
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
|
|
|
|
ValidateGC(pDraw, gc);
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
rects = xallocarray(nbox, sizeof(xRectangle));
|
2015-09-16 13:10:19 -06:00
|
|
|
if (rects) {
|
|
|
|
for (i = 0; i < nbox; i++, pbox++) {
|
|
|
|
rects[i].x = pbox->x1 - pDraw->x;
|
|
|
|
rects[i].y = pbox->y1 - pDraw->y;
|
|
|
|
rects[i].width = pbox->x2 - pbox->x1;
|
|
|
|
rects[i].height = pbox->y2 - pbox->y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
|
|
|
|
|
|
|
|
free(rects);
|
|
|
|
}
|
|
|
|
FreeScratchGC(gc);
|
|
|
|
}
|