forked from Mirrors/openclonk
Remove unused DInput/DSound code
parent
92c2d41d1e
commit
7b2d506869
|
@ -320,10 +320,6 @@ set(OC_CLONK_SOURCES
|
|||
src/platform/C4Video.h
|
||||
src/platform/C4VideoPlayback.cpp
|
||||
src/platform/C4VideoPlayback.h
|
||||
src/platform/DInputX.cpp
|
||||
src/platform/DInputX.h
|
||||
src/platform/DSoundX.cpp
|
||||
src/platform/DSoundX.h
|
||||
src/platform/Midi.cpp
|
||||
src/platform/Midi.h
|
||||
src/platform/OpenURL.cpp
|
||||
|
|
|
@ -1,196 +0,0 @@
|
|||
/* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
* Copyright (c) 1998-2000 Matthes Bender
|
||||
* Copyright (c) 2005 Günther Brammer
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
"Clonk" is a registered trademark of Matthes Bender. */
|
||||
|
||||
/* A mouse handling wrapper to DirectInput */
|
||||
|
||||
#ifdef USE_DIRECTX
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0700
|
||||
|
||||
#include <Standard.h>
|
||||
#include <DInputX.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <mmsystem.h>
|
||||
#include <stdio.h>
|
||||
#include <dinput.h>
|
||||
|
||||
// DIMOFS_X and co are defined in dinput.h with FIELD_OFFSET
|
||||
// and gcc>3.2 does not like that in constant expressions.
|
||||
#ifdef __GNUC__
|
||||
#include <stddef.h>
|
||||
#undef FIELD_OFFSET
|
||||
#define FIELD_OFFSET(t,f) offsetof(t,f)
|
||||
#endif
|
||||
|
||||
|
||||
bool Log(const char *szMessage);
|
||||
|
||||
void HResultErrorString(long hresult, char *tstr)
|
||||
{
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
|
||||
hresult,
|
||||
LANG_SYSTEM_DEFAULT,
|
||||
tstr,255,
|
||||
NULL);
|
||||
}
|
||||
|
||||
#define DINPUT_BUFFERSIZE 16
|
||||
|
||||
int DIRangeX1, DIRangeY1, DIRangeX2, DIRangeY2;
|
||||
int MouseX, MouseY, MouseB0, MouseB1, MouseB2;
|
||||
long MouseStatus=0;
|
||||
int g_dxFuzz=0;
|
||||
int g_dyFuzz=0;
|
||||
int g_iSensitivity=0;
|
||||
|
||||
LPDIRECTINPUT g_pdi = NULL;
|
||||
LPDIRECTINPUTDEVICE g_pMouse = NULL;
|
||||
HANDLE g_hevtMouse = NULL;
|
||||
|
||||
void DirectInputSyncAcquire(bool fActive);
|
||||
|
||||
bool InitDirectInput(HINSTANCE g_hinst, HWND hwnd, int resx, int resy)
|
||||
{
|
||||
HRESULT hr;
|
||||
hr = DirectInputCreate(g_hinst, DIRECTINPUT_VERSION, /*(void **)*/ &g_pdi, NULL);
|
||||
if (FAILED(hr)) { Log("DirectInputCreate failure"); return false; }
|
||||
|
||||
hr = g_pdi->CreateDevice(GUID_SysMouse, &g_pMouse, NULL);
|
||||
if (FAILED(hr)) { Log("CreateDevice(SysMouse) failure"); return false; }
|
||||
|
||||
hr = g_pMouse->SetDataFormat(&c_dfDIMouse);
|
||||
if (FAILED(hr)) { Log("SetDataFormat(SysMouse, dfDIMouse) failure"); return false; }
|
||||
|
||||
hr = g_pMouse->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
|
||||
if (FAILED(hr)) { Log("SetCooperativeLevel(SysMouse) failure"); return false; }
|
||||
|
||||
g_hevtMouse = CreateEvent(0, 0, 0, 0);
|
||||
if (g_hevtMouse == NULL) { Log("CreateEvent failure"); return false; }
|
||||
|
||||
hr = g_pMouse->SetEventNotification(g_hevtMouse);
|
||||
if (FAILED(hr)) { Log("SetEventNotification(SysMouse)"); return false; }
|
||||
|
||||
DIPROPDWORD dipdw =
|
||||
{
|
||||
{ sizeof(DIPROPDWORD), sizeof(DIPROPHEADER), 0, DIPH_DEVICE, },
|
||||
DINPUT_BUFFERSIZE,
|
||||
};
|
||||
|
||||
hr = g_pMouse->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph);
|
||||
if (FAILED(hr)) { Log("Set buffer size(SysMouse)"); return false; }
|
||||
|
||||
SetMouseRange(0,0,resx-1,resy-1);
|
||||
CenterMouse();
|
||||
MouseB0=MouseB1=MouseB2=0;
|
||||
|
||||
DirectInputSyncAcquire(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeInitDirectInput()
|
||||
{
|
||||
if (g_pdi) g_pdi ->Release(), g_pdi = NULL;
|
||||
if (g_pMouse) g_pMouse->Release(), g_pMouse = NULL;
|
||||
if (g_hevtMouse) CloseHandle(g_hevtMouse), g_hevtMouse = NULL;
|
||||
}
|
||||
|
||||
void ClipMouse2Range()
|
||||
{
|
||||
if (MouseX < DIRangeX1) MouseX = DIRangeX1;
|
||||
if (MouseX > DIRangeX2) MouseX = DIRangeX2;
|
||||
if (MouseY < DIRangeY1) MouseY = DIRangeY1;
|
||||
if (MouseY > DIRangeY2) MouseY = DIRangeY2;
|
||||
}
|
||||
|
||||
void DIMouseUpdatePosition(int dx, int dy)
|
||||
{
|
||||
dx += g_dxFuzz; g_dxFuzz = 0;
|
||||
dy += g_dyFuzz; g_dyFuzz = 0;
|
||||
switch (g_iSensitivity)
|
||||
{
|
||||
case 1: dx *= 2; dy *= 2; break;
|
||||
case -1: g_dxFuzz = dx % 2; g_dyFuzz = dy % 2; dx /= 2; dy /= 2; break;
|
||||
}
|
||||
MouseX += dx; MouseY += dy;
|
||||
ClipMouse2Range();
|
||||
}
|
||||
|
||||
void SetMouseRange(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
DIRangeX1=x1; DIRangeY1=y1;
|
||||
DIRangeX2=x2; DIRangeY2=y2;
|
||||
ClipMouse2Range();
|
||||
}
|
||||
|
||||
void CenterMouse()
|
||||
{
|
||||
MouseX=(DIRangeX2-DIRangeX1)/2;
|
||||
MouseY=(DIRangeY2-DIRangeY1)/2;
|
||||
ClipMouse2Range();
|
||||
}
|
||||
|
||||
void DirectInputSyncAcquire(bool fActive)
|
||||
{
|
||||
if (g_pMouse)
|
||||
if (fActive)
|
||||
{
|
||||
if (g_pMouse->Acquire()==DI_OK) Log("DirectInput: sync acquired");
|
||||
else Log("DirectInput: sync acquire failure");
|
||||
}
|
||||
else
|
||||
{ g_pMouse->Unacquire(); Log("DirectInput: sync released"); }
|
||||
}
|
||||
|
||||
|
||||
void DirectInputCritical()
|
||||
{
|
||||
// Test for mouse input
|
||||
if (WaitForSingleObject(g_hevtMouse,0)!=WAIT_OBJECT_0) return;
|
||||
// Retrieve mouse input
|
||||
while (true)
|
||||
{
|
||||
DIDEVICEOBJECTDATA od;
|
||||
DWORD dwElements = 1;
|
||||
HRESULT hr = g_pMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);
|
||||
MouseStatus=hr;
|
||||
if (hr == DIERR_INPUTLOST)
|
||||
{ DirectInputSyncAcquire(true); return; }
|
||||
// Unable to read data or no data available
|
||||
if (FAILED(hr) || dwElements == 0) return;
|
||||
switch (od.dwOfs)
|
||||
{
|
||||
// Mouse horizontal motion
|
||||
case DIMOFS_X: DIMouseUpdatePosition(od.dwData, 0); break;
|
||||
// Mouse vertical motion
|
||||
case DIMOFS_Y: DIMouseUpdatePosition(0, od.dwData); break;
|
||||
// Button 0 pressed or released
|
||||
case DIMOFS_BUTTON0: MouseB0 = (od.dwData & 0x80); break;
|
||||
// Button 1 pressed or released
|
||||
case DIMOFS_BUTTON1: MouseB1 = (od.dwData & 0x80); break;
|
||||
// Button 1 pressed or released
|
||||
case DIMOFS_BUTTON2: MouseB2 = (od.dwData & 0x80); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //USE_DIRECTX
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 1998-2000 Matthes Bender
|
||||
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
*
|
||||
* Portions might be copyrighted by other authors who have contributed
|
||||
* to OpenClonk.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
* See isc_license.txt for full license and disclaimer.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender.
|
||||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
|
||||
/* A mouse handling wrapper to DirectInput */
|
||||
|
||||
extern int MouseX,MouseY,MouseB0,MouseB1,MouseB2;
|
||||
extern long MouseStatus;
|
||||
|
||||
void SetMouseRange(int x1, int y1, int x2, int y2);
|
||||
void CenterMouse();
|
||||
bool InitDirectInput(HINSTANCE g_hinst, HWND hwnd, int resx, int resy);
|
||||
void DeInitDirectInput();
|
||||
void DirectInputSyncAcquire(bool fActive);
|
||||
void DirectInputCritical();
|
||||
|
||||
|
||||
|
|
@ -1,333 +0,0 @@
|
|||
/* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
* Copyright (c) 1998-2000 Matthes Bender
|
||||
* Copyright (c) 2002 Sven Eberhardt
|
||||
* Copyright (c) 2004 Günther Brammer
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
"Clonk" is a registered trademark of Matthes Bender. */
|
||||
|
||||
/* A wrapper to DirectSound - derived from DXSDK samples */
|
||||
#ifdef USE_DIRECTX
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
|
||||
#include <DSoundX.h>
|
||||
|
||||
LPDIRECTSOUND lpDS = NULL;
|
||||
|
||||
bool InitDirectSound(HWND hwnd)
|
||||
{
|
||||
if (!SUCCEEDED(DirectSoundCreate(NULL, &lpDS, NULL)))
|
||||
return false;
|
||||
if (!SUCCEEDED(lpDS->SetCooperativeLevel(hwnd,DSSCL_NORMAL)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeInitDirectSound()
|
||||
{
|
||||
if (lpDS)
|
||||
{
|
||||
lpDS->Release();
|
||||
lpDS = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct CSoundObject
|
||||
{
|
||||
BYTE *pbWaveData; // pointer into wave resource (for restore)
|
||||
DWORD cbWaveSize; // size of wave data (for restore)
|
||||
int iAlloc; // number of buffers.
|
||||
int iCurrent; // current buffer
|
||||
IDirectSoundBuffer* Buffers[1]; // list of buffers
|
||||
};
|
||||
|
||||
bool DSGetWaveResource(BYTE *pvRes, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData,DWORD *pcbWaveSize)
|
||||
{
|
||||
DWORD *pdw;
|
||||
DWORD *pdwEnd;
|
||||
DWORD dwRiff;
|
||||
DWORD dwType;
|
||||
DWORD dwLength;
|
||||
|
||||
if (ppWaveHeader) *ppWaveHeader = NULL;
|
||||
if (ppbWaveData) *ppbWaveData = NULL;
|
||||
if (pcbWaveSize) *pcbWaveSize = 0;
|
||||
|
||||
pdw = (DWORD *)pvRes;
|
||||
dwRiff = *pdw++;
|
||||
dwLength = *pdw++;
|
||||
dwType = *pdw++;
|
||||
|
||||
if (dwRiff != mmioFOURCC('R', 'I', 'F', 'F')) goto exit;
|
||||
if (dwType != mmioFOURCC('W', 'A', 'V', 'E')) goto exit;
|
||||
pdwEnd = (DWORD *)((BYTE *)pdw + dwLength-4);
|
||||
|
||||
while (pdw < pdwEnd)
|
||||
{
|
||||
dwType = *pdw++;
|
||||
dwLength = *pdw++;
|
||||
switch (dwType)
|
||||
{
|
||||
case mmioFOURCC('f', 'm', 't', ' '):
|
||||
if (ppWaveHeader && !*ppWaveHeader)
|
||||
{
|
||||
if (dwLength < sizeof(WAVEFORMAT)) goto exit;
|
||||
*ppWaveHeader = (WAVEFORMATEX *)pdw;
|
||||
if ((!ppbWaveData || *ppbWaveData) && (!pcbWaveSize || *pcbWaveSize))
|
||||
{ return true; }
|
||||
}
|
||||
break;
|
||||
case mmioFOURCC('d', 'a', 't', 'a'):
|
||||
if ((ppbWaveData && !*ppbWaveData) || (pcbWaveSize && !*pcbWaveSize))
|
||||
{
|
||||
if (ppbWaveData) *ppbWaveData = (LPBYTE)pdw;
|
||||
if (pcbWaveSize) *pcbWaveSize = dwLength;
|
||||
if (!ppWaveHeader || *ppWaveHeader) return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
pdw = (DWORD *)((BYTE *)pdw + ((dwLength+1)&~1));
|
||||
}
|
||||
|
||||
exit:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD cbWaveSize)
|
||||
{
|
||||
if (pDSB && pbWaveData && cbWaveSize)
|
||||
{
|
||||
LPVOID pMem1, pMem2;
|
||||
DWORD dwSize1, dwSize2;
|
||||
if (SUCCEEDED(pDSB->Lock( 0, cbWaveSize, &pMem1, &dwSize1, &pMem2, &dwSize2, 0)))
|
||||
{
|
||||
CopyMemory(pMem1, pbWaveData, dwSize1);
|
||||
if ( 0 != dwSize2 ) CopyMemory(pMem2, pbWaveData+dwSize1, dwSize2);
|
||||
pDSB->Unlock( pMem1, dwSize1, pMem2, dwSize2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IDirectSoundBuffer *DSLoadSoundBuffer(IDirectSound *pDS, BYTE *bpWaveBuf)
|
||||
{
|
||||
IDirectSoundBuffer *pDSB = NULL;
|
||||
DSBUFFERDESC dsBD = {0};
|
||||
BYTE *pbWaveData;
|
||||
if (DSGetWaveResource(bpWaveBuf, &dsBD.lpwfxFormat, &pbWaveData, &dsBD.dwBufferBytes ))
|
||||
{
|
||||
dsBD.dwSize = sizeof(dsBD);
|
||||
dsBD.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2;
|
||||
if (SUCCEEDED(pDS->CreateSoundBuffer(&dsBD, &pDSB, NULL)))
|
||||
{
|
||||
if (!DSFillSoundBuffer(pDSB, pbWaveData, dsBD.dwBufferBytes))
|
||||
{ pDSB->Release(); pDSB = NULL; }
|
||||
}
|
||||
else
|
||||
{
|
||||
pDSB = NULL;
|
||||
}
|
||||
}
|
||||
return pDSB;
|
||||
}
|
||||
|
||||
CSoundObject *DSndObjCreate(BYTE *bpWaveBuf, int iConcurrent)
|
||||
{
|
||||
CSoundObject *pSO = NULL;
|
||||
LPWAVEFORMATEX pWaveHeader;
|
||||
BYTE *pbData;
|
||||
DWORD cbData;
|
||||
|
||||
IDirectSound *pDS = lpDS;
|
||||
|
||||
if (DSGetWaveResource(bpWaveBuf, &pWaveHeader, &pbData, &cbData))
|
||||
{
|
||||
// Minimum one concurrent buffer
|
||||
if (iConcurrent < 1) iConcurrent = 1;
|
||||
|
||||
// Allocate sound object + buffer space
|
||||
if ((pSO = (CSoundObject *)LocalAlloc(LPTR, sizeof(CSoundObject) +
|
||||
(iConcurrent-1) * sizeof(IDirectSoundBuffer *))) != NULL)
|
||||
{
|
||||
int i;
|
||||
pSO->iAlloc = iConcurrent;
|
||||
pSO->pbWaveData = pbData;
|
||||
pSO->cbWaveSize = cbData;
|
||||
pSO->Buffers[0] = DSLoadSoundBuffer(pDS, bpWaveBuf);
|
||||
if (!pSO->Buffers[0])
|
||||
{
|
||||
DSndObjDestroy(pSO); return NULL;
|
||||
}
|
||||
// Load buffers
|
||||
for (i=1; i<pSO->iAlloc; i++)
|
||||
{
|
||||
if (FAILED(pDS->DuplicateSoundBuffer(pSO->Buffers[0], &pSO->Buffers[i])))
|
||||
{
|
||||
pSO->Buffers[i] = DSLoadSoundBuffer(pDS, bpWaveBuf);
|
||||
if (!pSO->Buffers[i]) { DSndObjDestroy(pSO); pSO = NULL; break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return sound object
|
||||
return pSO;
|
||||
}
|
||||
|
||||
void DSndObjDestroy(CSoundObject *pSO)
|
||||
{
|
||||
if (!pSO) return;
|
||||
|
||||
int i;
|
||||
for (i=0; i<pSO->iAlloc; i++)
|
||||
{
|
||||
if (pSO->Buffers[i])
|
||||
{
|
||||
pSO->Buffers[i]->Release();
|
||||
pSO->Buffers[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree((HANDLE)pSO);
|
||||
}
|
||||
|
||||
IDirectSoundBuffer *DSndObjGetFreeBuffer(CSoundObject *pSO)
|
||||
{
|
||||
IDirectSoundBuffer *pDSB;
|
||||
|
||||
if (pSO == NULL) return NULL;
|
||||
|
||||
// Check current buffer
|
||||
if (pDSB = pSO->Buffers[pSO->iCurrent])
|
||||
{
|
||||
HRESULT hres;
|
||||
DWORD dwStatus;
|
||||
|
||||
hres = pDSB->GetStatus(&dwStatus);
|
||||
if (FAILED(hres)) dwStatus = 0;
|
||||
|
||||
// Buffer is playing
|
||||
if ((dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
|
||||
{
|
||||
// More buffers available, try next one
|
||||
if (pSO->iAlloc > 1)
|
||||
{
|
||||
if (++pSO->iCurrent >= pSO->iAlloc) pSO->iCurrent = 0;
|
||||
pDSB = pSO->Buffers[pSO->iCurrent];
|
||||
hres = pDSB->GetStatus(&dwStatus);
|
||||
// Next buffer is non-playing, use this one
|
||||
if (SUCCEEDED(hres) && (dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
|
||||
{
|
||||
pDSB->Stop();
|
||||
pDSB->SetCurrentPosition(0);
|
||||
}
|
||||
}
|
||||
// Only one buffer available
|
||||
else
|
||||
{
|
||||
pDSB = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Buffer was lost
|
||||
if (pDSB && (dwStatus & DSBSTATUS_BUFFERLOST))
|
||||
{
|
||||
// Try restore
|
||||
if (FAILED(pDSB->Restore()) || !DSFillSoundBuffer(pDSB, pSO->pbWaveData, pSO->cbWaveSize))
|
||||
{
|
||||
// Restore failed
|
||||
pDSB = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return current, non-playing buffer, or NULL if failure
|
||||
return pDSB;
|
||||
}
|
||||
|
||||
bool DSndObjPlay(CSoundObject *pSO, DWORD dwPlayFlags)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (!pSO) return false;
|
||||
|
||||
if ( !(dwPlayFlags & DSBPLAY_LOOPING) || (pSO->iAlloc==1) )
|
||||
{
|
||||
// Get free buffer, play that
|
||||
IDirectSoundBuffer *pDSB = DSndObjGetFreeBuffer(pSO);
|
||||
if (pDSB)
|
||||
result = SUCCEEDED(pDSB->Play(0, 0, dwPlayFlags));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DSndObjPlaying(CSoundObject *pSO)
|
||||
{
|
||||
bool result,fPlaying=false;
|
||||
DWORD dwStatus;
|
||||
int i;
|
||||
if (pSO)
|
||||
for (i=0; i<pSO->iAlloc; i++)
|
||||
{
|
||||
result=pSO->Buffers[i]->GetStatus(&dwStatus);
|
||||
if (FAILED(result)) dwStatus=0;
|
||||
if ((dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
|
||||
fPlaying=true;
|
||||
}
|
||||
return fPlaying;
|
||||
}
|
||||
|
||||
bool DSndObjSetVolume(CSoundObject *pSO, long lVolume)
|
||||
{
|
||||
bool result,fSuccess=true;
|
||||
if (pSO)
|
||||
for (int i=0; i<pSO->iAlloc; i++)
|
||||
{
|
||||
result=pSO->Buffers[i]->SetVolume(lVolume);
|
||||
if (FAILED(result)) fSuccess=false;
|
||||
}
|
||||
return fSuccess;
|
||||
}
|
||||
|
||||
bool DSndObjGetVolume(CSoundObject *pSO, long *lpVolume)
|
||||
{
|
||||
bool result,fSuccess=true;
|
||||
if (pSO)
|
||||
{
|
||||
result=pSO->Buffers[0]->GetVolume(lpVolume);
|
||||
if (FAILED(result)) fSuccess=false;
|
||||
}
|
||||
return fSuccess;
|
||||
}
|
||||
|
||||
bool DSndObjStop(CSoundObject *pSO)
|
||||
{
|
||||
int i;
|
||||
if (!pSO) return false;
|
||||
for (i=0; i<pSO->iAlloc; i++)
|
||||
{
|
||||
pSO->Buffers[i]->Stop();
|
||||
pSO->Buffers[i]->SetCurrentPosition(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif //USE_DIRECTX
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 1998-2000 Matthes Bender
|
||||
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
*
|
||||
* Portions might be copyrighted by other authors who have contributed
|
||||
* to OpenClonk.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
* See isc_license.txt for full license and disclaimer.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender.
|
||||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
|
||||
/* A wrapper to DirectSound - derived from DXSDK samples */
|
||||
|
||||
struct CSoundObject;
|
||||
|
||||
CSoundObject *DSndObjCreate(BYTE *bpWaveBuf, int iConcurrent = 1);
|
||||
bool DSndObjPlay(CSoundObject *hSO, DWORD dwPlayFlags);
|
||||
bool DSndObjStop(CSoundObject *hSO);
|
||||
bool DSndObjPlaying(CSoundObject *hSO);
|
||||
void DSndObjDestroy(CSoundObject *hSO);
|
||||
bool DSndObjSetVolume(CSoundObject *pSO, long lVolume);
|
||||
|
||||
#define DSBPLAY_LOOPING 0x00000001
|
Loading…
Reference in New Issue