当前位置: 首页>>代码示例>>C++>>正文


C++ TRACE函数代码示例

本文整理汇总了C++中TRACE函数的典型用法代码示例。如果您正苦于以下问题:C++ TRACE函数的具体用法?C++ TRACE怎么用?C++ TRACE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TRACE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PSPropertyKeyFromString

HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
{
    BOOL has_minus = FALSE, has_comma = FALSE;

    TRACE("(%s, %p)\n", debugstr_w(pszString), pkey);

    if (!pszString || !pkey)
        return E_POINTER;

    memset(pkey, 0, sizeof(PROPERTYKEY));

    if (!string_to_guid(pszString, &pkey->fmtid))
        return E_INVALIDARG;

    pszString += GUIDSTRING_MAX - 1;

    if (!*pszString)
        return E_INVALIDARG;

    /* Only the space seems to be recognized as whitespace. The comma is only
     * recognized once and processing terminates if another comma is found. */
    while (*pszString == ' ' || *pszString == ',')
    {
        if (*pszString == ',')
        {
            if (has_comma)
                return S_OK;
            else
                has_comma = TRUE;
        }
        pszString++;
    }

    if (!*pszString)
        return E_INVALIDARG;

    /* Only two minus signs are recognized if no comma is detected. The first
     * sign is ignored, and the second is interpreted. If a comma is detected
     * before the minus sign, then only one minus sign counts, and property ID
     * interpretation begins with the next character. */
    if (has_comma)
    {
        if (*pszString == '-')
        {
            has_minus = TRUE;
            pszString++;
        }
    }
    else
    {
        if (*pszString == '-')
            pszString++;

        /* Skip any intermediate spaces after the first minus sign. */
        while (*pszString == ' ')
            pszString++;

        if (*pszString == '-')
        {
            has_minus = TRUE;
            pszString++;
        }

        /* Skip any remaining spaces after minus sign. */
        while (*pszString == ' ')
            pszString++;
    }

    /* Overflow is not checked. */
    while (isdigitW(*pszString))
    {
        pkey->pid *= 10;
        pkey->pid += (*pszString - '0');
        pszString++;
    }

    if (has_minus)
        pkey->pid = ~pkey->pid + 1;

    return S_OK;
}
开发者ID:DeltaYang,项目名称:wine,代码行数:81,代码来源:propsys_main.c

示例2: init

/* Module initialization/finalization handlers */
static int __init init(void)
{
    int rcVBox;
    int rcRet = 0;
    int err;

    TRACE();

    if (sizeof(struct vbsf_mount_info_new) > PAGE_SIZE)
    {
        printk(KERN_ERR
                "Mount information structure is too large %lu\n"
                "Must be less than or equal to %lu\n",
                (unsigned long)sizeof (struct vbsf_mount_info_new),
                (unsigned long)PAGE_SIZE);
        return -EINVAL;
    }

    err = register_filesystem(&vboxsf_fs_type);
    if (err)
    {
        LogFunc(("register_filesystem err=%d\n", err));
        return err;
    }

    rcVBox = VbglR0SfInit();
    if (RT_FAILURE(rcVBox))
    {
        LogRelFunc(("VbglR0SfInit failed, rc=%d\n", rcVBox));
        rcRet = -EPROTO;
        goto fail0;
    }

    rcVBox = VbglR0SfConnect(&client_handle);
    if (RT_FAILURE(rcVBox))
    {
        LogRelFunc(("VbglR0SfConnect failed, rc=%d\n", rcVBox));
        rcRet = -EPROTO;
        goto fail1;
    }

    rcVBox = VbglR0SfSetUtf8(&client_handle);
    if (RT_FAILURE(rcVBox))
    {
        LogRelFunc(("VbglR0SfSetUtf8 failed, rc=%d\n", rcVBox));
        rcRet = -EPROTO;
        goto fail2;
    }

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    if (!follow_symlinks)
    {
        rcVBox = VbglR0SfSetSymlinks(&client_handle);
        if (RT_FAILURE(rcVBox))
        {
            printk(KERN_WARNING
                     "vboxsf: Host unable to show symlinks, rc=%d\n",
                     rcVBox);
        }
    }
#endif

    printk(KERN_DEBUG
            "vboxsf: Successfully loaded version " VBOX_VERSION_STRING
            " (interface " RT_XSTR(VMMDEV_VERSION) ")\n");

    return 0;

fail2:
    VbglR0SfDisconnect(&client_handle);

fail1:
    VbglR0SfTerm();

fail0:
    unregister_filesystem(&vboxsf_fs_type);
    return rcRet;
}
开发者ID:bhanug,项目名称:virtualbox,代码行数:79,代码来源:vfsmod.c

