Ignore:
Timestamp:
Mar 23, 2001, 12:33:12 AM (24 years ago)
Author:
sandervl
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sbliveos2/trunk/drv16/dwavestrm.cpp

    r166 r167  
    3131#include <dbgos2.h>
    3232#include "ioctl.h"
     33#include "malloc.h"
    3334
    3435
     
    5556        }
    5657        DevHelp_VMFree((LIN)temp->pBuffptr);
    57         DevHelp_VMUnLock(temp->hLock);
     58        DevHelp_VMUnLock(temp->linLock);
     59        free(temp->pLock);
    5860        delete temp;
    5961    }
     
    6567{
    6668    PSTREAMBUFFEREX pStreamBuf;
    67     ULONG pGlobalAddr;
    68     LIN   linAddr = (LIN)&pGlobalAddr;
    69     ULONG lock;
    70     LIN   linLock = (LIN)&lock;
     69    LIN   linAddr;
     70    PULONG pLock;
     71    ULONG PageListCount;
     72    LIN   linLock;
    7173    int   rc;
    7274
    73     rc = DevHelp_VirtToLin(SELECTOROF(linAddr), OFFSETOF(linAddr), &linAddr);
     75    pLock = (PULONG)malloc(12);
     76    if(pLock == NULL) {
     77        DebugInt3();
     78        return 1;
     79    }
     80
     81    rc = DevHelp_VirtToLin(SELECTOROF(pLock), OFFSETOF(pLock), &linLock);
    7482    if(rc) {
    7583        DebugInt3();
     
    7785    }
    7886
    79     rc = DevHelp_VirtToLin(SELECTOROF(linLock), OFFSETOF(linLock), &linLock);
     87    rc = DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE, (LIN)pbuf, uLength, -1L, linLock, (PULONG)&PageListCount);
     88    if(rc) {
     89        DebugInt3();
     90        DevHelp_VMFree(linAddr);
     91        return rc;
     92    }
     93
     94    rc = DevHelp_VMProcessToGlobal(VMDHGP_WRITE, (LIN)pbuf, uLength, (PLIN)&linAddr);
    8095    if(rc) {
    8196        DebugInt3();
     
    8398    }
    8499
    85     rc = DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE, (LIN)pbuf, uLength, -1L, linLock, (PULONG)-1L);
    86     if(rc) {
    87         DebugInt3();
    88         return rc;
    89     }
     100    pStreamBuf = new STREAMBUFFEREX(uLength, (PSTREAMBUF)linAddr, linLock, pLock);
    90101
    91     rc = DevHelp_VMProcessToGlobal(VMDHGP_WRITE, (LIN)pbuf, uLength, (PLIN)linAddr);
    92     if(rc) {
    93         return rc;
    94     }
    95 
    96     pStreamBuf = new STREAMBUFFEREX(uLength, (PSTREAMBUF)pGlobalAddr, lock);
    97 
    98     return WAVESTREAM::Write((STREAMBUFFER *)pStreamBuf);
     102    return WAVESTREAM::Write((PSTREAMBUFFER)pStreamBuf);
    99103}
    100104
     
    111115        else {
    112116            DevHelp_VMFree((LIN)temp->pBuffptr);
    113             DevHelp_VMUnLock(temp->hLock);
     117            DevHelp_VMUnLock(temp->linLock);
     118            free(temp->pLock);
    114119            delete temp;
    115120        }
     
    117122}
    118123
     124ULONG DWAVESTREAM::Register(PDDCMDREGISTER pReg)
     125{
     126    hSem = pReg->hStream;
     127
     128    if(DevHelp_OpenEventSem(hSem) != 0) {
     129        dprintf(("DevHlp_OpenEventSem %lx failed!", hSem));
     130        hSem = 0;
     131        return 1;
     132    }
     133    return WAVESTREAM::Register(pReg);
     134}
     135
     136void DWAVESTREAM::DeRegister(void)
     137{
     138    if(DevHelp_CloseEventSem(hSem) != 0) {
     139        dprintf(("DevHlp_CloseEventSemaphore %lx failed!", hSem));
     140        return;
     141    }
     142    hSem = 0;
     143    WAVESTREAM::DeRegister();
     144}
     145
     146
    119147DWAVESTREAM::DWAVESTREAM(ULONG streamtype, LPMCI_AUDIO_INIT pinit, USHORT filesysnum):
    120    WAVESTREAM(streamtype, pinit, filesysnum), fError(FALSE), hCtxHook(0)
     148   WAVESTREAM(streamtype, pinit, filesysnum), fError(FALSE), hCtxHook(0), hSem(0)
    121149{
    122150    if(DevHelp_AllocateCtxHook((NPFN)HookHandlerAsm, &hCtxHook)) {
     
    132160        StopStream(&cParm);
    133161    }
     162    else ReturnBuffers();
     163
     164    if(hSem) {
     165        if(DevHelp_CloseEventSem(hSem) != 0) {
     166            dprintf(("DevHlp_CloseEventSemaphore %lx failed!", hSem));
     167        }
     168    }
    134169    if(hCtxHook) {
    135170        DevHelp_FreeCtxHook(hCtxHook);
Note: See TracChangeset for help on using the changeset viewer.