Commit 7e64247a authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

mmdevapi: Implement SpatialAudio features.

This makes car radio / ambient noises audible in Cyberpunk 2077. Signed-off-by: 's avatarArkadiusz Hiler <ahiler@codeweavers.com> Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c90ab917
...@@ -6,6 +6,7 @@ EXTRADLLFLAGS = -mno-cygwin ...@@ -6,6 +6,7 @@ EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ C_SRCS = \
audiovolume.c \ audiovolume.c \
devenum.c \ devenum.c \
main.c main.c \
spatialaudio.c
IDL_SRCS = mmdevapi_classes.idl IDL_SRCS = mmdevapi_classes.idl
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "audioclient.h" #include "audioclient.h"
#include "endpointvolume.h" #include "endpointvolume.h"
#include "audiopolicy.h" #include "audiopolicy.h"
#include "spatialaudioclient.h"
#include "mmdevapi.h" #include "mmdevapi.h"
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "audioclient.h" #include "audioclient.h"
#include "endpointvolume.h" #include "endpointvolume.h"
#include "audiopolicy.h" #include "audiopolicy.h"
#include "spatialaudioclient.h"
#include "mmdevapi.h" #include "mmdevapi.h"
#include "devpkey.h" #include "devpkey.h"
...@@ -635,6 +636,10 @@ static HRESULT WINAPI MMDevice_Activate(IMMDevice *iface, REFIID riid, DWORD cls ...@@ -635,6 +636,10 @@ static HRESULT WINAPI MMDevice_Activate(IMMDevice *iface, REFIID riid, DWORD cls
IDirectSoundCapture_Release((IDirectSoundCapture*)*ppv); IDirectSoundCapture_Release((IDirectSoundCapture*)*ppv);
} }
} }
else if (IsEqualIID(riid, &IID_ISpatialAudioClient))
{
hr = SpatialAudioClient_Create(iface, (ISpatialAudioClient**)ppv);
}
else else
ERR("Invalid/unknown iid %s\n", debugstr_guid(riid)); ERR("Invalid/unknown iid %s\n", debugstr_guid(riid));
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "audiopolicy.h" #include "audiopolicy.h"
#include "devpkey.h" #include "devpkey.h"
#include "winreg.h" #include "winreg.h"
#include "spatialaudioclient.h"
#include "mmdevapi.h" #include "mmdevapi.h"
#include "wine/debug.h" #include "wine/debug.h"
......
...@@ -71,5 +71,6 @@ typedef struct MMDevice { ...@@ -71,5 +71,6 @@ typedef struct MMDevice {
extern HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv) DECLSPEC_HIDDEN; extern HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv) DECLSPEC_HIDDEN;
extern HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv) DECLSPEC_HIDDEN; extern HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv) DECLSPEC_HIDDEN;
extern HRESULT SpatialAudioClient_Create(IMMDevice *device, ISpatialAudioClient **out) DECLSPEC_HIDDEN;
extern const WCHAR drv_keyW[] DECLSPEC_HIDDEN; extern const WCHAR drv_keyW[] DECLSPEC_HIDDEN;
...@@ -43,6 +43,47 @@ typedef [v1_enum] enum AudioObjectType ...@@ -43,6 +43,47 @@ typedef [v1_enum] enum AudioObjectType
AudioObjectType_BackCenter = 0x00020000, AudioObjectType_BackCenter = 0x00020000,
} AudioObjectType; } AudioObjectType;
cpp_quote("#define SPTLAUDCLNT_E_DESTROYED AUDCLNT_ERR(0x100)")
cpp_quote("#define SPTLAUDCLNT_E_OUT_OF_ORDER AUDCLNT_ERR(0x101)")
cpp_quote("#define SPTLAUDCLNT_E_RESOURCES_INVALIDATED AUDCLNT_ERR(0x102)")
cpp_quote("#define SPTLAUDCLNT_E_NO_MORE_OBJECTS AUDCLNT_ERR(0x103)")
cpp_quote("#define SPTLAUDCLNT_E_PROPERTY_NOT_SUPPORTED AUDCLNT_ERR(0x104)")
cpp_quote("#define SPTLAUDCLNT_E_ERRORS_IN_OBJECT_CALLS AUDCLNT_ERR(0x105)")
cpp_quote("#define SPTLAUDCLNT_E_METADATA_FORMAT_NOT_SUPPORTED AUDCLNT_ERR(0x106)")
cpp_quote("#define SPTLAUDCLNT_E_STREAM_NOT_AVAILABLE AUDCLNT_ERR(0x107)")
cpp_quote("#define SPTLAUDCLNT_E_INVALID_LICENSE AUDCLNT_ERR(0x108)")
cpp_quote("#define SPTLAUDCLNT_E_STREAM_NOT_STOPPED AUDCLNT_ERR(0x10a)")
cpp_quote("#define SPTLAUDCLNT_E_STATIC_OBJECT_NOT_AVAILABLE AUDCLNT_ERR(0x10b)")
cpp_quote("#define SPTLAUDCLNT_E_OBJECT_ALREADY_ACTIVE AUDCLNT_ERR(0x10c)")
cpp_quote("#define SPTLAUDCLNT_E_INTERNAL AUDCLNT_ERR(0x10d)")
interface ISpatialAudioObjectRenderStreamBase;
[
object,
uuid(dddf83e6-68d7-4c70-883f-a1836afb4a50),
pointer_default(unique),
local
]
interface ISpatialAudioObjectRenderStreamNotify : IUnknown
{
HRESULT OnAvailableDynamicObjectCountChange(
[in] ISpatialAudioObjectRenderStreamBase *stream,
[in] LONGLONG deadline,
[in] UINT32 object_count);
}
typedef struct tagSpatialAudioObjectRenderStreamActivationParams
{
const WAVEFORMATEX *ObjectFormat;
AudioObjectType StaticObjectTypeMask;
UINT32 MinDynamicObjectCount;
UINT32 MaxDynamicObjectCount;
AUDIO_STREAM_CATEGORY Category;
HANDLE EventHandle;
ISpatialAudioObjectRenderStreamNotify *NotifyObject;
} SpatialAudioObjectRenderStreamActivationParams;
[ [
object, object,
uuid(dcdaa858-895a-4a22-a5eb-67bda506096d), uuid(dcdaa858-895a-4a22-a5eb-67bda506096d),
...@@ -98,3 +139,83 @@ interface ISpatialAudioClient : IUnknown ...@@ -98,3 +139,83 @@ interface ISpatialAudioClient : IUnknown
[in] REFIID riid, [in] REFIID riid,
[out, iid_is(riid)] void **stream); [out, iid_is(riid)] void **stream);
} }
[
object,
uuid(cce0b8f2-8d4d-4efb-a8cf-3d6ecf1c30e0),
pointer_default(unique),
local
]
interface ISpatialAudioObjectBase : IUnknown
{
HRESULT GetBuffer(
[out] BYTE **buffer,
[out] UINT32 *bytes);
HRESULT SetEndOfStream(
[in] UINT32 frames);
HRESULT IsActive(
[out] BOOL *active);
HRESULT GetAudioObjectType(
[out] AudioObjectType *type);
}
[
object,
uuid(dde28967-521b-46e5-8f00-bd6f2bc8ab1d),
pointer_default(unique),
local
]
interface ISpatialAudioObject : ISpatialAudioObjectBase
{
HRESULT SetPosition(
[in] float x,
[in] float y,
[in] float z);
HRESULT SetVolume(
[in] float vol);
}
[
object,
uuid(feaaf403-c1d8-450d-aa05-e0ccee7502a8),
pointer_default(unique),
local
]
interface ISpatialAudioObjectRenderStreamBase : IUnknown
{
HRESULT GetAvailableDynamicObjectCount(
[out] UINT32 *count);
HRESULT GetService(
[in] REFIID riid,
[out] void **service);
HRESULT Start();
HRESULT Stop();
HRESULT Reset();
HRESULT BeginUpdatingAudioObjects(
[out] UINT32 *count,
[out] UINT32 *frames);
HRESULT EndUpdatingAudioObjects();
}
[
object,
uuid(bab5f473-b423-477b-85f5-b5a332a04153),
pointer_default(unique),
local
]
interface ISpatialAudioObjectRenderStream : ISpatialAudioObjectRenderStreamBase
{
HRESULT ActivateSpatialAudioObject(
[in] AudioObjectType type,
[out] ISpatialAudioObject **object);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment