Compile SoundCore from AW.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
259428a946
commit
04ef0bf377
20 changed files with 276 additions and 235 deletions
|
@ -1,6 +1,8 @@
|
|||
include(FindPkgConfig)
|
||||
|
||||
add_library(appleii SHARED
|
||||
|
||||
SoundCore.cpp
|
||||
AY8910.cpp
|
||||
Mockingboard.cpp
|
||||
|
||||
|
@ -42,6 +44,8 @@ add_library(appleii SHARED
|
|||
linux/windows/winbase.cpp
|
||||
linux/windows/winuser.cpp
|
||||
linux/windows/dsound.cpp
|
||||
linux/windows/guiddef.cpp
|
||||
linux/windows/dmusicc.cpp
|
||||
|
||||
linux/data.cpp
|
||||
linux/benchmark.cpp
|
||||
|
@ -52,7 +56,6 @@ add_library(appleii SHARED
|
|||
|
||||
linux/duplicates/Debug.cpp
|
||||
linux/duplicates/Video.cpp
|
||||
linux/duplicates/SoundCore.cpp
|
||||
linux/duplicates/Joystick.cpp
|
||||
linux/duplicates/Frame.cpp
|
||||
linux/duplicates/SerialComms.cpp
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include "YamlHelper.h"
|
||||
#include "Common.h"
|
||||
|
||||
void MB_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot4, UINT uSlot5)
|
||||
{
|
||||
}
|
||||
|
||||
void MB_UpdateCycles(ULONG uExecutedCycles)
|
||||
{
|
||||
}
|
||||
|
||||
void MB_StartOfCpuExecute()
|
||||
{
|
||||
}
|
||||
|
||||
void MB_SetCumulativeCycles()
|
||||
{
|
||||
}
|
||||
|
||||
void MB_SaveSnapshot(YamlSaveHelper&, unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
bool MB_LoadSnapshot(class YamlLoadHelper&, UINT, UINT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MB_Reset()
|
||||
{
|
||||
}
|
||||
|
||||
void MB_InitializeForLoadingSnapshot()
|
||||
{
|
||||
}
|
||||
|
||||
bool Phasor_LoadSnapshot(class YamlLoadHelper&, UINT, UINT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Phasor_SaveSnapshot(YamlSaveHelper&, unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
std::string MB_GetSnapshotCardName()
|
||||
{
|
||||
return "Mockingboard C";
|
||||
}
|
||||
|
||||
std::string Phasor_GetSnapshotCardName()
|
||||
{
|
||||
return "Phasor";
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "SoundCore.h"
|
||||
#include "Log.h"
|
||||
|
||||
|
||||
bool g_bDSAvailable = false;
|
||||
static int g_nErrorInc = 20; // Old: 1
|
||||
|
||||
bool DSZeroVoiceWritableBuffer(PVOICE Voice, const char* pszDevName, DWORD dwBufferSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void DSReleaseSoundBuffer(VOICE* pVoice)
|
||||
{
|
||||
delete pVoice->lpDSBvoice;
|
||||
pVoice->lpDSBvoice = nullptr;
|
||||
}
|
||||
|
||||
int SoundCore_GetErrorInc()
|
||||
{
|
||||
return g_nErrorInc;
|
||||
}
|
||||
|
||||
LONG NewVolume(DWORD dwVolume, DWORD dwVolumeMax)
|
||||
{
|
||||
float fVol = (float) dwVolume / (float) dwVolumeMax; // 0.0=Max, 1.0=Min
|
||||
|
||||
return (LONG) ((float) DSBVOLUME_MIN * fVol);
|
||||
}
|
||||
|
||||
HRESULT DSGetSoundBuffer(VOICE* pVoice, DWORD dwFlags, DWORD dwBufferSize, DWORD nSampleRate, int nChannels)
|
||||
{
|
||||
IDirectSoundBuffer * dsVoice = new IDirectSoundBuffer;
|
||||
|
||||
dsVoice->flags = dwFlags;
|
||||
dsVoice->bufferSize = dwBufferSize;
|
||||
dsVoice->sampleRate = nSampleRate;
|
||||
dsVoice->channels = nChannels;
|
||||
dsVoice->soundBuffer.resize(dwBufferSize);
|
||||
|
||||
pVoice->lpDSBvoice = dsVoice;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
bool DSInit()
|
||||
{
|
||||
g_bDSAvailable = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void DSUninit()
|
||||
{
|
||||
g_bDSAvailable = false;
|
||||
}
|
||||
|
||||
bool DSZeroVoiceBuffer(PVOICE Voice, const char* pszDevName, DWORD dwBufferSize)
|
||||
{
|
||||
#ifdef NO_DIRECT_X
|
||||
|
||||
return false;
|
||||
|
||||
#else
|
||||
|
||||
DWORD dwDSLockedBufferSize = 0; // Size of the locked DirectSound buffer
|
||||
SHORT* pDSLockedBuffer;
|
||||
|
||||
_ASSERT(Voice->lpDSBvoice);
|
||||
HRESULT hr = Voice->lpDSBvoice->Stop();
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if(g_fh) fprintf(g_fh, "%s: DSStop failed (%08X)\n",pszDevName,hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = DSGetLock(Voice->lpDSBvoice, 0, 0, &pDSLockedBuffer, &dwDSLockedBufferSize, NULL, 0);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if(g_fh) fprintf(g_fh, "%s: DSGetLock failed (%08X)\n",pszDevName,hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
_ASSERT(dwDSLockedBufferSize == dwBufferSize);
|
||||
memset(pDSLockedBuffer, 0x00, dwDSLockedBufferSize);
|
||||
|
||||
hr = Voice->lpDSBvoice->Unlock((void*)pDSLockedBuffer, dwDSLockedBufferSize, NULL, 0);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if(g_fh) fprintf(g_fh, "%s: DSUnlock failed (%08X)\n",pszDevName,hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = Voice->lpDSBvoice->Play(0,0,DSBPLAY_LOOPING);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if(g_fh) fprintf(g_fh, "%s: DSPlay failed (%08X)\n",pszDevName,hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif // NO_DIRECT_X
|
||||
}
|
||||
|
||||
bool DSGetLock(LPDIRECTSOUNDBUFFER pVoice, DWORD dwOffset, DWORD dwBytes,
|
||||
SHORT** ppDSLockedBuffer0, DWORD* pdwDSLockedBufferSize0,
|
||||
SHORT** ppDSLockedBuffer1, DWORD* pdwDSLockedBufferSize1)
|
||||
{
|
||||
DWORD nStatus;
|
||||
HRESULT hr = pVoice->GetStatus(&nStatus);
|
||||
if(hr != DS_OK)
|
||||
return false;
|
||||
|
||||
if(nStatus & DSBSTATUS_BUFFERLOST)
|
||||
{
|
||||
do
|
||||
{
|
||||
hr = pVoice->Restore();
|
||||
if(hr == DSERR_BUFFERLOST)
|
||||
Sleep(10);
|
||||
}
|
||||
while(hr != DS_OK);
|
||||
}
|
||||
|
||||
// Get write only pointer(s) to sound buffer
|
||||
if(dwBytes == 0)
|
||||
{
|
||||
if(FAILED(hr = pVoice->Lock(0, 0,
|
||||
(void**)ppDSLockedBuffer0, pdwDSLockedBufferSize0,
|
||||
(void**)ppDSLockedBuffer1, pdwDSLockedBufferSize1,
|
||||
DSBLOCK_ENTIREBUFFER)))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FAILED(hr = pVoice->Lock(dwOffset, dwBytes,
|
||||
(void**)ppDSLockedBuffer0, pdwDSLockedBufferSize0,
|
||||
(void**)ppDSLockedBuffer1, pdwDSLockedBufferSize1,
|
||||
0)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -10,3 +10,7 @@ void SpkrLoadSnapshot(YamlLoadHelper&)
|
|||
void SpkrSaveSnapshot(YamlSaveHelper&)
|
||||
{
|
||||
}
|
||||
|
||||
void SpkrUpdate_Timer()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "linux/windows/wincompat.h"
|
||||
#include "linux/windows/guiddef.h"
|
||||
#include "linux/windows/memory.h"
|
||||
#include "linux/windows/handles.h"
|
||||
#include "linux/windows/bitmap.h"
|
||||
|
@ -16,3 +17,6 @@
|
|||
#include "linux/windows/winuser.h"
|
||||
#include "linux/windows/dsound.h"
|
||||
#include "linux/windows/winerror.h"
|
||||
#include "linux/windows/mmreg.h"
|
||||
#include "linux/windows/mmsystem.h"
|
||||
#include "linux/windows/dmusicc.h"
|
||||
|
|
17
source/linux/windows/dmusicc.cpp
Normal file
17
source/linux/windows/dmusicc.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "linux/windows/dmusicc.h"
|
||||
#include "linux/windows/winerror.h"
|
||||
|
||||
HRESULT IReferenceClock::GetTime(REFERENCE_TIME *pTime)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT IReferenceClock::AdvisePeriodic(REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HSEMAPHORE hSemaphore, DWORD *pdwAdviseCookie)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT IReferenceClock::Unadvise(DWORD dwAdviseCookie)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
13
source/linux/windows/dmusicc.h
Normal file
13
source/linux/windows/dmusicc.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "linux/windows/winbase.h"
|
||||
#include "linux/windows/handles.h"
|
||||
#include "linux/windows/guiddef.h"
|
||||
|
||||
typedef LONGLONG REFERENCE_TIME;
|
||||
struct IReferenceClock : public IUnknown
|
||||
{
|
||||
HRESULT GetTime(REFERENCE_TIME *pTime);
|
||||
HRESULT AdvisePeriodic(REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HSEMAPHORE hSemaphore, DWORD *pdwAdviseCookie);
|
||||
HRESULT Unadvise(DWORD dwAdviseCookie);
|
||||
};
|
|
@ -1,12 +1,21 @@
|
|||
#include "linux/windows/dsound.h"
|
||||
#include "linux/windows/winerror.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
HRESULT IDirectSoundNotify::SetNotificationPositions(DWORD cPositionNotifies, LPCDSBPOSITIONNOTIFY lpcPositionNotifies)
|
||||
{
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
IDirectSoundBuffer::IDirectSoundBuffer(): soundNotify(new IDirectSoundNotify)
|
||||
IDirectSoundBuffer::IDirectSoundBuffer(const size_t bufferSize, const size_t channels, const size_t sampleRate, const size_t bitsPerSample, const size_t flags)
|
||||
: myBufferSize(bufferSize)
|
||||
, myChannels(channels)
|
||||
, mySampleRate(sampleRate)
|
||||
, myBitsPerSample(bitsPerSample)
|
||||
, myFlags(flags)
|
||||
, mySoundNotify(new IDirectSoundNotify)
|
||||
, mySoundBuffer(bufferSize)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,7 +23,7 @@ HRESULT IDirectSoundBuffer::QueryInterface(int riid, void **ppvObject)
|
|||
{
|
||||
if (riid == IID_IDirectSoundNotify)
|
||||
{
|
||||
*ppvObject = soundNotify.get();
|
||||
*ppvObject = mySoundNotify.get();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -24,14 +33,14 @@ HRESULT IDirectSoundBuffer::QueryInterface(int riid, void **ppvObject)
|
|||
HRESULT IDirectSoundBuffer::Unlock( LPVOID lpvAudioPtr1, DWORD dwAudioBytes1, LPVOID lpvAudioPtr2, DWORD dwAudioBytes2 )
|
||||
{
|
||||
const size_t totalWrittenBytes = dwAudioBytes1 + dwAudioBytes2;
|
||||
writePosition = (writePosition + totalWrittenBytes) % this->soundBuffer.size();
|
||||
this->myWritePosition = (this->myWritePosition + totalWrittenBytes) % this->mySoundBuffer.size();
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT IDirectSoundBuffer::Stop()
|
||||
{
|
||||
const DWORD mask = DSBSTATUS_PLAYING | DSBSTATUS_LOOPING;
|
||||
this->status &= ~mask;
|
||||
this->myStatus &= ~mask;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
|
@ -42,23 +51,23 @@ HRESULT IDirectSoundBuffer::SetCurrentPosition( DWORD dwNewPosition )
|
|||
|
||||
HRESULT IDirectSoundBuffer::Play( DWORD dwReserved1, DWORD dwReserved2, DWORD dwFlags )
|
||||
{
|
||||
this->status |= DSBSTATUS_PLAYING;
|
||||
this->myStatus |= DSBSTATUS_PLAYING;
|
||||
if (dwFlags & DSBPLAY_LOOPING)
|
||||
{
|
||||
this->status |= DSBSTATUS_LOOPING;
|
||||
this->myStatus |= DSBSTATUS_LOOPING;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT IDirectSoundBuffer::SetVolume( LONG lVolume )
|
||||
{
|
||||
this->volume = lVolume;
|
||||
this->myVolume = lVolume;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT IDirectSoundBuffer::GetStatus( LPDWORD lpdwStatus )
|
||||
{
|
||||
*lpdwStatus = this->status;
|
||||
*lpdwStatus = this->myStatus;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
|
@ -71,8 +80,8 @@ HRESULT IDirectSoundBuffer::Lock( DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOI
|
|||
{
|
||||
if (dwFlags & DSBLOCK_ENTIREBUFFER)
|
||||
{
|
||||
*lplpvAudioPtr1 = this->soundBuffer.data();
|
||||
*lpdwAudioBytes1 = this->soundBuffer.size();
|
||||
*lplpvAudioPtr1 = this->mySoundBuffer.data();
|
||||
*lpdwAudioBytes1 = this->mySoundBuffer.size();
|
||||
if (lplpvAudioPtr2 && lpdwAudioBytes2)
|
||||
{
|
||||
*lplpvAudioPtr2 = nullptr;
|
||||
|
@ -81,16 +90,16 @@ HRESULT IDirectSoundBuffer::Lock( DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOI
|
|||
}
|
||||
else
|
||||
{
|
||||
const DWORD availableInFirstPart = this->soundBuffer.size() - dwWriteCursor;
|
||||
const DWORD availableInFirstPart = this->mySoundBuffer.size() - dwWriteCursor;
|
||||
|
||||
*lplpvAudioPtr1 = this->soundBuffer.data() + dwWriteCursor;
|
||||
*lplpvAudioPtr1 = this->mySoundBuffer.data() + dwWriteCursor;
|
||||
*lpdwAudioBytes1 = std::min(availableInFirstPart, dwWriteBytes);
|
||||
|
||||
if (lplpvAudioPtr2 && lpdwAudioBytes2)
|
||||
{
|
||||
if (*lpdwAudioBytes1 < dwWriteBytes)
|
||||
{
|
||||
*lplpvAudioPtr2 = this->soundBuffer.data();
|
||||
*lplpvAudioPtr2 = this->mySoundBuffer.data();
|
||||
*lpdwAudioBytes2 = std::min(dwWriteCursor, dwWriteBytes - *lpdwAudioBytes1);
|
||||
}
|
||||
else
|
||||
|
@ -106,7 +115,50 @@ HRESULT IDirectSoundBuffer::Lock( DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOI
|
|||
|
||||
HRESULT IDirectSoundBuffer::GetCurrentPosition( LPDWORD lpdwCurrentPlayCursor, LPDWORD lpdwCurrentWriteCursor )
|
||||
{
|
||||
*lpdwCurrentPlayCursor = this->writePosition;
|
||||
*lpdwCurrentWriteCursor = this->writePosition;
|
||||
*lpdwCurrentPlayCursor = this->myWritePosition;
|
||||
*lpdwCurrentWriteCursor = this->myWritePosition;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT IDirectSoundBuffer::GetVolume( LONG * lplVolume )
|
||||
{
|
||||
*lplVolume = this->myVolume;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND* ppDS, LPUNKNOWN pUnkOuter)
|
||||
{
|
||||
*ppDS = new IDirectSound();
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT DirectSoundEnumerate(LPDSENUMCALLBACK lpDSEnumCallback, LPVOID lpContext)
|
||||
{
|
||||
GUID guid = 123;
|
||||
lpDSEnumCallback(&guid, "audio", "linux", lpContext);
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT IDirectSound::CreateSoundBuffer( LPCDSBUFFERDESC lpcDSBufferDesc, IDirectSoundBuffer **lplpDirectSoundBuffer, IUnknown FAR* pUnkOuter )
|
||||
{
|
||||
const size_t bufferSize = lpcDSBufferDesc->dwBufferBytes;
|
||||
const size_t channels = lpcDSBufferDesc->lpwfxFormat->nChannels;
|
||||
const size_t sampleRate = lpcDSBufferDesc->lpwfxFormat->nSamplesPerSec;
|
||||
const size_t bitsPerSample = lpcDSBufferDesc->lpwfxFormat->wBitsPerSample;
|
||||
const size_t flags = lpcDSBufferDesc->dwFlags;
|
||||
IDirectSoundBuffer * dsb = new IDirectSoundBuffer(bufferSize, channels, sampleRate, bitsPerSample, flags);
|
||||
|
||||
*lplpDirectSoundBuffer = dsb;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT IDirectSound::SetCooperativeLevel( HWND hwnd, DWORD dwLevel )
|
||||
{
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
HRESULT IDirectSound::GetCaps(LPDSCCAPS pDSCCaps)
|
||||
{
|
||||
memset(pDSCCaps, 0, sizeof(*pDSCCaps));
|
||||
return DS_OK;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "linux/windows/winbase.h"
|
||||
#include "linux/windows/winerror.h"
|
||||
#include "linux/windows/mmreg.h"
|
||||
#include "linux/windows/guiddef.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
@ -11,8 +13,10 @@
|
|||
#define DSBPN_OFFSETSTOP -1
|
||||
|
||||
#define DSBCAPS_CTRLVOLUME 0x00000080
|
||||
#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100
|
||||
#define DSBCAPS_LOCSOFTWARE 0x00000008
|
||||
#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100
|
||||
#define DSBCAPS_STICKYFOCUS 0x00004000
|
||||
#define DSBCAPS_GETCURRENTPOSITION2 0x00010000
|
||||
|
||||
#define DSBVOLUME_MIN -10000
|
||||
#define DSBVOLUME_MAX 0
|
||||
|
@ -30,10 +34,36 @@
|
|||
#define _FACDS 0x878
|
||||
#define MAKE_DSHRESULT(code) MAKE_HRESULT(1,_FACDS,code)
|
||||
|
||||
#define DSSCL_NORMAL 1
|
||||
|
||||
typedef BOOL (CALLBACK *LPDSENUMCALLBACK)(LPGUID,LPCSTR,LPCSTR,LPVOID);
|
||||
|
||||
HRESULT DirectSoundEnumerate(LPDSENUMCALLBACK lpDSEnumCallback, LPVOID lpContext);
|
||||
|
||||
typedef struct {
|
||||
DWORD dwSize;
|
||||
DWORD dwFlags;
|
||||
DWORD dwFormats;
|
||||
DWORD dwChannels;
|
||||
} DSCCAPS, DSCAPS, *LPDSCCAPS;
|
||||
|
||||
typedef const DSCCAPS *LPCDSCCAPS;
|
||||
|
||||
typedef struct _DSBUFFERDESC
|
||||
{
|
||||
DWORD dwSize;
|
||||
DWORD dwFlags;
|
||||
DWORD dwBufferBytes;
|
||||
DWORD dwReserved;
|
||||
LPWAVEFORMATEX lpwfxFormat;
|
||||
GUID guid3DAlgorithm;
|
||||
} DSBUFFERDESC,*LPDSBUFFERDESC;
|
||||
typedef const DSBUFFERDESC *LPCDSBUFFERDESC;
|
||||
|
||||
typedef struct _DSBPOSITIONNOTIFY
|
||||
{
|
||||
DWORD dwOffset;
|
||||
HANDLE hEventNotify;
|
||||
DWORD dwOffset;
|
||||
HANDLE hEventNotify;
|
||||
} DSBPOSITIONNOTIFY,*LPDSBPOSITIONNOTIFY;
|
||||
typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY;
|
||||
|
||||
|
@ -43,22 +73,24 @@ struct IDirectSoundNotify
|
|||
};
|
||||
typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY,**LPLPDIRECTSOUNDNOTIFY;
|
||||
|
||||
struct IDirectSoundBuffer
|
||||
class IDirectSoundBuffer : public IUnknown
|
||||
{
|
||||
std::unique_ptr<IDirectSoundNotify> soundNotify;
|
||||
std::vector<SHORT> soundBuffer;
|
||||
const size_t myBufferSize;
|
||||
const size_t mySampleRate;
|
||||
const size_t myChannels;
|
||||
const size_t myBitsPerSample;
|
||||
const size_t myFlags;
|
||||
|
||||
size_t playPosition = 0;
|
||||
size_t writePosition = 0;
|
||||
std::unique_ptr<IDirectSoundNotify> mySoundNotify;
|
||||
std::vector<SHORT> mySoundBuffer;
|
||||
|
||||
LONG volume = DSBVOLUME_MIN;
|
||||
DWORD flags = 0;
|
||||
DWORD bufferSize = 0;
|
||||
DWORD sampleRate = 0;
|
||||
WORD status = 0;
|
||||
int channels = 0;
|
||||
size_t myPlayPosition = 0;
|
||||
size_t myWritePosition = 0;
|
||||
WORD myStatus = 0;
|
||||
LONG myVolume = DSBVOLUME_MIN;
|
||||
|
||||
IDirectSoundBuffer();
|
||||
public:
|
||||
IDirectSoundBuffer(const size_t bufferSize, const size_t channels, const size_t sampleRate, const size_t bitsPerSample, const size_t flags);
|
||||
|
||||
HRESULT QueryInterface(int riid, void **ppvObject);
|
||||
|
||||
|
@ -72,8 +104,19 @@ struct IDirectSoundBuffer
|
|||
HRESULT Play( DWORD dwReserved1, DWORD dwReserved2, DWORD dwFlags );
|
||||
|
||||
HRESULT SetVolume( LONG lVolume );
|
||||
HRESULT GetVolume( LONG * lplVolume );
|
||||
|
||||
HRESULT GetStatus( LPDWORD lpdwStatus );
|
||||
HRESULT Restore();
|
||||
};
|
||||
typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER,**LPLPDIRECTSOUNDBUFFER;
|
||||
|
||||
struct IDirectSound : public IUnknown
|
||||
{
|
||||
HRESULT CreateSoundBuffer( LPCDSBUFFERDESC lpcDSBufferDesc, IDirectSoundBuffer **lplpDirectSoundBuffer, IUnknown FAR* pUnkOuter );
|
||||
HRESULT SetCooperativeLevel( HWND hwnd, DWORD dwLevel );
|
||||
HRESULT GetCaps(LPDSCCAPS pDSCCaps);
|
||||
};
|
||||
typedef struct IDirectSound *LPDIRECTSOUND;
|
||||
|
||||
HRESULT WINAPI DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND* ppDS, LPUNKNOWN pUnkOuter);
|
||||
|
|
24
source/linux/windows/guiddef.cpp
Normal file
24
source/linux/windows/guiddef.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "linux/windows/guiddef.h"
|
||||
#include "linux/windows/winerror.h"
|
||||
|
||||
HRESULT IUnknown::QueryInterface(int riid, void **ppvObject)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT IUnknown::Release()
|
||||
{
|
||||
delete this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoCreateInstance(
|
||||
REFCLSID rclsid,
|
||||
LPUNKNOWN pUnkOuter,
|
||||
DWORD dwClsContext,
|
||||
REFIID riid,
|
||||
LPVOID *ppv
|
||||
)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
27
source/linux/windows/guiddef.h
Normal file
27
source/linux/windows/guiddef.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "linux/windows/wincompat.h"
|
||||
|
||||
typedef int GUID;
|
||||
typedef GUID *LPGUID;
|
||||
typedef GUID REFCLSID;
|
||||
typedef GUID REFIID;
|
||||
|
||||
#define CLSCTX_INPROC 0
|
||||
#define CLSID_SystemClock 1
|
||||
#define IID_IReferenceClock 2
|
||||
|
||||
struct IUnknown
|
||||
{
|
||||
HRESULT QueryInterface(int riid, void **ppvObject);
|
||||
HRESULT Release();
|
||||
};
|
||||
typedef IUnknown *LPUNKNOWN;
|
||||
|
||||
HRESULT CoCreateInstance(
|
||||
REFCLSID rclsid,
|
||||
LPUNKNOWN pUnkOuter,
|
||||
DWORD dwClsContext,
|
||||
REFIID riid,
|
||||
LPVOID *ppv
|
||||
);
|
|
@ -23,5 +23,7 @@ typedef void * LPDIRECTDRAW;
|
|||
typedef void * LPOVERLAPPED;
|
||||
typedef void * OVERLAPPED;
|
||||
typedef void * LPSECURITY_ATTRIBUTES;
|
||||
typedef void * HSEMAPHORE;
|
||||
|
||||
|
||||
BOOL CloseHandle(HANDLE hObject);
|
||||
|
|
13
source/linux/windows/mmreg.h
Normal file
13
source/linux/windows/mmreg.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "linux/windows/wincompat.h"
|
||||
|
||||
typedef struct _WAVEFORMATEX {
|
||||
WORD wFormatTag;
|
||||
WORD nChannels;
|
||||
DWORD nSamplesPerSec;
|
||||
DWORD nAvgBytesPerSec;
|
||||
WORD nBlockAlign;
|
||||
WORD wBitsPerSample;
|
||||
WORD cbSize;
|
||||
} WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
|
3
source/linux/windows/mmsystem.h
Normal file
3
source/linux/windows/mmsystem.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#define WAVE_FORMAT_PCM 1
|
|
@ -41,6 +41,11 @@ DWORD WINAPI WaitForMultipleObjects(DWORD,const HANDLE*,BOOL,DWORD)
|
|||
return WAIT_FAILED;
|
||||
}
|
||||
|
||||
DWORD WINAPI WaitForSingleObject(const HANDLE,DWORD)
|
||||
{
|
||||
return WAIT_FAILED;
|
||||
}
|
||||
|
||||
BOOL WINAPI GetExitCodeThread(HANDLE,LPDWORD code)
|
||||
{
|
||||
*code = 0;
|
||||
|
@ -79,3 +84,13 @@ BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER*counter)
|
|||
counter->QuadPart = ms.count();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HANDLE CreateSemaphore(
|
||||
LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
|
||||
LONG lInitialCount,
|
||||
LONG lMaximumCount,
|
||||
LPCSTR lpName
|
||||
)
|
||||
{
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef DWORD (CALLBACK *LPTHREAD_START_ROUTINE)(LPVOID);
|
|||
typedef size_t SIZE_T;
|
||||
|
||||
BOOL WINAPI SetThreadPriority(HANDLE,INT);
|
||||
DWORD WINAPI WaitForSingleObject(const HANDLE,DWORD);
|
||||
DWORD WINAPI WaitForMultipleObjects(DWORD,const HANDLE*,BOOL,DWORD);
|
||||
BOOL WINAPI GetExitCodeThread(HANDLE,LPDWORD);
|
||||
BOOL WINAPI SetEvent(HANDLE);
|
||||
|
@ -46,3 +47,10 @@ typedef union _LARGE_INTEGER {
|
|||
} LARGE_INTEGER;
|
||||
|
||||
BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER*);
|
||||
|
||||
HANDLE CreateSemaphore(
|
||||
LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
|
||||
LONG lInitialCount,
|
||||
LONG lMaximumCount,
|
||||
LPCSTR lpName
|
||||
);
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef signed short INT16; // why there was char instead of short? --bb ??????
|
|||
typedef unsigned short UINT16; // why there was char instead of short? --bb ??????????????????? 0_0
|
||||
#define __int64 long long
|
||||
|
||||
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
|
||||
typedef long long LONGLONG;
|
||||
|
||||
typedef unsigned int UINT32;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#define FAILED(stat) ((HRESULT)(stat)<0)
|
||||
#define E_NOINTERFACE HRESULT(0x80004002)
|
||||
#define S_OK HRESULT(0)
|
||||
#define S_FALSE HRESULT(1)
|
||||
#define SEVERITY_SUCCESS 0
|
||||
#define SEVERITY_ERROR 1
|
||||
|
||||
|
|
|
@ -14,3 +14,13 @@ HWND GetDesktopWindow()
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UINT_PTR SetTimer(HWND,UINT_PTR,UINT,TIMERPROC)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL KillTimer(HWND hWnd, UINT uIDEvent)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -8,3 +8,8 @@ typedef void * HCURSOR;
|
|||
|
||||
HCURSOR LoadCursor(HINSTANCE hInstance, LPCSTR lpCursorName);
|
||||
HCURSOR SetCursor(HCURSOR hCursor);
|
||||
|
||||
typedef VOID (CALLBACK *TIMERPROC)(HWND,UINT,UINT_PTR,DWORD);
|
||||
|
||||
UINT_PTR SetTimer(HWND,UINT_PTR,UINT,TIMERPROC);
|
||||
BOOL KillTimer(HWND hWnd, UINT uIDEvent);
|
||||
|
|
Loading…
Add table
Reference in a new issue