Commit 06954925 authored by David Reid's avatar David Reid

Rename some APIs from previous commit.

This uses the "enabled" notion rather than "available" as I think it's
a bit clearer in terms of enabled at compile time rather than available
at run time.

Public issue https://github.com/mackron/miniaudio/issues/211
parent e59ee1e7
...@@ -5102,23 +5102,23 @@ MA_API const char* ma_get_backend_name(ma_backend backend); ...@@ -5102,23 +5102,23 @@ MA_API const char* ma_get_backend_name(ma_backend backend);
/* /*
Determines whether or not the given backend is available by the compilation environment. Determines whether or not the given backend is available by the compilation environment.
*/ */
MA_API ma_bool32 ma_is_backend_available(ma_backend backend); MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend);
/* /*
Retrieves available backends. Retrieves compile-time enabled backends.
Parameters Parameters
---------- ----------
pBackends(out, optional) pBackends(out, optional)
A pointer to the buffer that will receive the available backends. Set to NULL to retrieve the backend count. Setting A pointer to the buffer that will receive the enabled backends. Set to NULL to retrieve the backend count. Setting
the capacity of the buffer to `MA_BUFFER_COUNT` will guarantee it's large enough for all backends. the capacity of the buffer to `MA_BUFFER_COUNT` will guarantee it's large enough for all backends.
backendCap(in) backendCap(in)
The capacity of the `pBackends` buffer. The capacity of the `pBackends` buffer.
pBackendCount(out) pBackendCount(out)
A pointer to the variable that will receive the available backend count. A pointer to the variable that will receive the enabled backend count.
Return Value Return Value
...@@ -5156,26 +5156,26 @@ PulseAudio installed. ...@@ -5156,26 +5156,26 @@ PulseAudio installed.
Example 1 Example 1
--------- ---------
The example below retrieves the available backend count using a fixed sized buffer allocated on the stack. The buffer The example below retrieves the enabled backend count using a fixed sized buffer allocated on the stack. The buffer is
is given a capacity of `MA_BACKEND_COUNT` which will guarantee it'll be large enough to store all available backends. given a capacity of `MA_BACKEND_COUNT` which will guarantee it'll be large enough to store all available backends.
Since `MA_BACKEND_COUNT` is always a relatively small value, this should be suitable for most scenarios. Since `MA_BACKEND_COUNT` is always a relatively small value, this should be suitable for most scenarios.
``` ```
ma_backend availableBackends[MA_BACKEND_COUNT]; ma_backend enabledBackends[MA_BACKEND_COUNT];
size_t availableBackendCount; size_t enabledBackendCount;
result = ma_get_avaialable_backends(availableBackends, MA_BACKEND_COUNT, &availbleBackendCount); result = ma_get_enabled_backends(enabledBackends, MA_BACKEND_COUNT, &enabledBackendCount);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
// Failed to retrieve available backends. Should never happen in this example since all inputs are valid. // Failed to retrieve enabled backends. Should never happen in this example since all inputs are valid.
} }
``` ```
See Also See Also
-------- --------
ma_is_backend_available() ma_is_backend_enabled()
*/ */
MA_API ma_result ma_get_avaialable_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount); MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount);
/* /*
Determines whether or not loopback mode is support by a backend. Determines whether or not loopback mode is support by a backend.
...@@ -9456,7 +9456,7 @@ MA_API const char* ma_get_backend_name(ma_backend backend) ...@@ -9456,7 +9456,7 @@ MA_API const char* ma_get_backend_name(ma_backend backend)
} }
} }
MA_API ma_bool32 ma_is_backend_available(ma_backend backend) MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend)
{ {
/* /*
This looks a little bit gross, but we want all backends to be included in the switch to avoid warnings on some compilers This looks a little bit gross, but we want all backends to be included in the switch to avoid warnings on some compilers
...@@ -9553,7 +9553,7 @@ MA_API ma_bool32 ma_is_backend_available(ma_backend backend) ...@@ -9553,7 +9553,7 @@ MA_API ma_bool32 ma_is_backend_available(ma_backend backend)
} }
} }
MA_API ma_result ma_get_avaialable_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount) MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount)
{ {
size_t backendCount; size_t backendCount;
size_t iBackend; size_t iBackend;
...@@ -9568,8 +9568,8 @@ MA_API ma_result ma_get_avaialable_backends(ma_backend* pBackends, size_t backen ...@@ -9568,8 +9568,8 @@ MA_API ma_result ma_get_avaialable_backends(ma_backend* pBackends, size_t backen
for (iBackend = 0; iBackend <= ma_backend_null; iBackend += 1) { for (iBackend = 0; iBackend <= ma_backend_null; iBackend += 1) {
ma_backend backend = (ma_backend)iBackend; ma_backend backend = (ma_backend)iBackend;
if (ma_is_backend_available(backend)) { if (ma_is_backend_enabled(backend)) {
/* The backend is available. Try adding it to the list. If there's no room, MA_NO_SPACE needs to be returned. */ /* The backend is enabled. Try adding it to the list. If there's no room, MA_NO_SPACE needs to be returned. */
if (backendCount == backendCap) { if (backendCount == backendCap) {
result = MA_NO_SPACE; result = MA_NO_SPACE;
break; break;
...@@ -62814,7 +62814,7 @@ The following miscellaneous changes have also been made. ...@@ -62814,7 +62814,7 @@ The following miscellaneous changes have also been made.
REVISION HISTORY REVISION HISTORY
================ ================
v0.10.21 - TBD v0.10.21 - TBD
- Add ma_is_backend_available() and ma_get_avaialable_backends() for retrieving available backends at run-time. - Add ma_is_backend_enabled() and ma_get_enabled_backends() for retrieving available backends at run-time.
- WASAPI: Fix a copy and paste bug relating to loopback mode. - WASAPI: Fix a copy and paste bug relating to loopback mode.
- Core Audio: Fix a bug when using multiple contexts. - Core Audio: Fix a bug when using multiple contexts.
- Core Audio: Fix a compilation warning. - Core Audio: Fix a compilation warning.
...@@ -357,9 +357,9 @@ int main(int argc, char** argv) ...@@ -357,9 +357,9 @@ int main(int argc, char** argv)
{ {
int iarg; int iarg;
ma_result result; ma_result result;
ma_backend availableBackends[MA_BACKEND_COUNT]; ma_backend enabledBackends[MA_BACKEND_COUNT];
size_t availbleBackendCount; size_t enabledBackendCount;
size_t iAvailableBackend; size_t iEnabledBackend;
ma_backend backends[MA_BACKEND_COUNT]; ma_backend backends[MA_BACKEND_COUNT];
ma_uint32 backendCount = 0; ma_uint32 backendCount = 0;
ma_context_config contextConfig; ma_context_config contextConfig;
...@@ -407,15 +407,15 @@ int main(int argc, char** argv) ...@@ -407,15 +407,15 @@ int main(int argc, char** argv)
} }
/* Here we'll quickly print the available backends. */ /* Here we'll quickly print the available backends. */
printf("Available Backends:\n"); printf("Enabled Backends:\n");
result = ma_get_avaialable_backends(availableBackends, ma_countof(availableBackends), &availbleBackendCount); result = ma_get_enabled_backends(enabledBackends, ma_countof(enabledBackends), &enabledBackendCount);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to retrieve available backends.\n"); printf("Failed to retrieve available backends.\n");
return -1; return -1;
} }
for (iAvailableBackend = 0; iAvailableBackend < availbleBackendCount; iAvailableBackend += 1) { for (iEnabledBackend = 0; iEnabledBackend < enabledBackendCount; iEnabledBackend += 1) {
printf(" %s\n", ma_get_backend_name(availableBackends[iAvailableBackend])); printf(" %s\n", ma_get_backend_name(enabledBackends[iEnabledBackend]));
} }
printf("\n"); printf("\n");
......
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