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
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the names of Digital or MIT not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** File:
|
|
|
|
**
|
|
|
|
** xvmain.c --- Xv server extension main device independent module.
|
|
|
|
**
|
|
|
|
** Author:
|
|
|
|
**
|
|
|
|
** 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
|
|
|
|
**
|
|
|
|
** 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"
|
|
|
|
#include "gc.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#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);
|
|
|
|
|
|
|
|
static Bool XvCloseScreen(int, ScreenPtr);
|
|
|
|
static Bool XvDestroyPixmap(PixmapPtr);
|
|
|
|
static Bool XvDestroyWindow(WindowPtr);
|
2012-06-10 07:21:05 -06:00
|
|
|
static void XvResetProc(ExtensionEntry *);
|
2006-11-26 11:13:41 -07:00
|
|
|
static int XvdiDestroyGrab(pointer, XID);
|
|
|
|
static int XvdiDestroyEncoding(pointer, XID);
|
|
|
|
static int XvdiDestroyVideoNotify(pointer, XID);
|
|
|
|
static int XvdiDestroyPortNotify(pointer, XID);
|
|
|
|
static int XvdiDestroyVideoNotifyList(pointer, XID);
|
|
|
|
static int XvdiDestroyPort(pointer, XID);
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* LOOK TO SEE IF ANY SCREENS WERE INITIALIZED; IF NOT THEN
|
|
|
|
INIT GLOBAL VARIABLES SO THE EXTENSION CAN FUNCTION */
|
|
|
|
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
|
2012-06-10 07:21:05 -06:00
|
|
|
XvCloseScreen(int ii, ScreenPtr pScreen)
|
|
|
|
{
|
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
|
|
|
(*pxvs->ddCloseScreen) (ii, pScreen);
|
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
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*pScreen->CloseScreen) (ii, 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
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
XvDestroyPixmap(PixmapPtr pPix)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool status;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
XvScreenPtr pxvs;
|
|
|
|
XvAdaptorPtr pa;
|
|
|
|
int na;
|
|
|
|
XvPortPtr pp;
|
|
|
|
int np;
|
|
|
|
|
|
|
|
pScreen = pPix->drawable.pScreen;
|
|
|
|
|
|
|
|
SCREEN_PROLOGUE(pScreen, DestroyPixmap);
|
|
|
|
|
|
|
|
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
|
|
|
|
|
|
|
|
/* CHECK TO SEE IF THIS PORT IS IN USE */
|
|
|
|
|
|
|
|
pa = pxvs->pAdaptors;
|
|
|
|
na = pxvs->nAdaptors;
|
|
|
|
while (na--) {
|
|
|
|
np = pa->nPorts;
|
|
|
|
pp = pa->pPorts;
|
|
|
|
|
|
|
|
while (np--) {
|
|
|
|
if (pp->pDraw == (DrawablePtr) pPix) {
|
|
|
|
XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted);
|
|
|
|
|
|
|
|
(void) (*pp->pAdaptor->ddStopVideo) (NULL, pp, pp->pDraw);
|
|
|
|
|
|
|
|
pp->pDraw = NULL;
|
|
|
|
pp->client = NULL;
|
|
|
|
pp->time = currentTime;
|
|
|
|
}
|
|
|
|
pp++;
|
|
|
|
}
|
|
|
|
pa++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = (*pScreen->DestroyPixmap) (pPix);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool status;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
XvScreenPtr pxvs;
|
|
|
|
XvAdaptorPtr pa;
|
|
|
|
int na;
|
|
|
|
XvPortPtr pp;
|
|
|
|
int np;
|
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
|
|
|
|
SCREEN_PROLOGUE(pScreen, DestroyWindow);
|
|
|
|
|
|
|
|
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
|
|
|
|
|
|
|
|
/* CHECK TO SEE IF THIS PORT IS IN USE */
|
|
|
|
|
|
|
|
pa = pxvs->pAdaptors;
|
|
|
|
na = pxvs->nAdaptors;
|
|
|
|
while (na--) {
|
|
|
|
np = pa->nPorts;
|
|
|
|
pp = pa->pPorts;
|
|
|
|
|
|
|
|
while (np--) {
|
|
|
|
if (pp->pDraw == (DrawablePtr) pWin) {
|
|
|
|
XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted);
|
|
|
|
|
|
|
|
(void) (*pp->pAdaptor->ddStopVideo) (NULL, pp, pp->pDraw);
|
|
|
|
|
|
|
|
pp->pDraw = NULL;
|
|
|
|
pp->client = NULL;
|
|
|
|
pp->time = currentTime;
|
|
|
|
}
|
|
|
|
pp++;
|
|
|
|
}
|
|
|
|
pa++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = (*pScreen->DestroyWindow) (pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The XvdiVideoStopped procedure is a hook for the device dependent layer.
|
|
|
|
It provides a way for the dd layer to inform the di layer that video has
|
|
|
|
stopped in a port for reasons that the di layer had no control over; note
|
|
|
|
that it doesn't call back into the dd layer */
|
|
|
|
|
|
|
|
int
|
|
|
|
XvdiVideoStopped(XvPortPtr pPort, int reason)
|
|
|
|
{
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pPort->pDraw)
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiSendVideoNotify(pPort, pPort->pDraw, reason);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPort->pDraw = NULL;
|
|
|
|
pPort->client = NULL;
|
|
|
|
pPort->time = currentTime;
|
|
|
|
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
XvdiDestroyPort(pointer pPort, XID id)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*((XvPortPtr) pPort)->pAdaptor->ddFreePort) (pPort);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
XvdiDestroyGrab(pointer pGrab, XID id)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
((XvGrabPtr) pGrab)->client = NULL;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
XvdiDestroyVideoNotify(pointer pn, XID id)
|
|
|
|
{
|
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
|
|
|
|
XvdiDestroyPortNotify(pointer pn, XID id)
|
|
|
|
{
|
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
|
|
|
|
XvdiDestroyVideoNotifyList(pointer pn, XID id)
|
|
|
|
{
|
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
|
|
|
|
XvdiDestroyEncoding(pointer value, XID id)
|
|
|
|
{
|
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
|
|
|
xvEvent event;
|
|
|
|
XvVideoNotifyPtr pn;
|
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pn, pDraw->id, XvRTVideoNotifyList,
|
|
|
|
serverClient, DixReadAccess);
|
|
|
|
|
|
|
|
while (pn) {
|
|
|
|
event.u.u.type = XvEventBase + XvVideoNotify;
|
|
|
|
event.u.videoNotify.time = currentTime.milliseconds;
|
|
|
|
event.u.videoNotify.drawable = pDraw->id;
|
|
|
|
event.u.videoNotify.port = pPort->id;
|
|
|
|
event.u.videoNotify.reason = reason;
|
|
|
|
WriteEventsToClient(pn->client, 1, (xEventPtr) & event);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
xvEvent event;
|
|
|
|
XvPortNotifyPtr pn;
|
|
|
|
|
|
|
|
pn = pPort->pNotify;
|
|
|
|
|
|
|
|
while (pn) {
|
|
|
|
event.u.u.type = XvEventBase + XvPortNotify;
|
|
|
|
event.u.portNotify.time = currentTime.milliseconds;
|
|
|
|
event.u.portNotify.port = pPort->id;
|
|
|
|
event.u.portNotify.attribute = attribute;
|
|
|
|
event.u.portNotify.value = value;
|
|
|
|
WriteEventsToClient(pn->client, 1, (xEventPtr) & event);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) (*pPort->pAdaptor->ddPutVideo) (client, pDraw, pPort, pGC,
|
|
|
|
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
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = (*pPort->pAdaptor->ddPutStill) (client, pDraw, pPort, pGC,
|
|
|
|
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
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*pPort->pAdaptor->ddPutImage) (client, pDraw, pPort, pGC,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) (*pPort->pAdaptor->ddGetVideo) (client, pDraw, pPort, pGC,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = (*pPort->pAdaptor->ddGetStill) (client, pDraw, pPort, pGC,
|
|
|
|
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 */
|
|
|
|
|
|
|
|
rc = dixLookupResourceByType((pointer *) &pn, pDraw->id,
|
|
|
|
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;
|
|
|
|
if (!AddResource(pDraw->id, XvRTVideoNotifyList, tpn)) {
|
|
|
|
free(tpn);
|
|
|
|
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);
|
|
|
|
AddResource(tpn->id, XvRTVideoNotify, tpn);
|
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
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* DIDN'T FIND IT; SO REUSE LIST ELEMENT IF ONE IS FREE OTHERWISE
|
|
|
|
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);
|
|
|
|
AddResource(tpn->id, XvRTPortNotify, tpn);
|
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
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = (*pPort->pAdaptor->ddStopVideo) (client, 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
|
|
|
XvdiPreemptVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
int status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pPort->pDraw || (pPort->pDraw != pDraw))
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = (*pPort->pAdaptor->ddStopVideo) (client, pPort, 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 =
|
|
|
|
(*pPort->pAdaptor->ddSetPortAttribute) (client, pPort, attribute,
|
|
|
|
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
|
|
|
|
(*pPort->pAdaptor->ddGetPortAttribute) (client, pPort, attribute,
|
|
|
|
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
|
|
|
|
|
|
|
}
|