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/dwavestrm.cpp

    r468 r473  
    166166ULONG DWAVESTREAM::StartStream(void)
    167167{
     168    dprintf(("DWAVESTREAM::StartStream"));
    168169   return WAVESTREAM::StartStream();
    169170}
     
    175176   ULONG space, Buff_left, byteswritten;
    176177
    177    if(!pTemp) pTemp = (PSTREAMBUFFER)qhInProcess.Tail();
    178 
    179    if(ulStreamType & STREAM_WRITE && pTemp && pTemp->looping)
     178    dprintf(("DW::AddBuffers"));
     179    if (!pTemp) pTemp = (PSTREAMBUFFER)qhInProcess.Tail();
     180
     181    if (ulStreamType & STREAM_WRITE && pTemp && pTemp->looping)
     182    {
     183        Buff_left = pTemp->ulBuffsz - pTemp->ulBuffpos;
     184        if (pahw->GetPosition(StreamId, &_configinfo, &space) != OSSERR_SUCCESS)
     185        {
     186            dprintf(("DWAVESTREAM::AddBuffers GetPositions"));
     187            DebugInt3();
     188            return;
     189        }
     190        if(fFirst)
     191        {
     192             space = min(space, 4*_configinfo.ulFragsize);
     193        }
     194        else
     195        {
     196            space = min(space, _configinfo.ulFragsize);
     197        }
     198        if (space)
     199        {
     200           if (space >= Buff_left)
     201           {
     202              byteswritten = AddBuffer(Buff_left);
     203              if (byteswritten == Buff_left)
     204              {
     205                  pTemp->ulBuffpos = 0; //reset fill position
     206                  AddBuffer(space - Buff_left);
     207              }
     208           }
     209           else
     210           {
     211              AddBuffer(space);
     212           }
     213        }       
     214        pTemp->ulDonepos = 0; //make sure it ::Process never thinks it's done
     215   }
     216   else
    180217   {
    181         Buff_left = pTemp->ulBuffsz - pTemp->ulBuffpos;
    182 
    183             if (pahw->GetPosition(StreamId, &_configinfo, &space) != OSSERR_SUCCESS)
    184            {
    185                dprintf(("DWAVESTREAM::AddBuffers GetPositions"));
    186                DebugInt3();
    187                return;
    188            }
    189         if(fFirst) {
    190              space = min(space, 4*_configinfo.ulFragsize);
    191         }
    192         else space = min(space, _configinfo.ulFragsize);
    193 
    194             if(space) {
    195             if(space >= Buff_left) {
    196                  byteswritten = AddBuffer(Buff_left);
    197                  if(byteswritten == Buff_left) {
    198                      pTemp->ulBuffpos = 0; //reset fill position
    199                      AddBuffer(space - Buff_left);
    200                  }
    201             }
    202             else AddBuffer(space);
    203             }   
    204         pTemp->ulDonepos = 0; //make sure it ::Process never thinks it's done
    205    }
    206    else WAVESTREAM::AddBuffers(fFirst);
     218     WAVESTREAM::AddBuffers(fFirst);
     219   }
     220    dprintf(("DW::AddBuffers End"));
    207221}
    208222//*****************************************************************************
Note: See TracChangeset for help on using the changeset viewer.