Ignore:
Timestamp:
Nov 9, 2009, 2:36:35 AM (16 years ago)
Author:
pasha
Message:

Fix buffers overflow problem, check Flash10, fix some strange code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OCO/trunk/drv16/wavestrm.cpp

    r468 r473  
    181181        }
    182182        space &= (~(_configinfo.ulSampleSize - 1));
    183         curspace = space;
     183        curspace = min(space, _configinfo.ulBytesPerIRQ/_configinfo.ulSampleSize * 2);
    184184        while (space && qhInProcess.IsElements())
    185185        {
     
    188188            if (fFirst == TRUE)  //PS+++
    189189            {
    190                  DevHelp_ProcBlock (space, 20, 0);
     190                cli();
     191//                 DevHelp_ProcBlock (space, 20, 0);
    191192            }
    192193//            dgprintf(("AddBuffers write %ld SSize:%ld %d",space, _configinfo.ulSampleSize, fFirst == TRUE?1:2));
     
    195196            {
    196197//                dgprintf(("WAVESTREAM::AddBuffers Error 2"));
    197                 return;
     198                break;
    198199            }
    199200            if(byteswritten == (ULONG)-1)
     
    233234    if(pahw->GetHwPtr(StreamId, &_configinfo, &start_pos) == FALSE)
    234235    {
    235         dgprintf(("WAVESTREAM::AddBuffer Error in WaveGetHwPtr"));
     236        dgprintf(("WAVESTREAM::AddBuffer Err in GetHwPtr"));
    236237        DebugInt3();
    237238        return (ULONG)-1;
     
    240241    if (!pTemp->ulBuffsz || !space)
    241242    {
    242         dgprintf(("WAVESTREAM::AddBuffer NULL, Bufsz:%ld Space:%ld",pTemp->ulBuffsz, space));
     243        dgprintf(("WAVESTREAM::AddBuffer 0, Bufsz:%ld Space:%ld",pTemp->ulBuffsz, space));
    243244        //PS+++ if is ZERO do nothing and ask for give new buffer, See REMARK in mmpm2.inf
    244245        qhDone.PushOnTail(qhInProcess.PopHead());
    245246//        DebugInt3();
    246         return 0;
     247        return -1;
    247248    }
    248249    // get the buffer pointer and amount of data remaining
     
    261262        dgprintf(("AddBuffer: No more room!!"));
    262263//        DebugInt3();
    263         return (ULONG)-1; //no more room
     264//PS+++        return (ULONG)-1; //no more room
     265        return 0;   //PS+++ may be in next time?
    264266    }
    265267    // update the buffer pos counter
     
    304306    }
    305307
    306     dprintf4(("_vReadAudioBuf %lx size %ld, bytes read %ld", pdataBuf, Buff_left, bytesread));
     308//    dprintf4(("_vReadAudioBuf %lx size %ld, bytes read %ld", pdataBuf, Buff_left, bytesread));
    307309
    308310    // update the buffer pos counter
     
    325327// can be returned and finally process any events pending.
    326328//******************************************************************************
    327 //USHORT ProcNumber = 0;
     329USHORT ProcNumber = 0;
    328330void DBGCALLCONV WAVESTREAM::Process(void)
    329331{
    330332 PSTREAMBUFFER ptemp;
    331333 ULONG         ulCurBytesProcessed = 0;
    332 // USHORT        CurProcNumber = ProcNumber++;
     334 USHORT        CurProcNumber = ProcNumber++;
    333335 ULONG         space;
    334336
     
    351353    _ulBytesProcessed = ulCurBytesProcessed;
    352354
    353 //    if ((pahw->GetSpace(StreamId, &_configinfo, &space) != FALSE) && (space > _configinfo.ulBytesPerIRQ))
    354     switch (ulStreamType & STREAM_WRITE) {
     355    if ((pahw->GetSpace(StreamId, &_configinfo, &space) != FALSE) && (space > _configinfo.ulBytesPerIRQ/_configinfo.ulSampleSize ))
     356    switch (ulStreamType & STREAM_WRITE)
     357    {
    355358
    356359        // if there are buffers that have been completly written to the audio buffer
     
    522525
    523526#ifdef DEBUG
    524     ddprintf(("WAVESTREAM::StartStream"));
     527//    ddprintf(("WAVESTREAM::StartStream"));
    525528#endif
    526529
     
    572575        }
    573576    }
    574     ddprintf(("WAVESTREAM::StartStream %lx End", StreamId));
     577//    ddprintf(("WAVESTREAM::StartStream %lx End", StreamId));
    575578    return NO_ERROR;
    576579
     
    598601
    599602    ulStreamState = STREAM_STOPPED;
    600     ddprintf(("WAVESTREAM::StopStream %lx", StreamId));
     603//    ddprintf(("WAVESTREAM::StopStream %lx", StreamId));
    601604    ReturnBuffers();
    602605    pControl->ulTime = GetCurrentTime();
Note: See TracChangeset for help on using the changeset viewer.