Don't rely on terminate in a catch block giving a useful message
[openal-soft.git] / al / buffer.h
blob187bc6bd198354c058cbb009d6a7530f778a7e6a
1 #ifndef AL_BUFFER_H
2 #define AL_BUFFER_H
4 #include "config.h"
6 #include <array>
7 #include <atomic>
8 #include <cstddef>
9 #include <cstdint>
10 #include <string_view>
11 #include <utility>
13 #include "AL/al.h"
14 #include "AL/alc.h"
16 #include "alc/inprogext.h"
17 #include "almalloc.h"
18 #include "alnumeric.h"
19 #include "core/buffer_storage.h"
20 #include "vector.h"
22 #if ALSOFT_EAX
23 enum class EaxStorage : uint8_t {
24 Automatic,
25 Accessible,
26 Hardware
28 #endif // ALSOFT_EAX
31 struct ALbuffer : public BufferStorage {
32 ALbitfieldSOFT Access{0u};
34 al::vector<std::byte,16> mDataStorage;
36 ALuint OriginalSize{0};
38 ALuint UnpackAlign{0};
39 ALuint PackAlign{0};
40 ALuint UnpackAmbiOrder{1};
42 ALbitfieldSOFT MappedAccess{0u};
43 ALsizei MappedOffset{0};
44 ALsizei MappedSize{0};
46 ALuint mLoopStart{0u};
47 ALuint mLoopEnd{0u};
49 /* Number of times buffer was attached to a source (deletion can only occur when 0) */
50 std::atomic<ALuint> ref{0u};
52 /* Self ID */
53 ALuint id{0};
55 static void SetName(ALCcontext *context, ALuint id, std::string_view name);
57 DISABLE_ALLOC
59 #if ALSOFT_EAX
60 EaxStorage eax_x_ram_mode{EaxStorage::Automatic};
61 bool eax_x_ram_is_hardware{};
62 #endif // ALSOFT_EAX
65 struct BufferSubList {
66 uint64_t FreeMask{~0_u64};
67 gsl::owner<std::array<ALbuffer,64>*> Buffers{nullptr};
69 BufferSubList() noexcept = default;
70 BufferSubList(const BufferSubList&) = delete;
71 BufferSubList(BufferSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Buffers{rhs.Buffers}
72 { rhs.FreeMask = ~0_u64; rhs.Buffers = nullptr; }
73 ~BufferSubList();
75 BufferSubList& operator=(const BufferSubList&) = delete;
76 BufferSubList& operator=(BufferSubList&& rhs) noexcept
77 { std::swap(FreeMask, rhs.FreeMask); std::swap(Buffers, rhs.Buffers); return *this; }
80 #endif