add play sync API

main
cosmonaut 2021-11-24 11:26:02 -08:00
parent 5365f8993f
commit 90250633de
4 changed files with 39 additions and 12 deletions

Binary file not shown.

View File

@ -177,6 +177,10 @@
2,
2,
],"resourceVersion":"1.0","name":"FAudioGMS_SoundInstance_QueueSoundInstance","tags":[],"resourceType":"GMExtensionFunction",},
{"externalName":"FAudioGMS_SoundInstance_QueueSyncPlay","kind":1,"help":"FAudioGMS_SoundInstance_QueueSyncPlay(soundInstanceID)","hidden":false,"returnType":2,"argCount":0,"args":[
2,
],"resourceVersion":"1.0","name":"FAudioGMS_SoundInstance_QueueSyncPlay","tags":[],"resourceType":"GMExtensionFunction",},
{"externalName":"FAudioGMS_SoundInstance_SyncPlay","kind":1,"help":"FAudioGMS_SoundInstance_SyncPlay()","hidden":false,"returnType":2,"argCount":0,"args":[],"resourceVersion":"1.0","name":"FAudioGMS_SoundInstance_SyncPlay","tags":[],"resourceType":"GMExtensionFunction",},
],"constants":[],"ProxyFiles":[
{"TargetMask":7,"resourceVersion":"1.0","name":"libFAudioGMS.so","tags":[],"resourceType":"GMProxyFile",},
{"TargetMask":3,"resourceVersion":"1.0","name":"FAudioGMSAndroidDummy.ext","tags":[],"resourceType":"GMProxyFile",},
@ -190,6 +194,8 @@
{"name":"FAudioGMS_SoundInstance_Play","path":"extensions/FAudioGMS/FAudioGMS.yy",},
{"name":"FAudioGMS_SoundInstance_Pause","path":"extensions/FAudioGMS/FAudioGMS.yy",},
{"name":"FAudioGMS_SoundInstance_Stop","path":"extensions/FAudioGMS/FAudioGMS.yy",},
{"name":"FAudioGMS_SoundInstance_QueueSyncPlay","path":"extensions/FAudioGMS/FAudioGMS.yy",},
{"name":"FAudioGMS_SoundInstance_SyncPlay","path":"extensions/FAudioGMS/FAudioGMS.yy",},
{"name":"FAudioGMS_SoundInstance_SetLoop","path":"extensions/FAudioGMS/FAudioGMS.yy",},
{"name":"FAudioGMS_SoundInstance_SetPan","path":"extensions/FAudioGMS/FAudioGMS.yy",},
{"name":"FAudioGMS_SoundInstance_SetPitch","path":"extensions/FAudioGMS/FAudioGMS.yy",},

View File

@ -327,7 +327,7 @@ static inline FAudioGMS_EffectChain *FAudioGMS_INTERNAL_LookupEffectChain(uint32
/* Forward declarations to avoid some annoying BS */
static void FAudioGMS_INTERNAL_SoundInstance_AddBuffers(FAudioGMS_SoundInstance *instance);
static void FAudioGMS_INTERNAL_SoundInstance_Play(FAudioGMS_SoundInstance *instance);
static void FAudioGMS_INTERNAL_SoundInstance_Play(FAudioGMS_SoundInstance *instance, uint32_t operationSet);
static void FAudioGMS_INTERNAL_SoundInstance_Stop(FAudioGMS_SoundInstance *instance);
static void FAudioGMS_INTERNAL_SoundInstance_Destroy(FAudioGMS_SoundInstance *instance);
@ -379,7 +379,7 @@ static void FAudioGMS_INTERNAL_OnBufferEndCallback(
{
if (instance->queuedSoundInstance != NULL)
{
FAudioGMS_INTERNAL_SoundInstance_Play(instance->queuedSoundInstance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance->queuedSoundInstance, 0);
instance->queuedSoundInstance = NULL;
}
@ -1141,7 +1141,7 @@ static void FAudioGMS_INTERNAL_SoundInstance_AddEmitter(
FAudioGMS_INTERNAL_Apply3D(instance);
}
static void FAudioGMS_INTERNAL_SoundInstance_Play(FAudioGMS_SoundInstance *instance)
static void FAudioGMS_INTERNAL_SoundInstance_Play(FAudioGMS_SoundInstance *instance, uint32_t operationSet)
{
if (instance->soundState == SoundState_Playing)
{
@ -1190,7 +1190,7 @@ static void FAudioGMS_INTERNAL_SoundInstance_Play(FAudioGMS_SoundInstance *insta
FAudioGMS_INTERNAL_SoundInstance_AddBuffers(instance);
}
FAudioSourceVoice_Start(instance->voice.handle, 0, 0);
FAudioSourceVoice_Start(instance->voice.handle, 0, operationSet);
instance->soundState = SoundState_Playing;
}
@ -1202,10 +1202,28 @@ void FAudioGMS_SoundInstance_Play(double soundInstanceID)
if (instance != NULL)
{
FAudioGMS_INTERNAL_SoundInstance_Play(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance, 0);
}
}
FAUDIOGMSAPI void FAudioGMS_SoundInstance_QueueSyncPlay(double soundInstanceID)
{
RETURN_ON_NULL_DEVICE_VOID
FAudioGMS_SoundInstance *instance =
FAudioGMS_INTERNAL_LookupSoundInstance((uint32_t)soundInstanceID);
if (instance != NULL)
{
FAudioGMS_INTERNAL_SoundInstance_Play(instance, 1); /* operation set */
}
}
void FAudioGMS_SoundInstance_SyncPlay()
{
RETURN_ON_NULL_DEVICE_VOID
FAudio_CommitOperationSet(device->handle, 1);
}
static void FAudioGMS_INTERNAL_SoundInstance_Pause(FAudioGMS_SoundInstance *instance)
{
if (instance != NULL)
@ -1284,7 +1302,7 @@ void FAudioGMS_SoundInstance_SetLoop(double soundInstanceID, double loop)
/* We need to pause and play so that static buffers get resubmitted
*/
FAudioGMS_INTERNAL_SoundInstance_Pause(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance, 0);
}
}
}
@ -1407,7 +1425,7 @@ void FAudioGMS_SoundInstance_SetTrackPositionInSeconds(
if (currentState == SoundState_Playing)
{
FAudioGMS_INTERNAL_SoundInstance_Play(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance, 0);
}
}
}
@ -1467,7 +1485,7 @@ void FAudioGMS_SoundInstance_SetPlayRegion(
if (instance->isStatic && instance->soundState == SoundState_Playing)
{
FAudioGMS_INTERNAL_SoundInstance_Stop(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance, 0);
}
else if (!instance->isStatic)
{
@ -1483,7 +1501,7 @@ void FAudioGMS_SoundInstance_SetPlayRegion(
if (instance->isStatic && instance->soundState != SoundState_Stopped)
{
FAudioGMS_INTERNAL_SoundInstance_Pause(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance, 0);
}
}
}
@ -2081,7 +2099,7 @@ void FAudioGMS_ResumeAll()
if (instance != NULL && instance->isGlobalPaused)
{
instance->isGlobalPaused = 0;
FAudioGMS_INTERNAL_SoundInstance_Play(instance);
FAudioGMS_INTERNAL_SoundInstance_Play(instance, 0);
}
}
}

View File

@ -57,6 +57,9 @@ extern "C"
FAUDIOGMSAPI void FAudioGMS_SoundInstance_Pause(double soundInstanceID);
FAUDIOGMSAPI void FAudioGMS_SoundInstance_Stop(double soundInstanceID);
FAUDIOGMSAPI void FAudioGMS_SoundInstance_QueueSyncPlay(double soundInstanceID);
FAUDIOGMSAPI void FAudioGMS_SoundInstance_SyncPlay();
FAUDIOGMSAPI void FAudioGMS_SoundInstance_SetPlayRegion(
double soundInstanceID,
double startInMilliseconds,