Commit e0d031b5 authored by Led's avatar Led

0.13.2

parent 4bb8af8b
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
/* Define to enable Avahi Zeroconf support */ /* Define to enable Avahi Zeroconf support */
#undef HAVE_AVAHI #undef HAVE_AVAHI
/* Define to enable Bonjour Zeroconf support */
#undef HAVE_BONJOUR
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H #undef HAVE_DLFCN_H
...@@ -142,6 +145,9 @@ ...@@ -142,6 +145,9 @@
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
/* Define to enable Zeroconf support */
#undef HAVE_ZEROCONF
/* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O #undef NO_MINUS_C_MINUS_O
......
...@@ -2,7 +2,7 @@ dnl AC_INIT(src/main.c) ...@@ -2,7 +2,7 @@ dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(mpd, 0.13.0) dnl AM_INIT_AUTOMAKE(mpd, 0.13.0)
AC_PREREQ(2.58) AC_PREREQ(2.58)
AC_INIT(mpd, 0.13.1, warren.dukes@gmail.com) AC_INIT(mpd, 0.13.2, warren.dukes@gmail.com)
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
AC_SUBST(MPD_LIBS) AC_SUBST(MPD_LIBS)
...@@ -583,26 +583,38 @@ no|avahi|bonjour) ...@@ -583,26 +583,38 @@ no|avahi|bonjour)
esac esac
if test x$with_zeroconf != xno; then if test x$with_zeroconf != xno; then
if test x$with_zeroconf = xauto; then if test x$with_zeroconf = xavahi || test x$with_zeroconf = xauto; then
PKG_CHECK_MODULES([AVAHI], [avahi-client], PKG_CHECK_MODULES([AVAHI], [avahi-client],
[with_zeroconf=avahi;AC_DEFINE([HAVE_AVAHI], 1, [Define to enable Avahi Zeroconf support])] MPD_LIBS="$MPD_LIBS $AVAHI_LIBS" MPD_CFLAGS="$MPD_CFLAGS $AVAHI_CFLAGS", [found_avahi=1;AC_DEFINE([HAVE_AVAHI], 1, [Define to enable Avahi Zeroconf support])]
[with_zeroconf=auto]) MPD_LIBS="$MPD_LIBS $AVAHI_LIBS" MPD_CFLAGS="$MPD_CFLAGS $AVAHI_CFLAGS",
[found_avahi=0])
fi
if test x$found_avahi = x1; then
with_zeroconf=avahi
elif test x$with_zeroconf = xavahi; then elif test x$with_zeroconf = xavahi; then
PKG_CHECK_MODULES([AVAHI], [avahi-client], with_zeroconf=no
[with_zeroconf=avahi;AC_DEFINE([HAVE_AVAHI], 1, [Define to enable Avahi Zeroconf support])] MPD_LIBS="$MPD_LIBS $AVAHI_LIBS" MPD_CFLAGS="$MPD_CFLAGS $AVAHI_CFLAGS")
fi fi
# In the future, should add bonjour support (for OSX) and check at autodetect if test x$with_zeroconf = xbonjour || test x$with_zeroconf = xauto; then
# time AC_CHECK_HEADER(dns_sd.h,
#if test x$with_zeroconf = xbonjour -o x$with_zeroconf = xauto; then [found_bonjour=1;AC_DEFINE([HAVE_BONJOUR], 1, [Define to enable Bonjour Zeroconf support])],
if test x$with_zeroconf = xbonjour; then [found_bonjour=0])
AC_MSG_WARN([Bonjour support has not been implemented yet, disabling Zeroconf]) AC_CHECK_LIB(dns_sd, DNSServiceRegister,
MPD_LIBS="$MPD_LIBS -ldns_sd")
fi
if test x$found_bonjour = x1; then
with_zeroconf=bonjour
elif test x$with_zeroconf = xbonjour; then
with_zeroconf=no with_zeroconf=no
fi fi
if test x$with_zeroconf = xauto; then if test x$with_zeroconf = xauto || test x$with_zeroconf = xno; then
AC_MSG_WARN([No supported Zeroconf backend found, disabling Zeroconf]) AC_MSG_WARN([No supported Zeroconf backend found, disabling Zeroconf])
with_zeroconf=no with_zeroconf=no
else
AC_DEFINE([HAVE_ZEROCONF], 1, [Define to enable Zeroconf support])
fi fi
fi fi
......
...@@ -71,10 +71,14 @@ reports from what address a connection is opened, and when it is closed, and ...@@ -71,10 +71,14 @@ reports from what address a connection is opened, and when it is closed, and
"verbose" records excessive amounts of information for debugging purposes. The "verbose" records excessive amounts of information for debugging purposes. The
default is "default". default is "default".
.TP .TP
.B zeroconf_enabled <yes or no>
If yes, and MPD has been compiled with support for Avahi or Bonjour, service
information will be published with Zeroconf. The default is yes.
.TP
.B zeroconf_name <name> .B zeroconf_name <name>
If Zerconf is compiled into MPD, this is the service name to publish. This If Zeroconf is enabled, this is the service name to publish. This name should
should be unique to your local network, but name collisions will be properly be unique to your local network, but name collisions will be properly dealt
dealt with. with. The default is "Music Player".
.TP .TP
.B password <password@permissions> .B password <password@permissions>
This specifies a password for access to mpd. The format is This specifies a password for access to mpd. The format is
......
...@@ -45,9 +45,17 @@ error_file "~/.mpd/mpd.error" ...@@ -45,9 +45,17 @@ error_file "~/.mpd/mpd.error"
# #
#log_level "default" #log_level "default"
# #
# If Zeroconf is configured, the service name to publish. This ################################################################
# should be unique on your local network, but name collisions
# will be taken care of for you.
########################### ZEROCONF ###########################
#
# If yes, service information will be published with Zeroconf.
#
#zeroconf_enabled "yes"
#
# The service name to publish. This name should be unique on
# your local network.
# #
#zeroconf_name "Music Player" #zeroconf_name "Music Player"
# #
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -192,7 +192,9 @@ static int jack_initDriver(AudioOutput *audioOutput, ConfigParam *param) ...@@ -192,7 +192,9 @@ static int jack_initDriver(AudioOutput *audioOutput, ConfigParam *param)
BlockParam *bp; BlockParam *bp;
char *endptr; char *endptr;
int val; int val;
char *cp = NULL; char *cp = NULL;
audioOutput->data = NULL;
DEBUG("jack_initDriver (pid=%d)\n", getpid()); DEBUG("jack_initDriver (pid=%d)\n", getpid());
if ( ! param ) return 0; if ( ! param ) return 0;
......
...@@ -145,6 +145,7 @@ void initConf(void) ...@@ -145,6 +145,7 @@ void initConf(void)
registerConfigParam(CONF_PORT, 0, 0); registerConfigParam(CONF_PORT, 0, 0);
registerConfigParam(CONF_LOG_LEVEL, 0, 0); registerConfigParam(CONF_LOG_LEVEL, 0, 0);
registerConfigParam(CONF_ZEROCONF_NAME, 0, 0); registerConfigParam(CONF_ZEROCONF_NAME, 0, 0);
registerConfigParam(CONF_ZEROCONF_ENABLED, 0, 0);
registerConfigParam(CONF_PASSWORD, 1, 0); registerConfigParam(CONF_PASSWORD, 1, 0);
registerConfigParam(CONF_DEFAULT_PERMS, 0, 0); registerConfigParam(CONF_DEFAULT_PERMS, 0, 0);
registerConfigParam(CONF_AUDIO_OUTPUT, 1, 1); registerConfigParam(CONF_AUDIO_OUTPUT, 1, 1);
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define CONF_PORT "port" #define CONF_PORT "port"
#define CONF_LOG_LEVEL "log_level" #define CONF_LOG_LEVEL "log_level"
#define CONF_ZEROCONF_NAME "zeroconf_name" #define CONF_ZEROCONF_NAME "zeroconf_name"
#define CONF_ZEROCONF_ENABLED "zeroconf_enabled"
#define CONF_PASSWORD "password" #define CONF_PASSWORD "password"
#define CONF_DEFAULT_PERMS "default_permissions" #define CONF_DEFAULT_PERMS "default_permissions"
#define CONF_AUDIO_OUTPUT "audio_output" #define CONF_AUDIO_OUTPUT "audio_output"
......
...@@ -66,7 +66,7 @@ static MDRIVER drv_mpd = { ...@@ -66,7 +66,7 @@ static MDRIVER drv_mpd = {
255, 255,
#if (LIBMIKMOD_VERSION > 0x030106) #if (LIBMIKMOD_VERSION > 0x030106)
"mpd", /* Alias */ "mpd", /* Alias */
#if (LIBMIKMOD_VERSION > 0x030200) #if (LIBMIKMOD_VERSION >= 0x030200)
NULL, /* CmdLineHelp */ NULL, /* CmdLineHelp */
#endif #endif
NULL, /* CommandLine */ NULL, /* CommandLine */
......
...@@ -397,7 +397,7 @@ fail: ...@@ -397,7 +397,7 @@ fail:
return ret; return ret;
} }
static char *oggflac_Suffixes[] = { "ogg", NULL }; static char *oggflac_Suffixes[] = { "ogg", "oga", NULL };
static char *oggflac_mime_types[] = { "audio/x-flac+ogg", static char *oggflac_mime_types[] = { "audio/x-flac+ogg",
"application/ogg", "application/ogg",
"application/x-ogg", "application/x-ogg",
......
...@@ -408,7 +408,7 @@ static unsigned int oggvorbis_try_decode(InputStream * inStream) ...@@ -408,7 +408,7 @@ static unsigned int oggvorbis_try_decode(InputStream * inStream)
return (ogg_stream_type_detect(inStream) == VORBIS) ? 1 : 0; return (ogg_stream_type_detect(inStream) == VORBIS) ? 1 : 0;
} }
static char *oggvorbis_Suffixes[] = { "ogg", NULL }; static char *oggvorbis_Suffixes[] = { "ogg", "oga", NULL };
static char *oggvorbis_MimeTypes[] = { "application/ogg", static char *oggvorbis_MimeTypes[] = { "application/ogg",
"audio/x-vorbis+ogg", "audio/x-vorbis+ogg",
"application/x-ogg", "application/x-ogg",
......
...@@ -429,7 +429,6 @@ int main(int argc, char *argv[]) ...@@ -429,7 +429,6 @@ int main(int argc, char *argv[])
initAudioDriver(); initAudioDriver();
initVolume(); initVolume();
initInterfaces(); initInterfaces();
initZeroconf();
initReplayGainState(); initReplayGainState();
initNormalization(); initNormalization();
initInputStream(); initInputStream();
...@@ -438,10 +437,10 @@ int main(int argc, char *argv[]) ...@@ -438,10 +437,10 @@ int main(int argc, char *argv[])
setup_log_output(options.stdOutput); setup_log_output(options.stdOutput);
initSigHandlers(); initSigHandlers();
initZeroconf();
openVolumeDevice(); openVolumeDevice();
read_state_file(); read_state_file();
......
...@@ -275,7 +275,10 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer, ...@@ -275,7 +275,10 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
if (!myFgets(buffer, PLAYLIST_BUFFER_SIZE, fp)) if (!myFgets(buffer, PLAYLIST_BUFFER_SIZE, fp))
state_file_fatal(); state_file_fatal();
while (strcmp(buffer, PLAYLIST_STATE_FILE_PLAYLIST_END)) { while (strcmp(buffer, PLAYLIST_STATE_FILE_PLAYLIST_END)) {
song = atoi(strtok(buffer, ":")); temp = strtok(buffer, ":");
if (temp == NULL)
state_file_fatal();
song = atoi(temp);
if (!(temp = strtok(NULL, ""))) if (!(temp = strtok(NULL, "")))
state_file_fatal(); state_file_fatal();
if (!addToPlaylist(STDERR_FILENO, temp, 0) && current == song) { if (!addToPlaylist(STDERR_FILENO, temp, 0) && current == song) {
......
...@@ -250,9 +250,11 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir) ...@@ -250,9 +250,11 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
song->url = xstrdup(buffer + strlen(SONG_KEY)); song->url = xstrdup(buffer + strlen(SONG_KEY));
song->type = SONG_TYPE_FILE; song->type = SONG_TYPE_FILE;
song->parentDir = parentDir; song->parentDir = parentDir;
} else if (*buffer == 0) {
/* ignore empty lines (starting with '\0') */
} else if (song == NULL) {
FATAL("Problems reading song info\n");
} else if (0 == strncmp(SONG_FILE, buffer, strlen(SONG_FILE))) { } else if (0 == strncmp(SONG_FILE, buffer, strlen(SONG_FILE))) {
if (!song)
FATAL("Problems reading song info\n");
/* we don't need this info anymore /* we don't need this info anymore
song->url = xstrdup(&(buffer[strlen(SONG_FILE)])); song->url = xstrdup(&(buffer[strlen(SONG_FILE)]));
*/ */
...@@ -270,8 +272,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir) ...@@ -270,8 +272,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
} else if (0 == strncmp(SONG_MTIME, buffer, strlen(SONG_MTIME))) { } else if (0 == strncmp(SONG_MTIME, buffer, strlen(SONG_MTIME))) {
song->mtime = atoi(&(buffer[strlen(SONG_MTIME)])); song->mtime = atoi(&(buffer[strlen(SONG_MTIME)]));
} }
/* ignore empty lines (starting with '\0') */ else
else if (*buffer)
FATAL("songinfo: unknown line in db: %s\n", buffer); FATAL("songinfo: unknown line in db: %s\n", buffer);
} }
......
...@@ -427,25 +427,25 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song) ...@@ -427,25 +427,25 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song)
char *filename; char *filename;
FILE *file; FILE *file;
char *s; char *s;
int nr_songs = 0; struct stat st;
char path_max_tmp[MAXPATHLEN + 1]; char path_max_tmp[MAXPATHLEN + 1];
filename = utf8pathToFsPathInStoredPlaylist(utf8path, fd); filename = utf8pathToFsPathInStoredPlaylist(utf8path, fd);
if (!filename) if (!filename)
return -1; return -1;
while (!(file = fopen(filename, "a+")) && errno == EINTR); while (!(file = fopen(filename, "a")) && errno == EINTR);
if (file == NULL) { if (file == NULL) {
commandError(fd, ACK_ERROR_NO_EXIST, "could not open file " commandError(fd, ACK_ERROR_NO_EXIST, "could not open file "
"\"%s\": %s", filename, strerror(errno)); "\"%s\": %s", filename, strerror(errno));
return -1; return -1;
} }
while (myFgets(path_max_tmp, sizeof(path_max_tmp), file)) { if (fstat(fileno(file), &st) < 0) {
if (path_max_tmp[0] != PLAYLIST_COMMENT && commandError(fd, ACK_ERROR_NO_EXIST, "could not stat file "
(++nr_songs >= playlist_max_length)) "\"%s\": %s", path_max_tmp, strerror(errno));
break; return -1;
} }
if (nr_songs >= playlist_max_length) { if (st.st_size >= ((MAXPATHLEN+1) * playlist_max_length)) {
commandError(fd, ACK_ERROR_PLAYLIST_MAX, commandError(fd, ACK_ERROR_PLAYLIST_MAX,
"playlist is at the max size"); "playlist is at the max size");
return -1; return -1;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <arpa/inet.h>
#include "zeroconf.h" #include "zeroconf.h"
#include "conf.h" #include "conf.h"
...@@ -35,6 +36,17 @@ ...@@ -35,6 +36,17 @@
*/ */
#define SERVICE_NAME "Music Player" #define SERVICE_NAME "Music Player"
#ifdef HAVE_ZEROCONF
static struct ioOps zeroConfIo = {
};
#endif
#ifdef HAVE_BONJOUR
#include <dns_sd.h>
static DNSServiceRef dnsReference;
#endif
/* Here is the implementation for Avahi (http://avahi.org) Zeroconf support */ /* Here is the implementation for Avahi (http://avahi.org) Zeroconf support */
#ifdef HAVE_AVAHI #ifdef HAVE_AVAHI
...@@ -55,10 +67,6 @@ static int avahiRunning; ...@@ -55,10 +67,6 @@ static int avahiRunning;
static int avahiFdset( fd_set* rfds, fd_set* wfds, fd_set* efds ); static int avahiFdset( fd_set* rfds, fd_set* wfds, fd_set* efds );
static int avahiFdconsume( int fdCount, fd_set* rfds, fd_set* wfds, fd_set* efds ); static int avahiFdconsume( int fdCount, fd_set* rfds, fd_set* wfds, fd_set* efds );
static struct ioOps avahiIo = {
.fdset = avahiFdset,
.consume = avahiFdconsume,
};
/* Forward Declaration */ /* Forward Declaration */
static void avahiRegisterService(AvahiClient *c); static void avahiRegisterService(AvahiClient *c);
...@@ -453,36 +461,127 @@ static void init_avahi(const char *serviceName) ...@@ -453,36 +461,127 @@ static void init_avahi(const char *serviceName)
goto fail; goto fail;
} }
avahiIo.fdset = avahiFdset; zeroConfIo.fdset = avahiFdset;
avahiIo.consume = avahiFdconsume; zeroConfIo.consume = avahiFdconsume;
registerIO( &avahiIo ); registerIO( &zeroConfIo );
return; return;
fail: fail:
finishZeroconf(); finishZeroconf();
} }
#else /* !HAVE_AVAHI */
static void init_avahi(const char *serviceName) { }
#endif /* HAVE_AVAHI */ #endif /* HAVE_AVAHI */
#ifdef HAVE_BONJOUR
static int dnsRegisterFdset(fd_set* rfds, fd_set* wfds, fd_set* efds)
{
int fd;
if (dnsReference == NULL)
return -1;
fd = DNSServiceRefSockFD(dnsReference);
if (fd == -1)
return -1;
FD_SET(fd, rfds);
return fd;
}
static int dnsRegisterFdconsume(int fdCount, fd_set* rfds, fd_set* wfds,
fd_set* efds)
{
int fd;
if (dnsReference == NULL)
return -1;
fd = DNSServiceRefSockFD(dnsReference);
if (fd == -1)
return -1;
if (FD_ISSET(fd, rfds)) {
FD_CLR(fd, rfds);
DNSServiceProcessResult(dnsReference);
return fdCount - 1;
}
return fdCount;
}
static void dnsRegisterCallback (DNSServiceRef sdRef, DNSServiceFlags flags,
DNSServiceErrorType errorCode, const char *name,
const char *regtype, const char *domain, void *context)
{
if (errorCode != kDNSServiceErr_NoError) {
ERROR("Failed to register zeroconf service.\n");
DNSServiceRefDeallocate(dnsReference);
dnsReference = NULL;
deregisterIO( &zeroConfIo );
} else {
DEBUG("Registered zeroconf service with name '%s'\n", name);
}
}
static void init_zeroconf_osx(const char *serviceName)
{
DNSServiceErrorType error = DNSServiceRegister(&dnsReference,
0, 0, serviceName, SERVICE_TYPE, NULL, NULL, htons(getBoundPort()), 0,
NULL, dnsRegisterCallback, NULL);
if (error != kDNSServiceErr_NoError) {
ERROR("Failed to register zeroconf service.\n");
if (dnsReference) {
DNSServiceRefDeallocate(dnsReference);
dnsReference = NULL;
}
return;
}
zeroConfIo.fdset = dnsRegisterFdset;
zeroConfIo.consume = dnsRegisterFdconsume;
registerIO( &zeroConfIo );
}
#endif
void initZeroconf(void) void initZeroconf(void)
{ {
const char* serviceName = SERVICE_NAME; const char* serviceName = SERVICE_NAME;
ConfigParam *param; ConfigParam *param;
int enabled = getBoolConfigParam(CONF_ZEROCONF_ENABLED);
if (enabled != -1 && enabled != 1)
return;
param = getConfigParam(CONF_ZEROCONF_NAME); param = getConfigParam(CONF_ZEROCONF_NAME);
if (param && strlen(param->value) > 0) if (param && strlen(param->value) > 0)
serviceName = param->value; serviceName = param->value;
#ifdef HAVE_AVAHI
init_avahi(serviceName); init_avahi(serviceName);
#endif
#ifdef HAVE_BONJOUR
init_zeroconf_osx(serviceName);
#endif
} }
void finishZeroconf(void) void finishZeroconf(void)
{ {
int enabled = getBoolConfigParam(CONF_ZEROCONF_ENABLED);
if (enabled != -1 && enabled != 1)
return;
#ifdef HAVE_AVAHI #ifdef HAVE_AVAHI
DEBUG( "Avahi: Shutting down interface\n" ); DEBUG( "Avahi: Shutting down interface\n" );
deregisterIO( &avahiIo ); deregisterIO( &zeroConfIo );
if( avahiGroup ) { if( avahiGroup ) {
avahi_entry_group_free( avahiGroup ); avahi_entry_group_free( avahiGroup );
...@@ -497,4 +596,13 @@ void finishZeroconf(void) ...@@ -497,4 +596,13 @@ void finishZeroconf(void)
avahi_free( avahiName ); avahi_free( avahiName );
avahiName = NULL; avahiName = NULL;
#endif /* HAVE_AVAHI */ #endif /* HAVE_AVAHI */
#ifdef HAVE_BONJOUR
deregisterIO( &zeroConfIo );
if (dnsReference != NULL) {
DNSServiceRefDeallocate(dnsReference);
dnsReference = NULL;
DEBUG("Deregistered Zeroconf service.\n");
}
#endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment