Engine: Fix a bug where sounds groups are not initialized properly.

This is happening due to the hierarchy not being constructed properly.
This commit is contained in:
David Reid
2020-10-11 09:40:57 +10:00
parent ea82457317
commit 4f63069984
2 changed files with 17 additions and 6 deletions
+13 -4
View File
@@ -14,8 +14,10 @@ typedef struct
void on_sound_loaded(ma_async_notification* pNotification, int code)
{
sound_loaded_notification* pLoadedNotification = (sound_loaded_notification*)pNotification;
ma_uint64 lengthInPCMFrames;
//sound_loaded_notification* pLoadedNotification = (sound_loaded_notification*)pNotification;
//ma_uint64 lengthInPCMFrames;
(void)pNotification;
if (code == MA_NOTIFICATION_INIT) {
@@ -43,6 +45,7 @@ int main(int argc, char** argv)
ma_sound sound;
ma_sound sound2;
sound_loaded_notification loadNotification;
ma_sound_group group;
if (argc < 2) {
@@ -68,19 +71,25 @@ int main(int argc, char** argv)
return -1;
}
result = ma_sound_group_init(&engine, NULL, &group);
if (result != MA_SUCCESS) {
printf("Failed to initialize sound group.");
return -1;
}
#if 1
loadNotification.cb.onSignal = on_sound_loaded;
loadNotification.pSound = &sound;
result = ma_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE /*| MA_DATA_SOURCE_FLAG_ASYNC | MA_DATA_SOURCE_FLAG_STREAM*/, &loadNotification, NULL, &sound);
result = ma_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE /*| MA_DATA_SOURCE_FLAG_ASYNC | MA_DATA_SOURCE_FLAG_STREAM*/, &loadNotification, &group, &sound);
if (result != MA_SUCCESS) {
printf("Failed to load sound: %s\n", argv[1]);
ma_engine_uninit(&engine);
return -1;
}
#if 1
#if 0
result = ma_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE /*| MA_DATA_SOURCE_FLAG_ASYNC | MA_DATA_SOURCE_FLAG_STREAM*/, &loadNotification, NULL, &sound2);
if (result != MA_SUCCESS) {
printf("Failed to load sound: %s\n", argv[1]);
+4 -2
View File
@@ -4217,7 +4217,7 @@ MA_API ma_result ma_async_notification_event_signal(ma_async_notification_event*
#define MA_JOB_ID_NONE ~((ma_uint64)0)
#define MA_JOB_SLOT_NONE ~((ma_uint16)0)
#define MA_JOB_SLOT_NONE (ma_uint16)(~0)
static MA_INLINE ma_uint32 ma_job_extract_refcount(ma_uint64 toc)
{
@@ -8405,6 +8405,8 @@ static void ma_engine_mix_sound_internal(ma_engine* pEngine, ma_sound_group* pGr
ma_result result = MA_SUCCESS;
ma_uint64 framesProcessed;
(void)pEngine; /* Unused at the moment. */
/* Don't do anything if we're not playing. */
if (pSound->isPlaying == MA_FALSE) {
return;
@@ -9562,7 +9564,7 @@ static ma_result ma_sound_group_attach(ma_sound_group* pGroup, ma_sound_group* p
pOldFirstChild->pPrevSibling = pNewFirstChild;
}
pGroup->pFirstChild = pNewFirstChild;
pParentGroup->pFirstChild = pNewFirstChild;
return MA_SUCCESS;
}