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.
This commit is contained in:
parent
4ebb97bf73
commit
2ac0adaebb
@ -283,8 +283,10 @@ static const struct {
|
|||||||
|
|
||||||
DECL(alGetStringiSOFT),
|
DECL(alGetStringiSOFT),
|
||||||
|
|
||||||
|
DECL(alBufferStorageSOFT),
|
||||||
DECL(alMapBufferSOFT),
|
DECL(alMapBufferSOFT),
|
||||||
DECL(alUnmapBufferSOFT),
|
DECL(alUnmapBufferSOFT),
|
||||||
|
DECL(alFlushMappedBufferSOFT),
|
||||||
};
|
};
|
||||||
#undef DECL
|
#undef DECL
|
||||||
|
|
||||||
@ -649,6 +651,8 @@ static const struct {
|
|||||||
|
|
||||||
DECL(AL_MAP_READ_BIT_SOFT),
|
DECL(AL_MAP_READ_BIT_SOFT),
|
||||||
DECL(AL_MAP_WRITE_BIT_SOFT),
|
DECL(AL_MAP_WRITE_BIT_SOFT),
|
||||||
|
DECL(AL_MAP_PERSISTENT_BIT_SOFT),
|
||||||
|
DECL(AL_PRESERVE_DATA_BIT_SOFT),
|
||||||
};
|
};
|
||||||
#undef DECL
|
#undef DECL
|
||||||
|
|
||||||
|
@ -50,14 +50,16 @@
|
|||||||
#ifndef AL_SOFT_map_buffer
|
#ifndef AL_SOFT_map_buffer
|
||||||
#define AL_SOFT_map_buffer 1
|
#define AL_SOFT_map_buffer 1
|
||||||
typedef unsigned int ALbitfieldSOFT;
|
typedef unsigned int ALbitfieldSOFT;
|
||||||
#define AL_MAP_READ_BIT_SOFT 0x01000000
|
#define AL_MAP_READ_BIT_SOFT 0x00000001
|
||||||
#define AL_MAP_WRITE_BIT_SOFT 0x02000000
|
#define AL_MAP_WRITE_BIT_SOFT 0x00000002
|
||||||
#define AL_PRESERVE_DATA_BIT_SOFT 0x04000000
|
#define AL_MAP_PERSISTENT_BIT_SOFT 0x00000004
|
||||||
#define AL_MAP_PERSISTENT_BIT_SOFT 0x08000000
|
#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*LPALMAPBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
|
||||||
typedef void (AL_APIENTRY*LPALUNMAPBUFFERSOFT)(ALuint buffer);
|
typedef void (AL_APIENTRY*LPALUNMAPBUFFERSOFT)(ALuint buffer);
|
||||||
typedef void (AL_APIENTRY*LPALFLUSHMAPPEDBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length);
|
typedef void (AL_APIENTRY*LPALFLUSHMAPPEDBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length);
|
||||||
#ifdef AL_ALEXT_PROTOTYPES
|
#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 alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
|
||||||
AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer);
|
AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer);
|
||||||
AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length);
|
AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, ALsizei length);
|
||||||
|
@ -50,9 +50,7 @@ static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans,
|
|||||||
static ALsizei SanitizeAlignment(enum UserFmtType type, ALsizei align);
|
static ALsizei SanitizeAlignment(enum UserFmtType type, ALsizei align);
|
||||||
|
|
||||||
|
|
||||||
#define FORMAT_MASK 0x00ffffff
|
#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 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 MAP_READ_WRITE_FLAGS (AL_MAP_READ_BIT_SOFT | AL_MAP_WRITE_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)
|
#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)
|
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 UserFmtChannels srcchannels = UserFmtMono;
|
||||||
enum UserFmtType srctype = UserFmtUByte;
|
enum UserFmtType srctype = UserFmtUByte;
|
||||||
@ -160,11 +161,11 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi
|
|||||||
LockBuffersRead(device);
|
LockBuffersRead(device);
|
||||||
if((albuf=LookupBuffer(device, buffer)) == NULL)
|
if((albuf=LookupBuffer(device, buffer)) == NULL)
|
||||||
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
|
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);
|
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);
|
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);
|
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
|
||||||
|
|
||||||
align = SanitizeAlignment(srctype, ATOMIC_LOAD_SEQ(&albuf->UnpackAlign));
|
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);
|
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
|
||||||
|
|
||||||
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
|
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
|
||||||
data, align, format&CONSTRUCT_FLAGS);
|
data, align, flags);
|
||||||
if(err != AL_NO_ERROR)
|
if(err != AL_NO_ERROR)
|
||||||
SET_ERROR_AND_GOTO(context, err, done);
|
SET_ERROR_AND_GOTO(context, err, done);
|
||||||
break;
|
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);
|
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
|
||||||
|
|
||||||
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
|
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
|
||||||
data, align, format&CONSTRUCT_FLAGS);
|
data, align, flags);
|
||||||
if(err != AL_NO_ERROR)
|
if(err != AL_NO_ERROR)
|
||||||
SET_ERROR_AND_GOTO(context, err, done);
|
SET_ERROR_AND_GOTO(context, err, done);
|
||||||
break;
|
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);
|
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
|
||||||
|
|
||||||
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
|
err = LoadData(albuf, freq, size/framesize*align, srcchannels, srctype,
|
||||||
data, align, format&CONSTRUCT_FLAGS);
|
data, align, flags);
|
||||||
if(err != AL_NO_ERROR)
|
if(err != AL_NO_ERROR)
|
||||||
SET_ERROR_AND_GOTO(context, err, done);
|
SET_ERROR_AND_GOTO(context, err, done);
|
||||||
break;
|
break;
|
||||||
|
@ -41,18 +41,14 @@ extern "C" {
|
|||||||
#ifndef AL_SOFT_map_buffer
|
#ifndef AL_SOFT_map_buffer
|
||||||
#define AL_SOFT_map_buffer 1
|
#define AL_SOFT_map_buffer 1
|
||||||
typedef unsigned int ALbitfieldSOFT;
|
typedef unsigned int ALbitfieldSOFT;
|
||||||
#define AL_MAP_READ_BIT_SOFT 0x01000000
|
#define AL_MAP_READ_BIT_SOFT 0x00000001
|
||||||
#define AL_MAP_WRITE_BIT_SOFT 0x02000000
|
#define AL_MAP_WRITE_BIT_SOFT 0x00000002
|
||||||
#define AL_PRESERVE_DATA_BIT_SOFT 0x04000000
|
#define AL_MAP_PERSISTENT_BIT_SOFT 0x00000004
|
||||||
#define AL_MAP_PERSISTENT_BIT_SOFT 0x08000000
|
#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*LPALMAPBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
|
||||||
typedef void (AL_APIENTRY*LPALUNMAPBUFFERSOFT)(ALuint buffer);
|
typedef void (AL_APIENTRY*LPALUNMAPBUFFERSOFT)(ALuint buffer);
|
||||||
typedef void (AL_APIENTRY*LPALFLUSHMAPPEDBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +66,7 @@ bool EnableDirectOut = false;
|
|||||||
LPALGETSOURCEI64VSOFT alGetSourcei64vSOFT;
|
LPALGETSOURCEI64VSOFT alGetSourcei64vSOFT;
|
||||||
LPALCGETINTEGER64VSOFT alcGetInteger64vSOFT;
|
LPALCGETINTEGER64VSOFT alcGetInteger64vSOFT;
|
||||||
|
|
||||||
|
LPALBUFFERSTORAGESOFT alBufferStorageSOFT;
|
||||||
LPALMAPBUFFERSOFT alMapBufferSOFT;
|
LPALMAPBUFFERSOFT alMapBufferSOFT;
|
||||||
LPALUNMAPBUFFERSOFT alUnmapBufferSOFT;
|
LPALUNMAPBUFFERSOFT alUnmapBufferSOFT;
|
||||||
|
|
||||||
@ -805,13 +802,13 @@ int AudioState::handler()
|
|||||||
if(alGetError() != AL_NO_ERROR)
|
if(alGetError() != AL_NO_ERROR)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
if(!alMapBufferSOFT)
|
if(!alBufferStorageSOFT)
|
||||||
samples = av_malloc(buffer_len);
|
samples = av_malloc(buffer_len);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(ALuint bufid : mBuffers)
|
for(ALuint bufid : mBuffers)
|
||||||
alBufferData(bufid, mFormat | AL_MAP_WRITE_BIT_SOFT, nullptr, buffer_len,
|
alBufferStorageSOFT(bufid, mFormat, nullptr, buffer_len, mCodecCtx->sample_rate,
|
||||||
mCodecCtx->sample_rate);
|
AL_MAP_WRITE_BIT_SOFT);
|
||||||
if(alGetError() != AL_NO_ERROR)
|
if(alGetError() != AL_NO_ERROR)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to use mapped buffers\n");
|
fprintf(stderr, "Failed to use mapped buffers\n");
|
||||||
@ -1639,6 +1636,8 @@ int main(int argc, char *argv[])
|
|||||||
if(alIsExtensionPresent("AL_SOFTX_map_buffer"))
|
if(alIsExtensionPresent("AL_SOFTX_map_buffer"))
|
||||||
{
|
{
|
||||||
std::cout<< "Found AL_SOFT_map_buffer" <<std::endl;
|
std::cout<< "Found AL_SOFT_map_buffer" <<std::endl;
|
||||||
|
alBufferStorageSOFT = reinterpret_cast<LPALBUFFERSTORAGESOFT>(
|
||||||
|
alGetProcAddress("alBufferStorageSOFT"));
|
||||||
alMapBufferSOFT = reinterpret_cast<LPALMAPBUFFERSOFT>(
|
alMapBufferSOFT = reinterpret_cast<LPALMAPBUFFERSOFT>(
|
||||||
alGetProcAddress("alMapBufferSOFT"));
|
alGetProcAddress("alMapBufferSOFT"));
|
||||||
alUnmapBufferSOFT = reinterpret_cast<LPALUNMAPBUFFERSOFT>(
|
alUnmapBufferSOFT = reinterpret_cast<LPALUNMAPBUFFERSOFT>(
|
||||||
|
Loading…
Reference in New Issue
Block a user