Commit c8b0ef45 authored by Led's avatar Led

0.12.0rc2

parent 9f1f615e
...@@ -157,6 +157,9 @@ ...@@ -157,6 +157,9 @@
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION
/* The mpd protocol version */
#undef PROTOCOL_VERSION
/* The size of a `int', as computed by sizeof. */ /* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT #undef SIZEOF_INT
......
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for mpd 0.12.0. # Generated by GNU Autoconf 2.59 for mpd 0.12.0rc2.
# #
# Report bugs to <warren.dukes@gmail.com>. # Report bugs to <warren.dukes@gmail.com>.
# #
...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} ...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='mpd' PACKAGE_NAME='mpd'
PACKAGE_TARNAME='mpd' PACKAGE_TARNAME='mpd'
PACKAGE_VERSION='0.12.0' PACKAGE_VERSION='0.12.0rc2'
PACKAGE_STRING='mpd 0.12.0' PACKAGE_STRING='mpd 0.12.0rc2'
PACKAGE_BUGREPORT='warren.dukes@gmail.com' PACKAGE_BUGREPORT='warren.dukes@gmail.com'
# Factoring default headers for most tests. # Factoring default headers for most tests.
...@@ -965,7 +965,7 @@ if test "$ac_init_help" = "long"; then ...@@ -965,7 +965,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # 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. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures mpd 0.12.0 to adapt to many kinds of systems. \`configure' configures mpd 0.12.0rc2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1031,7 +1031,7 @@ fi ...@@ -1031,7 +1031,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of mpd 0.12.0:";; short | recursive ) echo "Configuration of mpd 0.12.0rc2:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1236,7 +1236,7 @@ fi ...@@ -1236,7 +1236,7 @@ fi
test -n "$ac_init_help" && exit 0 test -n "$ac_init_help" && exit 0
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
mpd configure 0.12.0 mpd configure 0.12.0rc2
generated by GNU Autoconf 2.59 generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc. Copyright (C) 2003 Free Software Foundation, Inc.
...@@ -1250,7 +1250,7 @@ cat >&5 <<_ACEOF ...@@ -1250,7 +1250,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by mpd $as_me 0.12.0, which was It was created by mpd $as_me 0.12.0rc2, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -18790,6 +18790,11 @@ fi ...@@ -18790,6 +18790,11 @@ fi
cat >>confdefs.h <<\_ACEOF
#define PROTOCOL_VERSION "0.12.0"
_ACEOF
MPD_LIBS="" MPD_LIBS=""
MPD_CFLAGS="" MPD_CFLAGS=""
case "$CC" in case "$CC" in
...@@ -27477,7 +27482,7 @@ _ASBOX ...@@ -27477,7 +27482,7 @@ _ASBOX
} >&5 } >&5
cat >&5 <<_CSEOF cat >&5 <<_CSEOF
This file was extended by mpd $as_me 0.12.0, which was This file was extended by mpd $as_me 0.12.0rc2, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -27540,7 +27545,7 @@ _ACEOF ...@@ -27540,7 +27545,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\ ac_cs_version="\\
mpd config.status 0.12.0 mpd config.status 0.12.0rc2
configured by $0, generated by GNU Autoconf 2.59, configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
......
dnl AC_INIT(src/main.c) dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(mpd, 0.12.0) dnl AM_INIT_AUTOMAKE(mpd, 0.12.0rc2)
AC_PREREQ(2.58) AC_PREREQ(2.58)
AC_INIT(mpd, 0.12.0, warren.dukes@gmail.com) AC_INIT(mpd, 0.12.0rc2, 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)
...@@ -16,6 +16,7 @@ AC_PROG_LIBTOOL ...@@ -16,6 +16,7 @@ AC_PROG_LIBTOOL
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
AC_DEFINE(PROTOCOL_VERSION, "0.12.0", [The mpd protocol version])
MPD_LIBS="" MPD_LIBS=""
MPD_CFLAGS="" MPD_CFLAGS=""
......
...@@ -59,7 +59,7 @@ void finishAudioOutputPlugins(void) ...@@ -59,7 +59,7 @@ void finishAudioOutputPlugins(void)
bp = getBlockParam(param, name); \ bp = getBlockParam(param, name); \
if(force && bp == NULL) { \ if(force && bp == NULL) { \
ERROR("couldn't find parameter \"%s\" in audio output " \ ERROR("couldn't find parameter \"%s\" in audio output " \
"definition begining at %i\n", \ "definition beginning at %i\n", \
name, param->line); \ name, param->line); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
} \ } \
......
...@@ -140,8 +140,9 @@ static int alsa_openDevice(AudioOutput * audioOutput) ...@@ -140,8 +140,9 @@ static int alsa_openDevice(AudioOutput * audioOutput)
snd_pcm_uframes_t alsa_period_size; snd_pcm_uframes_t alsa_period_size;
int err; int err;
const char *cmd = NULL; const char *cmd = NULL;
unsigned int period_time;
int retry = MPD_ALSA_RETRY_NR; int retry = MPD_ALSA_RETRY_NR;
unsigned int period_time, period_time_ro;
unsigned int buffer_time;
switch (audioFormat->bits) { switch (audioFormat->bits) {
case 8: case 8:
...@@ -175,6 +176,7 @@ static int alsa_openDevice(AudioOutput * audioOutput) ...@@ -175,6 +176,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
if (err < 0) if (err < 0)
goto error; goto error;
period_time_ro = period_time = ad->period_time;
configure_hw: configure_hw:
/* configure HW params */ /* configure HW params */
snd_pcm_hw_params_alloca(&hwparams); snd_pcm_hw_params_alloca(&hwparams);
...@@ -231,28 +233,29 @@ configure_hw: ...@@ -231,28 +233,29 @@ configure_hw:
} }
audioFormat->sampleRate = sampleRate; audioFormat->sampleRate = sampleRate;
buffer_time = ad->buffer_time;
cmd = "snd_pcm_hw_params_set_buffer_time_near"; cmd = "snd_pcm_hw_params_set_buffer_time_near";
err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams, err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams,
&ad->buffer_time, NULL); &buffer_time, NULL);
if (err < 0) if (err < 0)
goto error; goto error;
period_time = ad->period_time; period_time = period_time_ro;
cmd = "snd_pcm_hw_params_set_period_time_near"; cmd = "snd_pcm_hw_params_set_period_time_near";
err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams, err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams,
&ad->period_time, NULL); &period_time, NULL);
if (err < 0) if (err < 0)
goto error; goto error;
cmd = "snd_pcm_hw_params"; cmd = "snd_pcm_hw_params";
err = snd_pcm_hw_params(ad->pcmHandle, hwparams); err = snd_pcm_hw_params(ad->pcmHandle, hwparams);
if (err == -EPIPE && --retry > 0) { if (err == -EPIPE && --retry > 0) {
ad->period_time = period_time >> 1; period_time_ro = period_time_ro >> 1;
goto configure_hw; goto configure_hw;
} else if (err < 0) } else if (err < 0)
goto error; goto error;
if (retry != MPD_ALSA_RETRY_NR) if (retry != MPD_ALSA_RETRY_NR)
DEBUG("ALSA period_time set to %d\n", ad->period_time); DEBUG("ALSA period_time set to %d\n", period_time);
cmd = "snd_pcm_hw_params_get_buffer_size"; cmd = "snd_pcm_hw_params_get_buffer_size";
err = snd_pcm_hw_params_get_buffer_size(hwparams, &alsa_buffer_size); err = snd_pcm_hw_params_get_buffer_size(hwparams, &alsa_buffer_size);
......
...@@ -245,7 +245,7 @@ static int osx_openDevice(AudioOutput * audioOutput) ...@@ -245,7 +245,7 @@ static int osx_openDevice(AudioOutput * audioOutput)
if (AudioUnitInitialize(od->au) != 0) { if (AudioUnitInitialize(od->au) != 0) {
CloseComponent(od->au); CloseComponent(od->au);
ERROR("Unable to initialuze OS X audio unit\n"); ERROR("Unable to initialize OS X audio unit\n");
return -1; return -1;
} }
...@@ -257,7 +257,7 @@ static int osx_openDevice(AudioOutput * audioOutput) ...@@ -257,7 +257,7 @@ static int osx_openDevice(AudioOutput * audioOutput)
&callback, sizeof(callback)) != 0) { &callback, sizeof(callback)) != 0) {
AudioUnitUninitialize(od->au); AudioUnitUninitialize(od->au);
CloseComponent(od->au); CloseComponent(od->au);
ERROR("unable to set callbak for OS X audio unit\n"); ERROR("unable to set callback for OS X audio unit\n");
return -1; return -1;
} }
......
...@@ -423,7 +423,7 @@ static int initEncoder(ShoutData * sd) ...@@ -423,7 +423,7 @@ static int initEncoder(ShoutData * sd)
sd->audioFormat->channels, sd->audioFormat->channels,
sd->audioFormat->sampleRate, sd->audioFormat->sampleRate,
sd->quality * 0.1)) { sd->quality * 0.1)) {
ERROR("problem seting up vorbis encoder for shout\n"); ERROR("problem setting up vorbis encoder for shout\n");
vorbis_info_clear(&(sd->vi)); vorbis_info_clear(&(sd->vi));
return -1; return -1;
} }
...@@ -432,7 +432,7 @@ static int initEncoder(ShoutData * sd) ...@@ -432,7 +432,7 @@ static int initEncoder(ShoutData * sd)
sd->audioFormat->channels, sd->audioFormat->channels,
sd->audioFormat->sampleRate, -1.0, sd->audioFormat->sampleRate, -1.0,
sd->bitrate * 1000, -1.0)) { sd->bitrate * 1000, -1.0)) {
ERROR("problem seting up vorbis encoder for shout\n"); ERROR("problem setting up vorbis encoder for shout\n");
vorbis_info_clear(&(sd->vi)); vorbis_info_clear(&(sd->vi));
return -1; return -1;
} }
......
...@@ -233,7 +233,7 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string) ...@@ -233,7 +233,7 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
0 == strcmp(array[1], CONF_BLOCK_END)) { 0 == strcmp(array[1], CONF_BLOCK_END)) {
ERROR("improperly formatted config file at line %i:" ERROR("improperly formatted config file at line %i:"
" %s\n", *count, string); " %s\n", *count, string);
ERROR("in block begining at line %i\n", ret->line); ERROR("in block beginning at line %i\n", ret->line);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
......
...@@ -260,15 +260,11 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb, ...@@ -260,15 +260,11 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
InputStream inStream; InputStream inStream;
InputPlugin *plugin = NULL; InputPlugin *plugin = NULL;
char *path; char *path;
char *relativePath;
if (isRemoteUrl(pc->utf8url)) { if (isRemoteUrl(pc->utf8url))
path = utf8StrToLatin1Dup(pc->utf8url); path = utf8StrToLatin1Dup(pc->utf8url);
} else { else
relativePath = utf8ToFsCharset(pc->utf8url); path = strdup(rmp2amp(utf8ToFsCharset(pc->utf8url)));
path = strdup(rmp2amp(relativePath));
free(relativePath);
}
if (!path) { if (!path) {
dc->error = DECODE_ERROR_FILE; dc->error = DECODE_ERROR_FILE;
......
...@@ -138,6 +138,7 @@ typedef struct _mp3DecodeData { ...@@ -138,6 +138,7 @@ typedef struct _mp3DecodeData {
int dropFramesAtEnd; int dropFramesAtEnd;
int dropSamplesAtStart; int dropSamplesAtStart;
int dropSamplesAtEnd; int dropSamplesAtEnd;
int foundXing;
int foundFirstFrame; int foundFirstFrame;
int decodedFirstFrame; int decodedFirstFrame;
int flush; int flush;
...@@ -161,6 +162,7 @@ static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) ...@@ -161,6 +162,7 @@ static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream)
data->dropFramesAtEnd = 0; data->dropFramesAtEnd = 0;
data->dropSamplesAtStart = 0; data->dropSamplesAtStart = 0;
data->dropSamplesAtEnd = 0; data->dropSamplesAtEnd = 0;
data->foundXing = 0;
data->foundFirstFrame = 0; data->foundFirstFrame = 0;
data->decodedFirstFrame = 0; data->decodedFirstFrame = 0;
data->flush = 1; data->flush = 1;
...@@ -640,6 +642,7 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc, ...@@ -640,6 +642,7 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc,
bitlen = data->stream.anc_bitlen; bitlen = data->stream.anc_bitlen;
if (parse_xing(&xing, &ptr, &bitlen)) { if (parse_xing(&xing, &ptr, &bitlen)) {
data->foundXing = 1;
data->muteFrame = MUTEFRAME_SKIP; data->muteFrame = MUTEFRAME_SKIP;
if (parse_lame(&lame, &ptr, &bitlen)) { if (parse_lame(&lame, &ptr, &bitlen)) {
...@@ -737,9 +740,12 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, ...@@ -737,9 +740,12 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc,
mad_timer_add(&data->timer, (data->frame).header.duration); mad_timer_add(&data->timer, (data->frame).header.duration);
data->bitRate = (data->frame).header.bitrate; data->bitRate = (data->frame).header.bitrate;
if (data->currentFrame >= data->maxFrames) { if (data->currentFrame >= data->maxFrames) {
/* stop decoding, since Xing maxFrames is accurate */
if (data->foundXing) return DECODE_BREAK;
data->currentFrame = data->maxFrames - 1; data->currentFrame = data->maxFrames - 1;
} else } else {
data->highestFrame++; data->highestFrame++;
}
data->frameOffset[data->currentFrame] = data->inStream->offset; data->frameOffset[data->currentFrame] = data->inStream->offset;
if (data->stream.this_frame != NULL) { if (data->stream.this_frame != NULL) {
data->frameOffset[data->currentFrame] -= data->frameOffset[data->currentFrame] -=
...@@ -749,8 +755,9 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, ...@@ -749,8 +755,9 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc,
data->stream.bufend - data->stream.buffer; data->stream.bufend - data->stream.buffer;
} }
data->times[data->currentFrame] = data->timer; data->times[data->currentFrame] = data->timer;
} else } else {
data->timer = data->times[data->currentFrame]; data->timer = data->times[data->currentFrame];
}
data->currentFrame++; data->currentFrame++;
data->elapsedTime = data->elapsedTime =
((float)mad_timer_count(data->timer, MAD_UNITS_MILLISECONDS)) / ((float)mad_timer_count(data->timer, MAD_UNITS_MILLISECONDS)) /
...@@ -815,7 +822,9 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, ...@@ -815,7 +822,9 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc,
} else if (data->dropSamplesAtEnd && } else if (data->dropSamplesAtEnd &&
(data->currentFrame == (data->maxFrames - data->dropFramesAtEnd))) { (data->currentFrame == (data->maxFrames - data->dropFramesAtEnd))) {
samplesLeft--; samplesLeft--;
if (samplesLeft < data->dropSamplesAtEnd) break; /* stop decoding, since samples were dropped */
if (samplesLeft < data->dropSamplesAtEnd)
return DECODE_BREAK;
} }
sample = (mpd_sint16 *) data->outputPtr; sample = (mpd_sint16 *) data->outputPtr;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#define GREETING "OK MPD " VERSION "\n" #define GREETING "OK MPD " PROTOCOL_VERSION "\n"
#define INTERFACE_MAX_BUFFER_LENGTH (40960) #define INTERFACE_MAX_BUFFER_LENGTH (40960)
#define INTERFACE_LIST_MODE_BEGIN "command_list_begin" #define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
......
...@@ -188,10 +188,7 @@ mpd_printf void func(const char *fmt, ...) \ ...@@ -188,10 +188,7 @@ mpd_printf void func(const char *fmt, ...) \
log_func(ERROR, 0, stderr) log_func(ERROR, 0, stderr)
log_func(LOG, 0, stdout) log_func(LOG, 0, stdout)
log_func(SECURE, LOG_LEVEL_SECURE, stdout) log_func(SECURE, LOG_LEVEL_SECURE, stdout)
#ifndef NDEBUG
log_func(DEBUG, LOG_LEVEL_DEBUG, stdout) log_func(DEBUG, LOG_LEVEL_DEBUG, stdout)
#endif /* NDEBUG */
#undef log_func #undef log_func
......
...@@ -29,15 +29,10 @@ ...@@ -29,15 +29,10 @@
#define LOG_LEVEL_SECURE 1 #define LOG_LEVEL_SECURE 1
#define LOG_LEVEL_DEBUG 2 #define LOG_LEVEL_DEBUG 2
#ifndef NDEBUG
mpd_printf void DEBUG(const char *fmt, ...);
#else
static inline void DEBUG(const char *fmt, ...) { }
#endif
mpd_printf void ERROR(const char *fmt, ...); mpd_printf void ERROR(const char *fmt, ...);
mpd_printf void LOG(const char *fmt, ...); mpd_printf void LOG(const char *fmt, ...);
mpd_printf void SECURE(const char *fmt, ...); mpd_printf void SECURE(const char *fmt, ...);
mpd_printf void DEBUG(const char *fmt, ...);
mpd_printf void WARNING(const char *fmt, ...); mpd_printf void WARNING(const char *fmt, ...);
mpd_printf void FATAL(const char *fmt, ...); mpd_printf void FATAL(const char *fmt, ...);
......
...@@ -118,7 +118,6 @@ int lsPlaylists(int fd, char *utf8path) ...@@ -118,7 +118,6 @@ int lsPlaylists(int fd, char *utf8path)
int suff; int suff;
if (actlen > MAXPATHLEN - 1 || (dir = opendir(actualPath)) == NULL) { if (actlen > MAXPATHLEN - 1 || (dir = opendir(actualPath)) == NULL) {
free(path);
return 0; return 0;
} }
...@@ -143,7 +142,6 @@ int lsPlaylists(int fd, char *utf8path) ...@@ -143,7 +142,6 @@ int lsPlaylists(int fd, char *utf8path)
dup[suff] = '\0'; dup[suff] = '\0';
if ((utf8 = fsCharsetToUtf8(dup))) { if ((utf8 = fsCharsetToUtf8(dup))) {
insertInList(list, utf8, NULL); insertInList(list, utf8, NULL);
free(utf8);
} }
} }
} }
...@@ -151,7 +149,6 @@ int lsPlaylists(int fd, char *utf8path) ...@@ -151,7 +149,6 @@ int lsPlaylists(int fd, char *utf8path)
} }
closedir(dir); closedir(dir);
free(path);
if (list) { if (list) {
int i; int i;
...@@ -185,16 +182,11 @@ int myStat(char *utf8file, struct stat *st) ...@@ -185,16 +182,11 @@ int myStat(char *utf8file, struct stat *st)
{ {
char *file = utf8ToFsCharset(utf8file); char *file = utf8ToFsCharset(utf8file);
char *actualFile = file; char *actualFile = file;
int ret;
if (actualFile[0] != '/') if (actualFile[0] != '/')
actualFile = rmp2amp(file); actualFile = rmp2amp(file);
ret = stat(actualFile, st); return stat(actualFile, st);
free(file);
return ret;
} }
static int isFile(char *utf8file, time_t * mtime) static int isFile(char *utf8file, time_t * mtime)
......
...@@ -477,14 +477,13 @@ int main(int argc, char *argv[]) ...@@ -477,14 +477,13 @@ int main(int argc, char *argv[])
playerKill(); playerKill();
freeAllInterfaces(); freeAllInterfaces();
closeAllListenSockets(); closeAllListenSockets();
finishPlaylist();
start = clock(); start = clock();
closeMp3Directory(); closeMp3Directory();
DEBUG("closeMp3Directory took %f seconds\n", DEBUG("closeMp3Directory took %f seconds\n",
((float)(clock()-start))/CLOCKS_PER_SEC); ((float)(clock()-start))/CLOCKS_PER_SEC);
finishPlaylist();
freePlayerData();
finishNormalization(); finishNormalization();
finishAudioDriver(); finishAudioDriver();
finishAudioConfig(); finishAudioConfig();
...@@ -495,6 +494,7 @@ int main(int argc, char *argv[]) ...@@ -495,6 +494,7 @@ int main(int argc, char *argv[])
finishInputPlugins(); finishInputPlugins();
cleanUpPidFile(); cleanUpPidFile();
finishConf(); finishConf();
freePlayerData();
close_log_files(); close_log_files();
return EXIT_SUCCESS; return EXIT_SUCCESS;
......
...@@ -41,18 +41,18 @@ const char *musicDir; ...@@ -41,18 +41,18 @@ const char *musicDir;
static const char *playlistDir; static const char *playlistDir;
static char *fsCharset = NULL; static char *fsCharset = NULL;
static char *pathConvCharset(char *to, char *from, char *str) static char *pathConvCharset(char *to, char *from, char *str, char *ret)
{ {
if (setCharSetConversion(to, from) == 0) { if (ret)
return convStrDup(str); free(ret);
} return setCharSetConversion(to, from) ? NULL : convStrDup(str);
return NULL;
} }
char *fsCharsetToUtf8(char *str) char *fsCharsetToUtf8(char *str)
{ {
char *ret = pathConvCharset("UTF-8", fsCharset, str); static char *ret = NULL;
ret = pathConvCharset("UTF-8", fsCharset, str, ret);
if (ret && !validUtf8String(ret)) { if (ret && !validUtf8String(ret)) {
free(ret); free(ret);
...@@ -64,7 +64,9 @@ char *fsCharsetToUtf8(char *str) ...@@ -64,7 +64,9 @@ char *fsCharsetToUtf8(char *str)
char *utf8ToFsCharset(char *str) char *utf8ToFsCharset(char *str)
{ {
char *ret = pathConvCharset(fsCharset, "UTF-8", str); static char *ret = NULL;
ret = pathConvCharset(fsCharset, "UTF-8", str, ret);
if (!ret) if (!ret)
ret = strdup(str); ret = strdup(str);
......
...@@ -29,8 +29,17 @@ void initPaths(); ...@@ -29,8 +29,17 @@ void initPaths();
void finishPaths(); void finishPaths();
/* utf8ToFsCharset() and fsCharsetToUtf8()
* Each returns a static pointer to a dynamically allocated buffer
* which means:
* - Do not manually free the return value of these functions, it'll be
* automatically freed the next time it is called.
* - They are not reentrant, strdup the return value immediately if
* you expect to call one of these functions again, but still need the
* previous result.
* - The static pointer is unique to each function.
*/
char *utf8ToFsCharset(char *str); char *utf8ToFsCharset(char *str);
char *fsCharsetToUtf8(char *str); char *fsCharsetToUtf8(char *str);
void setFsCharset(char *charset); void setFsCharset(char *charset);
......
...@@ -124,8 +124,8 @@ int playerInit(void) ...@@ -124,8 +124,8 @@ int playerInit(void)
closeAllListenSockets(); closeAllListenSockets();
freeAllInterfaces(); freeAllInterfaces();
closeMp3Directory();
finishPlaylist(); finishPlaylist();
closeMp3Directory();
finishPermissions(); finishPermissions();
finishCommands(); finishCommands();
finishVolume(); finishVolume();
...@@ -307,7 +307,7 @@ char *getPlayerErrorStr(void) ...@@ -307,7 +307,7 @@ char *getPlayerErrorStr(void)
switch (pc->error) { switch (pc->error) {
case PLAYER_ERROR_FILENOTFOUND: case PLAYER_ERROR_FILENOTFOUND:
snprintf(error, errorlen, snprintf(error, errorlen,
"file \"%s\" does not exist or is inaccesible", "file \"%s\" does not exist or is inaccessible",
pc->erroredUrl); pc->erroredUrl);
break; break;
case PLAYER_ERROR_FILE: case PLAYER_ERROR_FILE:
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "log.h" #include "log.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h>
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <stdio.h> #include <stdio.h>
...@@ -164,5 +165,9 @@ PlayerData *getPlayerData(void) ...@@ -164,5 +165,9 @@ PlayerData *getPlayerData(void)
void freePlayerData(void) void freePlayerData(void)
{ {
/* We don't want to release this memory until we know our player and
* decoder have exited. Otherwise, their signal handlers will want to
* access playerData_pd and we need to keep it available for them */
waitpid(-1, NULL, 0);
shmdt(playerData_pd); shmdt(playerData_pd);
} }
...@@ -1272,8 +1272,6 @@ int deletePlaylist(int fd, char *utf8file) ...@@ -1272,8 +1272,6 @@ int deletePlaylist(int fd, char *utf8file)
strcat(rfile, "."); strcat(rfile, ".");
strcat(rfile, PLAYLIST_FILE_SUFFIX); strcat(rfile, PLAYLIST_FILE_SUFFIX);
free(file);
if ((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) if ((actualFile = rpp2app(rfile)) && isPlaylist(actualFile))
free(rfile); free(rfile);
else { else {
...@@ -1300,7 +1298,6 @@ int savePlaylist(int fd, char *utf8file) ...@@ -1300,7 +1298,6 @@ int savePlaylist(int fd, char *utf8file)
char *file; char *file;
char *rfile; char *rfile;
char *actualFile; char *actualFile;
char *url;
if (strstr(utf8file, "/")) { if (strstr(utf8file, "/")) {
commandError(fd, ACK_ERROR_ARG, commandError(fd, ACK_ERROR_ARG,
...@@ -1318,8 +1315,6 @@ int savePlaylist(int fd, char *utf8file) ...@@ -1318,8 +1315,6 @@ int savePlaylist(int fd, char *utf8file)
strcat(rfile, "."); strcat(rfile, ".");
strcat(rfile, PLAYLIST_FILE_SUFFIX); strcat(rfile, PLAYLIST_FILE_SUFFIX);
free(file);
actualFile = rpp2app(rfile); actualFile = rpp2app(rfile);
free(rfile); free(rfile);
...@@ -1343,10 +1338,8 @@ int savePlaylist(int fd, char *utf8file) ...@@ -1343,10 +1338,8 @@ int savePlaylist(int fd, char *utf8file)
rmp2amp(utf8ToFsCharset rmp2amp(utf8ToFsCharset
((getSongUrl(playlist.songs[i]))))); ((getSongUrl(playlist.songs[i])))));
} else { } else {
url = utf8ToFsCharset(getSongUrl(playlist.songs[i])); fprintf(fileP, "%s\n",
fprintf(fileP, "%s\n", url); utf8ToFsCharset(getSongUrl(playlist.songs[i])));
free(url);
} }
} }
...@@ -1441,8 +1434,6 @@ static int PlaylistIterFunc(int fd, char *utf8file, ...@@ -1441,8 +1434,6 @@ static int PlaylistIterFunc(int fd, char *utf8file,
strcat(rfile, "."); strcat(rfile, ".");
strcat(rfile, PLAYLIST_FILE_SUFFIX); strcat(rfile, PLAYLIST_FILE_SUFFIX);
free(temp);
if ((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) if ((actualFile = rpp2app(rfile)) && isPlaylist(actualFile))
free(rfile); free(rfile);
else { else {
...@@ -1499,7 +1490,6 @@ static int PlaylistIterFunc(int fd, char *utf8file, ...@@ -1499,7 +1490,6 @@ static int PlaylistIterFunc(int fd, char *utf8file,
strcpy(s, temp); strcpy(s, temp);
IterFunc(fd, s, &erroredFile); IterFunc(fd, s, &erroredFile);
} }
free(temp);
} else if (slength == MAXPATHLEN) { } else if (slength == MAXPATHLEN) {
s[slength] = '\0'; s[slength] = '\0';
commandError(fd, ACK_ERROR_PLAYLIST_LOAD, commandError(fd, ACK_ERROR_PLAYLIST_LOAD,
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "charConv.h" #include "charConv.h"
#include "tagTracker.h" #include "tagTracker.h"
#include "mpd_types.h" #include "mpd_types.h"
#include "gcc.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -132,15 +133,15 @@ void printMpdTag(int fd, MpdTag * tag) ...@@ -132,15 +133,15 @@ void printMpdTag(int fd, MpdTag * tag)
} }
#ifdef HAVE_ID3TAG #ifdef HAVE_ID3TAG
MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag) static MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag)
{ {
struct id3_frame const *frame; struct id3_frame const *frame;
id3_ucs4_t const *ucs4; id3_ucs4_t const *ucs4;
id3_utf8_t *utf8; id3_utf8_t *utf8;
id3_latin1_t *isostr;
union id3_field const *field; union id3_field const *field;
unsigned int nstrings; unsigned int nstrings;
int i; int i;
char *isostr;
char *encoding; char *encoding;
frame = id3_tag_findframe(tag, id, 0); frame = id3_tag_findframe(tag, id, 0);
...@@ -158,20 +159,24 @@ MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag) ...@@ -158,20 +159,24 @@ MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag)
if (type == TAG_ITEM_GENRE) if (type == TAG_ITEM_GENRE)
ucs4 = id3_genre_name(ucs4); ucs4 = id3_genre_name(ucs4);
utf8 = id3_ucs4_utf8duplicate(ucs4); if (isId3v1(tag) &&
if (!utf8) (encoding = getConfigParamValue(CONF_ID3V1_ENCODING))) {
continue; isostr = id3_ucs4_latin1duplicate(ucs4);
if (mpd_unlikely(!isostr))
if (isId3v1(tag)) { continue;
encoding = getConfigParamValue(CONF_ID3V1_ENCODING); setCharSetConversion("UTF-8", encoding);
if (encoding) { utf8 = (id3_utf8_t *)convStrDup((char *)isostr);
setCharSetConversion("ISO-8859-1", "UTF-8"); if (!utf8) {
isostr = convStrDup((char *)utf8); DEBUG("Unable to convert %s string to UTF-8: "
free(utf8); "'%s'\n", encoding, isostr);
setCharSetConversion("UTF-8", encoding);
utf8 = (id3_utf8_t *)convStrDup(isostr);
free(isostr); free(isostr);
continue;
} }
free(isostr);
} else {
utf8 = id3_ucs4_utf8duplicate(ucs4);
if (mpd_unlikely(!utf8))
continue;
} }
if (mpdTag == NULL) if (mpdTag == NULL)
...@@ -414,7 +419,7 @@ MpdTag *apeDup(char *file) ...@@ -414,7 +419,7 @@ MpdTag *apeDup(char *file)
if (readLEuint32(footer.version) != 2000) if (readLEuint32(footer.version) != 2000)
goto fail; goto fail;
/* find begining of ape tag */ /* find beginning of ape tag */
tagLen = readLEuint32(footer.length); tagLen = readLEuint32(footer.length);
if (tagLen < sizeof(footer)) if (tagLen < sizeof(footer))
goto fail; goto fail;
......
...@@ -233,7 +233,7 @@ static int prepAlsaMixer(char *card) ...@@ -233,7 +233,7 @@ static int prepAlsaMixer(char *card)
if ((err = snd_mixer_attach(volume_alsaMixerHandle, card)) < 0) { if ((err = snd_mixer_attach(volume_alsaMixerHandle, card)) < 0) {
closeAlsaMixer(); closeAlsaMixer();
WARNING("problems problems attaching alsa mixer: %s\n", WARNING("problems attaching alsa mixer: %s\n",
snd_strerror(err)); snd_strerror(err));
return -1; return -1;
} }
......
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