mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
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:
@@ -14,8 +14,10 @@ typedef struct
|
|||||||
|
|
||||||
void on_sound_loaded(ma_async_notification* pNotification, int code)
|
void on_sound_loaded(ma_async_notification* pNotification, int code)
|
||||||
{
|
{
|
||||||
sound_loaded_notification* pLoadedNotification = (sound_loaded_notification*)pNotification;
|
//sound_loaded_notification* pLoadedNotification = (sound_loaded_notification*)pNotification;
|
||||||
ma_uint64 lengthInPCMFrames;
|
//ma_uint64 lengthInPCMFrames;
|
||||||
|
|
||||||
|
(void)pNotification;
|
||||||
|
|
||||||
if (code == MA_NOTIFICATION_INIT) {
|
if (code == MA_NOTIFICATION_INIT) {
|
||||||
|
|
||||||
@@ -43,6 +45,7 @@ int main(int argc, char** argv)
|
|||||||
ma_sound sound;
|
ma_sound sound;
|
||||||
ma_sound sound2;
|
ma_sound sound2;
|
||||||
sound_loaded_notification loadNotification;
|
sound_loaded_notification loadNotification;
|
||||||
|
ma_sound_group group;
|
||||||
|
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
@@ -68,19 +71,25 @@ int main(int argc, char** argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = ma_sound_group_init(&engine, NULL, &group);
|
||||||
|
if (result != MA_SUCCESS) {
|
||||||
|
printf("Failed to initialize sound group.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
loadNotification.cb.onSignal = on_sound_loaded;
|
loadNotification.cb.onSignal = on_sound_loaded;
|
||||||
loadNotification.pSound = &sound;
|
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) {
|
if (result != MA_SUCCESS) {
|
||||||
printf("Failed to load sound: %s\n", argv[1]);
|
printf("Failed to load sound: %s\n", argv[1]);
|
||||||
ma_engine_uninit(&engine);
|
ma_engine_uninit(&engine);
|
||||||
return -1;
|
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);
|
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) {
|
if (result != MA_SUCCESS) {
|
||||||
printf("Failed to load sound: %s\n", argv[1]);
|
printf("Failed to load sound: %s\n", argv[1]);
|
||||||
|
|||||||
@@ -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_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)
|
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_result result = MA_SUCCESS;
|
||||||
ma_uint64 framesProcessed;
|
ma_uint64 framesProcessed;
|
||||||
|
|
||||||
|
(void)pEngine; /* Unused at the moment. */
|
||||||
|
|
||||||
/* Don't do anything if we're not playing. */
|
/* Don't do anything if we're not playing. */
|
||||||
if (pSound->isPlaying == MA_FALSE) {
|
if (pSound->isPlaying == MA_FALSE) {
|
||||||
return;
|
return;
|
||||||
@@ -9562,7 +9564,7 @@ static ma_result ma_sound_group_attach(ma_sound_group* pGroup, ma_sound_group* p
|
|||||||
pOldFirstChild->pPrevSibling = pNewFirstChild;
|
pOldFirstChild->pPrevSibling = pNewFirstChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
pGroup->pFirstChild = pNewFirstChild;
|
pParentGroup->pFirstChild = pNewFirstChild;
|
||||||
|
|
||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user