aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-20 11:49:01 -0800
committerChris Robinson <[email protected]>2018-01-20 11:49:01 -0800
commit03d4e4acc4c55ed87741b2b9960ac1ac3d4cf0bd (patch)
treeac94a5d8055d76ab6dab32ceb5f53967f2272793 /OpenAL32/Include
parent4e647bda07dd56479ea62de7a53b70c0154734e0 (diff)
Add methods to "map" a buffer's storage
Requires the MAP_READ_BIT or MAP_WRITE_BIT flags to be OR'd with the format upon a call to alBufferData, to enable mappable storage for the given access types. This will fail if the format requires internal conversion and doesn't resemble the original input data, so the app can be guaranteed the size, type, and layout of the original data is the same as what's in storage. Then alMapBufferSOFT may be called with appropriate bit flags to get a readable and/or writable pointer to the buffer's sample storage. alUnmapBufferSOFT must be called when access is finished. It is currently invalid to map a buffer that is attached to a source, or to attach a buffer to a source that is currently mapped. This restriction may be eased in the future, at least to allow read- only access while in use (perhaps also to allow writing, if coherency can be achieved). Currently the access flags occupy the upper 8 bits of a 32-bit bitfield to avoid clashing with format enum values, which don't use more than 16 or 17 bits. This means any future formats are limited to 24-bit enum values, and also means only 8 flags are possible when declaring storage. The alternative would be to add a new function (alBufferStorage?) with a separate flags parameter.
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r--OpenAL32/Include/alBuffer.h3
-rw-r--r--OpenAL32/Include/alMain.h12
2 files changed, 15 insertions, 0 deletions
diff --git a/OpenAL32/Include/alBuffer.h b/OpenAL32/Include/alBuffer.h
index 852a8782..60a047c9 100644
--- a/OpenAL32/Include/alBuffer.h
+++ b/OpenAL32/Include/alBuffer.h
@@ -76,6 +76,7 @@ typedef struct ALbuffer {
ALsizei Frequency;
ALenum Format;
+ ALbitfieldSOFT Access;
ALsizei SampleLen;
enum FmtChannels FmtChannels;
@@ -93,6 +94,8 @@ typedef struct ALbuffer {
ATOMIC(ALsizei) UnpackAlign;
ATOMIC(ALsizei) PackAlign;
+ ALbitfieldSOFT MappedAccess;
+
/* Number of times buffer was attached to a source (deletion can only occur when 0) */
RefCount ref;
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 50c9decf..dbb4f14b 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -47,6 +47,18 @@
#define ALC_N3D_SOFT 0xfff7
#endif
+#ifndef AL_SOFT_map_buffer
+typedef unsigned int ALbitfieldSOFT;
+#define AL_MAP_READ_BIT_SOFT 0x01000000
+#define AL_MAP_WRITE_BIT_SOFT 0x02000000
+typedef void* (AL_APIENTRY*LPALMAPBUFFERSOFT)(ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access);
+typedef void* (AL_APIENTRY*LPALUNMAPBUFFERSOFT)(ALuint buffer);
+#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);
+#endif
+#endif
+
#if defined(_WIN64)
#define SZFMT "%I64u"