[httpd/artwork] Drop support for libevent <2.1.4

This commit is contained in:
ejurgensen 2022-12-18 10:24:43 +01:00
parent 10a51a0af9
commit 84fd6e4efe
5 changed files with 2 additions and 75 deletions

View File

@ -148,13 +148,7 @@ OWNTONE_MODULES_CHECK([COMMON], [SQLITE3], [sqlite3 >= 3.5.0],
[AC_MSG_RESULT([[runtime will tell]])]) [AC_MSG_RESULT([[runtime will tell]])])
]) ])
OWNTONE_MODULES_CHECK([OWNTONE], [LIBEVENT], [libevent >= 2], OWNTONE_MODULES_CHECK([OWNTONE], [LIBEVENT], [libevent >= 2.1.4], [event_base_new], [event2/event.h])
[event_base_new], [event2/event.h],
[dnl check for old version
PKG_CHECK_EXISTS([libevent >= 2.1.4], [],
[AC_DEFINE([HAVE_LIBEVENT2_OLD], 1,
[Define to 1 if you have libevent 2 (<2.1.4)])])
])
OWNTONE_MODULES_CHECK([OWNTONE], [JSON_C], [json-c], OWNTONE_MODULES_CHECK([OWNTONE], [JSON_C], [json-c],
[json_tokener_parse], [json.h], [json_tokener_parse], [json.h],

View File

@ -233,7 +233,7 @@ Libraries:
from <http://ffmpeg.org/> from <http://ffmpeg.org/>
- libconfuse - libconfuse
from <http://www.nongnu.org/confuse/> from <http://www.nongnu.org/confuse/>
- libevent 2.0+ (best with 2.1.4+) - libevent 2.1.4+
from <http://libevent.org/> from <http://libevent.org/>
- MiniXML (aka mxml or libmxml) - MiniXML (aka mxml or libmxml)
from <http://minixml.org/software.php> from <http://minixml.org/software.php>

View File

@ -574,20 +574,6 @@ size_calculate(int *dst_w, int *dst_h, int src_w, int src_h, int max_w, int max_
DPRINTF(E_DBG, L_ART, "Rescale required, destination width %d height %d\n", *dst_w, *dst_h); DPRINTF(E_DBG, L_ART, "Rescale required, destination width %d height %d\n", *dst_w, *dst_h);
} }
#ifdef HAVE_LIBEVENT2_OLD
// This is not how this function is actually defined in libevent 2.1+, but it
// works as a less optimal stand-in
int
evbuffer_add_buffer_reference(struct evbuffer *outbuf, struct evbuffer *inbuf)
{
uint8_t *buf = evbuffer_pullup(inbuf, -1);
if (!buf)
return -1;
return evbuffer_add_reference(outbuf, buf, evbuffer_get_length(inbuf), NULL, NULL);
}
#endif
/* /*
* Either gets the artwork file given in "path" (rescaled if needed) or rescales * Either gets the artwork file given in "path" (rescaled if needed) or rescales
* the artwork given in "inbuf". * the artwork given in "inbuf".

View File

@ -63,17 +63,6 @@
#include "log.h" #include "log.h"
#include "rtsp-internal.h" #include "rtsp-internal.h"
// For compability with libevent 2.0 (HAVE_LIBEVENT2_OLD)
#if defined(_EVENT_HAVE_GETNAMEINFO)
# define EVENT__HAVE_GETNAMEINFO 1
#endif
#if defined(_EVENT_HAVE_GETADDRINFO)
# define EVENT__HAVE_GETADDRINFO 1
#endif
#if defined(_EVENT_HAVE_STRSEP)
# define EVENT__HAVE_STRSEP 1
#endif
#ifndef EVENT__HAVE_GETNAMEINFO #ifndef EVENT__HAVE_GETNAMEINFO
#define NI_MAXSERV 32 #define NI_MAXSERV 32
#define NI_MAXHOST 1025 #define NI_MAXHOST 1025

View File

@ -42,10 +42,6 @@
#include <event2/event.h> #include <event2/event.h>
#include <event2/http.h> #include <event2/http.h>
#include <event2/http_struct.h> #include <event2/http_struct.h>
#ifdef HAVE_LIBEVENT2_OLD
# include <event2/bufferevent.h>
# include <event2/bufferevent_struct.h>
#endif
#include <zlib.h> #include <zlib.h>
#include "logger.h" #include "logger.h"
@ -134,10 +130,6 @@ static pthread_t tid_httpd;
static const char *allow_origin; static const char *allow_origin;
static int httpd_port; static int httpd_port;
#ifdef HAVE_LIBEVENT2_OLD
struct stream_ctx *g_st;
#endif
/* -------------------------------- HELPERS --------------------------------- */ /* -------------------------------- HELPERS --------------------------------- */
@ -550,11 +542,6 @@ stream_end(struct stream_ctx *st, int failed)
close(st->fd); close(st->fd);
} }
#ifdef HAVE_LIBEVENT2_OLD
if (g_st == st)
g_st = NULL;
#endif
free(st); free(st);
} }
@ -592,15 +579,6 @@ stream_chunk_resched_cb(struct evhttp_connection *evcon, void *arg)
} }
} }
#ifdef HAVE_LIBEVENT2_OLD
static void
stream_chunk_resched_cb_wrapper(struct bufferevent *bufev, void *arg)
{
if (g_st)
stream_chunk_resched_cb(NULL, g_st);
}
#endif
static void static void
stream_chunk_xcode_cb(int fd, short event, void *arg) stream_chunk_xcode_cb(int fd, short event, void *arg)
{ {
@ -648,17 +626,7 @@ stream_chunk_xcode_cb(int fd, short event, void *arg)
else else
ret = xcoded; ret = xcoded;
#ifdef HAVE_LIBEVENT2_OLD
evhttp_send_reply_chunk(st->req, st->evbuf);
struct evhttp_connection *evcon = evhttp_request_get_connection(st->req);
struct bufferevent *bufev = evhttp_connection_get_bufferevent(evcon);
g_st = st; // Can't pass st to callback so use global - limits libevent 2.0 to a single stream
bufev->writecb = stream_chunk_resched_cb_wrapper;
#else
evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st); evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st);
#endif
st->offset += ret; st->offset += ret;
@ -714,17 +682,7 @@ stream_chunk_raw_cb(int fd, short event, void *arg)
evbuffer_add(st->evbuf, st->buf, ret); evbuffer_add(st->evbuf, st->buf, ret);
#ifdef HAVE_LIBEVENT2_OLD
evhttp_send_reply_chunk(st->req, st->evbuf);
struct evhttp_connection *evcon = evhttp_request_get_connection(st->req);
struct bufferevent *bufev = evhttp_connection_get_bufferevent(evcon);
g_st = st; // Can't pass st to callback so use global - limits libevent 2.0 to a single stream
bufev->writecb = stream_chunk_resched_cb_wrapper;
#else
evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st); evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st);
#endif
st->offset += ret; st->offset += ret;