Skip to content

Commit

Permalink
Merge pull request kcat#5 from Raulshc/updates
Browse files Browse the repository at this point in the history
MSVC updates
  • Loading branch information
kcat authored Oct 6, 2019
2 parents bdf5299 + 0f5e4a9 commit f615d0e
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 53 deletions.
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ else()
endif()
endif()

# MSVC workaround for C99 inline
if(MSVC)
check_c_source_compiles("inline void foo(void) { }
int main() {return 0;}" HAVE_INLINE)
if(NOT HAVE_INLINE)
check_c_source_compiles("__inline void foo(void) { }
int main() {return 0;}" HAVE___INLINE)
if(NOT HAVE___INLINE)
message(FATAL_ERROR "No inline keyword found, please update your MSVC version!")
endif()

set(DSOAL_DEFS ${DSOAL_DEFS} inline=__inline)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
endif()
endif()

if(NOT MSVC)
set(DSOAL_FLAGS ${DSOAL_FLAGS} -Winline -Wall)
Expand Down Expand Up @@ -97,9 +112,11 @@ endif()
set(DSOAL_DEFS ${DSOAL_DEFS} COBJMACROS)

if(MSVC)
add_library(dsound SHARED ${DSOAL_OBJS} msvc.def)
add_library(dsound SHARED ${DSOAL_OBJS} msvc.def)
set(DSOAL_DEFS ${DSOAL_DEFS} _CRT_SECURE_NO_WARNINGS)
set(DSOAL_FLAGS ${DSOAL_FLAGS} /W3 /wd4090 /wd4113)
else()
add_library(dsound SHARED ${DSOAL_OBJS} mingw.def)
add_library(dsound SHARED ${DSOAL_OBJS} mingw.def)
endif(MSVC)

if(WIN32)
Expand Down
30 changes: 15 additions & 15 deletions buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
/* TODO: when bufferlost is set, return from all calls except initialize with
* DSERR_BUFFERLOST
*/
static const IDirectSoundBuffer8Vtbl DSBuffer_Vtbl;
static const IDirectSound3DBufferVtbl DSBuffer3d_Vtbl;
static const IDirectSoundNotifyVtbl DSBufferNot_Vtbl;
static const IKsPropertySetVtbl DSBufferProp_Vtbl;
static IDirectSoundBuffer8Vtbl DSBuffer_Vtbl;
static IDirectSound3DBufferVtbl DSBuffer3d_Vtbl;
static IDirectSoundNotifyVtbl DSBufferNot_Vtbl;
static IKsPropertySetVtbl DSBufferProp_Vtbl;


static inline DSBuffer *impl_from_IDirectSoundBuffer8(IDirectSoundBuffer8 *iface)
Expand Down Expand Up @@ -745,7 +745,7 @@ static HRESULT DSBuffer_SetLoc(DSBuffer *buf, DWORD loc_status)
DWORD base = share->sources.maxhw_alloc;
buf->source = share->sources.ids[base + --(share->sources.availsw_num)];
}
alSourcef(buf->source, AL_GAIN, mB_to_gain(buf->current.vol));
alSourcef(buf->source, AL_GAIN, mB_to_gain((float)buf->current.vol));
alSourcef(buf->source, AL_PITCH,
buf->current.frequency ? (float)buf->current.frequency/data->format.Format.nSamplesPerSec
: 1.0f);
Expand Down Expand Up @@ -775,7 +775,7 @@ static HRESULT DSBuffer_SetLoc(DSBuffer *buf, DWORD loc_status)
alSource3f(source, AL_DIRECTION, params->vConeOrientation.x,
params->vConeOrientation.y,
-params->vConeOrientation.z);
alSourcef(source, AL_CONE_OUTER_GAIN, mB_to_gain(params->lConeOutsideVolume));
alSourcef(source, AL_CONE_OUTER_GAIN, mB_to_gain((float)params->lConeOutsideVolume));
alSourcef(source, AL_REFERENCE_DISTANCE, params->flMinDistance);
alSourcef(source, AL_MAX_DISTANCE, params->flMaxDistance);
if(HAS_EXTENSION(share, SOFT_SOURCE_SPATIALIZE))
Expand Down Expand Up @@ -809,7 +809,7 @@ static HRESULT DSBuffer_SetLoc(DSBuffer *buf, DWORD loc_status)
alSource3i(source, AL_AUXILIARY_SEND_FILTER, slot, i, filter);
}
alSourcef(source, AL_ROOM_ROLLOFF_FACTOR, eax_params->flRoomRolloffFactor);
alSourcef(source, AL_CONE_OUTER_GAINHF, mB_to_gain(eax_params->lOutsideVolumeHF));
alSourcef(source, AL_CONE_OUTER_GAINHF, mB_to_gain((float)eax_params->lOutsideVolumeHF));
alSourcef(source, AL_AIR_ABSORPTION_FACTOR,
clampF(prim->current.ctx.flAirAbsorptionHF / -5.0f *
eax_params->flAirAbsorptionFactor, 0.0f, 10.0f)
Expand Down Expand Up @@ -1550,7 +1550,7 @@ static HRESULT WINAPI DSBuffer_SetVolume(IDirectSoundBuffer8 *iface, LONG vol)
if(LIKELY(This->source))
{
setALContext(This->ctx);
alSourcef(This->source, AL_GAIN, mB_to_gain(vol));
alSourcef(This->source, AL_GAIN, mB_to_gain((float)vol));
popALContext();
}
}
Expand Down Expand Up @@ -1909,7 +1909,7 @@ static HRESULT WINAPI DSBuffer_GetObjectInPath(IDirectSoundBuffer8 *iface, REFGU
return E_NOTIMPL;
}

