Commit 105d016e authored by David Reid's avatar David Reid

Updates to the new ma_engine API.

  * The engine will now auto-start by default. This can be changed in
    the config by setting `noAutoStart` to true.

  * Initial implementation of ma_engine_play_sound() which can be used
    for fire-and-forget playback of sounds.

  * Add ma_engine_sound_at_end() for querying whether or not a sound
    has reached the end. The at-end flag is set atomically and
    locklessly in the mixing thread.
parent 8254324a
...@@ -26,14 +26,6 @@ int main(int argc, char** argv) ...@@ -26,14 +26,6 @@ int main(int argc, char** argv)
return (int)result; return (int)result;
} }
/* Currently an explicit start is required. Perhaps make it so this is started by default, or maybe start it when the first sound is started? Maybe make it an option? */
result = ma_engine_start(&engine); /* Do we want the engine to be started by default? */
if (result != MA_SUCCESS) {
ma_engine_uninit(&engine);
return (int)result;
}
/* We can load our resource after starting the engine - the engine will deal with loading everything properly. */ /* We can load our resource after starting the engine - the engine will deal with loading everything properly. */
if (argc > 1) { if (argc > 1) {
result = ma_engine_create_sound_from_file(&engine, argv[1], NULL, &sound1); result = ma_engine_create_sound_from_file(&engine, argv[1], NULL, &sound1);
...@@ -42,12 +34,22 @@ int main(int argc, char** argv) ...@@ -42,12 +34,22 @@ int main(int argc, char** argv)
return (int)result; return (int)result;
} }
ma_engine_sound_set_looping(&engine, &sound1, MA_TRUE);
ma_engine_sound_start(&engine, &sound1); ma_engine_sound_start(&engine, &sound1);
result = ma_engine_play_sound(&engine, argv[1], NULL);
if (result != MA_SUCCESS) {
printf("ma_engine_play_sound() failed with: %s\n", ma_result_description(result));
}
} }
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
/* Normally you would uninitialize and clean up all of your sounds manually because ma_engine_uninit() will _not_ do it for you. */
ma_engine_uninit(&engine);
return 0; return 0;
} }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment