/* $Id: OS2DSOUND.CPP,v 1.4 1999-10-23 23:00:49 sandervl Exp $ */ /* * DirectSound main class * * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) * * Project Odin Software License can be found in LICENSE.TXT * */ /*@Header*********************************************************************** * Header Files * *******************************************************************************/ #include #include #include #define INITGUID #include #include "os2dsound.h" #include "os2sndbuffer.h" #include "misc.h" //****************************************************************************** //****************************************************************************** OS2IDirectSound::OS2IDirectSound(const GUID *lpGUID) : Referenced(0), lastError(DS_OK), hwndClient(0) { lpVtbl = &Vtbl; Vtbl.AddRef = SoundAddRef; Vtbl.Release = SoundRelease; Vtbl.QueryInterface = SoundQueryInterface; Vtbl.Compact = SoundCompact; Vtbl.CreateSoundBuffer = SoundCreateSoundBuffer; Vtbl.GetCaps = SoundGetCaps; Vtbl.DuplicateSoundBuffer = SoundDuplicateSoundBuffer; Vtbl.SetCooperativeLevel = SoundSetCooperativeLevel; Vtbl.Compact = SoundCompact; Vtbl.GetSpeakerConfig = SoundGetSpeakerConfig; Vtbl.SetSpeakerConfig = SoundSetSpeakerConfig; Vtbl.Initialize = SoundInitialize; speakerConfig = DSSPEAKER_STEREO; CoopLevel = DSSCL_EXCLUSIVE; //default } //****************************************************************************** //****************************************************************************** OS2IDirectSound::~OS2IDirectSound() { } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundQueryInterface(THIS, REFIID riid, LPVOID * ppvObj) { dprintf(("OS2IDirectSound::QueryInterface\n")); if(This == NULL) { return DSERR_INVALIDPARAM; } *ppvObj = NULL; if(!IsEqualGUID(riid, CLSID_DirectSound) && !IsEqualGUID(riid, IID_IDirectSound)) return E_NOINTERFACE; *ppvObj = This; SoundAddRef(This); return(DS_OK); } //****************************************************************************** //****************************************************************************** ULONG WIN32API SoundAddRef(THIS) { OS2IDirectSound *me = (OS2IDirectSound *)This; dprintf(("OS2IDirectSound::AddRef %d\n", me->Referenced+1)); return ++me->Referenced; } //****************************************************************************** //****************************************************************************** ULONG WIN32API SoundRelease(THIS) { OS2IDirectSound *me = (OS2IDirectSound *)This; dprintf(("OS2IDirectSound::Release %d\n", me->Referenced-1)); if(me->Referenced) { me->Referenced--; if(me->Referenced == 0) { delete me; return(0); } else return me->Referenced; } else return(0); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundCompact(THIS) { dprintf(("OS2IDirectSound::Compact\n")); return(DS_OK); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundCreateSoundBuffer(THIS_ LPDSBUFFERDESC lpDSBufferDesc, //new, const LPDIRECTSOUNDBUFFER *lplpDirectSoundBuffer, LPUNKNOWN pUnkOuter) { OS2IDirectSound *me = (OS2IDirectSound *)This; OS2IDirectSoundBuffer *sndbuf; dprintf(("OS2IDirectSound::CreateSoundBuffer\n")); if(me == NULL || lpDSBufferDesc == NULL || lplpDirectSoundBuffer == NULL) { return(DSERR_INVALIDPARAM); } sndbuf = new OS2IDirectSoundBuffer(lpDSBufferDesc); if(sndbuf == NULL) { return(DSERR_OUTOFMEMORY); } if(sndbuf->GetLastError() != DS_OK) { ULONG lastErr = sndbuf->GetLastError(); delete sndbuf; return lastErr; } *lplpDirectSoundBuffer = (LPDIRECTSOUNDBUFFER)sndbuf; return(DS_OK); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundGetCaps(THIS_ LPDSCAPS lpCaps) { dprintf(("OS2IDirectSound::GetCaps\n")); return(DS_OK); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundDuplicateSoundBuffer(THIS_ LPDIRECTSOUNDBUFFER, LPLPDIRECTSOUNDBUFFER ) { dprintf(("OS2IDirectSound::DuplicateSoundBuffer\n")); return(DSERR_OUTOFMEMORY); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundSetCooperativeLevel(THIS_ HWND hwndClient, DWORD level) { OS2IDirectSound *me = (OS2IDirectSound *)This; dprintf(("OS2IDirectSound::SetCooperativeLevel\n")); if(me == NULL) { return(DSERR_INVALIDPARAM); } me->hwndClient = (HWND)hwndClient; me->CoopLevel = level; return(DS_OK); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundGetSpeakerConfig(THIS_ LPDWORD lpSpeakerCfg) { OS2IDirectSound *me = (OS2IDirectSound *)This; dprintf(("OS2IDirectSound::GetSpeakerConfig\n")); if(me == NULL) { return(DSERR_INVALIDPARAM); } *lpSpeakerCfg = me->speakerConfig; return(DS_OK); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundSetSpeakerConfig(THIS_ DWORD speakerCfg) { OS2IDirectSound *me = (OS2IDirectSound *)This; dprintf(("OS2IDirectSound::SetSpeakerConfig %X\n", speakerCfg)); if(me == NULL) { return(DSERR_INVALIDPARAM); } me->speakerConfig = speakerCfg; return(DS_OK); } //****************************************************************************** //****************************************************************************** HRESULT WIN32API SoundInitialize(THIS_ LPGUID) { dprintf(("OS2IDirectSound::Initialize UNSUPPORTED\n")); return(DS_OK); } //****************************************************************************** //******************************************************************************