Merge branch 'libevent2' into dev

This commit is contained in:
ejurgensen 2014-03-24 04:59:08 +01:00
commit 3ff4fa77be
26 changed files with 2052 additions and 112 deletions

17
INSTALL
View File

@ -13,8 +13,8 @@ The original (now unmaintained) source can be found here:
<http://git.debian.org/?p=users/jblache/forked-daapd.git>
Quick version for Debian users
------------------------------
Quick version for Debian/Ubuntu users
-------------------------------------
If you are the lucky kind, this should get you all the required tools and
libraries:
@ -23,15 +23,18 @@ sudo apt-get install \
build-essential git autotools-dev autoconf libtool gettext gawk gperf \
antlr3 libantlr3c-dev libconfuse-dev libunistring-dev libsqlite3-dev \
libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libasound2-dev \
libmxml-dev libgcrypt11-dev libavahi-client-dev libavl-dev libevent1-dev \
libflac-dev
libmxml-dev libgcrypt11-dev libavahi-client-dev libavl-dev zlib1g-dev \
libevent1-dev
Note that libevent1-dev is not in the Debian repository, but you can get the
packages in the Ubuntu repository.
Then run the following:
git clone https://github.com/ejurgensen/forked-daapd.git
cd forked-daapd
autoreconf -i
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-flac
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
make
sudo make install
@ -79,8 +82,8 @@ Libraries:
from <http://libav.org/releases/>
- libconfuse
from <http://www.nongnu.org/confuse/>
- libevent 1.4 (** NOT libevent 2 **)
from <http://www.monkey.org/~provos/libevent/>
- libevent 1.4 or 2.1.4+
from <http://libevent.org/>
- libavl 0.3.5
from <http://ftp.debian.org/debian/pool/main/liba/libavl>
- MiniXML (aka mxml or libmxml)

View File

@ -159,9 +159,24 @@ fi
PKG_CHECK_MODULES(MINIXML, [ mxml ])
AC_CHECK_HEADER(event.h, , AC_MSG_ERROR([event.h not found]))
AC_CHECK_LIB([event_core], [event_init], [LIBEVENT_LIBS="-levent_core"], AC_MSG_ERROR([libevent not found]))
AC_SUBST(LIBEVENT_LIBS)
PKG_CHECK_MODULES(LIBEVENT, [ libevent >= 2],
AC_CHECK_LIB([event], [evhttp_request_set_header_cb],
AC_DEFINE(HAVE_LIBEVENT2, 1, [Define to 1 if you have libevent 2 with evhttp_request_set_header_cb()]),
AC_MSG_ERROR([found libevent 2 but without evhttp_request_set_header_cb() - try version >= 2.1.4])
),
try_libevent1=true;
)
if test x$try_libevent1 = xtrue; then
AC_CHECK_HEADER(event.h,
AC_CHECK_LIB([event_core], [event_init], [LIBEVENT_LIBS="-levent_core"], AC_MSG_ERROR([libevent not found])),
AC_MSG_ERROR([event.h not found])
)
AC_SUBST(LIBEVENT_LIBS)
AM_CONDITIONAL(COND_LIBEVENT2, false)
else
AM_CONDITIONAL(COND_LIBEVENT2, true)
fi
AC_CHECK_HEADER(avl.h, , AC_MSG_ERROR([avl.h not found]))
AC_CHECK_LIB([avl], [avl_alloc_tree], [LIBAVL_LIBS="-lavl"], AC_MSG_ERROR([libavl not found]))
@ -191,12 +206,12 @@ fi
if test x$use_spotify = xtrue; then
AC_CHECK_HEADER(libspotify/api.h, , AC_MSG_ERROR([libspotify/api.h not found]))
AC_DEFINE(HAVE_SPOTIFY_H, 1, [Define to 1 if you have the <libspotify/api.h> header file.])
dnl Don't link to libspotify, but instead enable dynamic linking
SPOTIFY_CFLAGS="-rdynamic"
SPOTIFY_LIBS="-ldl"
AC_SUBST(SPOTIFY_CFLAGS)
AC_SUBST(SPOTIFY_LIBS)
AC_DEFINE(HAVE_SPOTIFY_H, 1, [Define to 1 if you have the <libspotify/api.h> header file.])
dnl Don't link to libspotify, but instead enable dynamic linking
SPOTIFY_CFLAGS="-rdynamic"
SPOTIFY_LIBS="-ldl"
AC_SUBST(SPOTIFY_CFLAGS)
AC_SUBST(SPOTIFY_LIBS)
fi
case "$host" in

