| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include "../miniaudio.c" |
| 9 |
#include "../extras/decoders/libvorbis/miniaudio_libvorbis.c" |
| 10 |
#include "../extras/decoders/libopus/miniaudio_libopus.c" |
| 11 |
|
| 12 |
#include <stdio.h> |
| 13 |
|
| 14 |
|
| 15 |
int main(int argc, char** argv) |
| 16 |
{ |
| 17 |
ma_result result; |
| 18 |
ma_resource_manager_config resourceManagerConfig; |
| 19 |
ma_resource_manager resourceManager; |
| 20 |
ma_engine_config engineConfig; |
| 21 |
ma_engine engine; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
ma_decoding_backend_vtable* pCustomBackendVTables[] = |
| 28 |
{ |
| 29 |
ma_decoding_backend_libvorbis, |
| 30 |
ma_decoding_backend_libopus |
| 31 |
}; |
| 32 |
|
| 33 |
|
| 34 |
if (argc < 2) { |
| 35 |
printf("No input file.\n"); |
| 36 |
return -1; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
resourceManagerConfig = ma_resource_manager_config_init(); |
| 42 |
resourceManagerConfig.ppCustomDecodingBackendVTables = pCustomBackendVTables; |
| 43 |
resourceManagerConfig.customDecodingBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]); |
| 44 |
resourceManagerConfig.pCustomDecodingBackendUserData = NULL; |
| 45 |
|
| 46 |
result = ma_resource_manager_init(&resourceManagerConfig, &resourceManager); |
| 47 |
if (result != MA_SUCCESS) { |
| 48 |
printf("Failed to initialize resource manager."); |
| 49 |
return -1; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
engineConfig = ma_engine_config_init(); |
| 55 |
engineConfig.pResourceManager = &resourceManager; |
| 56 |
|
| 57 |
result = ma_engine_init(&engineConfig, &engine); |
| 58 |
if (result != MA_SUCCESS) { |
| 59 |
printf("Failed to initialize engine."); |
| 60 |
return -1; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
result = ma_engine_play_sound(&engine, argv[1], NULL); |
| 66 |
if (result != MA_SUCCESS) { |
| 67 |
printf("Failed to play sound."); |
| 68 |
return -1; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
printf("Press Enter to quit..."); |
| 73 |
getchar(); |
| 74 |
|
| 75 |
ma_engine_uninit(&engine); |
| 76 |
ma_resource_manager_uninit(&resourceManager); |
| 77 |
|
| 78 |
return 0; |
| 79 |
} |