aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alc/alc.cpp40
-rw-r--r--alc/backends/base.h5
-rw-r--r--alc/backends/coreaudio.cpp11
-rw-r--r--alc/backends/coreaudio.h2
-rw-r--r--alc/backends/pipewire.cpp17
-rw-r--r--alc/backends/pipewire.h2
-rw-r--r--alc/backends/pulseaudio.cpp14
-rw-r--r--alc/backends/pulseaudio.h2
-rw-r--r--alc/backends/wasapi.cpp17
-rw-r--r--alc/backends/wasapi.h2
-rw-r--r--alc/events.cpp26
-rw-r--r--alc/events.h8
-rw-r--r--alc/export_list.h1
-rw-r--r--include/AL/alext.h4
-rw-r--r--utils/openal-info.c51
15 files changed, 184 insertions, 18 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 08ef0063..be41f278 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -69,6 +69,7 @@
#include "al/filter.h"
#include "al/listener.h"
#include "al/source.h"
+#include "alc/events.h"
#include "albit.h"
#include "alconfig.h"
#include "almalloc.h"
@@ -3469,3 +3470,42 @@ FORCE_ALIGN ALCboolean ALC_APIENTRY alcReopenDeviceSOFT(ALCdevice *device,
ResetDeviceParams(dev.get(), attribs);
return ALC_TRUE;
}
+
+/************************************************
+ * ALC event query functions
+ ************************************************/
+
+FORCE_ALIGN ALCenum ALC_APIENTRY alcEventIsSupportedSOFT(ALCenum eventType, ALCenum deviceType) noexcept
+{
+ auto etype = alc::GetEventType(eventType);
+ if(!etype)
+ {
+ WARN("Invalid event type: 0x%04x\n", eventType);
+ alcSetError(nullptr, ALC_INVALID_ENUM);
+ return ALC_EVENT_NOT_SUPPORTED_SOFT;
+ }
+ switch(deviceType)
+ {
+ case al::to_underlying(alc::DeviceType::Playback):
+ {
+ if(!PlaybackFactory)
+ {
+ return ALC_EVENT_NOT_SUPPORTED_SOFT;
+ }
+
+ auto supported = PlaybackFactory->queryEventSupport(*etype, BackendType::Playback);
+ return al::to_underlying(supported);
+ }
+ case al::to_underlying(alc::DeviceType::Capture):
+ {
+ if(!CaptureFactory)
+ {
+ return ALC_EVENT_NOT_SUPPORTED_SOFT;
+ }
+
+ auto supported = CaptureFactory->queryEventSupport(*etype, BackendType::Capture);
+ return al::to_underlying(supported);
+ }
+ }
+ return ALC_EVENT_NOT_SUPPORTED_SOFT;
+} \ No newline at end of file
diff --git a/alc/backends/base.h b/alc/backends/base.h
index a4079fe4..ea3b57a3 100644
--- a/alc/backends/base.h
+++ b/alc/backends/base.h
@@ -11,6 +11,7 @@
#include "core/device.h"
#include "core/except.h"
+#include "alc/events.h"
using uint = unsigned int;
@@ -79,6 +80,10 @@ struct BackendFactory {
virtual bool querySupport(BackendType type) = 0;
+ virtual alc::EventSupport queryEventSupport(alc::EventType eventType, BackendType type) {
+ return alc::EventSupport::NoSupport;
+ }
+
virtual std::string probe(BackendType type) = 0;
virtual BackendPtr createBackend(DeviceBase *device, BackendType type) = 0;
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index 1684545b..eb4e5880 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -39,7 +39,6 @@
#include "core/device.h"
#include "core/logging.h"
#include "ringbuffer.h"
-#include "alc/events.h"
#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioToolbox.h>
@@ -1013,3 +1012,13 @@ BackendPtr CoreAudioBackendFactory::createBackend(DeviceBase *device, BackendTyp
return BackendPtr{new CoreAudioCapture{device}};
return nullptr;
}
+
+alc::EventSupport CoreAudioBackendFactory::queryEventSupport(alc::EventType eventType, BackendType type)
+{
+ switch(eventType) {
+ case alc::EventType::DefaultDeviceChanged: {
+ return alc::EventSupport::FullSupport;
+ }
+ }
+ return alc::EventSupport::NoSupport;
+}
diff --git a/alc/backends/coreaudio.h b/alc/backends/coreaudio.h
index 1252edde..6ea4307c 100644
--- a/alc/backends/coreaudio.h
+++ b/alc/backends/coreaudio.h
@@ -9,6 +9,8 @@ public:
bool querySupport(BackendType type) override;
+ alc::EventSupport queryEventSupport(alc::EventType eventType, BackendType type) override;
+
std::string probe(BackendType type) override;
BackendPtr createBackend(DeviceBase *device, BackendType type) override;
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 6cfb31a4..d1a9d095 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -40,7 +40,6 @@
#include "albit.h"
#include "alc/alconfig.h"
-#include "alc/events.h"
#include "almalloc.h"
#include "alnumeric.h"
#include "alspan.h"
@@ -2266,3 +2265,19 @@ BackendFactory &PipeWireBackendFactory::getFactory()
static PipeWireBackendFactory factory{};
return factory;
}
+
+alc::EventSupport PipeWireBackendFactory::queryEventSupport(alc::EventType eventType, BackendType type)
+{
+ switch(eventType) {
+ case alc::EventType::DefaultDeviceChanged: {
+ return alc::EventSupport::FullSupport;
+ }
+ case alc::EventType::DeviceAdded: {
+ return alc::EventSupport::FullSupport;
+ }
+ case alc::EventType::DeviceRemoved: {
+ return alc::EventSupport::FullSupport;
+ }
+ }
+ return alc::EventSupport::NoSupport;
+} \ No newline at end of file
diff --git a/alc/backends/pipewire.h b/alc/backends/pipewire.h
index 5f930239..5493684f 100644
--- a/alc/backends/pipewire.h
+++ b/alc/backends/pipewire.h
@@ -13,6 +13,8 @@ public:
bool querySupport(BackendType type) override;
+ alc::EventSupport queryEventSupport(alc::EventType eventType, BackendType type) override;
+
std::string probe(BackendType type) override;
BackendPtr createBackend(DeviceBase *device, BackendType type) override;
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index e2cea8a8..23ed1415 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -41,7 +41,6 @@
#include "albit.h"
#include "alc/alconfig.h"
-#include "alc/events.h"
#include "almalloc.h"
#include "alnumeric.h"
#include "alspan.h"
@@ -1491,3 +1490,16 @@ BackendFactory &PulseBackendFactory::getFactory()
static PulseBackendFactory factory{};
return factory;
}
+
+alc::EventSupport PulseBackendFactory::queryEventSupport(alc::EventType eventType, BackendType type)
+{
+ switch(eventType) {
+ case alc::EventType::DeviceAdded: {
+ return alc::EventSupport::FullSupport;
+ }
+ case alc::EventType::DeviceRemoved: {
+ return alc::EventSupport::FullSupport;
+ }
+ }
+ return alc::EventSupport::NoSupport;
+}
diff --git a/alc/backends/pulseaudio.h b/alc/backends/pulseaudio.h
index 6690fe8a..4752a891 100644
--- a/alc/backends/pulseaudio.h
+++ b/alc/backends/pulseaudio.h
@@ -9,6 +9,8 @@ public:
bool querySupport(BackendType type) override;
+ alc::EventSupport queryEventSupport(alc::EventType eventType, BackendType type) override;
+
std::string probe(BackendType type) override;
BackendPtr createBackend(DeviceBase *device, BackendType type) override;
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index 37151ef9..a4d6ea2f 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -60,7 +60,6 @@
#include "albit.h"
#include "alc/alconfig.h"
-#include "alc/events.h"
#include "alnumeric.h"
#include "alspan.h"
#include "althrd_setname.h"
@@ -2741,3 +2740,19 @@ BackendFactory &WasapiBackendFactory::getFactory()
static WasapiBackendFactory factory{};
return factory;
}
+
+alc::EventSupport WasapiBackendFactory::queryEventSupport(alc::EventType eventType, BackendType type)
+{
+ switch(eventType) {
+ case alc::EventType::DefaultDeviceChanged: {
+ return alc::EventSupport::FullSupport;
+ }
+ case alc::EventType::DeviceAdded: {
+ return alc::EventSupport::FullSupport;
+ }
+ case alc::EventType::DeviceRemoved: {
+ return alc::EventSupport::FullSupport;
+ }
+ }
+ return alc::EventSupport::NoSupport;
+}
diff --git a/alc/backends/wasapi.h b/alc/backends/wasapi.h
index bb2671ee..12fd95ef 100644
--- a/alc/backends/wasapi.h
+++ b/alc/backends/wasapi.h
@@ -9,6 +9,8 @@ public:
bool querySupport(BackendType type) override;
+ alc::EventSupport queryEventSupport(alc::EventType eventType, BackendType type) override;
+
std::string probe(BackendType type) override;
BackendPtr createBackend(DeviceBase *device, BackendType type) override;
diff --git a/alc/events.cpp b/alc/events.cpp
index a80faf8a..1010a338 100644
--- a/alc/events.cpp
+++ b/alc/events.cpp
@@ -3,8 +3,6 @@
#include "events.h"
-#include <optional>
-
#include "alspan.h"
#include "core/logging.h"
#include "device.h"
@@ -12,17 +10,6 @@
namespace {
-std::optional<alc::EventType> GetEventType(ALCenum type)
-{
- switch(type)
- {
- case ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT: return alc::EventType::DefaultDeviceChanged;
- case ALC_EVENT_TYPE_DEVICE_ADDED_SOFT: return alc::EventType::DeviceAdded;
- case ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT: return alc::EventType::DeviceRemoved;
- }
- return std::nullopt;
-}
-
ALCenum EnumFromEventType(const alc::EventType type)
{
switch(type)
@@ -39,6 +26,17 @@ ALCenum EnumFromEventType(const alc::EventType type)
namespace alc {
+std::optional<alc::EventType> GetEventType(ALCenum type)
+{
+ switch(type)
+ {
+ case ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT: return alc::EventType::DefaultDeviceChanged;
+ case ALC_EVENT_TYPE_DEVICE_ADDED_SOFT: return alc::EventType::DeviceAdded;
+ case ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT: return alc::EventType::DeviceRemoved;
+ }
+ return std::nullopt;
+}
+
void Event(EventType eventType, DeviceType deviceType, ALCdevice *device, std::string_view message) noexcept
{
auto eventlock = std::unique_lock{EventMutex};
@@ -73,7 +71,7 @@ FORCE_ALIGN ALCboolean ALC_APIENTRY alcEventControlSOFT(ALCsizei count, const AL
alc::EventBitSet eventSet{0};
for(ALCenum type : al::span{events, static_cast<ALCuint>(count)})
{
- auto etype = GetEventType(type);
+ auto etype = alc::GetEventType(type);
if(!etype)
{
WARN("Invalid event type: 0x%04x\n", type);
diff --git a/alc/events.h b/alc/events.h
index 4acc505d..3f53ec76 100644
--- a/alc/events.h
+++ b/alc/events.h
@@ -6,6 +6,7 @@
#include <bitset>
#include <mutex>
+#include <optional>
#include <string_view>
@@ -19,6 +20,13 @@ enum class EventType : uint8_t {
Count
};
+std::optional<alc::EventType> GetEventType(ALCenum type);
+
+enum class EventSupport : ALCenum {
+ FullSupport = ALC_EVENT_SUPPORTED_SOFT,
+ NoSupport = ALC_EVENT_NOT_SUPPORTED_SOFT,
+};
+
enum class DeviceType : ALCenum {
Playback = ALC_PLAYBACK_DEVICE_SOFT,
Capture = ALC_CAPTURE_DEVICE_SOFT,
diff --git a/alc/export_list.h b/alc/export_list.h
index 47b04a08..c5af1ab0 100644
--- a/alc/export_list.h
+++ b/alc/export_list.h
@@ -56,6 +56,7 @@ inline const FuncExport alcFunctions[]{
DECL(alcReopenDeviceSOFT),
+ DECL(alcEventIsSupportedSOFT),
DECL(alcEventControlSOFT),
DECL(alcEventCallbackSOFT),
diff --git a/include/AL/alext.h b/include/AL/alext.h
index b99d6aac..c75e0770 100644
--- a/include/AL/alext.h
+++ b/include/AL/alext.h
@@ -720,11 +720,15 @@ void AL_APIENTRY alGetObjectLabelEXT(ALenum identifier, ALuint name, ALsizei buf
#define ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT 0x19D6
#define ALC_EVENT_TYPE_DEVICE_ADDED_SOFT 0x19D7
#define ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT 0x19D8
+#define ALC_EVENT_SUPPORTED_SOFT 0x19D9
+#define ALC_EVENT_NOT_SUPPORTED_SOFT 0x19DA
typedef void (ALC_APIENTRY*ALCEVENTPROCTYPESOFT)(ALCenum eventType, ALCenum deviceType,
ALCdevice *device, ALCsizei length, const ALCchar *message, void *userParam) ALC_API_NOEXCEPT17;
+typedef ALCenum (ALC_APIENTRY*LPALCEVENTISSUPPORTEDSOFT)(ALCenum eventType, ALCenum deviceType) ALC_API_NOEXCEPT17;
typedef ALCboolean (ALC_APIENTRY*LPALCEVENTCONTROLSOFT)(ALCsizei count, const ALCenum *events, ALCboolean enable) ALC_API_NOEXCEPT17;
typedef void (ALC_APIENTRY*LPALCEVENTCALLBACKSOFT)(ALCEVENTPROCTYPESOFT callback, void *userParam) ALC_API_NOEXCEPT17;
#ifdef AL_ALEXT_PROTOTYPES
+ALCenum ALC_APIENTRY alcEventIsSupportedSOFT(ALCenum eventType, ALCenum deviceType) ALC_API_NOEXCEPT;
ALCboolean ALC_APIENTRY alcEventControlSOFT(ALCsizei count, const ALCenum *events, ALCboolean enable) ALC_API_NOEXCEPT;
void ALC_APIENTRY alcEventCallbackSOFT(ALCEVENTPROCTYPESOFT callback, void *userParam) ALC_API_NOEXCEPT;
#endif
diff --git a/utils/openal-info.c b/utils/openal-info.c
index 0af27422..11c49245 100644
--- a/utils/openal-info.c
+++ b/utils/openal-info.c
@@ -230,6 +230,56 @@ static void printModeInfo(ALCdevice *device)
}
}
+static void printALCSOFTSystemEventIsSupportedResult(LPALCEVENTISSUPPORTEDSOFT alcEventIsSupportedSOFT, ALCenum eventType, ALCenum deviceType)
+{
+ if (alcEventIsSupportedSOFT == NULL)
+ {
+ printf("ERROR (alcEventIsSupportedSOFT missing)\n");
+ return;
+ }
+ ALCenum supported = alcEventIsSupportedSOFT(eventType, deviceType);
+ if (supported == ALC_EVENT_SUPPORTED_SOFT)
+ {
+ printf("SUPPORTED\n");
+ }
+ else if (supported == ALC_EVENT_NOT_SUPPORTED_SOFT)
+ {
+ printf("NOT SUPPORTED\n");
+ }
+ else
+ {
+ printf("UNEXPECTED VALUE : %d\n", supported);
+ }
+}
+
+static void printALC_SOFT_system_event(void)
+{
+ printf("ALC_SOFT_system_events:");
+ if (alcIsExtensionPresent(NULL, "ALC_SOFT_system_events"))
+ {
+ static LPALCEVENTISSUPPORTEDSOFT alcEventIsSupportedSOFT;
+ alcEventIsSupportedSOFT = FUNCTION_CAST(LPALCEVENTISSUPPORTEDSOFT, alGetProcAddress("alcEventIsSupportedSOFT"));
+ printf(" Supported.\n");
+ printf(" Events:\n");
+ printf(" ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT for ALC_PLAYBACK_DEVICE_SOFT - ");
+ printALCSOFTSystemEventIsSupportedResult(alcEventIsSupportedSOFT, ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT, ALC_PLAYBACK_DEVICE_SOFT);
+ printf(" ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT for ALC_CAPTURE_DEVICE_SOFT - ");
+ printALCSOFTSystemEventIsSupportedResult(alcEventIsSupportedSOFT, ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT, ALC_CAPTURE_DEVICE_SOFT);
+ printf(" ALC_EVENT_TYPE_DEVICE_ADDED_SOFT for ALC_PLAYBACK_DEVICE_SOFT - ");
+ printALCSOFTSystemEventIsSupportedResult(alcEventIsSupportedSOFT, ALC_EVENT_TYPE_DEVICE_ADDED_SOFT, ALC_PLAYBACK_DEVICE_SOFT);
+ printf(" ALC_EVENT_TYPE_DEVICE_ADDED_SOFT for ALC_CAPTURE_DEVICE_SOFT - ");
+ printALCSOFTSystemEventIsSupportedResult(alcEventIsSupportedSOFT, ALC_EVENT_TYPE_DEVICE_ADDED_SOFT, ALC_CAPTURE_DEVICE_SOFT);
+ printf(" ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT for ALC_PLAYBACK_DEVICE_SOFT - ");
+ printALCSOFTSystemEventIsSupportedResult(alcEventIsSupportedSOFT, ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT, ALC_PLAYBACK_DEVICE_SOFT);
+ printf(" ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT for ALC_CAPTURE_DEVICE_SOFT - ");
+ printALCSOFTSystemEventIsSupportedResult(alcEventIsSupportedSOFT, ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT, ALC_CAPTURE_DEVICE_SOFT);
+ }
+ else
+ {
+ printf(" Not supported.\n");
+ }
+}
+
static void printALInfo(void)
{
printf("OpenAL vendor string: %s\n", alGetString(AL_VENDOR));
@@ -435,6 +485,7 @@ int main(int argc, char *argv[])
}
printALCInfo(device);
printHRTFInfo(device);
+ printALC_SOFT_system_event();
context = alcCreateContext(device, NULL);
if(!context || alcMakeContextCurrent(context) == ALC_FALSE)