View File

@ -31,6 +31,13 @@ else
FFURL_SRC=ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h
endif
if COND_LIBEVENT2
RTSP_SRC=evrtsp/rtsp.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
else
EVHTTP_SRC=evhttp/http.c evhttp/evhttp.h evhttp/http-internal.h evhttp/log.h
RTSP_SRC=evrtsp/rtsp-libevent1.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
endif
GPERF_FILES = \
daap_query.gperf \
rsp_query.gperf \
@ -79,8 +86,7 @@ forked_daapd_SOURCES = main.c \
filescanner_ffmpeg.c filescanner_m3u.c filescanner_icy.c $(ITUNESSRC) \
mdns_avahi.c mdns.h \
remote_pairing.c remote_pairing.h \
evhttp/http.c evhttp/evhttp.h \
evhttp/http-internal.h evhttp/log.h \
$(EVHTTP_SRC) \
$(FFURL_SRC) $(AVIO_SRC) \
httpd.c httpd.h \
httpd_rsp.c httpd_rsp.h \
@ -96,10 +102,9 @@ forked_daapd_SOURCES = main.c \
player.c player.h \
$(ALSASRC) $(OSS4SRC) laudio.h \
raop.c raop.h \
evrtsp/rtsp.c evrtp/evrtsp.h \
evrtsp/rtsp-internal.h evrtsp/log.h \
$(RTSP_SRC) \
scan-wma.c \
$(SPOTIFYSRC) \
$(SPOTIFYSRC) \
$(FLACSRC) $(MUSEPACKSRC)
nodist_forked_daapd_SOURCES = \

View File

@ -29,8 +29,6 @@
#include <fcntl.h>
#include <limits.h>
#include <event.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>

View File

@ -8,6 +8,7 @@
#define ART_FMT_PNG 1
#define ART_FMT_JPEG 2
#include <event.h>
int
artwork_get_item_filename(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf);

View File

@ -24,8 +24,6 @@
#include <libavformat/avformat.h>
#include <event.h>
#include "logger.h"
#include "avio_evbuffer.h"

View File

@ -2,6 +2,8 @@
#ifndef __AVIO_EVBUFFER_H__
#define __AVIO_EVBUFFER_H__
#include <event.h>
AVIOContext *
avio_evbuffer_open(struct evbuffer *evbuf);

View File

@ -23,9 +23,6 @@
#include <string.h>
#include <stdint.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include "db.h"
#include "misc.h"
#include "logger.h"

View File

@ -3,7 +3,11 @@
#define __DMAP_HELPERS_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include "db.h"

