Ignore:
Timestamp:
Jul 17, 2000, 8:37:33 PM (25 years ago)
Author:
sandervl
Message:

misc updates

File:
1 edited

Legend:

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

    r151 r152  
    3434#include "ioctl.h"
    3535
     36#ifndef min
     37#define min(a,b) (a>b) ? b : a
     38#endif
     39
    3640//
    3741//  _vRealignBuffer
     
    152156void WAVESTREAM::AddBuffers(void)
    153157{
     158 ULONG space, byteswritten;
     159
    154160   if (ulStreamType & STREAM_WRITE) {
    155161        if(!qhInProcess.Head() && !qhDone.Head()) {
     
    160166                return;
    161167        }
    162         AddBuffer();
    163         AddBuffer();
     168        space = OSS16_StreamGetSpace(this);
     169        if(space > 128) {
     170                space -= 128;
     171        }
     172        while(space) {
     173                byteswritten = AddBuffer(space);
     174                space -= byteswritten;
     175                if(byteswritten == 0) break;
     176        }       
    164177   }
    165178}
     
    171184// there are buffers on pHead... BEWARE
    172185//
    173 void WAVESTREAM::AddBuffer()
     186ULONG WAVESTREAM::AddBuffer(ULONG space)
    174187{
    175188   PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhDone.Head();
     
    180193        pTemp = (PSTREAMBUFFER)qhInProcess.Head();
    181194   }
    182    if(!pTemp) return;
     195   if(!pTemp) return 0;
    183196
    184197   // get the buffer pointer and amount of data remaining
     
    187200
    188201   // write the audio buffer
     202   Buff_left = min(Buff_left, space);
    189203   byteswritten = OSS16_StreamAddBuffer(this, pdataBuf, Buff_left);
    190204   if(byteswritten == 0) {
    191         return; //no more room
    192    }
    193 
    194 //   dprintf(("AddBuffer %lx size %d, bytes written %d", pdataBuf, (USHORT)Buff_left, (USHORT)byteswritten));
     205        return 0; //no more room
     206   }
    195207
    196208   // update the buffer pos counter
     
    200212      qhDone.PushOnTail(qhInProcess.PopHead());
    201213   }
     214   dprintf4(("AddBuffer %lx size %d, bytes written %d", pdataBuf, (USHORT)Buff_left, (USHORT)byteswritten));
     215   return byteswritten;
    202216}
    203217
     
    226240   }
    227241
    228 ////   dprintf(("_vReadAudioBuf %lx size %d, bytes read %d", pdataBuf, Buff_left, bytesread));
     242   dprintf4(("_vReadAudioBuf %lx size %d, bytes read %d", pdataBuf, Buff_left, bytesread));
    229243
    230244   // update the buffer pos counter
     
    236250   }
    237251   if(pTemp->ulBuffpos == pTemp->ulBuffsz) {
    238         dprintf(("_vReadAudioBuf return buffer %lx size %ld, bytes read %ld", (ULONG)pTemp->pBuffptr, pTemp->ulBuffsz, bytesread));
     252        dprintf4(("_vReadAudioBuf return buffer %lx size %ld, bytes read %ld", (ULONG)pTemp->pBuffptr, pTemp->ulBuffsz, bytesread));
    239253        ReturnBuffer();
    240254   }
     
    280294                        //calc position in next buffer
    281295                        bytesinc = ptemp->ulDonepos - ptemp->ulBuffsz;
    282 ////                    dprintf(("Process: Return buffer %lx size %d", ptemp->pBuffptr, ptemp->ulBuffsz));
     296                        dprintf3(("Process: Return buffer %lx size %d", ptemp->pBuffptr, ptemp->ulBuffsz));
    283297                        ReturnBuffer();
    284298                }
     
    309323{
    310324   qhInProcess.PushOnTail((PQUEUEELEMENT)new STREAMBUFFER(uLength, pbuf));
    311 ////   dprintf(("WAVESTREAM::Write: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
     325   dprintf2(("WAVESTREAM::Write: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
    312326   if(fUnderrun) {
    313327        fUnderrun = FALSE;
     
    323337{
    324338   qhInProcess.PushOnTail((PQUEUEELEMENT)new STREAMBUFFER(uLength, pbuf));
    325    dprintf(("WAVESTREAM::Read: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
     339   dprintf2(("WAVESTREAM::Read: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
    326340   return 0;
    327341}
     
    384398 ULONG         fragsize;
    385399
     400#ifdef DEBUG
     401   int oldlevel = dbglevel;
     402   dbglevel = 4;
     403#endif
    386404   // configure the wave device
    387405   ((PWAVEAUDIO)pahw)->ConfigDev(this, &_configinfo);
     
    421439        OSS16_StartStream(this);
    422440   }
     441#ifdef DEBUG
     442   dbglevel = oldlevel;
     443#endif
    423444
    424445   //Must set volume after adding buffers (voices inside sblive driver might not
Note: See TracChangeset for help on using the changeset viewer.