Ignore:
Timestamp:
Mar 10, 2001, 7:21:06 AM (24 years ago)
Author:
mike
Message:

Added DuplicateSoundBuffer support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/dsound/OS2DSOUND.CPP

    r3555 r5292  
    1 /* $Id: OS2DSOUND.CPP,v 1.7 2000-05-18 20:37:08 mike Exp $ */
     1/* $Id: OS2DSOUND.CPP,v 1.8 2001-03-10 06:21:06 mike Exp $ */
    22
    33/*
     
    55 *
    66 * Copyright 1998 Sander van Leeuwen
    7  * Copyright 2000 Michal Necasek
     7 * Copyright 2000 Kevin Langman
     8 * Copyright 2001 Michal Necasek
    89 *
    910 * Project Odin Software License can be found in LICENSE.TXT
     
    1819#include <string.h>
    1920
    20 
    21 
    2221#include <stdio.h> /****** DEBUGGING ********/
    23 
    24 
    2522
    2623#define INITGUID
     
    3431#include <misc.h>
    3532
    36 // TODO: primary buffer should probably created right away when creating the DSound
    37 // object
    3833// TODO: handle cooperative levels properly!!
    3934
     
    6055   Vtbl.Initialize           = SoundInitialize;
    6156
    62    dprintf(("DSOUND-OS2IDirectSound::OS2IDirectSound\n"));
     57   dprintf(("DSOUND-OS2IDirectSound::OS2IDirectSound"));
    6358
    6459   speakerConfig = DSSPEAKER_STEREO;
     
    7570   if ( primary->GetLastError() != DS_OK ){
    7671      ULONG lastErr = primary->GetLastError();
    77       dprintf(("LastErr = %d\n", lastErr));
     72      dprintf(("LastErr = %d", lastErr));
    7873      delete primary;
    7974      lastError = lastErr;
     
    8277   primary->Vtbl.AddRef(primary);
    8378
    84    dprintf(("Sound init OK\n"));
    85 }
     79   dprintf(("Sound init OK"));
     80}
     81
    8682//******************************************************************************
    8783//******************************************************************************
     
    9288   OS2IDirectSound::fDSExists = FALSE;
    9389}
     90
    9491//******************************************************************************
    9592//******************************************************************************
    9693HRESULT WIN32API SoundQueryInterface(THIS, REFIID riid, LPVOID * ppvObj)
    9794{
    98    dprintf(("DSOUND-OS2IDirectSound::QueryInterface\n"));
     95   dprintf(("DSOUND-OS2IDirectSound::QueryInterface"));
    9996   if (This == NULL) {
    10097      return DSERR_INVALIDPARAM;
     
    118115   OS2IDirectSound *me = (OS2IDirectSound *)This;
    119116
    120    dprintf(("DSOUND-OS2IDirectSound::AddRef %d\n", me->Referenced+1));
     117   dprintf(("DSOUND-OS2IDirectSound::AddRef %d", me->Referenced+1));
    121118   return ++me->Referenced;
    122119}
     
    128125   OS2IDirectSound *me = (OS2IDirectSound *)This;
    129126
    130    dprintf(("DSOUND-OS2IDirectSound::Release %d\n", me->Referenced-1));
     127   dprintf(("DSOUND-OS2IDirectSound::Release %d", me->Referenced-1));
    131128   if (me->Referenced) {
    132129      me->Referenced--;
     
    146143HRESULT WIN32API SoundCompact(THIS)
    147144{
    148   dprintf(("DSOUND-OS2IDirectSound::Compact\n"));
     145  dprintf(("DSOUND-OS2IDirectSound::Compact - NOP"));
    149146  return DS_OK;
    150147}
     
    160157   OS2IDirectSoundBuffer *sndbuf;
    161158
    162    dprintf(("DSOUND-OS2IDirectSound::CreateSoundBuffer\n"));
     159   dprintf(("DSOUND-OS2IDirectSound::CreateSoundBuffer"));
    163160   if (me == NULL || lpDSBufferDesc == NULL || lplpDirectSoundBuffer == NULL) {
    164161      return DSERR_INVALIDPARAM;
     
    171168
    172169   if (lpDSBufferDesc->dwFlags & DSBCAPS_PRIMARYBUFFER) {
    173 
    174 /*
    175 
    176       // The Primary buffer is now created by the Constructor.. This only
    177       // makes sence becuse you can really only have one primary buffer and
    178       // you need it before you can to do anything.
    179 
    180       OS2PrimBuff *primbuff;
    181       primbuff = new OS2PrimBuff(me, lpDSBufferDesc);
    182 
    183       if (primbuff == NULL)
    184          return DSERR_OUTOFMEMORY;
    185 
    186       if ( primbuff->GetLastError() != DS_OK ){
    187          ULONG lastErr = primbuff->GetLastError();
    188 
    189          dprintf(("LastErr = %d\n", lastErr));
    190          delete primbuff;
    191          return lastErr;
    192       }
    193       *lplpDirectSoundBuffer = (LPDIRECTSOUNDBUFFER)primbuff;
    194       primbuff->Vtbl.AddRef(primbuff);
    195       dprintf(("Created PrimBuff... Exiting Create Buffer function\n"));
    196 */
    197 
    198170      *lplpDirectSoundBuffer = (LPDIRECTSOUNDBUFFER)me->primary;
    199171      return DS_OK;
     
    204176      return DSERR_OUTOFMEMORY;
    205177   }
    206    if(sndbuf->GetLastError() != DS_OK) {
     178   if (sndbuf->GetLastError() != DS_OK) {
    207179      ULONG lastErr = sndbuf->GetLastError();
    208180      delete sndbuf;
     
    220192HRESULT WIN32API SoundGetCaps(THIS_ LPDSCAPS lpCaps)
    221193{
    222    dprintf(("DSOUND-OS2IDirectSound::GetCaps\n"));
     194   dprintf(("DSOUND-OS2IDirectSound::GetCaps"));
    223195
    224196   if (lpCaps == NULL)
     
    258230//******************************************************************************
    259231//******************************************************************************
    260 HRESULT WIN32API SoundDuplicateSoundBuffer(THIS_ LPDIRECTSOUNDBUFFER, LPLPDIRECTSOUNDBUFFER )
    261 {
    262    dprintf(("DSOUND-OS2IDirectSound::DuplicateSoundBuffer\n"));
    263    return DSERR_OUTOFMEMORY;
     232HRESULT WIN32API SoundDuplicateSoundBuffer(THIS_ LPDIRECTSOUNDBUFFER lpBuf, LPLPDIRECTSOUNDBUFFER lplpDirectSoundBuffer)
     233{
     234   OS2IDirectSound *me = (OS2IDirectSound *)This;
     235   OS2IDirectSoundBuffer *srcBuf = (OS2IDirectSoundBuffer*)lpBuf;
     236   OS2IDirectSoundBuffer *tgtBuf;
     237
     238   dprintf(("DSOUND-OS2IDirectSound::DuplicateSoundBuffer (%X to %X)", lpBuf, lplpDirectSoundBuffer));
     239   if (me == NULL || lpBuf == NULL || lplpDirectSoundBuffer == NULL) {
     240      return DSERR_INVALIDPARAM;
     241   }
     242
     243   tgtBuf = new OS2IDirectSoundBuffer(me, srcBuf);
     244   if (tgtBuf == NULL) {
     245      return DSERR_OUTOFMEMORY;
     246   }
     247
     248   if (tgtBuf->GetLastError() != DS_OK) {
     249      ULONG lastErr = tgtBuf->GetLastError();
     250      delete tgtBuf;
     251      return lastErr;
     252   }
     253   tgtBuf->Vtbl.AddRef(tgtBuf);
     254
     255   *lplpDirectSoundBuffer = (LPDIRECTSOUNDBUFFER)tgtBuf;
     256
     257   return DS_OK;
    264258}
    265259
     
    270264   OS2IDirectSound *me = (OS2IDirectSound *)This;
    271265
    272    dprintf(("DSOUND-OS2IDirectSound::SetCooperativeLevel (to %d)\n", level));
     266   dprintf(("DSOUND-OS2IDirectSound::SetCooperativeLevel (to %d)", level));
    273267   if (me == NULL) {
    274268     return DSERR_INVALIDPARAM;
     
    278272   return DS_OK;
    279273}
     274
    280275//******************************************************************************
    281276//******************************************************************************
     
    284279   OS2IDirectSound *me = (OS2IDirectSound *)This;
    285280
    286    dprintf(("DSOUND-OS2IDirectSound::GetSpeakerConfig\n"));
     281   dprintf(("DSOUND-OS2IDirectSound::GetSpeakerConfig"));
    287282   if (me == NULL) {
    288283      return(DSERR_INVALIDPARAM);
     
    299294   OS2IDirectSound *me = (OS2IDirectSound *)This;
    300295
    301    dprintf(("DSOUND-OS2IDirectSound::SetSpeakerConfig %X\n", speakerCfg));
     296   dprintf(("DSOUND-OS2IDirectSound::SetSpeakerConfig %X", speakerCfg));
    302297   if (me == NULL) {
    303298     return DSERR_INVALIDPARAM;
     
    311306HRESULT WIN32API SoundInitialize(THIS_ LPGUID)
    312307{
    313    dprintf(("DSOUND-OS2IDirectSound::Initialize NOP\n"));
    314    return DS_OK;
    315 }
    316 //******************************************************************************
    317 //******************************************************************************
     308   dprintf(("DSOUND-OS2IDirectSound::Initialize NOP"));
     309   return DS_OK;
     310}
     311//******************************************************************************
     312//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.