Commit e7337704 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

xaudio2: Implement GetVoiceDetails for source and submix voices.

parent b77ec00f
......@@ -216,6 +216,21 @@ static void test_simple_streaming(IXAudio2 *xa)
XA2CALL(CreateSourceVoice, &src, &fmt, 0, 1.f, &vcb1, NULL, NULL);
ok(hr == S_OK, "CreateSourceVoice failed: %08x\n", hr);
if(xaudio27){
XAUDIO27_VOICE_DETAILS details;
IXAudio27SourceVoice_GetVoiceDetails((IXAudio27SourceVoice*)src, &details);
ok(details.CreationFlags == 0, "Got wrong flags: 0x%x\n", details.CreationFlags);
ok(details.InputChannels == 2, "Got wrong channel count: 0x%x\n", details.InputChannels);
ok(details.InputSampleRate == 44100, "Got wrong sample rate: 0x%x\n", details.InputSampleRate);
}else{
XAUDIO2_VOICE_DETAILS details;
IXAudio2SourceVoice_GetVoiceDetails(src, &details);
ok(details.CreationFlags == 0, "Got wrong creation flags: 0x%x\n", details.CreationFlags);
ok(details.ActiveFlags == 0, "Got wrong active flags: 0x%x\n", details.CreationFlags);
ok(details.InputChannels == 2, "Got wrong channel count: 0x%x\n", details.InputChannels);
ok(details.InputSampleRate == 44100, "Got wrong sample rate: 0x%x\n", details.InputSampleRate);
}
memset(&buf, 0, sizeof(buf));
buf.AudioBytes = 22050 * fmt.nBlockAlign;
buf.pAudioData = HeapAlloc(GetProcessHeap(), 0, buf.AudioBytes);
......@@ -231,6 +246,21 @@ static void test_simple_streaming(IXAudio2 *xa)
XA2CALL(CreateSourceVoice, &src2, &fmt, 0, 1.f, &vcb2, NULL, NULL);
ok(hr == S_OK, "CreateSourceVoice failed: %08x\n", hr);
if(xaudio27){
XAUDIO27_VOICE_DETAILS details;
IXAudio27SourceVoice_GetVoiceDetails((IXAudio27SourceVoice*)src2, &details);
ok(details.CreationFlags == 0, "Got wrong flags: 0x%x\n", details.CreationFlags);
ok(details.InputChannels == 2, "Got wrong channel count: 0x%x\n", details.InputChannels);
ok(details.InputSampleRate == 44100, "Got wrong sample rate: 0x%x\n", details.InputSampleRate);
}else{
XAUDIO2_VOICE_DETAILS details;
IXAudio2SourceVoice_GetVoiceDetails(src2, &details);
ok(details.CreationFlags == 0, "Got wrong creation flags: 0x%x\n", details.CreationFlags);
ok(details.ActiveFlags == 0, "Got wrong active flags: 0x%x\n", details.CreationFlags);
ok(details.InputChannels == 2, "Got wrong channel count: 0x%x\n", details.InputChannels);
ok(details.InputSampleRate == 44100, "Got wrong sample rate: 0x%x\n", details.InputSampleRate);
}
memset(&buf2, 0, sizeof(buf2));
buf2.AudioBytes = 22050 * fmt.nBlockAlign;
buf2.pAudioData = HeapAlloc(GetProcessHeap(), 0, buf2.AudioBytes);
......@@ -775,6 +805,42 @@ static void test_looping(IXAudio2 *xa)
HeapFree(GetProcessHeap(), 0, (void*)buf.pAudioData);
}
static void test_submix(IXAudio2 *xa)
{
HRESULT hr;
IXAudio2MasteringVoice *master;
IXAudio2SubmixVoice *sub;
XA2CALL_0V(StopEngine);
if(xaudio27)
hr = IXAudio27_CreateMasteringVoice((IXAudio27*)xa, &master, 2, 44100, 0, 0, NULL);
else
hr = IXAudio2_CreateMasteringVoice(xa, &master, 2, 44100, 0, NULL, NULL, AudioCategory_GameEffects);
ok(hr == S_OK, "CreateMasteringVoice failed: %08x\n", hr);
XA2CALL(CreateSubmixVoice, &sub, 2, 44100, 0, 0, NULL, NULL);
ok(hr == S_OK, "CreateSubmixVoice failed: %08x\n", hr);
if(xaudio27){
XAUDIO27_VOICE_DETAILS details;
IXAudio27SubmixVoice_GetVoiceDetails((IXAudio27SubmixVoice*)sub, &details);
ok(details.CreationFlags == 0, "Got wrong flags: 0x%x\n", details.CreationFlags);
ok(details.InputChannels == 2, "Got wrong channel count: 0x%x\n", details.InputChannels);
ok(details.InputSampleRate == 44100, "Got wrong sample rate: 0x%x\n", details.InputSampleRate);
}else{
XAUDIO2_VOICE_DETAILS details;
IXAudio2SubmixVoice_GetVoiceDetails(sub, &details);
ok(details.CreationFlags == 0, "Got wrong creation flags: 0x%x\n", details.CreationFlags);
ok(details.ActiveFlags == 0, "Got wrong active flags: 0x%x\n", details.CreationFlags);
ok(details.InputChannels == 2, "Got wrong channel count: 0x%x\n", details.InputChannels);
ok(details.InputSampleRate == 44100, "Got wrong sample rate: 0x%x\n", details.InputSampleRate);
}
IXAudio2SubmixVoice_DestroyVoice(sub);
IXAudio2MasteringVoice_DestroyVoice(master);
}
static UINT32 test_DeviceDetails(IXAudio27 *xa)
{
HRESULT hr;
......@@ -1069,6 +1135,7 @@ START_TEST(xaudio2)
test_simple_streaming((IXAudio2*)xa27);
test_buffer_callbacks((IXAudio2*)xa27);
test_looping((IXAudio2*)xa27);
test_submix((IXAudio2*)xa27);
}else
skip("No audio devices available\n");
......@@ -1091,6 +1158,7 @@ START_TEST(xaudio2)
test_simple_streaming(xa);
test_buffer_callbacks(xa);
test_looping(xa);
test_submix(xa);
}else
skip("No audio devices available\n");
......
......@@ -173,7 +173,13 @@ static void WINAPI XA2SRC_GetVoiceDetails(IXAudio2SourceVoice *iface,
XAUDIO2_VOICE_DETAILS *pVoiceDetails)
{
XA2SourceImpl *This = impl_from_IXAudio2SourceVoice(iface);
TRACE("%p, %p\n", This, pVoiceDetails);
pVoiceDetails->CreationFlags = 0;
pVoiceDetails->ActiveFlags = 0;
pVoiceDetails->InputChannels = This->fmt->nChannels;
pVoiceDetails->InputSampleRate = This->fmt->nSamplesPerSec;
}
static HRESULT WINAPI XA2SRC_SetOutputVoices(IXAudio2SourceVoice *iface,
......@@ -799,6 +805,7 @@ static void WINAPI XA2M_GetVoiceDetails(IXAudio2MasteringVoice *iface,
IXAudio2Impl *This = impl_from_IXAudio2MasteringVoice(iface);
TRACE("%p, %p\n", This, pVoiceDetails);
pVoiceDetails->CreationFlags = 0;
pVoiceDetails->ActiveFlags = 0;
pVoiceDetails->InputChannels = This->fmt.Format.nChannels;
pVoiceDetails->InputSampleRate = This->fmt.Format.nSamplesPerSec;
}
......@@ -1010,7 +1017,10 @@ static void WINAPI XA2SUB_GetVoiceDetails(IXAudio2SubmixVoice *iface,
XAUDIO2_VOICE_DETAILS *pVoiceDetails)
{
XA2SubmixImpl *This = impl_from_IXAudio2SubmixVoice(iface);
TRACE("%p, %p\n", This, pVoiceDetails);
*pVoiceDetails = This->details;
}
static HRESULT WINAPI XA2SUB_SetOutputVoices(IXAudio2SubmixVoice *iface,
......@@ -1499,6 +1509,8 @@ static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface,
sub->IXAudio20SubmixVoice_iface.lpVtbl = &XAudio20SubmixVoice_Vtbl;
#elif XAUDIO2_VER <= 3
sub->IXAudio23SubmixVoice_iface.lpVtbl = &XAudio23SubmixVoice_Vtbl;
#elif XAUDIO2_VER <= 7
sub->IXAudio27SubmixVoice_iface.lpVtbl = &XAudio27SubmixVoice_Vtbl;
#endif
InitializeCriticalSection(&sub->lock);
......@@ -1509,6 +1521,11 @@ static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface,
sub->in_use = TRUE;
sub->details.CreationFlags = flags;
sub->details.ActiveFlags = flags;
sub->details.InputChannels = inputChannels;
sub->details.InputSampleRate = inputSampleRate;
LeaveCriticalSection(&This->lock);
LeaveCriticalSection(&sub->lock);
......@@ -1516,6 +1533,8 @@ static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface,
*ppSubmixVoice = (IXAudio2SubmixVoice*)&sub->IXAudio20SubmixVoice_iface;
#elif XAUDIO2_VER <= 3
*ppSubmixVoice = (IXAudio2SubmixVoice*)&sub->IXAudio23SubmixVoice_iface;
#elif XAUDIO2_VER <= 7
*ppSubmixVoice = (IXAudio2SubmixVoice*)&sub->IXAudio27SubmixVoice_iface;
#else
*ppSubmixVoice = &sub->IXAudio2SubmixVoice_iface;
#endif
......@@ -1751,6 +1770,8 @@ static HRESULT WINAPI IXAudio2Impl_CreateMasteringVoice(IXAudio2 *iface,
*ppMasteringVoice = (IXAudio2MasteringVoice*)&This->IXAudio20MasteringVoice_iface;
#elif XAUDIO2_VER <= 3
*ppMasteringVoice = (IXAudio2MasteringVoice*)&This->IXAudio23MasteringVoice_iface;
#elif XAUDIO2_VER <= 7
*ppMasteringVoice = (IXAudio2MasteringVoice*)&This->IXAudio27MasteringVoice_iface;
#else
*ppMasteringVoice = &This->IXAudio2MasteringVoice_iface;
#endif
......@@ -2001,6 +2022,8 @@ static HRESULT WINAPI XAudio2CF_CreateInstance(IClassFactory *iface, IUnknown *p
object->IXAudio20MasteringVoice_iface.lpVtbl = &XAudio20MasteringVoice_Vtbl;
#elif XAUDIO2_VER <= 3
object->IXAudio23MasteringVoice_iface.lpVtbl = &XAudio23MasteringVoice_Vtbl;
#elif XAUDIO2_VER <= 7
object->IXAudio27MasteringVoice_iface.lpVtbl = &XAudio27MasteringVoice_Vtbl;
#endif
list_init(&object->source_voices);
......
......@@ -93,10 +93,14 @@ typedef struct _XA2SubmixImpl {
IXAudio20SubmixVoice IXAudio20SubmixVoice_iface;
#elif XAUDIO2_VER <= 3
IXAudio23SubmixVoice IXAudio23SubmixVoice_iface;
#elif XAUDIO2_VER <= 7
IXAudio27SubmixVoice IXAudio27SubmixVoice_iface;
#endif
BOOL in_use;
XAUDIO2_VOICE_DETAILS details;
CRITICAL_SECTION lock;
struct list entry;
......@@ -118,6 +122,8 @@ struct _IXAudio2Impl {
IXAudio20MasteringVoice IXAudio20MasteringVoice_iface;
#elif XAUDIO2_VER <= 3
IXAudio23MasteringVoice IXAudio23MasteringVoice_iface;
#elif XAUDIO2_VER <= 7
IXAudio27MasteringVoice IXAudio27MasteringVoice_iface;
#endif
LONG ref;
......@@ -163,6 +169,8 @@ extern const IXAudio23SubmixVoiceVtbl XAudio23SubmixVoice_Vtbl DECLSPEC_HIDDEN;
extern const IXAudio23MasteringVoiceVtbl XAudio23MasteringVoice_Vtbl DECLSPEC_HIDDEN;
#elif XAUDIO2_VER <= 7
extern const IXAudio27SourceVoiceVtbl XAudio27SourceVoice_Vtbl DECLSPEC_HIDDEN;
extern const IXAudio27SubmixVoiceVtbl XAudio27SubmixVoice_Vtbl DECLSPEC_HIDDEN;
extern const IXAudio27MasteringVoiceVtbl XAudio27MasteringVoice_Vtbl DECLSPEC_HIDDEN;
#endif
#if XAUDIO2_VER == 0
......
......@@ -223,9 +223,17 @@ typedef struct XAUDIO2_DEVICE_DETAILS
WAVEFORMATEXTENSIBLE OutputFormat;
} XAUDIO2_DEVICE_DETAILS;
typedef struct XAUDIO27_VOICE_DETAILS
{
UINT32 CreationFlags;
UINT32 InputChannels;
UINT32 InputSampleRate;
} XAUDIO27_VOICE_DETAILS;
typedef struct XAUDIO2_VOICE_DETAILS
{
UINT32 CreationFlags;
UINT32 ActiveFlags;
UINT32 InputChannels;
UINT32 InputSampleRate;
} XAUDIO2_VOICE_DETAILS;
......@@ -323,7 +331,7 @@ typedef struct XAUDIO2_FILTER_PARAMETERS
]
interface IXAudio20Voice
{
void GetVoiceDetails([out] XAUDIO2_VOICE_DETAILS* pVoiceDetails);
void GetVoiceDetails([out] XAUDIO27_VOICE_DETAILS* pVoiceDetails);
HRESULT SetOutputVoices([in] const XAUDIO23_VOICE_SENDS* pSendList);
......@@ -398,7 +406,7 @@ interface IXAudio20Voice
]
interface IXAudio23Voice
{
void GetVoiceDetails([out] XAUDIO2_VOICE_DETAILS* pVoiceDetails);
void GetVoiceDetails([out] XAUDIO27_VOICE_DETAILS* pVoiceDetails);
HRESULT SetOutputVoices([in] const XAUDIO23_VOICE_SENDS* pSendList);
......@@ -464,6 +472,90 @@ interface IXAudio23Voice
void DestroyVoice();
}
/* XAudio 2.7's IXAudio2Voice */
/* XAudio2 2.7's IXAudio2Voice interface. Actually called
* IXAudio2Voice in the Jun 2010 DX SDK */
[
object,
local
]
interface IXAudio27Voice
{
void GetVoiceDetails([out] XAUDIO27_VOICE_DETAILS* pVoiceDetails);
HRESULT SetOutputVoices([in] const XAUDIO2_VOICE_SENDS* pSendList);
HRESULT SetEffectChain([in] const XAUDIO2_EFFECT_CHAIN* pEffectChain);
HRESULT EnableEffect(
[in] UINT32 EffectIndex,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
HRESULT DisableEffect(
[in] UINT32 EffectIndex,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetEffectState(
[in] UINT32 EffectIndex,
[out] BOOL* pEnabled);
HRESULT SetEffectParameters(
[in] UINT32 EffectIndex,
[in] const void* pParameters,
[in] UINT32 ParametersByteSize,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
HRESULT GetEffectParameters(
[in] UINT32 EffectIndex,
[out] void* pParameters,
[in] UINT32 ParametersByteSize);
HRESULT SetFilterParameters(
[in] const XAUDIO2_FILTER_PARAMETERS* pParameters,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetFilterParameters([out] XAUDIO2_FILTER_PARAMETERS* pParameters);
HRESULT SetOutputFilterParameters(
[in] IXAudio2Voice* pDestinationVoice,
[in] const XAUDIO2_FILTER_PARAMETERS* pParameters,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetOutputFilterParameters(
[in] IXAudio2Voice* pDestinationVoice,
[out] XAUDIO2_FILTER_PARAMETERS* pParameters);
HRESULT SetVolume(
[in] float Volume,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetVolume([out] float* pVolume);
HRESULT SetChannelVolumes(
[in] UINT32 Channels,
[in, size_is(Channels)] const float* pVolumes,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetChannelVolumes(
[in] UINT32 Channels,
[out, size_is(Channels)] float* pVolumes);
HRESULT SetOutputMatrix(
[in] IXAudio2Voice* pDestinationVoice,
[in] UINT32 SourceChannels,
[in] UINT32 DestinationChannels,
[in, size_is(SourceChannels * DestinationChannels)] const float* pLevelMatrix,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetOutputMatrix(
[in] IXAudio2Voice* pDestinationVoice,
[in] UINT32 SourceChannels,
[in] UINT32 DestinationChannels,
[out, size_is(SourceChannels * DestinationChannels)] float* pLevelMatrix);
void DestroyVoice();
}
[
object,
local
......@@ -644,7 +736,7 @@ interface IXAudio23SourceVoice : IXAudio23Voice
]
/* XAudio2 2.7's IXAudio2SourceVoice interface. Actually called
* IXAudio2SourceVoice in the Jun 2010 DX SDK */
interface IXAudio27SourceVoice : IXAudio2Voice
interface IXAudio27SourceVoice : IXAudio27Voice
{
HRESULT Start(
[in, defaultvalue(0)] UINT32 Flags,
......@@ -731,6 +823,15 @@ interface IXAudio23SubmixVoice : IXAudio23Voice
[
local
]
/* XAudio2 2.7's IXAudio2SubmixVoice interface. Actually called
* IXAudio2SubmixVoice in the Jun 2010 DX SDK */
interface IXAudio27SubmixVoice : IXAudio27Voice
{
}
[
local
]
interface IXAudio2SubmixVoice : IXAudio2Voice
{
}
......@@ -756,6 +857,15 @@ interface IXAudio23MasteringVoice : IXAudio23Voice
[
local
]
/* XAudio2 2.7's IXAudio2MasteringVoice interface. Actually called
* IXAudio2MasteringVoice in the Jun 2010 DX SDK */
interface IXAudio27MasteringVoice : IXAudio27Voice
{
}
[
local
]
interface IXAudio2MasteringVoice : IXAudio2Voice
{
/* not present in XAudio2 2.7 */
......
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