示例3: ClassFactory_Release

static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
{
    TRACE("(%p)\n", iface);
    return 1;
}
开发者ID:DeltaYang,项目名称:wine,代码行数:5,代码来源:propsys_main.c

示例4: evalcommand

STATIC void
evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
{
	struct stackmark smark;
	union node *argp;
	struct arglist arglist;
	struct arglist varlist;
	char **argv;
	int argc;
	char **envp;
	int varflag;
	struct strlist *sp;
	int mode;
	int pip[2];
	struct cmdentry cmdentry;
	struct job *jp;
	struct jmploc jmploc;
	struct jmploc *volatile savehandler;
	char *volatile savecmdname;
	volatile struct shparam saveparam;
	struct localvar *volatile savelocalvars;
	volatile int e;
	char *lastarg;
	const char *path = pathval();
	volatile int temp_path;
#if __GNUC__
	/* Avoid longjmp clobbering */
	(void) &argv;
	(void) &argc;
	(void) &lastarg;
	(void) &flags;
#endif

	vforked = 0;
	/* First expand the arguments. */
	TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
	setstackmark(&smark);
	back_exitstatus = 0;

	arglist.lastp = &arglist.list;
	varflag = 1;
	/* Expand arguments, ignoring the initial 'name=value' ones */
	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
		char *p = argp->narg.text;
		if (varflag && is_name(*p)) {
			do {
				p++;
			} while (is_in_name(*p));
			if (*p == '=')
				continue;
		}
		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
		varflag = 0;
	}
	*arglist.lastp = NULL;

	expredir(cmd->ncmd.redirect);

	/* Now do the initial 'name=value' ones we skipped above */
	varlist.lastp = &varlist.list;
	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
		char *p = argp->narg.text;
		if (!is_name(*p))
			break;
		do
			p++;
		while (is_in_name(*p));
		if (*p != '=')
			break;
		expandarg(argp, &varlist, EXP_VARTILDE);
	}
	*varlist.lastp = NULL;

	argc = 0;
	for (sp = arglist.list ; sp ; sp = sp->next)
		argc++;
	argv = stalloc(sizeof (char *) * (argc + 1));

	for (sp = arglist.list ; sp ; sp = sp->next) {
		TRACE(("evalcommand arg: %s\n", sp->text));
		*argv++ = sp->text;
	}
	*argv = NULL;
	lastarg = NULL;
	if (iflag && funcnest == 0 && argc > 0)
		lastarg = argv[-1];
	argv -= argc;

	/* Print the command if xflag is set. */
	if (xflag) {
		char sep = 0;
		out2str(ps4val());
		for (sp = varlist.list ; sp ; sp = sp->next) {
			if (sep != 0)
				outc(sep, &errout);
			out2str(sp->text);
			sep = ' ';
		}
		for (sp = arglist.list ; sp ; sp = sp->next) {
			if (sep != 0)
//.........这里部分代码省略.........
开发者ID:28vicky,项目名称:android_system_core,代码行数:101,代码来源:eval.c

示例5: ClassFactory_LockServer

static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
{
    TRACE("(%p)->(%x)\n", iface, fLock);

    return S_OK;
}
开发者ID:DeltaYang,项目名称:wine,代码行数:6,代码来源:propsys_main.c

示例6: ACM_GetStream

static PWINE_ACMSTREAM	ACM_GetStream(HACMSTREAM has)
{
    TRACE("(%p)\n", has);

    return (PWINE_ACMSTREAM)has;
}
开发者ID:AndreRH,项目名称:wine,代码行数:6,代码来源:stream.c

示例7: ASSERT

bool CHotlineIcon::LoadItem( CFile* pFile )
	{
	if ( m_pIconData )
		// Déjà chargée
		return true;

	if ( 0 == m_iFileOffset )
		// Offset 0 -> erreur
		return false;

	TRY
		{
		int y;
		struct {
			char awpx[4];
			unsigned __int16 iVersion;
			unsigned __int16 iPad2;
			unsigned __int32 iPad1;
			unsigned __int32 iOne;
			unsigned __int32 iRealWidth;
			unsigned __int32 iHeight;
			unsigned __int32 iWidthBytes;
			unsigned __int32 iB, iC, iD, iDataSize;
			unsigned char iRTrans, iGTrans, iBTrans, iATrans;
			unsigned __int32 iNumColors;
			unsigned __int32 iZero;
			unsigned char iNumBits, iF, iG, iH;
			unsigned __int16 iHasTrans, iZ;
			} IconHeader;

		pFile->Seek( m_iFileOffset, CFile::begin );
		ASSERT( sizeof( IconHeader ) == 64 );
		pFile->Read( &IconHeader, sizeof( IconHeader ) );
		if ( strncmp( IconHeader.awpx, "AWPX", 4 ) != 0 )
			{
			TRACE( "CHotlineDatFile : load icon failed !\n" );
			return false;
			}
		if ( INT16_FROM_BE( IconHeader.iVersion ) != 1 )
			{
			TRACE( "CHotlineDatFile : load icon failed !\n" );
			return false;
			}
		if ( IconHeader.iNumBits != 8 )
			{
			TRACE( "CHotlineDatFile : load icon failed !\n" );
			return false;
			}
		
		IconHeader.iHasTrans = INT16_FROM_BE( IconHeader.iHasTrans );

		m_iNumberColors = INT32_FROM_BE( IconHeader.iNumColors );
		m_iDataWidth = INT32_FROM_BE( IconHeader.iWidthBytes);
		m_iWidth = INT32_FROM_BE( IconHeader.iRealWidth );
		m_iHeight = INT32_FROM_BE( IconHeader.iHeight );

		if ( m_iWidth > 32 )
			{
			m_iIconOffset = m_iWidth / 2 - 17;
			m_iWidth = m_iWidth - m_iIconOffset;
			}

		m_pPalette = new PALETTEENTRY[ m_iNumberColors ];
		pFile->Read( m_pPalette, 4 * m_iNumberColors );

		if ( IconHeader.iHasTrans )
			{
			const unsigned char cRed = IconHeader.iRTrans;
			const unsigned char cGreen = IconHeader.iGTrans;
			const unsigned char cBlue = IconHeader.iBTrans;
			for ( int iColor = 0; iColor < m_iNumberColors; iColor++ )
				{
				if ( ( cRed == m_pPalette[ iColor ].peRed ) &&
					( cGreen == m_pPalette[ iColor ].peGreen ) &&
					( cBlue == m_pPalette[ iColor ].peBlue ) )
					{
					m_iTransparentIndex = iColor;
					break;
					}
				}
			}
	
		m_pIconData = new char*[ m_iHeight ];

		for ( y = 0; y < m_iHeight; y++ )
			{
			m_pIconData[ y ] = new char[ m_iDataWidth ];
			pFile->Read( m_pIconData[ y ], m_iDataWidth );
			}
		}
	CATCH( CFileException, e )
		{
		e->Delete( );
		TRACE( "HotlineDatFile : load icon failed !\n" );
		return false;
		}
开发者ID:Schala,项目名称:AniClient,代码行数:96,代码来源:HotlineIcon.cpp

示例8: TRACE

void QEglGLPixmapData::setHasAlpha(bool val)
{
    TRACE();
    m_hasAlpha = val;
}
开发者ID:RS102839,项目名称:qt,代码行数:5,代码来源:qpixmapdata_egl_p.cpp

示例9: WinLdrScanRegistry

static VOID
WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
                   IN LPCSTR DirectoryPath)
{
    LONG rc = 0;
    HKEY hGroupKey, hOrderKey, hServiceKey, hDriverKey;
    LPWSTR GroupNameBuffer;
    WCHAR ServiceName[256];
    ULONG OrderList[128];
    ULONG BufferSize;
    ULONG Index;
    ULONG TagIndex;
    LPWSTR GroupName;

    ULONG ValueSize;
    ULONG ValueType;
    ULONG StartValue;
    ULONG TagValue;
    WCHAR DriverGroup[256];
    ULONG DriverGroupSize;

    CHAR ImagePath[256];
    WCHAR TempImagePath[256];

    BOOLEAN Success;

    /* get 'service group order' key */
    rc = RegOpenKey(NULL,
        L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
        &hGroupKey);
    if (rc != ERROR_SUCCESS) {

        TRACE_CH(REACTOS, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc);
        return;
    }

    /* get 'group order list' key */
    rc = RegOpenKey(NULL,
        L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
        &hOrderKey);
    if (rc != ERROR_SUCCESS) {

        TRACE_CH(REACTOS, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc);
        return;
    }

    /* enumerate drivers */
    rc = RegOpenKey(NULL,
        L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
        &hServiceKey);
    if (rc != ERROR_SUCCESS)  {

        TRACE_CH(REACTOS, "Failed to open the 'Services' key (rc %d)\n", (int)rc);
        return;
    }

    /* Get the Name Group */
    BufferSize = 4096;
    GroupNameBuffer = FrLdrHeapAlloc(BufferSize, TAG_WLDR_NAME);
    rc = RegQueryValue(hGroupKey, L"List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize);
    TRACE_CH(REACTOS, "RegQueryValue(): rc %d\n", (int)rc);
    if (rc != ERROR_SUCCESS)
        return;
    TRACE_CH(REACTOS, "BufferSize: %d \n", (int)BufferSize);
    TRACE_CH(REACTOS, "GroupNameBuffer: '%S' \n", GroupNameBuffer);

    /* Loop through each group */
    GroupName = GroupNameBuffer;
    while (*GroupName)
    {
        TRACE("Driver group: '%S'\n", GroupName);

        /* Query the Order */
        BufferSize = sizeof(OrderList);
        rc = RegQueryValue(hOrderKey, GroupName, NULL, (PUCHAR)OrderList, &BufferSize);
        if (rc != ERROR_SUCCESS) OrderList[0] = 0;

        /* enumerate all drivers */
        for (TagIndex = 1; TagIndex <= OrderList[0]; TagIndex++)
        {
            Index = 0;

            while (TRUE)
            {
                /* Get the Driver's Name */
                ValueSize = sizeof(ServiceName);
                rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize, &hDriverKey);
                TRACE("RegEnumKey(): rc %d\n", (int)rc);

                /* Make sure it's valid, and check if we're done */
                if (rc == ERROR_NO_MORE_ITEMS)
                    break;
                if (rc != ERROR_SUCCESS)
                {
                    FrLdrHeapFree(GroupNameBuffer, TAG_WLDR_NAME);
                    return;
                }
                //TRACE_CH(REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName);

                /* Read the Start Value */
//.........这里部分代码省略.........
开发者ID:amaneureka,项目名称:reactos,代码行数:101,代码来源:wlregistry.c

示例10: TRACE

void Tapplication::BlankScreen()
{
	TRACE("Blanking screen\n");
	TAP_Osd_FillBox(screenRgn, 0, 0, MAX_SCREEN_X, MAX_SCREEN_Y, COLOR_None);
}
开发者ID:BackupTheBerlios,项目名称:tap-svn,代码行数:5,代码来源:Tapplication.cpp

示例11: WinLdrLoadSystemHive

BOOLEAN
WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
                     IN LPCSTR DirectoryPath,
                     IN LPCSTR HiveName)
{
    ULONG FileId;
    CHAR FullHiveName[256];
    ARC_STATUS Status;
    FILEINFORMATION FileInfo;
    ULONG HiveFileSize;
    ULONG_PTR HiveDataPhysical;
    PVOID HiveDataVirtual;
    ULONG BytesRead;
    LPCWSTR FsService;

    /* Concatenate path and filename to get the full name */
    strcpy(FullHiveName, DirectoryPath);
    strcat(FullHiveName, HiveName);
    //Print(L"Loading %s...\n", FullHiveName);
    Status = ArcOpen(FullHiveName, OpenReadOnly, &FileId);
    if (Status != ESUCCESS)
    {
        UiMessageBox("Opening hive file failed!");
        return FALSE;
    }

    /* Get the file length */
    Status = ArcGetFileInformation(FileId, &FileInfo);
    if (Status != ESUCCESS)
    {
        ArcClose(FileId);
        UiMessageBox("Hive file has 0 size!");
        return FALSE;
    }
    HiveFileSize = FileInfo.EndingAddress.LowPart;

    /* Round up the size to page boundary and alloc memory */
    HiveDataPhysical = (ULONG_PTR)MmAllocateMemoryWithType(
        MM_SIZE_TO_PAGES(HiveFileSize + MM_PAGE_SIZE - 1) << MM_PAGE_SHIFT,
        LoaderRegistryData);

    if (HiveDataPhysical == 0)
    {
        ArcClose(FileId);
        UiMessageBox("Unable to alloc memory for a hive!");
        return FALSE;
    }

    /* Convert address to virtual */
    HiveDataVirtual = PaToVa((PVOID)HiveDataPhysical);

    /* Fill LoaderBlock's entries */
    LoaderBlock->RegistryLength = HiveFileSize;
    LoaderBlock->RegistryBase = HiveDataVirtual;

    /* Finally read from file to the memory */
    Status = ArcRead(FileId, (PVOID)HiveDataPhysical, HiveFileSize, &BytesRead);
    if (Status != ESUCCESS)
    {
        ArcClose(FileId);
        UiMessageBox("Unable to read from hive file!");
        return FALSE;
    }

    // Add boot filesystem driver to the list
    FsService = FsGetServiceName(FileId);
    if (FsService)
    {
        BOOLEAN Success;
        TRACE("  Adding filesystem service %S\n", FsService);
        Success = WinLdrAddDriverToList(&LoaderBlock->BootDriverListHead,
                                        L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\",
                                        NULL,
                                        (LPWSTR)FsService);
        if (!Success)
            TRACE(" Failed to add filesystem service\n");
    }
    else
    {
        TRACE("  No required filesystem service\n");
    }

    ArcClose(FileId);
    return TRUE;
}
开发者ID:amaneureka,项目名称:reactos,代码行数:85,代码来源:wlregistry.c

示例12: WinLdrLoadNLSData

BOOLEAN
WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
                  IN LPCSTR DirectoryPath,
                  IN LPCSTR AnsiFileName,
                  IN LPCSTR OemFileName,
                  IN LPCSTR LanguageFileName)
{
    CHAR FileName[255];
    ULONG AnsiFileId;
    ULONG OemFileId;
    ULONG LanguageFileId;
    ULONG AnsiFileSize, OemFileSize, LanguageFileSize;
    ULONG TotalSize;
    ULONG_PTR NlsDataBase;
    PVOID NlsVirtual;
    BOOLEAN AnsiEqualsOem = FALSE;
    FILEINFORMATION FileInfo;
    ULONG BytesRead;
    ARC_STATUS Status;

    /* There may be a case, when OEM and ANSI page coincide */
    if (!strcmp(AnsiFileName, OemFileName))
        AnsiEqualsOem = TRUE;

    /* Open file with ANSI and store its size */
    //Print(L"Loading %s...\n", Filename);
    strcpy(FileName, DirectoryPath);
    strcat(FileName, AnsiFileName);
    Status = ArcOpen(FileName, OpenReadOnly, &AnsiFileId);
    if (Status != ESUCCESS)
        goto Failure;

    Status = ArcGetFileInformation(AnsiFileId, &FileInfo);
    if (Status != ESUCCESS)
        goto Failure;
    AnsiFileSize = FileInfo.EndingAddress.LowPart;
    TRACE("AnsiFileSize: %d\n", AnsiFileSize);
    ArcClose(AnsiFileId);

    /* Open OEM file and store its length */
    if (AnsiEqualsOem)
    {
        OemFileSize = 0;
    }
    else
    {
        //Print(L"Loading %s...\n", Filename);
        strcpy(FileName, DirectoryPath);
        strcat(FileName, OemFileName);
        Status = ArcOpen(FileName, OpenReadOnly, &OemFileId);
        if (Status != ESUCCESS)
            goto Failure;

        Status = ArcGetFileInformation(OemFileId, &FileInfo);
        if (Status != ESUCCESS)
            goto Failure;
        OemFileSize = FileInfo.EndingAddress.LowPart;
        ArcClose(OemFileId);
    }
    TRACE("OemFileSize: %d\n", OemFileSize);

    /* And finally open the language codepage file and store its length */
    //Print(L"Loading %s...\n", Filename);
    strcpy(FileName, DirectoryPath);
    strcat(FileName, LanguageFileName);
    Status = ArcOpen(FileName, OpenReadOnly, &LanguageFileId);
    if (Status != ESUCCESS)
        goto Failure;

    Status = ArcGetFileInformation(LanguageFileId, &FileInfo);
    if (Status != ESUCCESS)
        goto Failure;
    LanguageFileSize = FileInfo.EndingAddress.LowPart;
    ArcClose(LanguageFileId);
    TRACE("LanguageFileSize: %d\n", LanguageFileSize);

    /* Sum up all three length, having in mind that every one of them
       must start at a page boundary => thus round up each file to a page */
    TotalSize = MM_SIZE_TO_PAGES(AnsiFileSize) +
        MM_SIZE_TO_PAGES(OemFileSize)  +
        MM_SIZE_TO_PAGES(LanguageFileSize);

    /* Store it for later marking the pages as NlsData type */
    TotalNLSSize = TotalSize;

    NlsDataBase = (ULONG_PTR)MmAllocateMemoryWithType(TotalSize*MM_PAGE_SIZE, LoaderNlsData);

    if (NlsDataBase == 0)
        goto Failure;

    NlsVirtual = PaToVa((PVOID)NlsDataBase);
    LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual;
    LoaderBlock->NlsData->OemCodePageData = (PVOID)((PUCHAR)NlsVirtual +
        (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT));
    LoaderBlock->NlsData->UnicodeCodePageData = (PVOID)((PUCHAR)NlsVirtual +
        (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT) +
        (MM_SIZE_TO_PAGES(OemFileSize) << MM_PAGE_SHIFT));

    /* Ansi and OEM data are the same - just set pointers to the same area */
    if (AnsiEqualsOem)
//.........这里部分代码省略.........
开发者ID:amaneureka,项目名称:reactos,代码行数:101,代码来源:wlregistry.c

示例13: cpc5621_open

/**
  Open the device.
  
  At the first time:
  - allocating internal memory for each new device
  - initialize the device
  - set up the interrupt
 
   \return
   0 - if no error,
   otherwise error code
*/
static int cpc5621_open (
    char    *path,      /**< pointer to the device path */
    INT     flags       /**< flag of the open */
)
{
    int result = 0;
    int devNum, chNum;
    CPC5621_DEV *pDev = NULL;
    
    if (Get_Dev_Num(path, &devNum, &chNum) == ERR)
        return -ENODEV;

    /* check the device number */
    if (chNum >= MAX_CHANNEL)
    {
        TRACE(CPC5621_DRV, DBG_LEVEL_HIGH, ("cpc5621_open: max. device number exceed\n"));
        result = -ENODEV;
        goto OPEN_ERROR;
    }
    
    Sem_Lock(CpcSemDrv);

    pDev = CPC5621_Devices[devNum][chNum];

    if (pDev == NULL)
    {
        pDev = (CPC5621_DEV*)Alloc_Mem(sizeof(CPC5621_DEV));
        if (!pDev)
        {
            TRACE(CPC5621_DRV, DBG_LEVEL_HIGH,("cpc5621_open: no memory for device structure.\n"));
            result = -ENOMEM;
            goto OPEN_ERROR;
        }

        memset((char*)pDev, 0, sizeof(CPC5621_DEV));

        /* The device number and channel number should be getted from upper layer */
        if (Drv_CPC5621_Init(pDev, devNum, chNum) == ERR)
        {
            TRACE(CPC5621_DRV, DBG_LEVEL_HIGH,("cpc5621_open: driver init failed!\n"));
            result = -ENOMEM;
            goto OPEN_ERROR;
        }
        
        CPC5621_Devices[devNum][chNum] = pDev;
    }

    if (pDev->bOpen == TRUE)
    {
        TRACE(CPC5621_DRV, DBG_LEVEL_HIGH,("cpc5621_open: already opened!\n"));
        return -EBUSY;
    }

    pDev->bOpen = TRUE;
    pDev->nInUse++;

    /* and use filp->private_data to point to the device data */
    filp->private_data = pDev;
    
    Sem_Unlock(CpcSemDrv);

    return (int)(pDev);

OPEN_ERROR:

    if (pDev != NULL)
    {
        Free_Mem(pDev);
        CPC5621_Devices[devNum][chNum] = NULL;
    }
    
    Sem_Unlock(CpcSemDrv);
    
    return result;
}
开发者ID:pekiZG,项目名称:sx76x-openwrt-danube,代码行数:87,代码来源:drv_cpc5621_noOS.c

示例14: acmStreamOpen

/***********************************************************************
 *           acmStreamOpen ([email protected])
 */
MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had,
                              PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst,
                              PWAVEFILTER pwfltr, DWORD_PTR dwCallback,
                              DWORD_PTR dwInstance, DWORD fdwOpen)
{
    PWINE_ACMSTREAM	was;
    PWINE_ACMDRIVER	wad;
    MMRESULT		ret;
    int			wfxSrcSize;
    int			wfxDstSize;
    WAVEFORMATEX	wfxSrc, wfxDst;

    TRACE("(%p, %p, %p, %p, %p, %ld, %ld, %d)\n",
	  phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);

    /* NOTE: pwfxSrc and/or pwfxDst can point to a structure smaller than
     * WAVEFORMATEX so don't use them directly when not sure */
    if (pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) {
        memcpy(&wfxSrc, pwfxSrc, sizeof(PCMWAVEFORMAT));
        wfxSrc.wBitsPerSample = pwfxSrc->wBitsPerSample;
        wfxSrc.cbSize = 0;
        pwfxSrc = &wfxSrc;
    }

    if (pwfxDst->wFormatTag == WAVE_FORMAT_PCM) {
        memcpy(&wfxDst, pwfxDst, sizeof(PCMWAVEFORMAT));
        wfxDst.wBitsPerSample = pwfxDst->wBitsPerSample;
        wfxDst.cbSize = 0;
        pwfxDst = &wfxDst;
    }

    TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
	  pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec,
	  pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);

    TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
	  pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec,
	  pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);

    /* (WS) In query mode, phas should be NULL. If it is not, then instead
     * of returning an error we are making sure it is NULL, preventing some
     * applications that pass garbage for phas from crashing.
     */
    if (fdwOpen & ACM_STREAMOPENF_QUERY) phas = NULL;

    if (pwfltr && (pwfxSrc->wFormatTag != pwfxDst->wFormatTag)) {
        WARN("invalid parameter\n");
        return MMSYSERR_INVALPARAM;
    }

    wfxSrcSize = wfxDstSize = sizeof(WAVEFORMATEX);
    if (pwfxSrc->wFormatTag != WAVE_FORMAT_PCM) wfxSrcSize += pwfxSrc->cbSize;
    if (pwfxDst->wFormatTag != WAVE_FORMAT_PCM) wfxDstSize += pwfxDst->cbSize;

    was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize +
		    ((pwfltr) ? sizeof(WAVEFILTER) : 0));
    if (was == NULL) {
        WARN("no memory\n");
	return MMSYSERR_NOMEM;
    }

    was->drvInst.cbStruct = sizeof(was->drvInst);
    was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
    memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
    was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize);
    memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
    if (pwfltr) {
	was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
	memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
    } else {
	was->drvInst.pwfltr = NULL;
    }
    was->drvInst.dwCallback = dwCallback;
    was->drvInst.dwInstance = dwInstance;
    was->drvInst.fdwOpen = fdwOpen;
    was->drvInst.fdwDriver = 0L;
    was->drvInst.dwDriver = 0L;
    /* real value will be stored once ACMDM_STREAM_OPEN succeeds */
    was->drvInst.has = 0L;

    if (had) {
	if (!(wad = MSACM_GetDriver(had))) {
	    ret = MMSYSERR_INVALPARAM;
	    goto errCleanUp;
	}

	was->obj.dwType = WINE_ACMOBJ_STREAM;
	was->obj.pACMDriverID = wad->obj.pACMDriverID;
	was->pDrv = wad;
	was->hAcmDriver = 0; /* not to close it in acmStreamClose */

	ret = MSACM_Message((HACMDRIVER)wad, ACMDM_STREAM_OPEN, (LPARAM)&was->drvInst, 0L);
	if (ret != MMSYSERR_NOERROR)
	    goto errCleanUp;
    } else {
	PWINE_ACMDRIVERID wadi;

//.........这里部分代码省略.........
开发者ID:AndreRH,项目名称:wine,代码行数:101,代码来源:stream.c

示例15: acmStreamPrepareHeader

/***********************************************************************
 *           acmStreamPrepareHeader ([email protected])
 */
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
				       DWORD fdwPrepare)
{
    PWINE_ACMSTREAM	was;
    MMRESULT		ret = MMSYSERR_NOERROR;
    PACMDRVSTREAMHEADER	padsh;

    TRACE("(%p, %p, %d)\n", has, pash, fdwPrepare);

    if ((was = ACM_GetStream(has)) == NULL) {
        WARN("invalid handle\n");
        return MMSYSERR_INVALHANDLE;
    }
    if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) {
        WARN("invalid parameter\n");
        return MMSYSERR_INVALPARAM;
    }
    if (fdwPrepare) {
        WARN("invalid use of reserved parameter\n");
        return MMSYSERR_INVALFLAG;
    }
    if ((was->drvInst.pwfxSrc->wFormatTag == WAVE_FORMAT_ADPCM ||
         was->drvInst.pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) &&
        pash->cbSrcLength < was->drvInst.pwfxSrc->nBlockAlign) {
        WARN("source smaller than block align (%d < %d)\n",
             pash->cbSrcLength, was->drvInst.pwfxSrc->nBlockAlign);
        return pash->cbSrcLength ? ACMERR_NOTPOSSIBLE : MMSYSERR_INVALPARAM;
    }

    /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
     * size. some fields are private to msacm internals, and are exposed
     * in ACMSTREAMHEADER in the dwReservedDriver array
     */
    padsh = (PACMDRVSTREAMHEADER)pash;

    padsh->fdwConvert = fdwPrepare;
    padsh->padshNext = NULL;
    padsh->fdwDriver = padsh->dwDriver = 0L;

    padsh->fdwPrepared = 0;
    padsh->dwPrepared = 0;
    padsh->pbPreparedSrc = 0;
    padsh->cbPreparedSrcLength = 0;
    padsh->pbPreparedDst = 0;
    padsh->cbPreparedDstLength = 0;

    ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_PREPARE, (LPARAM)&was->drvInst, (LPARAM)padsh);
    if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
	ret = MMSYSERR_NOERROR;
	padsh->fdwStatus &= ~ACMSTREAMHEADER_STATUSF_INQUEUE;
	padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED;
	padsh->fdwPrepared = padsh->fdwStatus;
	padsh->dwPrepared = 0;
	padsh->pbPreparedSrc = padsh->pbSrc;
	padsh->cbPreparedSrcLength = padsh->cbSrcLength;
	padsh->pbPreparedDst = padsh->pbDst;
	padsh->cbPreparedDstLength = padsh->cbDstLength;
    } else {
	padsh->fdwPrepared = 0;
	padsh->dwPrepared = 0;
	padsh->pbPreparedSrc = 0;
	padsh->cbPreparedSrcLength = 0;
	padsh->pbPreparedDst = 0;
	padsh->cbPreparedDstLength = 0;
    }
    TRACE("=> (%d)\n", ret);
    return ret;
}
开发者ID:AndreRH,项目名称:wine,代码行数:71,代码来源:stream.c


注:本文中的TRACE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。