Commit 4be1dc1b authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

faudio: Import upstream commit e3c444e4f819d2364a6adb0ae73b1d01185b1e93.

parent 1ac80a99
......@@ -485,7 +485,7 @@ extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT;
#define FAUDIO_ABI_VERSION 0
#define FAUDIO_MAJOR_VERSION 22
#define FAUDIO_MINOR_VERSION 6
#define FAUDIO_MINOR_VERSION 7
#define FAUDIO_PATCH_VERSION 0
#define FAUDIO_COMPILED_VERSION ( \
......
......@@ -433,9 +433,17 @@ uint32_t FACTAudioEngine_DoWork(FACTAudioEngine *pEngine)
uint8_t i;
FACTCue *cue;
LinkedList *list;
FACTNotification *note;
FAudio_PlatformLockMutex(pEngine->apiLock);
while (pEngine->wb_notifications_list)
{
note = (FACTNotification*) pEngine->wb_notifications_list->entry;
pEngine->notificationCallback(note);
LinkedList_RemoveEntry(&pEngine->wb_notifications_list, note, pEngine->apiLock, pEngine->pFree);
}
list = pEngine->sbList;
while (list != NULL)
{
......@@ -495,6 +503,7 @@ uint32_t FACTAudioEngine_CreateInMemoryWaveBank(
uint32_t dwAllocAttributes,
FACTWaveBank **ppWaveBank
) {
FACTNotification *note;
uint32_t retval;
FAudio_PlatformLockMutex(pEngine->apiLock);
retval = FACT_INTERNAL_ParseWaveBank(
......@@ -507,6 +516,14 @@ uint32_t FACTAudioEngine_CreateInMemoryWaveBank(
0,
ppWaveBank
);
if (pEngine->notifications & NOTIFY_WAVEBANKPREPARED)
{
note = (FACTNotification*) pEngine->pMalloc(sizeof(FACTNotification));
note->type = FACTNOTIFICATIONTYPE_WAVEBANKPREPARED;
note->waveBank.pWaveBank = *ppWaveBank;
note->pvContext = pEngine->wb_context;
LinkedList_AddEntry(&pEngine->wb_notifications_list, note, pEngine->apiLock, pEngine->pMalloc);
}
FAudio_PlatformUnlockMutex(pEngine->apiLock);
return retval;
}
......@@ -516,6 +533,7 @@ uint32_t FACTAudioEngine_CreateStreamingWaveBank(
const FACTStreamingParameters *pParms,
FACTWaveBank **ppWaveBank
) {
FACTNotification *note;
uint32_t retval, packetSize;
FAudio_PlatformLockMutex(pEngine->apiLock);
if ( pEngine->pReadFile == FACT_INTERNAL_DefaultReadFile &&
......@@ -538,6 +556,14 @@ uint32_t FACTAudioEngine_CreateStreamingWaveBank(
1,
ppWaveBank
);
if (pEngine->notifications & NOTIFY_WAVEBANKPREPARED)
{
note = (FACTNotification*) pEngine->pMalloc(sizeof(FACTNotification));
note->type = FACTNOTIFICATIONTYPE_WAVEBANKPREPARED;
note->waveBank.pWaveBank = *ppWaveBank;
note->pvContext = pEngine->wb_context;
LinkedList_AddEntry(&pEngine->wb_notifications_list, note, pEngine->apiLock, pEngine->pMalloc);
}
FAudio_PlatformUnlockMutex(pEngine->apiLock);
return retval;
}
......@@ -2175,11 +2201,13 @@ uint32_t FACTWave_Stop(FACTWave *pWave, uint32_t dwFlags)
{
FACTNotification note;
note.type = FACTNOTIFICATIONTYPE_WAVESTOP;
note.wave.cueIndex = pWave->parentCue->index;
note.wave.pCue = pWave->parentCue;
note.wave.pSoundBank = pWave->parentCue->parentBank;
note.wave.pWave = pWave;
if (pWave->parentBank->parentEngine->notifications & NOTIFY_WAVESTOP)
{
note.pvContext = pWave->parentBank->parentEngine->wave_context;
}
note.wave.pWaveBank = pWave->parentBank;
note.pvContext = pWave->parentBank->parentEngine->wave_context;
pWave->parentBank->parentEngine->notificationCallback(&note);
}
......
......@@ -440,6 +440,7 @@ struct FACTAudioEngine
void *sb_context;
void *wb_context;
void *wave_context;
LinkedList *wb_notifications_list;
/* Settings handle */
void *settings;
......
......@@ -1015,35 +1015,35 @@ static inline float DspReverb_INTERNAL_Process_2_to_2(
size_t sample_count
) {
const float *in_end = samples_in + sample_count;
float in, in_ratio, early, late[2];
float in, early, late[2];
float squared_sum = 0;
while (samples_in < in_end)
{
/* Input - Combine 2 channels into 1 */
in = (samples_in[0] + samples_in[1]) / 2.0f;
in_ratio = in * reverb->dry_ratio;
samples_in += 2;
/* Early Reflections */
early = DspReverb_INTERNAL_ProcessEarly(reverb, in);
/* Reverberation with Wet/Dry Mix */
late[0] = DspReverb_INTERNAL_ProcessChannel(
late[0] = (DspReverb_INTERNAL_ProcessChannel(
reverb,
&reverb->channel[0],
early
);
) * reverb->wet_ratio) + samples_in[0] * reverb->dry_ratio;
late[1] = (DspReverb_INTERNAL_ProcessChannel(
reverb,
&reverb->channel[1],
early
) * reverb->wet_ratio) + in_ratio;
) * reverb->wet_ratio) + samples_in[1] * reverb->dry_ratio;
squared_sum += (late[0] * late[0]) + (late[1] * late[1]);
/* Output */
*samples_out++ = late[0];
*samples_out++ = late[1];
samples_in += 2;
}
return squared_sum;
......@@ -1407,6 +1407,22 @@ uint32_t FAudioFXReverb_LockForProcess(
fapo->base.pMalloc
);
/* Initialize the effect to a default setting */
if (fapo->apiVersion == 9)
{
DspReverb_SetParameters9(
&fapo->reverb,
(FAudioFXReverbParameters9*) fapo->base.m_pParameterBlocks
);
}
else
{
DspReverb_SetParameters(
&fapo->reverb,
(FAudioFXReverbParameters*) fapo->base.m_pParameterBlocks
);
}
/* Call parent to do basic validation */
return FAPOBase_LockForProcess(
&fapo->base,
......@@ -1487,6 +1503,24 @@ void FAudioFXReverb_Process(
FAudioFXReverbParameters *params;
uint8_t update_params = FAPOBase_ParametersChanged(&fapo->base);
float total;
params = (FAudioFXReverbParameters*) FAPOBase_BeginProcess(&fapo->base);
/* Update parameters before doing anything else */
if (update_params)
{
if (fapo->apiVersion == 9)
{
DspReverb_SetParameters9(
&fapo->reverb,
(FAudioFXReverbParameters9*) params
);
}
else
{
DspReverb_SetParameters(&fapo->reverb, params);
}
}
/* Handle disabled filter */
if (IsEnabled == 0)
......@@ -1503,6 +1537,7 @@ void FAudioFXReverb_Process(
);
}
FAPOBase_EndProcess(&fapo->base);
return;
}
......@@ -1516,24 +1551,6 @@ void FAudioFXReverb_Process(
);
}
params = (FAudioFXReverbParameters*) FAPOBase_BeginProcess(&fapo->base);
/* Update parameters */
if (update_params)
{
if (fapo->apiVersion == 9)
{
DspReverb_SetParameters9(
&fapo->reverb,
(FAudioFXReverbParameters9*) params
);
}
else
{
DspReverb_SetParameters(&fapo->reverb, params);
}
}
/* Run reverb effect */
#define PROCESS(pin, pout) \
DspReverb_INTERNAL_Process_##pin##_to_##pout( \
......@@ -1666,16 +1683,6 @@ uint32_t FAudioCreateReverbWithCustomAllocatorEXT(
sizeof(FAudioFXReverbParameters) * 3
);
result->apiVersion = 7;
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAudioFXReverbParameters) * offset, \
&fxdefault, \
sizeof(FAudioFXReverbParameters) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
/* Initialize... */
FAudio_memcpy(
......@@ -1711,6 +1718,13 @@ uint32_t FAudioCreateReverbWithCustomAllocatorEXT(
result->base.Destructor = FAudioFXReverb_Free;
#undef ASSIGN_VT
/* Prepare the default parameters */
result->base.base.Initialize(
result,
&fxdefault,
sizeof(FAudioFXReverbParameters)
);
/* Finally. */
*ppApo = &result->base.base;
return 0;
......@@ -1839,16 +1853,6 @@ uint32_t FAudioCreateReverb9WithCustomAllocatorEXT(
sizeof(FAudioFXReverbParameters9) * 3
);
result->apiVersion = 9;
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAudioFXReverbParameters9) * offset, \
&fxdefault, \
sizeof(FAudioFXReverbParameters9) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
/* Initialize... */
FAudio_memcpy(
......@@ -1884,6 +1888,13 @@ uint32_t FAudioCreateReverb9WithCustomAllocatorEXT(
result->base.Destructor = FAudioFXReverb_Free;
#undef ASSIGN_VT
/* Prepare the default parameters */
result->base.base.Initialize(
result,
&fxdefault,
sizeof(FAudioFXReverbParameters9)
);
/* Finally. */
*ppApo = &result->base.base;
return 0;
......
......@@ -285,10 +285,10 @@ void FAudio_INTERNAL_Convert_U8_To_F32_NEON(
const uint16x8_t uint16hi = vmovl_u8(vget_high_u8(bytes)); /* convert top 8 bytes to 8 uint16 */
const uint16x8_t uint16lo = vmovl_u8(vget_low_u8(bytes)); /* convert bottom 8 bytes to 8 uint16 */
/* split uint16 to two uint32, then convert to float, then multiply to normalize, subtract to adjust for sign, store. */
vst1q_f32(dst, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16hi))), divby128));
vst1q_f32(dst+4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16hi))), divby128));
vst1q_f32(dst+8, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16lo))), divby128));
vst1q_f32(dst+12, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16lo))), divby128));
vst1q_f32(dst, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16lo))), divby128));
vst1q_f32(dst+4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16lo))), divby128));
vst1q_f32(dst+8, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16hi))), divby128));
vst1q_f32(dst+12, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16hi))), divby128));
i -= 16; mmsrc -= 16; dst -= 16;
}
......
......@@ -501,6 +501,10 @@ uint32_t FAudio_PlatformGetDeviceDetails(
sizeof(GUID)
);
}
else
{
details->OutputFormat.dwChannelMask = GetMask(format->nChannels);
}
CoTaskMemFree(format);
......
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