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
+29 -20
View File
@@ -27,7 +27,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include "AL/al.h"
#include "AL/alc.h"
@@ -35,6 +35,8 @@
#include "common/alhelpers.h"
#include "win_main_utf8.h"
#if defined(_WIN64)
#define SZFMT "%I64u"
@@ -54,13 +56,19 @@ static float msvc_strtof(const char *str, char **end)
static void fwrite16le(ALushort val, FILE *f)
{
ALubyte data[2] = { val&0xff, (val>>8)&0xff };
ALubyte data[2];
data[0] = (ALubyte)(val&0xff);
data[1] = (ALubyte)(val>>8);
fwrite(data, 1, 2, f);
}
static void fwrite32le(ALuint val, FILE *f)
{
ALubyte data[4] = { val&0xff, (val>>8)&0xff, (val>>16)&0xff, (val>>24)&0xff };
ALubyte data[4];
data[0] = (ALubyte)(val&0xff);
data[1] = (ALubyte)((val>>8)&0xff);
data[2] = (ALubyte)((val>>16)&0xff);
data[3] = (ALubyte)(val>>24);
fwrite(data, 1, 4, f);
}
@@ -73,9 +81,9 @@ typedef struct Recorder {
ALuint mDataSize;
float mRecTime;
int mChannels;
int mBits;
int mSampleRate;
ALuint mChannels;
ALuint mBits;
ALuint mSampleRate;
ALuint mFrameSize;
ALbyte *mBuffer;
ALsizei mBufferSize;
@@ -133,13 +141,13 @@ int main(int argc, char **argv)
break;
else if(strcmp(argv[0], "--channels") == 0 || strcmp(argv[0], "-c") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
}
recorder.mChannels = strtol(argv[1], &end, 0);
recorder.mChannels = (ALuint)strtoul(argv[1], &end, 0);
if((recorder.mChannels != 1 && recorder.mChannels != 2) || (end && *end != '\0'))
{
fprintf(stderr, "Invalid channels: %s\n", argv[1]);
@@ -150,13 +158,13 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--bits") == 0 || strcmp(argv[0], "-b") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
}
recorder.mBits = strtol(argv[1], &end, 0);
recorder.mBits = (ALuint)strtoul(argv[1], &end, 0);
if((recorder.mBits != 8 && recorder.mBits != 16 && recorder.mBits != 32) ||
(end && *end != '\0'))
{
@@ -168,13 +176,13 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--rate") == 0 || strcmp(argv[0], "-r") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
}
recorder.mSampleRate = strtol(argv[1], &end, 0);
recorder.mSampleRate = (ALuint)strtoul(argv[1], &end, 0);
if(!(recorder.mSampleRate >= 8000 && recorder.mSampleRate <= 96000) || (end && *end != '\0'))
{
fprintf(stderr, "Invalid sample rate: %s\n", argv[1]);
@@ -185,7 +193,7 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--time") == 0 || strcmp(argv[0], "-t") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
@@ -202,7 +210,7 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--outfile") == 0 || strcmp(argv[0], "-o") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
@@ -285,15 +293,15 @@ int main(int argc, char **argv)
// 16-bit val, format type id (1 = integer PCM, 3 = float PCM)
fwrite16le((recorder.mBits == 32) ? 0x0003 : 0x0001, recorder.mFile);
// 16-bit val, channel count
fwrite16le(recorder.mChannels, recorder.mFile);
fwrite16le((ALushort)recorder.mChannels, recorder.mFile);
// 32-bit val, frequency
fwrite32le(recorder.mSampleRate, recorder.mFile);
// 32-bit val, bytes per second
fwrite32le(recorder.mSampleRate * recorder.mFrameSize, recorder.mFile);
// 16-bit val, frame size
fwrite16le(recorder.mFrameSize, recorder.mFile);
fwrite16le((ALushort)recorder.mFrameSize, recorder.mFile);
// 16-bit val, bits per sample
fwrite16le(recorder.mBits, recorder.mFile);
fwrite16le((ALushort)recorder.mBits, recorder.mFile);
// 16-bit val, extra byte count
fwrite16le(0, recorder.mFile);
@@ -316,6 +324,7 @@ int main(int argc, char **argv)
recorder.mRecTime, (recorder.mRecTime != 1.0f) ? "s" : ""
);
err = ALC_NO_ERROR;
alcCaptureStart(recorder.mDevice);
while((double)recorder.mDataSize/(double)recorder.mSampleRate < recorder.mRecTime &&
(err=alcGetError(recorder.mDevice)) == ALC_NO_ERROR && !ferror(recorder.mFile))
@@ -330,7 +339,7 @@ int main(int argc, char **argv)
}
if(count > recorder.mBufferSize)
{
ALbyte *data = calloc(recorder.mFrameSize, count);
ALbyte *data = calloc(recorder.mFrameSize, (ALuint)count);
free(recorder.mBuffer);
recorder.mBuffer = data;
recorder.mBufferSize = count;
@@ -364,7 +373,7 @@ int main(int argc, char **argv)
}
}
#endif
recorder.mDataSize += (ALuint)fwrite(recorder.mBuffer, recorder.mFrameSize, count,
recorder.mDataSize += (ALuint)fwrite(recorder.mBuffer, recorder.mFrameSize, (ALuint)count,
recorder.mFile);
}
alcCaptureStop(recorder.mDevice);
@@ -384,7 +393,7 @@ int main(int argc, char **argv)
{
fwrite32le(recorder.mDataSize*recorder.mFrameSize, recorder.mFile);
if(fseek(recorder.mFile, 4, SEEK_SET) == 0)
fwrite32le(total_size - 8, recorder.mFile);
fwrite32le((ALuint)total_size - 8, recorder.mFile);
}
fclose(recorder.mFile);