1816
src/evrtsp/rtsp-libevent1.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -28,19 +28,19 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <event-config.h>
#include <event.h>
#ifdef _EVENT_HAVE_SYS_PARAM_H
#ifdef EVENT__HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef _EVENT_HAVE_SYS_TYPES_H
#ifdef EVENT__HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef _EVENT_HAVE_SYS_TIME_H
#ifdef EVENT__HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef _EVENT_HAVE_SYS_IOCCOM_H
#ifdef EVENT__HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif
@ -74,19 +74,17 @@
#endif
#include <signal.h>
#include <time.h>
#ifdef _EVENT_HAVE_UNISTD_H
#ifdef EVENT__HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _EVENT_HAVE_FCNTL_H
#ifdef EVENT__HAVE_FCNTL_H
#include <fcntl.h>
#endif
#undef timeout_pending
#undef timeout_initialized
#include <event.h>
#include "evrtsp.h"
#include <evutil.h>
/* #define USE_DEBUG */
#include "log.h"
#include "rtsp-internal.h"
@ -97,7 +95,7 @@
#define strdup _strdup
#endif
#ifndef _EVENT_HAVE_GETNAMEINFO
#ifndef EVENT__HAVE_GETNAMEINFO
#define NI_MAXSERV 32
#define NI_MAXHOST 1025
@ -146,7 +144,7 @@ fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
#endif
#ifndef _EVENT_HAVE_GETADDRINFO
#ifndef EVENT__HAVE_GETADDRINFO
struct addrinfo {
int ai_family;
int ai_socktype;
@ -220,7 +218,7 @@ static int evrtsp_add_header_internal(struct evkeyvalq *headers,
void evrtsp_read(int, short, void *);
void evrtsp_write(int, short, void *);
#ifndef _EVENT_HAVE_STRSEP
#ifndef EVENT__HAVE_STRSEP
/* strsep replacement for platforms that lack it. Only works if
* del is one character long. */
static char *
@ -319,8 +317,7 @@ evrtsp_write_buffer(struct evrtsp_connection *evcon,
if (event_pending(&evcon->ev, EV_WRITE|EV_TIMEOUT, NULL))
event_del(&evcon->ev);
event_set(&evcon->ev, evcon->fd, EV_WRITE, evrtsp_write, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_WRITE, evrtsp_write, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_WRITE_TIMEOUT);
}
@ -357,12 +354,12 @@ evrtsp_make_header_request(struct evrtsp_connection *evcon,
method, req->uri, req->major, req->minor);
/* Content-Length is mandatory, absent means 0 */
if ((EVBUFFER_LENGTH(req->output_buffer) > 0)
if ((evbuffer_get_length(req->output_buffer) > 0)
&& (evrtsp_find_header(req->output_headers, "Content-Length") == NULL))
{
char size[12];
evutil_snprintf(size, sizeof(size), "%ld",
(long)EVBUFFER_LENGTH(req->output_buffer));
(long)evbuffer_get_length(req->output_buffer));
evrtsp_add_header(req->output_headers, "Content-Length", size);
}
}
@ -380,7 +377,7 @@ evrtsp_make_header(struct evrtsp_connection *evcon, struct evrtsp_request *req)
}
evbuffer_add(evcon->output_buffer, "\r\n", 2);
if (EVBUFFER_LENGTH(req->output_buffer) > 0) {
if (evbuffer_get_length(req->output_buffer) > 0) {
evbuffer_add_buffer(evcon->output_buffer, req->output_buffer);
}
}
@ -498,7 +495,7 @@ evrtsp_write(int fd, short what, void *arg)
return;
}
if (EVBUFFER_LENGTH(evcon->output_buffer) != 0) {
if (evbuffer_get_length(evcon->output_buffer) != 0) {
evrtsp_add_event(&evcon->ev,
evcon->timeout, RTSP_WRITE_TIMEOUT);
return;
@ -577,9 +574,9 @@ evrtsp_read_body(struct evrtsp_connection *evcon, struct evrtsp_request *req)
if (req->ntoread < 0) {
/* Read until connection close. */
evbuffer_add_buffer(req->input_buffer, buf);
} else if (EVBUFFER_LENGTH(buf) >= req->ntoread) {
} else if (evbuffer_get_length(buf) >= req->ntoread) {
/* Completed content length */
evbuffer_add(req->input_buffer, EVBUFFER_DATA(buf),
evbuffer_add(req->input_buffer, evbuffer_pullup(buf,-1),
(size_t)req->ntoread);
evbuffer_drain(buf, (size_t)req->ntoread);
req->ntoread = 0;
@ -587,8 +584,7 @@ evrtsp_read_body(struct evrtsp_connection *evcon, struct evrtsp_request *req)
return;
}
/* Read more! */
event_set(&evcon->ev, evcon->fd, EV_READ, evrtsp_read, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_READ, evrtsp_read, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_READ_TIMEOUT);
}
@ -756,9 +752,9 @@ evrtsp_connection_reset(struct evrtsp_connection *evcon)
evcon->state = EVCON_DISCONNECTED;
evbuffer_drain(evcon->input_buffer,
EVBUFFER_LENGTH(evcon->input_buffer));
evbuffer_get_length(evcon->input_buffer));
evbuffer_drain(evcon->output_buffer,
EVBUFFER_LENGTH(evcon->output_buffer));
evbuffer_get_length(evcon->output_buffer));
}
static void
@ -776,9 +772,8 @@ evrtsp_connection_start_detectclose(struct evrtsp_connection *evcon)
if (event_initialized(&evcon->close_ev))
event_del(&evcon->close_ev);
event_set(&evcon->close_ev, evcon->fd, EV_READ,
event_assign(&evcon->close_ev, evcon->base, evcon->fd, EV_READ,
evrtsp_detect_close_cb, evcon);
EVRTSP_BASE_SET(evcon, &evcon->close_ev);
event_add(&evcon->close_ev, NULL);
}
@ -1033,7 +1028,7 @@ evrtsp_parse_firstline(struct evrtsp_request *req, struct evbuffer *buffer)
char *line;
enum message_read_status status = ALL_DATA_READ;
line = evbuffer_readline(buffer);
line = evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY);
if (line == NULL)
return (MORE_DATA_EXPECTED);
@ -1074,13 +1069,13 @@ evrtsp_append_to_last_header(struct evkeyvalq *headers, const char *line)
}
enum message_read_status
evrtsp_parse_headers(struct evrtsp_request *req, struct evbuffer* buffer)
evrtsp_parse_headers(struct evrtsp_request *req, struct evbuffer *buffer)
{
char *line;
enum message_read_status status = MORE_DATA_EXPECTED;
struct evkeyvalq* headers = req->input_headers;
while ((line = evbuffer_readline(buffer))
struct evkeyvalq *headers = req->input_headers;
while ((line = evbuffer_readln(buffer, NULL, EVBUFFER_EOL_CRLF))
!= NULL) {
char *skey, *svalue;
@ -1143,7 +1138,7 @@ evrtsp_get_body_length(struct evrtsp_request *req)
event_debug(("%s: bytes to read: %lld (in buffer %ld)\n",
__func__, req->ntoread,
EVBUFFER_LENGTH(req->evcon->input_buffer)));
evbuffer_get_length(req->evcon->input_buffer)));
return (0);
}
@ -1401,8 +1396,7 @@ evrtsp_connection_connect(struct evrtsp_connection *evcon)
}
/* Set up a callback for successful connection setup */
event_set(&evcon->ev, evcon->fd, EV_WRITE, evrtsp_connectioncb, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_WRITE, evrtsp_connectioncb, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_CONNECT_TIMEOUT);
evcon->state = EVCON_CONNECTING;
@ -1467,9 +1461,7 @@ evrtsp_start_read(struct evrtsp_connection *evcon)
/* Set up an event to read the headers */
if (event_initialized(&evcon->ev))
event_del(&evcon->ev);
event_set(&evcon->ev, evcon->fd, EV_READ, evrtsp_read, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_READ, evrtsp_read, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_READ_TIMEOUT);
evcon->state = EVCON_READING_FIRSTLINE;
}
@ -1604,7 +1596,7 @@ evrtsp_request_uri(struct evrtsp_request *req) {
static struct addrinfo *
addr_from_name(char *address)
{
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
struct addrinfo ai, *aitop;
int ai_result;
@ -1635,7 +1627,7 @@ name_from_addr(struct sockaddr *sa, socklen_t salen,
char strport[NI_MAXSERV];
int ni_result;
#ifdef _EVENT_HAVE_GETNAMEINFO
#ifdef EVENT__HAVE_GETNAMEINFO
ni_result = getnameinfo(sa, salen,
ntop, sizeof(ntop), strport, sizeof(strport),
NI_NUMERICHOST|NI_NUMERICSERV);
@ -1717,7 +1709,7 @@ make_addrinfo(const char *address, u_short port)
{
struct addrinfo *aitop = NULL;
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
struct addrinfo ai;
char strport[NI_MAXSERV];
int ai_result;
@ -1767,7 +1759,7 @@ bind_socket(int family, const char *address, u_short port, int reuse)
fd = bind_socket_ai(family, aitop, reuse);
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
freeaddrinfo(aitop);
#else
fake_freeaddrinfo(aitop);
@ -1806,7 +1798,7 @@ socket_connect(int fd, const char *address, unsigned short port)
res = 0;
out:
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
freeaddrinfo(ai);
#else
fake_freeaddrinfo(ai);

View File

@ -43,7 +43,11 @@
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include <libavformat/avformat.h>

View File

@ -37,7 +37,11 @@
#include <avl.h>
#include <plist/plist.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include "logger.h"
#include "db.h"

View File

@ -42,8 +42,6 @@
#endif
#include <zlib.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include "logger.h"
#include "db.h"

View File

@ -3,8 +3,11 @@
#define __HTTPD_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
void
httpd_stream_file(struct evhttp_request *req, int id);

View File

@ -38,8 +38,6 @@
#include <uninorm.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include <avl.h>
#include "logger.h"

View File

@ -3,7 +3,11 @@
#define __HTTPD_DAAP_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
int
daap_init(void);

View File

@ -37,9 +37,6 @@
# include <sys/eventfd.h>
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#include "logger.h"
#include "misc.h"
#include "conffile.h"

View File

@ -3,7 +3,11 @@
#define __HTTPD_DACP_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
int
dacp_init(void);

View File

@ -31,9 +31,6 @@
#include <regex.h>
#include <limits.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include <mxml.h>
#include "logger.h"

View File

@ -3,7 +3,11 @@
#define __HTTPD_RSP_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
int
rsp_init(void);

View File

@ -34,7 +34,11 @@
#include <arpa/inet.h>
#include <net/if.h>
#include <event.h>
#ifdef HAVE_LIBEVENT2
# include <event2/event.h>
#else
# include <event.h>
#endif
#include <avahi-common/watch.h>
#include <avahi-common/malloc.h>
@ -56,7 +60,7 @@ static AvahiEntryGroup *mdns_group = NULL;
struct AvahiWatch
{
struct event ev;
struct event *ev;
AvahiWatchCallback cb;
void *userdata;
@ -66,7 +70,7 @@ struct AvahiWatch
struct AvahiTimeout
{
struct event ev;
struct event *ev;
AvahiTimeoutCallback cb;
void *userdata;
@ -93,7 +97,7 @@ evcb_watch(int fd, short ev_events, void *arg)
if (ev_events & EV_WRITE)
a_events |= AVAHI_WATCH_OUT;
event_add(&w->ev, NULL);
event_add(w->ev, NULL);
w->cb(w, fd, a_events, w->userdata);
}
@ -121,10 +125,32 @@ _ev_watch_add(AvahiWatch *w, int fd, AvahiWatchEvent a_events)
if (a_events & AVAHI_WATCH_OUT)
ev_events |= EV_WRITE;
event_set(&w->ev, fd, ev_events, evcb_watch, w);
event_base_set(evbase_main, &w->ev);
#ifdef HAVE_LIBEVENT2
if (w->ev)
event_free(w->ev);
return event_add(&w->ev, NULL);
w->ev = event_new(evbase_main, fd, ev_events, evcb_watch, w);
if (!w->ev)
{
DPRINTF(E_LOG, L_MDNS, "Could not make new event in _ev_watch_add\n");
return -1;
}
#else
if (w->ev)
free(w->ev);
w->ev = (struct event *)malloc(sizeof(struct event));
if (!w->ev)
{
DPRINTF(E_LOG, L_MDNS, "Out of memory in _ev_watch_add\n");
return -1;
}
event_set(w->ev, fd, ev_events, evcb_watch, w);
event_base_set(evbase_main, w->ev);
#endif
return event_add(w->ev, NULL);
}
static AvahiWatch *
@ -158,9 +184,14 @@ ev_watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent a_events, AvahiWatchC
static void
ev_watch_update(AvahiWatch *w, AvahiWatchEvent a_events)
{
event_del(&w->ev);
if (w->ev)
event_del(w->ev);
_ev_watch_add(w, EVENT_FD(&w->ev), a_events);
#ifdef HAVE_LIBEVENT2
_ev_watch_add(w, (int)event_get_fd(w->ev), a_events);
#else
_ev_watch_add(w, EVENT_FD(w->ev), a_events);
#endif
}
static AvahiWatchEvent
@ -170,9 +201,9 @@ ev_watch_get_events(AvahiWatch *w)
a_events = 0;
if (event_pending(&w->ev, EV_READ, NULL))
if (event_pending(w->ev, EV_READ, NULL))
a_events |= AVAHI_WATCH_IN;
if (event_pending(&w->ev, EV_WRITE, NULL))
if (event_pending(w->ev, EV_WRITE, NULL))
a_events |= AVAHI_WATCH_OUT;
return a_events;
@ -184,7 +215,16 @@ ev_watch_free(AvahiWatch *w)
AvahiWatch *prev;
AvahiWatch *cur;
event_del(&w->ev);
if (w->ev)
{
event_del(w->ev);
#ifdef HAVE_LIBEVENT2
event_free(w->ev);
#else
free(w->ev);
#endif
w->ev = NULL;
}
prev = NULL;
for (cur = all_w; cur; prev = cur, cur = cur->next)
@ -211,8 +251,30 @@ _ev_timeout_add(AvahiTimeout *t, const struct timeval *tv)
struct timeval now;
int ret;
evtimer_set(&t->ev, evcb_timeout, t);
event_base_set(evbase_main, &t->ev);
#ifdef HAVE_LIBEVENT2
if (t->ev)
event_free(t->ev);
t->ev = evtimer_new(evbase_main, evcb_timeout, t);
if (!t->ev)
{
DPRINTF(E_LOG, L_MDNS, "Could not make event in _ev_timeout_add - out of memory?\n");
return -1;
}
#else
if (t->ev)
free(t->ev);
t->ev = (struct event *)malloc(sizeof(struct event));
if (!t->ev)
{
DPRINTF(E_LOG, L_MDNS, "Out of memory in _ev_timeout_add\n");
return -1;
}
evtimer_set(t->ev, evcb_timeout, t);
event_base_set(evbase_main, t->ev);
#endif
if ((tv->tv_sec == 0) && (tv->tv_usec == 0))
{
@ -227,7 +289,7 @@ _ev_timeout_add(AvahiTimeout *t, const struct timeval *tv)
evutil_timersub(tv, &now, &e_tv);
}
return evtimer_add(&t->ev, &e_tv);
return evtimer_add(t->ev, &e_tv);
}
static AvahiTimeout *
@ -265,7 +327,8 @@ ev_timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallb
static void
ev_timeout_update(AvahiTimeout *t, const struct timeval *tv)
{
event_del(&t->ev);
if (t->ev)
event_del(t->ev);
if (tv)
_ev_timeout_add(t, tv);
@ -277,7 +340,16 @@ ev_timeout_free(AvahiTimeout *t)
AvahiTimeout *prev;
AvahiTimeout *cur;
event_del(&t->ev);
if (t->ev)
{
event_del(t->ev);
#ifdef HAVE_LIBEVENT2
event_free(t->ev);
#else
free(t->ev);
#endif
t->ev = NULL;
}
prev = NULL;
for (cur = all_t; cur; prev = cur, cur = cur->next)
@ -954,10 +1026,28 @@ mdns_deinit(void)
AvahiTimeout *t;
for (t = all_t; t; t = t->next)
event_del(&t->ev);
if (t->ev)
{
event_del(t->ev);
#ifdef HAVE_LIBEVENT2
event_free(t->ev);
#else
free(t->ev);
#endif
t->ev = NULL;
}
for (w = all_w; w; w = w->next)
event_del(&w->ev);
if (w->ev)
{
event_del(w->ev);
#ifdef HAVE_LIBEVENT2
event_free(w->ev);
#else
free(w->ev);
#endif
w->ev = NULL;
}
for (ge = group_entries; group_entries; ge = group_entries)
{

View File

@ -47,7 +47,11 @@
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include <gcrypt.h>

View File

@ -3,7 +3,7 @@
#define __SPOTIFY_H__
#include "db.h"
#include "evhttp/evhttp.h"
#include <event.h>
int
spotify_playback_play(struct media_file_info *mfi);

View File

@ -38,9 +38,6 @@
# include <sys/endian.h>
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/mathematics.h>

View File

@ -2,7 +2,12 @@
#ifndef __TRANSCODE_H__
#define __TRANSCODE_H__
#include "evhttp/evhttp.h"
#include <event.h>
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
struct transcode_ctx;