static const IDirectSoundBuffer8Vtbl DSBuffer_Vtbl = {
static IDirectSoundBuffer8Vtbl DSBuffer_Vtbl = {
DSBuffer_QueryInterface,
DSBuffer_AddRef,
DSBuffer_Release,
Expand Down Expand Up @@ -1993,7 +1993,7 @@ void DSBuffer_SetParams(DSBuffer *This, const DS3DBUFFER *params, LONG flags)
params->vConeOrientation.y,
-params->vConeOrientation.z);
if(dirty.bit.cone_outsidevolume)
alSourcef(source, AL_CONE_OUTER_GAIN, mB_to_gain(params->lConeOutsideVolume));
alSourcef(source, AL_CONE_OUTER_GAIN, mB_to_gain((float)params->lConeOutsideVolume));
if(dirty.bit.min_distance)
alSourcef(source, AL_REFERENCE_DISTANCE, params->flMinDistance);
if(dirty.bit.max_distance)
Expand Down Expand Up @@ -2038,7 +2038,7 @@ void DSBuffer_SetParams(DSBuffer *This, const DS3DBUFFER *params, LONG flags)
if(dirty.bit.room_rolloff)
alSourcef(source, AL_ROOM_ROLLOFF_FACTOR, This->current.eax.flRoomRolloffFactor);
if(dirty.bit.cone_outsidevolumehf)
alSourcef(source, AL_CONE_OUTER_GAINHF, mB_to_gain(This->current.eax.lOutsideVolumeHF));
alSourcef(source, AL_CONE_OUTER_GAINHF, mB_to_gain((float)This->current.eax.lOutsideVolumeHF));
if(dirty.bit.air_absorb)
alSourcef(source, AL_AIR_ABSORPTION_FACTOR, This->current.eax.flAirAbsorptionFactor *
prim->current.ctx.flAirAbsorptionHF / -5.0f);
Expand Down Expand Up @@ -2336,7 +2336,7 @@ static HRESULT WINAPI DSBuffer3D_SetConeOutsideVolume(IDirectSound3DBuffer *ifac
This->current.ds3d.lConeOutsideVolume = vol;
if(LIKELY(This->source))
{
alSourcef(This->source, AL_CONE_OUTER_GAIN, mB_to_gain(vol));
alSourcef(This->source, AL_CONE_OUTER_GAIN, mB_to_gain((float)vol));
checkALError();
}
popALContext();
Expand Down Expand Up @@ -2598,7 +2598,7 @@ static HRESULT WINAPI DSBuffer3D_SetAllParameters(IDirectSound3DBuffer *iface, c
return S_OK;
}

static const IDirectSound3DBufferVtbl DSBuffer3d_Vtbl =
static IDirectSound3DBufferVtbl DSBuffer3d_Vtbl =
{
DSBuffer3D_QueryInterface,
DSBuffer3D_AddRef,
Expand Down Expand Up @@ -2713,7 +2713,7 @@ static HRESULT WINAPI DSBufferNot_SetNotificationPositions(IDirectSoundNotify *i
return hr;
}

static const IDirectSoundNotifyVtbl DSBufferNot_Vtbl =
static IDirectSoundNotifyVtbl DSBufferNot_Vtbl =
{
DSBufferNot_QueryInterface,
DSBufferNot_AddRef,
Expand Down Expand Up @@ -3024,7 +3024,7 @@ static HRESULT WINAPI DSBufferProp_QuerySupport(IKsPropertySet *iface,
return hr;
}

static const IKsPropertySetVtbl DSBufferProp_Vtbl =
static IKsPropertySetVtbl DSBufferProp_Vtbl =
{
DSBufferProp_QueryInterface,
DSBufferProp_AddRef,
Expand Down
16 changes: 8 additions & 8 deletions capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ struct DSCBuffer {
BOOL playing, looping;
};

static const IDirectSoundCaptureVtbl DSC_Vtbl;
static const IUnknownVtbl DSC_Unknown_Vtbl;
static const IDirectSoundCaptureBuffer8Vtbl DSCBuffer_Vtbl;
static const IDirectSoundNotifyVtbl DSCNot_Vtbl;
static IDirectSoundCaptureVtbl DSC_Vtbl;
static IUnknownVtbl DSC_Unknown_Vtbl;
static IDirectSoundCaptureBuffer8Vtbl DSCBuffer_Vtbl;
static IDirectSoundNotifyVtbl DSCNot_Vtbl;

static void DSCImpl_Destroy(DSCImpl *This);

Expand Down Expand Up @@ -718,7 +718,7 @@ static HRESULT WINAPI DSCBuffer_GetFXStatus(IDirectSoundCaptureBuffer8 *iface, D
return E_NOTIMPL;
}

static const IDirectSoundCaptureBuffer8Vtbl DSCBuffer_Vtbl =
static IDirectSoundCaptureBuffer8Vtbl DSCBuffer_Vtbl =
{
DSCBuffer_QueryInterface,
DSCBuffer_AddRef,
Expand Down Expand Up @@ -824,7 +824,7 @@ static HRESULT WINAPI DSCBufferNot_SetNotificationPositions(IDirectSoundNotify *
return hr;
}

static const IDirectSoundNotifyVtbl DSCNot_Vtbl =
static IDirectSoundNotifyVtbl DSCNot_Vtbl =
{
DSCBufferNot_QueryInterface,
DSCBufferNot_AddRef,
Expand Down Expand Up @@ -933,7 +933,7 @@ static ULONG WINAPI DSCImpl_IUnknown_Release(IUnknown *iface)
return ref;
}

static const IUnknownVtbl DSC_Unknown_Vtbl = {
static IUnknownVtbl DSC_Unknown_Vtbl = {
DSCImpl_IUnknown_QueryInterface,
DSCImpl_IUnknown_AddRef,
DSCImpl_IUnknown_Release
Expand Down Expand Up @@ -1144,7 +1144,7 @@ static HRESULT WINAPI DSCImpl_Initialize(IDirectSoundCapture *iface, const GUID
return hr;
}

static const IDirectSoundCaptureVtbl DSC_Vtbl =
static IDirectSoundCaptureVtbl DSC_Vtbl =
{
DSCImpl_QueryInterface,
DSCImpl_AddRef,
Expand Down
12 changes: 6 additions & 6 deletions dsound8.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,9 @@ static ULONG DSShare_Release(DeviceShare *share)
}


static const IDirectSound8Vtbl DS8_Vtbl;
static const IDirectSoundVtbl DS_Vtbl;
static const IUnknownVtbl DS8_Unknown_Vtbl;
static IDirectSound8Vtbl DS8_Vtbl;
static IDirectSoundVtbl DS_Vtbl;
static IUnknownVtbl DS8_Unknown_Vtbl;

static HRESULT DSDevice_Create(BOOL is8, REFIID riid, LPVOID *ds);
static void DSDevice_Destroy(DSDevice *This);
Expand Down Expand Up @@ -496,7 +496,7 @@ static ULONG WINAPI DSDevice_IUnknown_Release(IUnknown *iface)
return ref;
}

static const IUnknownVtbl DS8_Unknown_Vtbl = {
static IUnknownVtbl DS8_Unknown_Vtbl = {
DSDevice_IUnknown_QueryInterface,
DSDevice_IUnknown_AddRef,
DSDevice_IUnknown_Release
Expand Down Expand Up @@ -1139,7 +1139,7 @@ static HRESULT WINAPI DS8_VerifyCertification(IDirectSound8 *iface, DWORD *certi
return DS_OK;
}

static const IDirectSound8Vtbl DS8_Vtbl = {
static IDirectSound8Vtbl DS8_Vtbl = {
DS8_QueryInterface,
DS8_AddRef,
DS8_Release,
Expand Down Expand Up @@ -1221,7 +1221,7 @@ static HRESULT WINAPI DS_Initialize(IDirectSound *iface, const GUID *devguid)
return DS8_Initialize(&This->IDirectSound8_iface, devguid);
}

static const IDirectSoundVtbl DS_Vtbl = {
static IDirectSoundVtbl DS_Vtbl = {
DS_QueryInterface,
DS_AddRef,
DS_Release,
Expand Down
6 changes: 3 additions & 3 deletions duplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_VerifyCertification(
return IDirectSound8_VerifyCertification(This->renderer_device,cert);
}

static const IDirectSound8Vtbl DirectSoundFullDuplex_DirectSound8_Vtbl = {
static IDirectSound8Vtbl DirectSoundFullDuplex_DirectSound8_Vtbl = {
IDirectSoundFullDuplex_IDirectSound8_QueryInterface,
IDirectSoundFullDuplex_IDirectSound8_AddRef,
IDirectSoundFullDuplex_IDirectSound8_Release,
Expand Down Expand Up @@ -289,7 +289,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_Initialize(
return IDirectSoundCapture_Initialize(This->capture_device,lpcGUID);
}

static const IDirectSoundCaptureVtbl DirectSoundFullDuplex_DirectSoundCapture_Vtbl = {
static IDirectSoundCaptureVtbl DirectSoundFullDuplex_DirectSoundCapture_Vtbl = {
IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface,
IDirectSoundFullDuplex_IDirectSoundCapture_AddRef,
IDirectSoundFullDuplex_IDirectSoundCapture_Release,
Expand Down Expand Up @@ -460,7 +460,7 @@ static HRESULT WINAPI IDirectSoundFullDuplexImpl_Initialize(
return hr;
}

static const IDirectSoundFullDuplexVtbl dsfdvt = {
static IDirectSoundFullDuplexVtbl dsfdvt = {
/* IUnknown methods */
IDirectSoundFullDuplexImpl_QueryInterface,
IDirectSoundFullDuplexImpl_AddRef,
Expand Down
16 changes: 8 additions & 8 deletions primary.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#endif


static const IDirectSoundBufferVtbl DSPrimary_Vtbl;
static const IDirectSound3DListenerVtbl DSPrimary3D_Vtbl;
static const IKsPropertySetVtbl DSPrimaryProp_Vtbl;
static IDirectSoundBufferVtbl DSPrimary_Vtbl;
static IDirectSound3DListenerVtbl DSPrimary3D_Vtbl;
static IKsPropertySetVtbl DSPrimaryProp_Vtbl;

static void DSPrimary_SetParams(DSPrimary *This, const DS3DLISTENER *params, LONG flags);

Expand Down Expand Up @@ -995,7 +995,7 @@ static HRESULT WINAPI DSPrimary_SetVolume(IDirectSoundBuffer *iface, LONG vol)
return DSERR_CONTROLUNAVAIL;

setALContext(This->ctx);
alListenerf(AL_GAIN, mB_to_gain(vol));
alListenerf(AL_GAIN, mB_to_gain((float)vol));
popALContext();

return DS_OK;
Expand Down Expand Up @@ -1085,7 +1085,7 @@ static HRESULT WINAPI DSPrimary_Restore(IDirectSoundBuffer *iface)
return hr;
}

static const IDirectSoundBufferVtbl DSPrimary_Vtbl =
static IDirectSoundBufferVtbl DSPrimary_Vtbl =
{
DSPrimary_QueryInterface,
DSPrimary_AddRef,
Expand Down Expand Up @@ -1254,7 +1254,7 @@ static void DSPrimary_SetParams(DSPrimary *This, const DS3DLISTENER *params, LON
alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, This->effect[i]);
if(FXSLOT_IS_DIRTY(dirty.bit, i, FXSLOT_VOL_BIT))
alAuxiliaryEffectSlotf(slot, AL_EFFECTSLOT_GAIN,
mB_to_gain(This->current.fxslot[i].props.lVolume)
mB_to_gain((float)This->current.fxslot[i].props.lVolume)
);
if(FXSLOT_IS_DIRTY(dirty.bit, i, FXSLOT_FLAGS_BIT))
alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO,
Expand Down Expand Up @@ -1743,7 +1743,7 @@ HRESULT WINAPI DSPrimary3D_CommitDeferredSettings(IDirectSound3DListener *iface)
return DS_OK;
}

static const IDirectSound3DListenerVtbl DSPrimary3D_Vtbl =
static IDirectSound3DListenerVtbl DSPrimary3D_Vtbl =
{
DSPrimary3D_QueryInterface,
DSPrimary3D_AddRef,
Expand Down Expand Up @@ -1842,7 +1842,7 @@ static HRESULT WINAPI DSPrimaryProp_QuerySupport(IKsPropertySet *iface,
return E_PROP_ID_UNSUPPORTED;
}

static const IKsPropertySetVtbl DSPrimaryProp_Vtbl =
static IKsPropertySetVtbl DSPrimaryProp_Vtbl =
{
DSPrimaryProp_QueryInterface,
DSPrimaryProp_AddRef,
Expand Down
2 changes: 1 addition & 1 deletion propset.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
return E_PROP_ID_UNSUPPORTED;
}

static const IKsPropertySetVtbl ikspvt = {
static IKsPropertySetVtbl ikspvt = {
IKsPrivatePropertySetImpl_QueryInterface,
IKsPrivatePropertySetImpl_AddRef,
IKsPrivatePropertySetImpl_Release,
Expand Down
Loading

0 comments on commit f615d0e

Please sign in to comment.