aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-23 14:33:30 -0800
committerChris Robinson <[email protected]>2018-01-23 14:33:30 -0800
commit2ac0adaebbc9b7378f1ec85d7495a044c7580239 (patch)
tree515d37223d3214e334ab45c3423922e586be1dfb
parent4ebb97bf737713b07642266ab54055f13dbd9833 (diff)
Use a new proper buffer function with a flags parameter
Rather than hackily combining bit flags with the format, to increase the number of potential flags. alBufferData now behaves as if calling alBufferStorageSOFT with a flags value of 0.
-rw-r--r--Alc/ALc.c4
-rw-r--r--OpenAL32/Include/alMain.h10
-rw-r--r--OpenAL32/alBuffer.c19
-rw-r--r--examples/alffplay.cpp23
4 files changed, 31 insertions, 25 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index dbdc2986..0d8bbe86 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -283,8 +283,10 @@ static const struct {
DECL(alGetStringiSOFT),
+ DECL(alBufferStorageSOFT),
DECL(alMapBufferSOFT),
DECL(alUnmapBufferSOFT),
+ DECL(alFlushMappedBufferSOFT),
};
#undef DECL
@@ -649,6 +651,8 @@ static const struct {
DECL(AL_MAP_READ_BIT_SOFT),
DECL(AL_MAP_WRITE_BIT_SOFT),
+ DECL(AL_MAP_PERSISTENT_BIT_SOFT),
+ DECL(AL_PRESERVE_DATA_BIT_SOFT),
};
#undef DECL
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index d986adde..17bff871 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -50,14 +50,16 @@
#ifndef AL_SOFT_map_buffer
#define AL_SOFT_map_buffer 1
typedef unsigned int ALbitfieldSOFT;
-#define AL_MAP_READ_BIT_SOFT 0x01000000
-#define AL_MAP_WRITE_BIT_SOFT 0x02000000
-#define AL_PRESERVE_DATA_BIT_SOFT 0x04000000
-#define AL_MAP_PERSISTENT_BIT_SOFT 0x08000000
+#define AL_MAP_READ_BIT_SOFT 0x00000001
+#define AL_MAP_WRITE_BIT_SOFT 0x00000002
+#define AL_MAP_PERSISTENT_BIT_SOFT 0x00000004
+#define AL_PRESERVE_DATA_BIT_SOFT 0x00000008
+typedef void (AL_APIENTRY*LPALBUFFERSTORAGESOFT)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq, ALbitfieldSOFT flags);
typedef void* (AL_APIENTRY*LPALMAPBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
typedef void (AL_APIENTRY*LPALUNMAPBUFFERSOFT)(ALuint buffer);
typedef void (AL_APIENTRY*LPALFLUSHMAPPEDBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length);
#ifdef AL_ALEXT_PROTOTYPES
+AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq, ALbitfieldSOFT flags);
AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer);
AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length);
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index 45f63832..1290ca23 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -50,9 +50,7 @@ static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans,
static ALsizei SanitizeAlignment(enum UserFmtType type, ALsizei align);
-#define FORMAT_MASK 0x00ffffff
-#define CONSTRUCT_FLAGS (AL_MAP_READ_BIT_SOFT | AL_MAP_WRITE_BIT_SOFT | AL_PRESERVE_DATA_BIT_SOFT | AL_MAP_PERSISTENT_BIT_SOFT)
-#define INVALID_FORMAT_MASK ~(FORMAT_MASK | CONSTRUCT_FLAGS)
+#define INVALID_STORAGE_MASK ~(AL_MAP_READ_BIT_SOFT | AL_MAP_WRITE_BIT_SOFT | AL_PRESERVE_DATA_BIT_SOFT | AL_MAP_PERSISTENT_BIT_SOFT)
#define MAP_READ_WRITE_FLAGS (AL_MAP_READ_BIT_SOFT | AL_MAP_WRITE_BIT_SOFT)
#define MAP_ACCESS_FLAGS (AL_MAP_READ_BIT_SOFT | AL_MAP_WRITE_BIT_SOFT | AL_MAP_PERSISTENT_BIT_SOFT)
@@ -143,6 +141,9 @@ AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer)
AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq)
+{ alBufferStorageSOFT(buffer, format, data, size, freq, 0); }
+
+AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq, ALbitfieldSOFT flags)
{
enum UserFmtChannels srcchannels = UserFmtMono;
enum UserFmtType srctype = UserFmtUByte;
@@ -160,11 +161,11 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi
LockBuffersRead(device);
if((albuf=LookupBuffer(device, buffer)) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
- if(!(size >= 0 && freq > 0) || (format&INVALID_FORMAT_MASK) != 0)
+ if(!(size >= 0 && freq > 0) || (flags&INVALID_STORAGE_MASK) != 0)
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
- if((format&AL_MAP_PERSISTENT_BIT_SOFT) && !(format&MAP_READ_WRITE_FLAGS))
+ if((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
- if(DecomposeUserFormat(format&FORMAT_MASK, &srcchannels, &srctype) == AL_FALSE)
+ if(DecomposeUserFormat(format, &srcchannels, &srctype) == AL_FALSE)
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
align = SanitizeAlignment(srctype, ATOMIC_LOAD_SEQ(&albuf->UnpackAlign));
@@ -183,7 +184,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
- data, align, format&CONSTRUCT_FLAGS);
+ data, align, flags);
if(err != AL_NO_ERROR)
SET_ERROR_AND_GOTO(context, err, done);
break;
@@ -194,7 +195,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
- data, align, format&CONSTRUCT_FLAGS);
+ data, align, flags);
if(err != AL_NO_ERROR)
SET_ERROR_AND_GOTO(context, err, done);
break;
@@ -205,7 +206,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
- data, align, format&CONSTRUCT_FLAGS);
+ data, align, flags);
if(err != AL_NO_ERROR)
SET_ERROR_AND_GOTO(context, err, done);
break;
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp
index f9ca8324..f372983a 100644
--- a/examples/alffplay.cpp
+++ b/examples/alffplay.cpp
@@ -41,18 +41,14 @@ extern "C" {
#ifndef AL_SOFT_map_buffer
#define AL_SOFT_map_buffer 1
typedef unsigned int ALbitfieldSOFT;
-#define AL_MAP_READ_BIT_SOFT 0x01000000
-#define AL_MAP_WRITE_BIT_SOFT 0x02000000
-#define AL_PRESERVE_DATA_BIT_SOFT 0x04000000
-#define AL_MAP_PERSISTENT_BIT_SOFT 0x08000000
+#define AL_MAP_READ_BIT_SOFT 0x00000001
+#define AL_MAP_WRITE_BIT_SOFT 0x00000002
+#define AL_MAP_PERSISTENT_BIT_SOFT 0x00000004
+#define AL_PRESERVE_DATA_BIT_SOFT 0x00000008
+typedef void (AL_APIENTRY*LPALBUFFERSTORAGESOFT)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq, ALbitfieldSOFT flags);
typedef void* (AL_APIENTRY*LPALMAPBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
typedef void (AL_APIENTRY*LPALUNMAPBUFFERSOFT)(ALuint buffer);
typedef void (AL_APIENTRY*LPALFLUSHMAPPEDBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length);
-#ifdef AL_ALEXT_PROTOTYPES
-AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
-AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer);
-AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length);
-#endif
#endif
}
@@ -70,6 +66,7 @@ bool EnableDirectOut = false;
LPALGETSOURCEI64VSOFT alGetSourcei64vSOFT;
LPALCGETINTEGER64VSOFT alcGetInteger64vSOFT;
+LPALBUFFERSTORAGESOFT alBufferStorageSOFT;
LPALMAPBUFFERSOFT alMapBufferSOFT;
LPALUNMAPBUFFERSOFT alUnmapBufferSOFT;
@@ -805,13 +802,13 @@ int AudioState::handler()
if(alGetError() != AL_NO_ERROR)
goto finish;
- if(!alMapBufferSOFT)
+ if(!alBufferStorageSOFT)
samples = av_malloc(buffer_len);
else
{
for(ALuint bufid : mBuffers)
- alBufferData(bufid, mFormat | AL_MAP_WRITE_BIT_SOFT, nullptr, buffer_len,
- mCodecCtx->sample_rate);
+ alBufferStorageSOFT(bufid, mFormat, nullptr, buffer_len, mCodecCtx->sample_rate,
+ AL_MAP_WRITE_BIT_SOFT);
if(alGetError() != AL_NO_ERROR)
{
fprintf(stderr, "Failed to use mapped buffers\n");
@@ -1639,6 +1636,8 @@ int main(int argc, char *argv[])
if(alIsExtensionPresent("AL_SOFTX_map_buffer"))
{
std::cout<< "Found AL_SOFT_map_buffer" <<std::endl;
+ alBufferStorageSOFT = reinterpret_cast<LPALBUFFERSTORAGESOFT>(
+ alGetProcAddress("alBufferStorageSOFT"));
alMapBufferSOFT = reinterpret_cast<LPALMAPBUFFERSOFT>(
alGetProcAddress("alMapBufferSOFT"));
alUnmapBufferSOFT = reinterpret_cast<LPALUNMAPBUFFERSOFT>(