Commit bdc29293 authored by Led's avatar Led

0.11.3-rc1

parent 22e8abfa
ver 0.11.3 (2004/7/21)
1) Add support for http authentication for streams
2) Added replaygain pre-amp support
3) Better error handling for fread() in inputStream_file
4) Fixed a bug so that when a freeAllInterfaces is called, it sets max_interface_connections to 0. This prevents potential segfaults and other nastiness for forked processes, like the player and update-er (do to interfacePrintWithFD()).
5) Allow blockingWrite() to handle errors more gracefully (for example, if the disc is full, and thus the write() fails or can't be completed, we just skip this write() and continue, instead of getting stuck in an infinite loop until the write() becomes successful)
6) Updated mpdconf.example from sbh/avuton
7) If "user" is specified, then convert ~ in paths to the user's home path specified by "user" config paramter (not the actual current user running mpd).
ver 0.11.2 (2004/7/5)
1) Work around in computing total time for mp3's whose first valid mpeg frame is not layer III
2) Fix mp3 and mp4 decoders when seeking past the end of the file
......
......@@ -14,6 +14,8 @@
*) allow find/search commands take arbitrary search pairs
*) abstract out input buffering from inputStream_http to inputStream
Post-1.0
--------
1) crosslink "list" stuff, for example, artists are crosslinked to alubms and
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for mpd 0.11.2.
# Generated by GNU Autoconf 2.59 for mpd 0.11.3.
#
# Report bugs to <shank@mercury.chem.pitt.edu>.
#
......@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='mpd'
PACKAGE_TARNAME='mpd'
PACKAGE_VERSION='0.11.2'
PACKAGE_STRING='mpd 0.11.2'
PACKAGE_VERSION='0.11.3'
PACKAGE_STRING='mpd 0.11.3'
PACKAGE_BUGREPORT='shank@mercury.chem.pitt.edu'
# Factoring default headers for most tests.
......@@ -955,7 +955,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures mpd 0.11.2 to adapt to many kinds of systems.
\`configure' configures mpd 0.11.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1021,7 +1021,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of mpd 0.11.2:";;
short | recursive ) echo "Configuration of mpd 0.11.3:";;
esac
cat <<\_ACEOF
......@@ -1207,7 +1207,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
mpd configure 0.11.2
mpd configure 0.11.3
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
......@@ -1221,7 +1221,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by mpd $as_me 0.11.2, which was
It was created by mpd $as_me 0.11.3, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
......@@ -26085,7 +26085,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by mpd $as_me 0.11.2, which was
This file was extended by mpd $as_me 0.11.3, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -26148,7 +26148,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
mpd config.status 0.11.2
mpd config.status 0.11.3
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
......
......@@ -2,7 +2,7 @@ dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(mpd, 0.10.0)
AC_PREREQ(2.52)
AC_INIT(mpd, 0.11.2, shank@mercury.chem.pitt.edu)
AC_INIT(mpd, 0.11.3, shank@mercury.chem.pitt.edu)
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
dnl MAD wants this stuff
......
......@@ -2,118 +2,191 @@
# For a full description of all config parameters,
# Check the mpd man page, "man mpd".
########## REQUIRED ###############
##################### REQUIRED ###########################
port "6600"
music_directory "~/music"
playlist_directory "~/.mpd/playlists"
log_file "~/.mpd/mpd.log"
error_file "~/.mpd/mpd.error"
###################################
##########################################################
###################################
##########################################################
# EVERYTHING ELSE IS OPTIONAL
###################################
##########################################################
######### FILESYSTEM SETTINGS ###########
# If filenames or directory names don't
# display correctly, set the character
# set (encoding) for the filesystem
# here. The fileystem encoding is
# typically "ISO-8859-1" or "UTF-8".
# After changing fileystem_charset,
# recreate the db: mpd --create-db
################# FILESYSTEM SETTINGS ####################
#
# If the names of files or directories are
# not correctly displayed then set the
# following to the filesystem coding.
#
# Usually this is either:
# ISO-8859-1 or UTF-8
#
# After changing the filesystem_charset
# you will need to recreate the db:
# mpd --create-db
#
#filesystem_charset "ISO-8859-1"
#########################################
#
##########################################################
########### OPTIONAL FILES ##############
#################### OPTIONAL FILES ######################
#
# Location of DB file
#db_file "~/.mpd/mpddb"
#
# State file for storing state of mpd
# when it is shutdown. MPD will restore
# the state (i.e. load playlist, start
# playing, etc) upon restart.
#db_file "~/.mpd/mpd.db"
#
# The state file (if set) will be a file
# for storing all current information
# (playlist, playing/paused, etc...) from
# the last MPD session. This will be used
# to recreate your last MPD session after
# restart.
#
#state_file "~/.mpd/mpdstate"
##########################################
#
##########################################################
######### VOLUME MIXER ############
# for OSS Mixer
#mixer_type "oss"
#mixer_device "/dev/mixer"
#mixer_control "Pcm"
# for Alsa Mixer
################### VOLUME MIXER #########################
#
# Examples:
# ALSA Mixer
#mixer_type "alsa"
#mixer_device "default"
#mixer_control "PCM"
# for Software Mixer
#
# OSS Mixer
#mixer_type "oss"
#mixer_device "/dev/mixer"
#mixer_control "PCM"
#
# Software Mixer
#mixer_type "software"
##################################
#
##########################################################
######### AUDIO OUTPUT ###########
# for OSS Audio Output
################## AUDIO OUTPUT ##########################
#
# OSS Audio Output
#ao_driver "oss"
#ao_driver_options "dsp=/dev/dsp"
# for ALSA Audio Output
#
# ALSA Audio Output
#ao_driver "alsa09"
#ao_driver_options "dev=hw:0,0"
# misc audio output options
#
# Set this if you have problems
# playing audio files.
# This will resample your music so
# that it comes out at the set rate.
#
#audio_output_format "44100:16:2"
#
# You should not need mess with
# this value unless you know
# what you're doing.
#
#audio_write_size "1024"
# use track or album replaygain
#
##########################################################
################# REPLAYGAIN #############################
#
# Use Replay Gain (album or title)
# http://www.replaygain.org
#
#replaygain "album"
##################################
#
# Sets the pre-amp used for files that have replaygain
# info. Valid values are between -15 to 15 (in dB).
#
#replaygain_preamp "0"
#
##########################################################
#### OUTPUT BUFFER SETTINGS ######
################ OUTPUT BUFFER SETTINGS ##################
#
# You should not need to mess with this
# unless you know what you're doing.
#
#audio_buffer_size "2048"
#
# This means exactly what it says, it will
# buffer your file up to the percentage of
# the buffer before it begins playing.
#
#buffer_before_play "25%"
##################################
#
##########################################################
############ HTTP PROXY ################
################### HTTP PROXY ###########################
#
# http_proxy_host "proxy.isp.com"
# http_proxy_port "8080"
# http_proxy_user "user"
# http_proxy_password "password"
########################################
#
##########################################################
########### SECURITY SETTINGS ############
# if you start mpd as root, its recommended
# you specify a a user for mpd to run.
################# SECURITY SETTINGS ######################
#
# It is encouraged to run MPD as
# non-superuser. If you start mpd as root
# (for example, in an init script), set
# this value, then mpd will drop root priveleges
# and runs as the user specified.
#
#user "nobody"
# to only allow connections from localhost
#
# Set this value if you only have one
# address you want to allow connection to.
#
#bind_to_address "localhost"
# Specify one or more passwords required to
# access mpd:
#
# If you want to setup MPD to use
# passwords set them here
#
#password "password1@read,add,control,admin"
#password "password2@read"
#
# Specify permissions used by default when no password is
# given by for a connection/client.
# given by for a connection/client.
#
#default_permissions "read,add,control,admin"
#
##########################################
########### MISC OPTIONS #################
################ MISCELLANEOUS OPTIONS ###################
#
# This setting exists as precaution against attacks.
#
#max_playlist_length "16384"
#
# Valid options are "default", "secure" or "verbose".
#log_level "default"
#
#connection_timeout "60"
#
# This should be fine for 2-3 people using clients
# at the same time.
#
#max_connections "5"
#
# No need to change these unless you know better.
#
#max_command_list_size "2048"
#max_output_buffer_size "2048"
#max_output_buffer_size "2048"
#
# This will make playlists compatible with normal music
# players.
#
#save_absolute_paths_in_playlists "no"
# log_level can be "default", "secure", "verbose"
#log_level "default"
#########################################
#
##########################################################
......@@ -37,7 +37,7 @@
#define CONF_COMMENT '#'
#define CONF_NUMBER_OF_PARAMS 33
#define CONF_NUMBER_OF_PARAMS 34
#define CONF_NUMBER_OF_PATHS 6
#define CONF_NUMBER_OF_REQUIRED 5
#define CONF_NUMBER_OF_ALLOW_CATS 1
......@@ -129,7 +129,8 @@ char ** readConf(char * file) {
"http_proxy_host",
"http_proxy_port",
"http_proxy_user",
"http_proxy_password"
"http_proxy_password",
"replaygain_preamp"
};
int conf_absolutePaths[CONF_NUMBER_OF_PATHS] = {
......@@ -232,11 +233,25 @@ char ** readConf(char * file) {
if(conf_params[conf_absolutePaths[i]][1]=='/' ||
conf_params[conf_absolutePaths[i]][1]=='\0')
{
uid_t uid = geteuid();
if((pwd = getpwuid(uid)) == NULL) {
ERROR("problems getting passwd entry "
"for current user\n");
exit(EXIT_FAILURE);
if(conf_params[CONF_USER] &&
strlen(conf_params[CONF_USER]))
{
pwd = getpwnam(
conf_params[CONF_USER]);
if(!pwd) {
ERROR("no such user: %s\n",
conf_params[CONF_USER]);
exit(EXIT_FAILURE);
}
}
else {
uid_t uid = geteuid();
if((pwd = getpwuid(uid)) == NULL) {
ERROR("problems getting passwd "
"entry "
"for current user\n");
exit(EXIT_FAILURE);
}
}
}
else {
......
......@@ -54,6 +54,7 @@
#define CONF_HTTP_PROXY_PORT 30
#define CONF_HTTP_PROXY_USER 31
#define CONF_HTTP_PROXY_PASSWORD 32
#define CONF_REPLAYGAIN_PREAMP 33
#define CONF_CAT_CHAR "\n"
......
......@@ -115,6 +115,7 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
MAXPATHLEN); \
pc->erroredUrl[MAXPATHLEN] = '\0'; \
pc->error = PLAYER_ERROR_AUDIO; \
ERROR("problems opeing audio device while playing \"%s\"", pc->utf8url); \
quitDecode(pc,dc); \
return; \
} \
......@@ -227,6 +228,7 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
MAXPATHLEN); \
pc->erroredUrl[MAXPATHLEN] = '\0'; \
pc->error = PLAYER_ERROR_AUDIO; \
ERROR("problems opeing audio device while playing \"%s\"", pc->utf8url); \
quitDecode(pc,dc); \
return; \
} \
......
......@@ -18,7 +18,10 @@
#include "inputStream_file.h"
#include "log.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
......@@ -69,6 +72,11 @@ size_t inputStream_fileRead(InputStream * inStream, void * ptr, size_t size,
size_t readSize;
readSize = fread(ptr,size,nmemb,(FILE *)inStream->data);
if(readSize <=0 && ferror((FILE *)inStream->data)) {
inStream->error = errno;
DEBUG("inputStream_fileRead: error reading: %s\n",
strerror(inStream->error));
}
inStream->offset = ftell((FILE *)inStream->data);
......@@ -85,10 +93,15 @@ int inputStream_fileClose(InputStream * inStream) {
}
int inputStream_fileAtEOF(InputStream * inStream) {
return feof((FILE *)inStream->data);
if(feof((FILE *)inStream->data)) return 1;
if(ferror((FILE *)inStream->data) && inStream->error != EINTR) {
return 1;
}
return 0;
}
int inputStream_fileBuffer(InputStream * inStream) {
return 0;
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
......@@ -63,6 +63,7 @@ typedef struct _InputStreemHTTPData {
char * proxyHost;
int proxyPort;
char * proxyAuth;
char * httpAuth;
} InputStreamHTTPData;
void inputStream_initHttp() {
......@@ -154,9 +155,7 @@ static char * base64Dup(char * s) {
return ret;
}
#define PROXY_AUTH_HEADER "Proxy-Authorization: Basic "
static char * proxyAuthString(char * user, char * password) {
static char * authString(char * header, char * user, char * password) {
char * ret = NULL;
int templen;
char * temp;
......@@ -172,8 +171,8 @@ static char * proxyAuthString(char * user, char * password) {
temp64 = base64Dup(temp);
free(temp);
ret = malloc(strlen(temp64)+strlen(PROXY_AUTH_HEADER)+3);
strcpy(ret, PROXY_AUTH_HEADER);
ret = malloc(strlen(temp64)+strlen(header)+3);
strcpy(ret, header);
strcat(ret, temp64);
strcat(ret, "\r\n");
free(temp64);
......@@ -181,6 +180,12 @@ static char * proxyAuthString(char * user, char * password) {
return ret;
}
#define PROXY_AUTH_HEADER "Proxy-Authorization: Basic "
#define HTTP_AUTH_HEADER "Authorization: Basic "
#define proxyAuthString(x, y) authString(PROXY_AUTH_HEADER, x, y)
#define httpAuthString(x, y) authString(HTTP_AUTH_HEADER, x, y)
static InputStreamHTTPData * newInputStreamHTTPData() {
InputStreamHTTPData * ret = malloc(sizeof(InputStreamHTTPData));
......@@ -198,6 +203,7 @@ static InputStreamHTTPData * newInputStreamHTTPData() {
ret->proxyAuth = NULL;
}
ret->httpAuth = NULL;
ret->host = NULL;
ret->path = NULL;
ret->port = 80;
......@@ -214,6 +220,7 @@ static void freeInputStreamHTTPData(InputStreamHTTPData * data) {
if(data->host) free(data->host);
if(data->path) free(data->path);
if(data->proxyAuth) free(data->proxyAuth);
if(data->httpAuth) free(data->httpAuth);
free(data);
}
......@@ -222,14 +229,52 @@ static int parseUrl(InputStreamHTTPData * data, char * url) {
char * temp;
char * colon;
char * slash;
char * at;
int len;
if(strncmp("http://",url,strlen("http://"))!=0) return -1;
temp = url+strlen("http://");
slash = strchr(temp, '/');
colon = strchr(temp, ':');
at = strchr(temp, '@');
if(data->httpAuth) {
free(data->httpAuth);
data->httpAuth = NULL;
}
if(at) {
char * user;
char * passwd;
if(colon && colon < at) {
user = malloc(colon-temp+1);
strncpy(user, temp, colon-temp);
user[colon-temp] = '\0';
passwd = malloc(at-colon);
strncpy(passwd, colon+1, at-colon-1);
passwd[at-colon-1] = '\0';
}
else {
user = malloc(at-temp+1);
strncpy(user, temp, at-temp);
user[at-temp] = '\0';
passwd = strdup("");
}
data->httpAuth = httpAuthString(user, passwd);
free(user);
free(passwd);
temp = at+1;
colon = strchr(temp, ':');
}
slash = strchr(temp, '/');
if(slash && colon && slash <= colon) return -1;
......@@ -390,7 +435,9 @@ static int finishHTTPInit(InputStream * inStream) {
data->path, data->host, "httpTest", "0.0.0",
/*inStream->offset,*/
data->proxyAuth ? data->proxyAuth : "" );
data->proxyAuth ? data->proxyAuth :
(data->httpAuth ? data->httpAuth : "")
);
ret = write(data->sock, request, strlen(request));
if(ret!=strlen(request)) {
......
......@@ -49,7 +49,7 @@
#define INTERFACE_LIST_MODE_END "command_list_end"
#define INTERFACE_DEFAULT_OUT_BUFFER_SIZE 4096
int interface_max_connections;
int interface_max_connections = 0;
int interface_timeout;
unsigned long long interface_max_command_list_size;
unsigned long long interface_max_output_buffer_size;
......@@ -472,6 +472,8 @@ void freeAllInterfaces() {
closeAllInterfaces();
free(interfaces);
interface_max_connections = 0;
}
void closeOldInterfaces() {
......
......@@ -42,6 +42,7 @@ void blockingWrite(int fd, char * string, int len) {
while(len) {
ret = write(fd,string,len);
if(ret==0) return;
if(ret<0) {
switch(errno) {
case EAGAIN:
......@@ -74,13 +75,15 @@ void myfprintf(FILE * fp, char * format, ... ) {
memset(buffer,0,BUFFER_LENGTH+1);
va_start(arglist,format);
if(myfprintf_stdLogMode && (fd==1 || fd==2)) {
time_t t = time(NULL);
if(fd==1) fp = myfprintf_out;
else fp = myfprintf_err;
strftime(buffer,14,"%b %e %R",localtime(&t));
blockingWrite(fd,buffer,strlen(buffer));
blockingWrite(fd," : ",3);
if(fd==1 || fd==2) {
if(myfprintf_stdLogMode) {
time_t t = time(NULL);
if(fd==1) fp = myfprintf_out;
else fp = myfprintf_err;
strftime(buffer,14,"%b %e %R",localtime(&t));
blockingWrite(fd,buffer,strlen(buffer));
blockingWrite(fd," : ",3);
}
vsnprintf(buffer,BUFFER_LENGTH,format,arglist);
blockingWrite(fd,buffer,strlen(buffer));
}
......
......@@ -261,7 +261,7 @@ char * sanitizePathDup(char * path) {
ret[len] = '\0';
}
printf("sanitized: %s\n", ret);
DEBUG("sanitized: %s\n", ret);
return realloc(ret,len+1);
}
......
......@@ -29,6 +29,8 @@
/* Added 4/14/2004 by AliasMrJones */
static int replayGainState = REPLAYGAIN_OFF;
static float replayGainPreamp = 1.0;
void initReplayGainState() {
if(!getConf()[CONF_REPLAYGAIN]) return;
......@@ -43,17 +45,38 @@ void initReplayGainState() {
getConf()[CONF_REPLAYGAIN]);
exit(EXIT_FAILURE);
}
if(getConf()[CONF_REPLAYGAIN_PREAMP]) {
char * test;
float f = strtod(getConf()[CONF_REPLAYGAIN_PREAMP], &test);
if(*test != '\0') {
ERROR("Replaygain preamp \"%s\" is not a number\n",
getConf()[CONF_REPLAYGAIN_PREAMP]);
exit(EXIT_FAILURE);
}
if(f < -15 || f > 15) {
ERROR("Replaygain preamp \"%s\" is not between -15 and"
"15\n",
getConf()[CONF_REPLAYGAIN_PREAMP]);
exit(EXIT_FAILURE);
}
replayGainPreamp = pow(10, f/20.0);
}
}
int getReplayGainState() {
return replayGainState;
}
float computeReplayGainScale(float gain, float peak){
float computeReplayGainScale(float gain, float peak) {
float scale;
if(gain == 0.0) return(1);
scale = pow(10.0, gain/20.0);
scale*= replayGainPreamp;
if(scale > 15.0) scale = 15.0;
if (scale * peak > 1.0) {
......
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