Add createContext methods that don't throw on error
[alure.git] / src / device.h
blob24417fb4c011d77c9bea526054fbaebc90c9a380
1 #ifndef DEVICE_H
2 #define DEVICE_H
4 #include "main.h"
6 #include <mutex>
8 #include "alc.h"
9 #include "alext.h"
12 namespace alure {
14 class ContextImpl;
15 class BufferImpl;
18 enum ALCExtension {
19 EXT_thread_local_context,
20 SOFT_device_pause,
21 SOFT_HRTF,
23 ALC_EXTENSION_MAX
26 class DeviceImpl {
27 ALCdevice *mDevice;
29 Vector<UniquePtr<ContextImpl>> mContexts;
31 bool mHasExt[ALC_EXTENSION_MAX];
33 std::once_flag mSetExts;
34 void setupExts();
36 public:
37 DeviceImpl(ALCdevice *device);
38 ~DeviceImpl();
40 ALCdevice *getDevice() const { return mDevice; }
42 bool hasExtension(ALCExtension ext) const { return mHasExt[ext]; }
44 LPALCDEVICEPAUSESOFT alcDevicePauseSOFT;
45 LPALCDEVICERESUMESOFT alcDeviceResumeSOFT;
47 LPALCGETSTRINGISOFT alcGetStringiSOFT;
48 LPALCRESETDEVICESOFT alcResetDeviceSOFT;
50 void removeContext(ContextImpl *ctx);
52 String getName(PlaybackName type) const;
53 bool queryExtension(const char *name) const;
55 Version getALCVersion() const;
56 Version getEFXVersion() const;
58 ALCuint getFrequency() const;
60 ALCuint getMaxAuxiliarySends() const;
62 Vector<String> enumerateHRTFNames() const;
63 bool isHRTFEnabled() const;
64 String getCurrentHRTF() const;
65 void reset(ArrayView<AttributePair> attributes);
67 Context createContext(ArrayView<AttributePair> attributes, bool dothrow);
69 void pauseDSP();
70 void resumeDSP();
72 void close();
75 } // namespace alure
77 #endif /* DEVICE_H */