From 5296ed141f86acc2e7f6365e2e1f9db6a9bc9ec0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 10 Jun 2020 15:58:47 +0200 Subject: [PATCH] Fix support for older libwebsocket versions LWS_WITH_EXTERNAL_POLL a new optional define for libwebsocket 4.x. Earlier versions always supported it, without the compile-time define. This fixes support for libwesocket 2.x (Debian, Ubuntu), and 3.x. Also for Windows, LWS_WITH_GLIB is not available. --- libs/surfaces/websockets/server.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/surfaces/websockets/server.cc b/libs/surfaces/websockets/server.cc index 44eec9389b..f7d5621046 100644 --- a/libs/surfaces/websockets/server.cc +++ b/libs/surfaces/websockets/server.cc @@ -116,13 +116,6 @@ WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface) int WebsocketsServer::start () { -#if !defined(LWS_WITH_GLIB) && !defined(LWS_WITH_EXTERNAL_POLL) - PBD::error << "ArdourWebsockets: check your libwebsockets was compiled" - " with LWS_WITH_GLIB or LWS_WITH_EXTERNAL_POLL enabled" - << endmsg; - return -1; -#endif - #ifndef NDEBUG lws_set_log_level (LLL_ERR | LLL_WARN | LLL_DEBUG, 0); #endif @@ -145,6 +138,17 @@ WebsocketsServer::start () return -1; } +#ifndef LWS_WITH_GLIB + /* sometimes LWS_WITH_EXTERNAL_POLL is missing from lws_config.h + but the feature is still available, hence this runtime check */ + if (_fd_ctx.empty ()) { + PBD::error << "ArdourWebsockets: check your libwebsockets was compiled" + " with LWS_WITH_GLIB or LWS_WITH_EXTERNAL_POLL enabled" + << endmsg; + return -1; + } +#endif + return 0; }