mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Add support for customizing the VFS for ma_engine.
This commit is contained in:
@@ -44,6 +44,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
resourceManagerConfig = ma_resource_manager_config_init();
|
resourceManagerConfig = ma_resource_manager_config_init();
|
||||||
//resourceManagerConfig.decodedFormat = ma_format_s16;
|
//resourceManagerConfig.decodedFormat = ma_format_s16;
|
||||||
|
resourceManagerConfig.decodedSampleRate = 48000;
|
||||||
result = ma_resource_manager_init(&resourceManagerConfig, &resourceManager);
|
result = ma_resource_manager_init(&resourceManagerConfig, &resourceManager);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
printf("Failed to initialize resource manager.\n");
|
printf("Failed to initialize resource manager.\n");
|
||||||
@@ -64,7 +65,7 @@ int main(int argc, char** argv)
|
|||||||
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, NULL, &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);
|
||||||
@@ -72,7 +73,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
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]);
|
||||||
ma_engine_uninit(&engine);
|
ma_engine_uninit(&engine);
|
||||||
@@ -101,8 +102,8 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
//ma_sleep(1000);
|
//ma_sleep(1000);
|
||||||
//ma_sound_set_looping(&sound2, MA_TRUE);
|
//ma_sound_set_looping(&sound2, MA_TRUE);
|
||||||
ma_sound_set_volume(&sound2, 0.5f);
|
//ma_sound_set_volume(&sound2, 0.5f);
|
||||||
ma_sound_start(&sound2);
|
//ma_sound_start(&sound2);
|
||||||
|
|
||||||
//ma_sleep(2000);
|
//ma_sleep(2000);
|
||||||
printf("Stopping...\n");
|
printf("Stopping...\n");
|
||||||
|
|||||||
@@ -914,10 +914,10 @@ struct ma_sound_group
|
|||||||
ma_sound_group* pPrevSibling;
|
ma_sound_group* pPrevSibling;
|
||||||
ma_sound_group* pNextSibling;
|
ma_sound_group* pNextSibling;
|
||||||
ma_sound* pFirstSoundInGroup;
|
ma_sound* pFirstSoundInGroup;
|
||||||
ma_engine_effect effect; /* The main effect for panning, etc. This is set on the mixer at initialisation time. */
|
ma_engine_effect effect; /* The main effect for panning, etc. This is set on the mixer at initialisation time. */
|
||||||
ma_mixer mixer;
|
ma_mixer mixer;
|
||||||
ma_mutex lock; /* Only used by ma_sound_init_*() and ma_sound_uninit(). Not used in the mixing thread. */
|
ma_mutex lock; /* Only used by ma_sound_init_*() and ma_sound_uninit(). Not used in the mixing thread. */
|
||||||
ma_uint64 runningTimeInEngineFrames; /* The amount of time the sound has been running in engine frames, including start delays. */
|
ma_uint64 runningTimeInEngineFrames; /* The amount of time the sound has been running in engine frames, including start delays. */
|
||||||
ma_uint64 startDelayInEngineFrames;
|
ma_uint64 startDelayInEngineFrames;
|
||||||
ma_uint64 stopDelayInEngineFrames; /* In the engine's sample rate. */
|
ma_uint64 stopDelayInEngineFrames; /* In the engine's sample rate. */
|
||||||
ma_uint64 stopDelayInEngineFramesRemaining; /* The number of frames relative to the engine's clock before the sound is stopped. */
|
ma_uint64 stopDelayInEngineFramesRemaining; /* The number of frames relative to the engine's clock before the sound is stopped. */
|
||||||
@@ -943,6 +943,7 @@ typedef struct
|
|||||||
ma_device_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */
|
ma_device_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */
|
||||||
ma_allocation_callbacks allocationCallbacks;
|
ma_allocation_callbacks allocationCallbacks;
|
||||||
ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
|
ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
|
||||||
|
ma_vfs* pResourceManagerVFS; /* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */
|
||||||
} ma_engine_config;
|
} ma_engine_config;
|
||||||
|
|
||||||
MA_API ma_engine_config ma_engine_config_init_default();
|
MA_API ma_engine_config ma_engine_config_init_default();
|
||||||
@@ -5686,6 +5687,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng
|
|||||||
resourceManagerConfig.decodedChannels = 0; /* Leave the decoded channel count as 0 so we can get good spatialization. */
|
resourceManagerConfig.decodedChannels = 0; /* Leave the decoded channel count as 0 so we can get good spatialization. */
|
||||||
resourceManagerConfig.decodedSampleRate = pEngine->sampleRate;
|
resourceManagerConfig.decodedSampleRate = pEngine->sampleRate;
|
||||||
ma_allocation_callbacks_init_copy(&resourceManagerConfig.allocationCallbacks, &pEngine->allocationCallbacks);
|
ma_allocation_callbacks_init_copy(&resourceManagerConfig.allocationCallbacks, &pEngine->allocationCallbacks);
|
||||||
|
resourceManagerConfig.pVFS = pConfig->pResourceManagerVFS;
|
||||||
|
|
||||||
result = ma_resource_manager_init(&resourceManagerConfig, pEngine->pResourceManager);
|
result = ma_resource_manager_init(&resourceManagerConfig, pEngine->pResourceManager);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user