mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-10 05:59:45 -05:00
Make compatible with libevent 2.0 by crippling streaming and ICY metadata (see issue #30)
This commit is contained in:
37
src/httpd.c
37
src/httpd.c
@@ -122,6 +122,9 @@ static struct event exitev;
|
||||
static struct evhttp *evhttpd;
|
||||
static pthread_t tid_httpd;
|
||||
|
||||
#ifdef HAVE_LIBEVENT2_OLD
|
||||
struct stream_ctx *g_st;
|
||||
#endif
|
||||
|
||||
static void
|
||||
stream_end(struct stream_ctx *st, int failed)
|
||||
@@ -146,6 +149,11 @@ stream_end(struct stream_ctx *st, int failed)
|
||||
close(st->fd);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBEVENT2_OLD
|
||||
if (g_st == st)
|
||||
g_st = NULL;
|
||||
#endif
|
||||
|
||||
free(st);
|
||||
}
|
||||
|
||||
@@ -180,6 +188,15 @@ 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
|
||||
stream_chunk_xcode_cb(int fd, short event, void *arg)
|
||||
{
|
||||
@@ -227,7 +244,17 @@ stream_chunk_xcode_cb(int fd, short event, void *arg)
|
||||
else
|
||||
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);
|
||||
#endif
|
||||
|
||||
st->offset += ret;
|
||||
|
||||
@@ -283,7 +310,17 @@ stream_chunk_raw_cb(int fd, short event, void *arg)
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
st->offset += ret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user