Update OpenAL-soft to 1.21.1

This commit is contained in:
Miku AuahDark
2021-02-11 18:04:50 +08:00
parent 08f227997e
commit 904cc75ba8
358 changed files with 61122 additions and 60973 deletions
+83 -6
View File
@@ -28,15 +28,16 @@
* finding an appropriate buffer format, and getting readable strings for
* channel configs and sample types. */
#include "alhelpers.h"
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"
#include "alhelpers.h"
/* InitAL opens a device and sets up a context using default attributes, making
* the program ready to call OpenAL functions. */
@@ -107,10 +108,86 @@ const char *FormatName(ALenum format)
{
switch(format)
{
case AL_FORMAT_MONO8: return "Mono, U8";
case AL_FORMAT_MONO16: return "Mono, S16";
case AL_FORMAT_STEREO8: return "Stereo, U8";
case AL_FORMAT_STEREO16: return "Stereo, S16";
case AL_FORMAT_MONO8: return "Mono, U8";
case AL_FORMAT_MONO16: return "Mono, S16";
case AL_FORMAT_MONO_FLOAT32: return "Mono, Float32";
case AL_FORMAT_STEREO8: return "Stereo, U8";
case AL_FORMAT_STEREO16: return "Stereo, S16";
case AL_FORMAT_STEREO_FLOAT32: return "Stereo, Float32";
case AL_FORMAT_BFORMAT2D_8: return "B-Format 2D, U8";
case AL_FORMAT_BFORMAT2D_16: return "B-Format 2D, S16";
case AL_FORMAT_BFORMAT2D_FLOAT32: return "B-Format 2D, Float32";
case AL_FORMAT_BFORMAT3D_8: return "B-Format 3D, U8";
case AL_FORMAT_BFORMAT3D_16: return "B-Format 3D, S16";
case AL_FORMAT_BFORMAT3D_FLOAT32: return "B-Format 3D, Float32";
}
return "Unknown Format";
}
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
int altime_get(void)
{
static int start_time = 0;
int cur_time;
union {
FILETIME ftime;
ULARGE_INTEGER ulint;
} systime;
GetSystemTimeAsFileTime(&systime.ftime);
/* FILETIME is in 100-nanosecond units, or 1/10th of a microsecond. */
cur_time = (int)(systime.ulint.QuadPart/10000);
if(!start_time)
start_time = cur_time;
return cur_time - start_time;
}
void al_nssleep(unsigned long nsec)
{
Sleep(nsec / 1000000);
}
#else
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
int altime_get(void)
{
static int start_time = 0u;
int cur_time;
#if _POSIX_TIMERS > 0
struct timespec ts;
int ret = clock_gettime(CLOCK_REALTIME, &ts);
if(ret != 0) return 0;
cur_time = (int)(ts.tv_sec*1000 + ts.tv_nsec/1000000);
#else /* _POSIX_TIMERS > 0 */
struct timeval tv;
int ret = gettimeofday(&tv, NULL);
if(ret != 0) return 0;
cur_time = (int)(tv.tv_sec*1000 + tv.tv_usec/1000);
#endif
if(!start_time)
start_time = cur_time;
return cur_time - start_time;
}
void al_nssleep(unsigned long nsec)
{
struct timespec ts, rem;
ts.tv_sec = (time_t)(nsec / 1000000000ul);
ts.tv_nsec = (long)(nsec % 1000000000ul);
while(nanosleep(&ts, &rem) == -1 && errno == EINTR)
ts = rem;
}
#endif
+7 -7
View File
@@ -1,15 +1,11 @@
#ifndef ALHELPERS_H
#define ALHELPERS_H
#include "AL/alc.h"
#include "AL/al.h"
#include "AL/alext.h"
#include "threads.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif
/* Some helper functions to get the name from the format enums. */
const char *FormatName(ALenum type);
@@ -18,8 +14,12 @@ const char *FormatName(ALenum type);
int InitAL(char ***argv, int *argc);
void CloseAL(void);
/* Cross-platform timeget and sleep functions. */
int altime_get(void);
void al_nssleep(unsigned long nsec);
#ifdef __cplusplus
}
#endif /* __cplusplus */
} // extern "C"
#endif
#endif /* ALHELPERS_H */