diff options
author | Sven Gothel <[email protected]> | 2019-04-07 23:39:04 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-04-07 23:39:04 +0200 |
commit | 73233ce69919fc19c53ce8663c5b8cc05227f07e (patch) | |
tree | f2b6ccc1a14d7c387f33398a44ea4511d7ecb212 /utils/openal-info.c | |
parent | 8efa4c7ba5ee8eb399d31a9884e45f743d4625ad (diff) | |
parent | 99a55c445211fea77af6ab61cbc6a6ec4fbdc9b9 (diff) |
Merge branch 'v1.19' of git://repo.or.cz/openal-soft into v1.19v1.19
Diffstat (limited to 'utils/openal-info.c')
-rw-r--r-- | utils/openal-info.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/utils/openal-info.c b/utils/openal-info.c index 5b45ceef..12dc6311 100644 --- a/utils/openal-info.c +++ b/utils/openal-info.c @@ -24,6 +24,7 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #include "AL/alc.h" #include "AL/al.h" @@ -41,6 +42,70 @@ #endif +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +static WCHAR *FromUTF8(const char *str) +{ + WCHAR *out = NULL; + int len; + + if((len=MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0)) > 0) + { + out = calloc(sizeof(WCHAR), len); + MultiByteToWideChar(CP_UTF8, 0, str, -1, out, len); + } + return out; +} + +/* Override printf, fprintf, and fwrite so we can print UTF-8 strings. */ +static void al_fprintf(FILE *file, const char *fmt, ...) +{ + char str[1024]; + WCHAR *wstr; + va_list ap; + + va_start(ap, fmt); + vsnprintf(str, sizeof(str), fmt, ap); + va_end(ap); + + str[sizeof(str)-1] = 0; + wstr = FromUTF8(str); + if(!wstr) + fprintf(file, "<UTF-8 error> %s", str); + else + fprintf(file, "%ls", wstr); + free(wstr); +} +#define fprintf al_fprintf +#define printf(...) al_fprintf(stdout, __VA_ARGS__) + +static size_t al_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file) +{ + char str[1024]; + WCHAR *wstr; + size_t len; + + len = size * nmemb; + if(len > sizeof(str)-1) + len = sizeof(str)-1; + memcpy(str, ptr, len); + str[len] = 0; + + wstr = FromUTF8(str); + if(!wstr) + fprintf(file, "<UTF-8 error> %s", str); + else + fprintf(file, "%ls", wstr); + free(wstr); + + return len / size; +} +#define fwrite al_fwrite +#endif + + #define MAX_WIDTH 80 static void printList(const char *list, char separator) @@ -186,6 +251,38 @@ static void printALInfo(void) checkALErrors(); } +static void printResamplerInfo(void) +{ + LPALGETSTRINGISOFT alGetStringiSOFT; + ALint num_resamplers; + ALint def_resampler; + + if(!alIsExtensionPresent("AL_SOFT_source_resampler")) + { + printf("Resampler info not available\n"); + return; + } + + alGetStringiSOFT = alGetProcAddress("alGetStringiSOFT"); + + num_resamplers = alGetInteger(AL_NUM_RESAMPLERS_SOFT); + def_resampler = alGetInteger(AL_DEFAULT_RESAMPLER_SOFT); + + if(!num_resamplers) + printf("!!! No resamplers found !!!\n"); + else + { + ALint i; + printf("Available resamplers:\n"); + for(i = 0;i < num_resamplers;++i) + { + const ALchar *name = alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i); + printf(" %s%s\n", name, (i==def_resampler)?" *":""); + } + } + checkALErrors(); +} + static void printEFXInfo(ALCdevice *device) { ALCint major, minor, sends; @@ -329,6 +426,7 @@ int main(int argc, char *argv[]) } printALInfo(); + printResamplerInfo(); printEFXInfo(device); alcMakeContextCurrent(NULL); |