Ignore:
Timestamp:
Apr 30, 2001, 11:08:00 PM (24 years ago)
Author:
sandervl
Message:

DirectAudio interface updates

File:
1 edited

Legend:

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

    r174 r178  
    2626
    2727#include <devhelp.h>
     28#include <include.h>
    2829
    2930#include "dwavestrm.hpp"
     
    3233#include "ioctl.h"
    3334#include "malloc.h"
     35#include <ossidc.h>
    3436
    3537void cdecl HookHandler(ULONG ulSysFileNum)
    3638{
    3739    PDWAVESTREAM pStream;
    38     PSTREAMBUFFEREX temp;
     40    PSTREAMBUFFER temp;
    3941    int rc;
    4042
     
    4648    }
    4749
    48     temp = (PSTREAMBUFFEREX)pStream->qhReturn.PopHead();
     50    temp = (PSTREAMBUFFER)pStream->qhReturn.PopHead();
    4951    while(temp) {
    5052        if(pStream->hSem) {
     
    5860        delete temp;
    5961
    60         temp = (PSTREAMBUFFEREX)pStream->qhReturn.PopHead();
     62        temp = (PSTREAMBUFFER)pStream->qhReturn.PopHead();
    6163    }
    6264    return;
     
    6466
    6567
    66 ULONG DWAVESTREAM::Write(PSTREAMBUF pbuf, ULONG uLength)
    67 {
    68     PSTREAMBUFFEREX pStreamBuf;
     68ULONG DWAVESTREAM::Write(PSTREAMBUF pbuf, ULONG uLength, BOOL fLooping)
     69{
     70    PSTREAMBUFFER pStreamBuf;
    6971    LIN             linAddr;
    7072    PULONG          pLock;
     
    7375    int             rc;
    7476
    75     pStreamBuf = new STREAMBUFFEREX(uLength, (PSTREAMBUF)0);
     77    pStreamBuf = new STREAMBUFFER(uLength, (PSTREAMBUF)0, fLooping);
    7678    if(pStreamBuf == NULL) {
    7779        DebugInt3();
     
    110112void DWAVESTREAM::ReturnBuffer(void)
    111113{
    112    PSTREAMBUFFEREX temp = (PSTREAMBUFFEREX)qhDone.PopHead();
     114   PSTREAMBUFFER temp = (PSTREAMBUFFER)qhDone.PopHead();
    113115
    114116   if(temp)
     
    148150}
    149151
     152//
     153//
     154ULONG DWAVESTREAM::StartStream(void)
     155{
     156   return WAVESTREAM::StartStream();
     157}
     158
     159
     160void DWAVESTREAM::AddBuffers(BOOL fFirst)
     161{
     162   PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhDone.Tail();
     163   ULONG space, Buff_left, byteswritten;
     164
     165   if(!pTemp) pTemp = (PSTREAMBUFFER)qhInProcess.Tail();
     166
     167   if(ulStreamType & STREAM_WRITE && pTemp && pTemp->looping)
     168   {
     169        Buff_left = pTemp->ulBuffsz - pTemp->ulBuffpos;
     170
     171        space = OSS16_StreamGetSpace(this);
     172        if(fFirst) {
     173             space = min(space, 4*fragsize);
     174        }
     175        else space = min(space, fragsize);
     176
     177        if(space) {
     178            if(space >= Buff_left) {
     179                 byteswritten = AddBuffer(Buff_left);
     180                 if(byteswritten == Buff_left) {
     181                     pTemp->ulBuffpos = 0; //reset fill position
     182                     AddBuffer(space - Buff_left);
     183                 }
     184            }
     185            else AddBuffer(space);
     186        }       
     187        pTemp->ulDonepos = 0; //make sure it ::Process never thinks it's done
     188   }
     189   else WAVESTREAM::AddBuffers(fFirst);
     190}
     191
     192BOOL DWAVESTREAM::SetProperty(int type, ULONG value, ULONG reserved)
     193{
     194   switch(type) {
     195   case PROPERTY_LOOPING:
     196   {
     197       cli();
     198       PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhInProcess.Head();
     199
     200       if(!pTemp) pTemp = (PSTREAMBUFFER)qhDone.Head();
     201
     202       if(pTemp) {
     203           pTemp->looping = (BOOL)value;
     204           if(pTemp->looping == FALSE) {
     205               //calculate current play position
     206               pTemp->ulDonepos = (_ulBytesProcessed % pTemp->ulBuffsz);
     207           }
     208       }
     209       sti();
     210   }
     211   case PROPERTY_FREQUENCY:
     212       break;
     213
     214   default:
     215       return WAVESTREAM::SetProperty(type, value, reserved);
     216
     217   }
     218   return TRUE;
     219}
     220
     221ULONG DWAVESTREAM::GetProperty(int type)
     222{
     223   switch(type) {
     224   case PROPERTY_LOOPING:
     225   {
     226       cli();
     227       PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhInProcess.Head();
     228       ULONG         ret = FALSE;
     229
     230       if(!pTemp) pTemp = (PSTREAMBUFFER)qhDone.Head();
     231
     232       if(pTemp) {
     233           ret = pTemp->looping;
     234       }
     235       sti();
     236       return ret;
     237   }
     238
     239   default:
     240       return WAVESTREAM::GetProperty(type);
     241   }
     242}
    150243
    151244DWAVESTREAM::DWAVESTREAM(ULONG streamtype, LPMCI_AUDIO_INIT pinit, USHORT filesysnum):
     
    161254{
    162255    if (ulStreamState == STREAM_STREAMING) {
    163         CONTROL_PARM cParm;
    164         StopStream(&cParm);
     256         CONTROL_PARM cParm;
     257         StopStream(&cParm);
    165258    }
    166259    else ReturnBuffers();
Note: See TracChangeset for help on using the changeset viewer.